I've been trying to use GSMComm library in a C# app, in order to sent SMS messages using a mobile phone (connected via USB cable) as a GSM modem. I've read all similar threads in SO, but didn't help.
Everything works well, except the delivery reports. I set RequestStatusReport to true and i enabled notifications (EnableMessageNotifications()).
The problem is that i am not able to read the received delivery report, although i know its storage (it's always "SR") and index number. I keep getting a 321 error code (invalid index) because SR storage looks empty when i try to read from it.
The MessageReceived event code and the corresponding report are as following, any help would be greatly appreciated!
private static void Comm_MessageReceived(object sender, MessageReceivedEventArgs e)
{
IMessageIndicationObject obj = e.IndicationObject;
if (obj is MemoryLocation)
{
MemoryLocation loc = (MemoryLocation)obj;
Util.AddLog(string.Format("New message received in storage \"{0}\", index {1}.", loc.Storage, loc.Index));
DecodedShortMessage msg = Comm.ReadMessage(loc.Index, loc.Storage);
if (((SmsPdu)msg.Data) is SmsStatusReportPdu)
{
SmsStatusReportPdu data = (SmsStatusReportPdu)msg.Data;
Util.AddLog("rec msg ref #: " + data.MessageReference.ToString());
}
}
else
{
Util.AddLog("Error: Unknown notification object!");
}
}
Report:
New message received in storage "SR", index 0.
[GSM_LOG] 17:08:49.528 Reading message...
[Catch in MessageReceived] ##### ERROR: Message service error 321 occurred.
[GSM_LOG] 17:08:49.501 [gsmphone] >>
[GSM_LOG] 17:08:49.501 [gsmphone] +CDSI: "SR",0
[GSM_LOG] 17:08:49.501 [gsmphone]
[GSM_LOG] 17:08:49.501 [gsmphone] Unsolicited message: New SMS-STATUS-REPORT received (indicated by memory location)
[GSM_LOG] 17:08:49.501 [gsmphone] Firing async MessageReceived event.
[GSM_LOG] 17:08:49.528 [gsmphone] Selecting "SR" as read storage...
[GSM_LOG] 17:08:49.528 [gsmphone] << AT+CPMS="SR"
[GSM_LOG] 17:08:49.528 [gsmphone]
[GSM_LOG] 17:08:49.528 [gsmphone] >> AT+CPMS="SR"
[GSM_LOG] 17:08:49.528 [gsmphone]
[GSM_LOG] 17:08:49.528 [gsmphone] +CPMS: 0,0,0,23,1,40
[GSM_LOG] 17:08:49.528 [gsmphone]
[GSM_LOG] 17:08:49.528 [gsmphone] OK
[GSM_LOG] 17:08:49.528 [gsmphone]
[GSM_LOG] 17:08:49.528 [gsmphone] Memory status: 0/0 (0% used)
[GSM_LOG] 17:08:49.528 [gsmphone] Activating PDU mode...
[GSM_LOG] 17:08:49.528 [gsmphone] << AT+CMGF=0
[GSM_LOG] 17:08:49.528 [gsmphone]
[GSM_LOG] 17:08:49.528 [gsmphone] >> AT+CMGF=0
[GSM_LOG] 17:08:49.528 [gsmphone]
[GSM_LOG] 17:08:49.528 [gsmphone] OK
[GSM_LOG] 17:08:49.528 [gsmphone]
[GSM_LOG] 17:08:49.528 [gsmphone] Reading message from index 0...
[GSM_LOG] 17:08:49.528 [gsmphone] << AT+CMGR=0
[GSM_LOG] 17:08:49.528 [gsmphone]
[GSM_LOG] 17:08:49.528 [gsmphone] >> AT+CMGR=0
[GSM_LOG] 17:08:49.528 [gsmphone]
[GSM_LOG] 17:08:49.528 [gsmphone] +CMS ERROR: 321
[GSM_LOG] 17:08:49.528 [gsmphone]
[GSM_LOG] 17:08:49.545 [gsmphone] Failed. Phone reports message service (MS) error 321.
[GSM_LOG] 17:08:49.545 [gsmphone] AT+CMGR=0
[GSM_LOG] 17:08:49.545 [gsmphone]
[GSM_LOG] 17:08:49.545 [gsmphone] +CMS ERROR: 321
[GSM_LOG] 17:08:49.545 [gsmphone]
[GSM_LOG] 17:08:49.548 [gsmphone] Ending async MessageReceivedEventHandler call