So this is kind of a bummer, there seems to be an SMS retrieval bug in hardware or firmware in the SIM7000A (module specs below).
Basically, when you retrieve an SMS, it shows lots of info including the # of chars to read, and in some cases this number is incorrect. I just ran these commands in the Arduino IDE Serial monitor using a Serial connection and AT commands.
The last number, "36" here, is the # of chars in the SMS message. So all alphanumerics work:
+CMGR: "REC READ","+15127500974",,"20/01/25,20:17:04+00",145,4,0,0,"+447797704131",145,36
qwertyuiopasdfghjklzxcvbnm1234567890
All "common" symbols work. "Common" means all the symbols on the "alternate" keyboard on my Motorola Z3 Play:
+CMGR: "REC READ","+15127500974",,"20/01/25,20:17:44+00",145,4,0,0,"+447797704131",145,19
@#$_&-+()/*"':;!?,.
Here's where it gets weird, which I suspect is part of the issue. Here's the text message "abc"
But you'll notice that it is indeed the right number of characters: 4
The charcters are in hexadecimal, and I'm not sure what character set it is, but 0061 is "a" in most sets. Since I'm using the Arduino IDE's serial monitor, God knows it's possible some translation it's doing to try to show me these characters. I don't know, don't want to. Let's not go down that route in this thread.
+CMGR: "REC UNREAD","+15127500974",,"20/01/25,21:01:52+00",145,4,0,8,"+447797704131",145,4
00610062006300A3
Now here are the examples of when you combine alphanums with "uncommon" characters. The above message with "abc" I can understand having issues, because isn't part of the first 128 chars in most character sets, but is, and it causes this problem:
Correct, 3 characters:
+CMGR: "REC UNREAD","+15127500974",,"20/01/25,21:11:26+00",145,4,0,0,"+447797704131",145,3
abc
Incorrect, also 3 characters but 4 reported:
+CMGR: "REC UNREAD","+15127500974",,"20/01/25,21:11:28+00",145,4,0,0,"+447797704131",145,4
a{c
Tilde symbol also exhibits the behavior. This example shows that there is not just 1 extra character counted, but 1 extra character counted PER "uncommon" character:
+CMGR: "REC UNREAD","+15127500974",,"20/01/25,21:19:26+00",145,0,0,0,"+447797704131",145,6
a{~c
So what happens is you try to read N characters from the next line and you get extra characters, specifically '\n' and '\r' over and over.
Here are the characters and the hexadecimal representations of them.
61 = 'a'
7D = close curly brace
D = '\r'
A = '\n'
+CMGR: "REC READ","+15127500974",,"20/01/25,21:43:14+00",145,4,0,0,"+447797704131",145,4
aaaa
61 61 61 61
+CMGR: "REC READ","+15127500974",,"20/01/25,21:43:26+00",145,4,0,0,"+447797704131",145,5
aa}a
61 61 7D 61 D
+CMGR: "REC READ","+15127500974",,"20/01/25,21:43:38+00",145,4,0,0,"+447797704131",145,6
a}}a
61 7D 7D 61 D A
+CMGR: "REC UNREAD","+15127500974",,"20/01/25,21:43:46+00",145,4,0,0,"+447797704131",145,6
a}a}
61 7D 61 7D D A
+CMGR: "REC UNREAD","+15127500974",,"20/01/25,21:46:00+00",145,4,0,0,"+447797704131",145,8
}}}}
7D 7D 7D 7D D A D A
Some now I'll wait for someone to tell me this is working as designed. The Adafruit FONA library and the Botletics library (builds on FONA) are both victims of this behavior. It may be something that is inherent to the chip design and therefore not a true bug, but it's a bug far as I'm concerned. I'm a software guy and this EE stuff is for the birds. Sorry for the rant but it took me about 8 hours to find the root cause.
Module specs:
ATI: SIM7000A R1351
AT+GMM: SIMCOM_SIM7000A
AT+GMR: Revision:1351B03SIM7000A // firmware version B03. I think B04 is available
AT command settings:
AT+CMGF: 1 // Text mode (not PDU mode)
AT+CSDH: 1 // Show all fields from CMGR command
AT+CPMS: ("SM"),("SM"),("SM") // "SM" = SIM message storage. It looks like the SIM7000A only supports SIM storage, whereas the SIM808 included "ME" (Phone storage) and others