c# - 使用 GSMComm ReadMessage 错误的 SMS 传递报告
问题描述
我一直在尝试在 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."
}
}
解决方案
推荐阅读
- r - 从 r 中的日期减去十进制年份
- security - 自动创建 CTF 问题
- php - 使用电子邮件、密码或手机号码登录 api,codeigniter 中的密码
- android - 如何根据构建风格禁用 Google 的应用内更新?
- python - 使用 for 循环在 tkinter 中创建按钮并为每个按钮提供唯一的输入
- javascript - 将带有对象和其他字段的嵌套数组上传到 Firestore 的优雅方法是什么?(Node.js,Javascript)
- python - 提取深度嵌套 JSON 中的所有特定值对
- java - 使用 Simba Spark JDBC 驱动程序的多语句查询
- python - 如何在 Python 中制作(字符串)标签数据的 2D 直方图/热图?
- mysql - 使用 AND 条件创建弹性搜索查询并获取计数总和