Hi All,
I'm working with the SM5100B GPRS Module, and have gotten into a strange situation. I have several while(1) loops that wait for an acknowledgement "OK" from the GPRS module before continuing. I have one loop that doesn't behave as expected and I can't figure out why.
Here's the method:
void waitForSocketConnection(){
//Inform the user we're checking the socket status
strcpy_P(buffer, (char*)pgm_read_word(&(msg_table[18])));
Serial.println( buffer );
//Ask the GSM module for the socket status
strcpy_P(buffer, (char*)pgm_read_word(&(at_table[13])));
cell.println( buffer );
while(1){
//Might need to pet the watchdog here. wdt_reset()
readline_GPRS_wait();
String bufferString = buffer_GPRS_w;
if(bufferString.indexOf("0102") >= 0){
//The socket is connected, inform the user and break out of the loop
strcpy_P(buffer, (char*)pgm_read_word(&(msg_table[21])));
Serial.println( buffer );
break;
}
if(bufferString.indexOf("0104") >= 0){
//The socket is still connecting, inform the user and stay in the loop
strcpy_P(buffer, (char*)pgm_read_word(&(msg_table[21])));
Serial.println( buffer );
//Ask the module for socket status again
Serial.println(buffer_GPRS_w);
strcpy_P(buffer, (char*)pgm_read_word(&(at_table[13])));
cell.println( buffer );
}else{
//Got something unexpected, ask the module for the socket status again
Serial.println(buffer_GPRS_w);
strcpy_P(buffer, (char*)pgm_read_word(&(at_table[13])));
cell.println( buffer );
}
}
}
The method gets called here:
void sendData(){
wdt_reset();
sendAndConfirm(1, 10, 10); // Start TCP Connection
waitForSocketConnection();
wdt_reset();
//do some other stuff once the socket is connected...
}
Here's what I get back from the arduino:
Socket Connected
Socket Connected
OK
?=
-MQQUM??????????5)5)=-5)5)?M=
-MQQUM????
Socket Connected
OK
Socket Connected
Socket Connected
OK
Socket Connected
Socket Connected
OK
Socket Connected
Socket Connected
OK
Socket Connected
Socket Connected
OK
Socket Connected
Socket Connected
OK
Socket Connected
Socket Connected
OK
Socket Connected
Socket Connected