【问题标题】:GSM USSD Modem RequestGSM USSD 调制解调器请求
【发布时间】:2016-04-26 20:52:07
【问题描述】:

如何使用 c# 通过 GSM 调制解调器发送 USSD 请求。

我希望能够执行任何代码,并且响应应该以对象或字符串的形式返回,我可以将其用于正则表达式

【问题讨论】:

  • 回答这个问题需要更多信息... C# 不包括对此的本机支持。你在使用任何库吗?
  • 我正在使用 GSM 通信库

标签: c# gsm modem


【解决方案1】:

这是我在 GSM COMm 库中使用的摘录

   public string SendUssdRequest(string request)
  {
    log.DebugFormat("Sending USSD Request {0}", request);
    string result = "";
    try
    {
        IProtocol protocol = comm.GetProtocol();
        string gottenString = protocol.ExecAndReceiveMultiple("AT+CUSD=1," + request + ",15");
        result = gottenString;
        int i = 0;
        if (!gottenString.Contains("\r\n+CUSD: 2"))
        {
            bool receiving = false;
            do
            {
                receiving = protocol.Receive(out gottenString);
                result += gottenString;
                ++i;
            } while (receiving);
        }

        result = result.Replace("\r\n", "");

        result = result.Replace("+CUSD: 2,", "");
        result = result.Replace(",15", "");
        log.DebugFormat("{1} - USSD Response is:  {0}", result,SenderNumber);
        return result;
    }
    catch(Exception ex) 
    {
        log.Error(ex);
    }
    finally
    {

        comm.ReleaseProtocol();
    }
    return "";
}

【讨论】:

  • 我会试试这个。感谢您的回复
  • 什么是 SenderNumber 变量,我假设 comm 是 GSM 通信对象?
  • 发件人号码是我存储在课堂上的另一个属性。如果您跟踪它,您可以删除它或设置实际的电话号码
  • 啊,这似乎有效。我不是在循环响应。感谢@Scrappy 的帮助
猜你喜欢
  • 1970-01-01
  • 2013-12-05
  • 1970-01-01
  • 1970-01-01
  • 2019-02-03
  • 1970-01-01
  • 1970-01-01
  • 2015-11-28
  • 1970-01-01
相关资源
最近更新 更多