Description
In the Arduino example sketch ReceiveSMS.ino, when a message is received by the device, the response gets cut off and the sketch hangs. This was discussed partially in #50, but is a separate issue from what has been discussed there. #80 hypothesized that it was an issue with the '/' character, but the issue was closed without clear resolution (using another library may have solved this). With Serial debugging active, I see that the response returned over the serial monitor is cut off abruptly, like this:
14:32:05.683 -> AT+CMGL="REC UNREAD"
14:32:05.683 -> +CMGL: 6,"REC UNREAD","+1##########",,"21
After this, the code gets stuck in a while() loop, waiting for MODEM.ready() to return something other than 0. This is where the problem becomes more clear. Incoming uart data is stored in the RX ring buffer, which has a size of 64 ints. The first 64 characters of the response are being stored in this buffer, and the rest seems to be dropped. I verified this by adding a Serial.print statement with the size of the RX buffer after each character is read. This means that the response code at the end is not stored or read in the modem's poll() function, causing the return value for "ready" to always remain 0.
I have verified that this is NOT an issue with processing the '/' character; if you change the AT command in the library from "AT+CMGL="REC UNREAD"" to just "AT+CGML" (identical commands, see AT commands reference), the serial monitor will print more of the date/time, like this:
15:45:05.700 -> AT+CMGL
15:45:05.746 -> +CMGL: 11,"REC UNREAD","+1##########",,"21/09/08,12:45
I see that buffering is handled differently for the NBClient functions (the NBSocketBuffer files), where the buffer is extended to 512 ints. Does a similar solution need to be applied here to handle SMS message reading? Is there something that I am missing in my understanding?
Steps to replicate:
- Upload ReceiveSMS.ino to an NB1500 with an activated SIM card that has SMS service. Set debugging to true in the NB constructor- nbAccess(true)
- Wait for the device to initialize and be in the "Waiting for messages" state
- Send an SMS message to the device
Link to gist of Serial Monitor output following the 3 steps above (with phone number redacted)
https://gist.github.com/joshbober/9a9a01e35c540c0f4d4771276bfee0be
Other relevant information:
- My device firmware is updated to the latest release 05.12
- Using the SerialSARAPassthrough sketch and u-blox tool m-center, the AT+CGML command returns the full expected response