我一直在尝试在 C# 应用程序中使用 GSMComm 库,以便使用 GSM 调制解调器(wavecom)发送 SMS 消息(接收传递报告)。我已经阅读了 SO 中所有类似的线程,但没有帮助。错误:“消息类型 SmsDeliverReport 已识别,但 SMS 解码器不支持。”
public bool SendSMS()
{
try
{
string strMsg = "Hello";
string strSendPhoneNum = "phone num";
string strSimPhoneNum = "phone num";
if (comm.IsConnected() == false) comm.Open();
var dcs = (byte)DataCodingScheme.GeneralCoding.Alpha16Bit;
GsmComm.PduConverter.SmsSubmitPdu pdu = new GsmComm.PduConverter.SmsSubmitPdu(strMsg, strSendPhoneNum, strSimPhoneNum, dcs);
pdu.RequestStatusReport = true;
comm.SendMessage(pdu);
SmsDeliverMessageFlags sdmf = new SmsDeliverMessageFlags();
string DeliverRpt = sdmf.MessageType.ToString();
return true;
}
catch (Exception ex)
{
return false;
}
}
private void comm_MessageReceived(object sender, GsmComm.GsmCommunication.MessageReceivedEventArgs e)
{
try
{
IMessageIndicationObject obj = e.IndicationObject;
//Get status report for this condition
if (obj is MemoryLocation)
{
MemoryLocation loc = (MemoryLocation)obj;
string stTemp = string.Format("New message received in storage \"{0}\", index {1}.", loc.Storage, loc.Index);
var msg = comm.ReadMessage(loc.Index, loc.Storage);
if (((SmsPdu)msg.Data) is SmsStatusReportPdu)
{
SmsStatusReportPdu data = (SmsStatusReportPdu)msg.Data;
string strTemp2 = "rec msg ref #: " + data.MessageReference;
}
string strTemp3 = msg.Status.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message); //Error:"Message type SmsDeliverReport recognized, but not supported by the SMS decoder."
}
}