Cellular library for MTS Socket Modem Arduino Shield devices from Multi-Tech Systems
Dependents: mtsas mtsas mtsas mtsas
Revision 23:8333593dd86f, committed 2014-06-19
- Comitter:
- mfiore
- Date:
- Thu Jun 19 21:24:21 2014 +0000
- Parent:
- 22:c1004a807490
- Child:
- 24:32d29cdfc1fa
- Commit message:
- add robustness to SendSMS function
Changed in this revision
Cellular/Cellular.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Cellular/Cellular.cpp Thu Jun 19 14:59:35 2014 +0000 +++ b/Cellular/Cellular.cpp Thu Jun 19 21:24:21 2014 +0000 @@ -273,10 +273,17 @@ string cmd = "AT+CMGS=\"+"; cmd.append(phoneNumber); cmd.append("\",145"); - string response1 = sendCommand(cmd, 1000); - if (response1.find('>') == string::npos) { - logError("CMGS phone number failed"); - return MTS_NO_RESPONSE; + for (int i = 0; i < 5; i++) { + string response1 = sendCommand(cmd, 1000); + if (response1.find('>') != string::npos) { + break; + } + if (i >= 5) { + logError("CMGS phone number failed"); + return MTS_NO_RESPONSE; + } + + wait(1); } wait(.2); string response2 = sendCommand(message, 4000, CTRL_Z);