标签: gsmcomm

使用GSMComm库获取USSD结果

我正在尝试通过gsm调制解调器运行usdd代码以获取sim卡余额。我正在使用GsmComm库,ASP.NET Web窗体,C#。下面是我的代码:

    public string SendUssdRequest2(string request)
    {
        comm = ConnectAndGetComm();
        string data = TextDataConverter.StringTo7Bit(request);

        string msg = "";
        var asPDUencoded = Calc.IntToHex(TextDataConverter.SeptetsToOctetsInt(data));
        try
        {
            IProtocol protocol = comm.GetProtocol();
            string gottenString = protocol.ExecAndReceiveMultiple("AT+CUSD=1," + asPDUencoded + ",15");
            var re = new Regex("\".*?\"");
            int i = 0;
            if (!re.IsMatch(gottenString))
            {
                do
                {
                    protocol.Receive(out gottenString);
                    ++i;
                } while (!(i >= 5
                           || re.IsMatch(gottenString)
                           || gottenString.Contains("\r\nOK")
                           || gottenString.Contains("\r\nERROR")
                           || gottenString.Contains("\r\nDONE"))); 
            }

            string m = re.Match(gottenString).Value.Trim('"');
            return PduParts.Decode7BitText(Calc.HexToInt(m));
        }
        catch(Exception e)
        {
            msg = e.Message; …
Run Code Online (Sandbox Code Playgroud)

c# gsm gsmcomm

6
推荐指数
1
解决办法
94
查看次数

如何在GSMComm库中连接长短信?

这是我的代码:

根据这个页面,CreateConcatTextMessage方法返回一个类型的数组,SmsSubmitPdu[]但是,当我尝试发送它时,SendMessages我得到一个MessageServiceError 500.我错过了什么?

       SmsSubmitPdu[] pdu2;

        try{
            pdu2 = SmartMessageFactory.CreateConcatTextMessage("My name is Barry Allen. And I am the fastest man alive. When I was a child I saw my mother killed by something impossible. My father went to prison for her murder.", "+639234597676");
            comm.SendMessages(pdu2);
        }

        catch (MessageServiceErrorException e500){
            MessageBox.Show(e500.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }
        catch (CommException e501){
            MessageBox.Show(e501.ToString(), "Information", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }
Run Code Online (Sandbox Code Playgroud)

c# sms gsm pdu gsmcomm

5
推荐指数
2
解决办法
1304
查看次数

标签 统计

c# ×2

gsm ×2

gsmcomm ×2

pdu ×1

sms ×1