none
How to Send USSD Codes for Check Balance and Capture the USSD Reply Message using ZTE MF665C Modem RRS feed

  • Question

  • Hi,

    I'm Try to Send USSD code for check balance and capture the USSD reply from the provider. currently I can send SMS using below code. Please help me.

    My Task Is:

    1) Send SMS

    2) Check Credit Balance on Sim Card

    Device I Have: ZTE MF665C USB MODEM

    My Code:

    Imports System.IO.Ports
    Public Class Form1
        Dim GLOBAL_SMS_Message As String = ""
        Private Sub btnsend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsend.Click
    
            SerialPort1 = New System.IO.Ports.SerialPort()
            SerialPort1.PortName = "COM3"
            SerialPort1.BaudRate = 9600
            SerialPort1.Parity = Parity.None
            SerialPort1.StopBits = StopBits.One
            SerialPort1.DataBits = 8
            SerialPort1.Handshake = Handshake.RequestToSend
            SerialPort1.DtrEnable = True
            SerialPort1.RtsEnable = True
            SerialPort1.NewLine = vbCrLf
            GLOBAL_SMS_Message = txtmsg.Text
            SerialPort1.Open()
    
            If SerialPort1.IsOpen() = True Then
                SerialPort1.Write("AT" & vbCrLf)
                SerialPort1.Write("AT+CMGF=1" & vbCrLf)
                SerialPort1.Write("AT+CMGS=" & Chr(34) & (TextBox1.Text) & Chr(34) & vbCrLf)
                SerialPort1.Write(GLOBAL_SMS_Message & Chr(26))
                MsgBox("Sent")
                SerialPort1.Close()
    
            Else
                MsgBox("Port not available")
            End If
    
    
        End Sub
    
    End Class

    txtmsg.Text = Text Box for Write Message 

    TextBox1 = Type Phone Number 

    Thank You....!!!


    RohanD


    • Edited by RAT_SL Saturday, January 25, 2020 9:06 AM
    Saturday, January 25, 2020 9:05 AM

Answers

  • Rohan

    I don't know anything about USSD.  But, I know a lot about Windows CE and serial - so since nobody else replied, I will jump in.

    1. You don't tell us anything about what happens when you try this.  So you leave us to guess, which most of us don't like to do.
    2. You don't include much error checking, so you probably don't even know what happens when you try it.  So, you should first add some error checking.
    3. Since you have proven that your code does work (sometimes) for sending SMS, then the problem probably has a lot more to do with USSD, so I would recommend that try to find a discussion about USSD to ask your questions.  If no discussions, look for sample code.  Look for sample apps to test on your device.
    4. What little research that I did on USSD tells me that unlike SMS, USSD seems to be a two way communication, so your code won't work because you don't read the responses.

    Bruce Eitman
    Senior Enginer
    Bruce.Eitman AT Synopsys DOT com
    My BLOG http://geekswithblogs.net/bruceeitman
    I work for
    Synopsys

    Wednesday, January 29, 2020 3:24 PM
    Moderator