Seeed-Studio / GPRS_Shield_Suli

GPRS Shield based on SIM900
http://www.seeedstudio.com/depot/GPRS-Shield-V20-p-1379.html?cPath=19_20
MIT License
48 stars 40 forks source link

GPRS init #16

Open TheAce58 opened 2 years ago

TheAce58 commented 2 years ago

Hi,

I saw your sendSMS function and was wondering if your initialization condition is false or not. Here is your code :

` void setup() {

Serial.begin(9600);

while (0 != gprsTest.init()) {
    delay(1000);

    Serial.print("init error\r\n");

}

Serial.println("gprs init success");

Serial.println("start to send message ...");

gprsTest.sendSMS(PHONE_NUMBER, MESSAGE); //define phone number and text

} `

I see here that your condition is waiting for a 0, or a false in the gprs.init() method. But if we go to your GPRS_Shield_Arduino.cpp file, we see that the function returns true if everything went well. Why do you wait for a false to say if the initialization was successful ? Here is the code :

` int GPRS::init(void) { if (0 != sim900_check_with_cmd("AT\r\n", "OK\r\n", CMD)) { return false;

}

if (0 != sim900_check_with_cmd("AT+CFUN=1\r\n", "OK\r\n", CMD)) {
    return false;

}

if (0 != checkSIMStatus()) {
    return false;

}

return true;

} `

Is there anything I have misunderstood ?

Best regards.