I made some “experiment”…
I checked the supported message storage areas and this is the module response:
I tried to delete messages using all these ways, always without success:
cellularRadio.DeleteAllSms();
cellularRadio.SendATCommand("AT+CMGDA=\"DEL ALL\"");
cellularRadio.SendATCommand("AT+CMGD=1,4");
I edited the standard gadgeteer driver to show each response received by cellular radio module… this allowed me to check many things and verify the response received for each command I sent.
Example:
[quote]CellularRadio : +CREG: 2
CellularRadio : +CSQ: 18,0
CellularRadio : +CPAS: 0
[/quote]
Each command gets always a response… AT+CMGD=0,4 respond “OK” so the command is being interpreted but, I don’t know why, not correctly executed even if it doesn’t returns ERROR.
Between all my attempts, once AT+CMGD=0,4 has worked properly and the 6 SMS stored were deleted!
Seems to be a race condition, because I found a condition that delete all sms correctly:
- I added a breakpoint between commands “SendSms” and “DeleteAllSms”
- I waited until the SMS arrived on my smarphone before executing “DeleteAllSms” (thanks to breakpoing)
- I executed the “DeleteAllSms” and it worked
This is a snippet of my code:
Try
_Cell.SendSms(strNumber, strText)
Thread.Sleep(5000)
_Cell.DeleteAllSms()
Thread.Sleep(1000)
Catch ex As Exception
Debug.Print(ex.ToString)
WriteFileError("SendSmsMessage", ex.Message)
End Try
Before there was a Sleep of 1 second, now I set the Sleep at 5 seconds.
If I give enough time to send the SMS, the cellular radio module removes all SMS correctly.
But if the module requires more than 5 seconds to send the SMS?
What do you suggest to do to check when the module has completed to send?
Reading the documentation I found that after each SMS sent the module responds with “+CMGS: ” where is the message reference (index). When I receive this string I can raise an event “SmsSent”.
To you could be a good way?