GsmComm USSD command
Asked Answered
G

3

2

I have been using scampers library to send and receive SMS through a GSM modem. It is working pretty much the way I wanted. But the problem I stuck with is I can not issue command like *101# or similar, after doing some research I found these command are called USSD command. So my question is, has anyone been able to issue USSD command through Scampers library.

Gunshy answered 23/2, 2012 at 4:36 Comment(0)
E
6

USSD is a different protocol than SMS so you can't use an SMS centric library to send USMD messages. It would be like trying to send http requests from an ftp client library.

Euphemism answered 27/2, 2012 at 8:15 Comment(2)
Here's an example using SMSLib for .net (hope that's what you wanted) groups.google.com/group/smslib-dotnet/browse_thread/thread/… smslib.org/doc/smslib/dotnetEuphemism
@Euphemism , the group link appears to be broken. can you provide any other reference?Kirkpatrick
T
6

This worked quite nicely for me using GsmComm:

    public string SendUssdRequest(string request)
    {
        string data = TextDataConverter.StringTo7Bit(request);

        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"))); //additional tests "just in case"
            }
            string m = re.Match(gottenString).Value.Trim('"');
            return PduParts.Decode7BitText(Calc.HexToInt(m));
        }
        catch { }
        finally
        {
            _comm.ReleaseProtocol();
        }
        return "";
    }
Turnip answered 12/11, 2013 at 10:33 Comment(3)
How can i find port number for _comm and if i set default port number by GsmComm.defaultportnumber then i only received that exception "Communication thread isn't running".Alessi
What is the type of _comm ?Kirkpatrick
hi, when i use your code i get this exception: "Message = "Mobile equipment error 50 occurred." what's the problem? i think you change some settings for _comm object before sending request.Assegai
E
0

the type of _comm is a GsmCommMain

using GsmComm.GsmCommunication;
using GsmComm.PduConverter;
using GsmComm.PduConverter.SmartMessaging;

GsmCommMain _comm;
Endurance answered 18/5, 2017 at 13:24 Comment(1)
You should post a comment, not just plain code in order to make a good answer.Allveta

© 2022 - 2024 — McMap. All rights reserved.