How to cancel a USSD response

I have a Nokia device connected to a PC

This is the code I use to send the USSD command:

Port.Write("AT+CUSD=0,\"*147*1*#\",15\r\n");

It works great, BUT it displays a service selection option. I want to stop it OR exit (exit) from this message. I can press the cancel button from the phone, but how can I do this using C #?

+5
source share
2 answers

I publish this because it is one of the best results regarding terminating USSD sessions using AT commands, and also because the answers are vague. This is the C # code that I used at the end (I sent commands to the gsm modem). Hope this helps someone else.

    SerialPort SendingPort=null;

    public string TerminateUssdSession()
    {
            InitializePort();

            //// generate terminate command for modem
            string cmd = "";
            cmd = "AT+CUSD=2\r";

            // send cmd to modem
            OpenPort();

            SendingPort.Write(cmd);

            Thread.Sleep(500);

            string response = SendingPort.ReadExisting();

            return response;

    }

    private void InitializePort()
    {
        if (SendingPort == null)
        {
            SendingPort = new SerialPort();
            SendingPort.PortName = PortName;//put port name e.g COM5
            SendingPort.BaudRate = 112500;
            SendingPort.Parity = Parity.None;
            SendingPort.DataBits = 8;
            SendingPort.StopBits = StopBits.One;
            SendingPort.Handshake = Handshake.None;
            SendingPort.ReadTimeout = 500;
        }
    }

    private void OpenPort()
    {
        if (!SendingPort.IsOpen)
        {
            SendingPort.Open();
        }
    }
+1
source

, AT + CUSD = 2 . , USSD ( - )

0

All Articles