Problem showing received SMS

Asked

Viewed 113 times

6

Fala galera!

I’m trying to show a SMS received in a text box in a Form that I have, but instead of showing me the message that I get in my SIM, it shows something like +CMTI: "ME",33. I’ll leave the code I have down:

Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO.Ports
Imports System.Text

Public Class Form1
Dim inputData As String = ""
Public Event DataReceived As IO.Ports.SerialDataReceivedEventHandler

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    SerialPort1.PortName = "COM5"
    SerialPort1.BaudRate = 9600
    SerialPort1.Parity = Parity.None
    SerialPort1.DataBits = 0
    SerialPort1.StopBits = StopBits.One
    SerialPort1.Handshake = Handshake.None
    SerialPort1.RtsEnable = True

    SerialPort1.Open()
End Sub



Private Sub SerialPort1_DataReceived(sender As Object, e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
    inputData = SerialPort1.ReadExisting()
    Me.Invoke(New EventHandler(AddressOf DoUpdate))
End Sub

Public Sub DoUpdate()
    TextBox1.Text = TextBox1.Text & inputData
End Sub


End Class

Can someone give me a help how to show the message in the call Plain text and not as it is showing?

NOTE: Both Portname and the rest are correct

  • What have you got in inputData on the line inputData = SerialPort1.ReadExisting()?

  • Readexisting receives the last message that arrived, in my case, when I send an SMS Readexisting will store that message

  • Yes, and what it returns and stores in inputData?

  • 1

    What API are you using to forward/receive these messages ?

1 answer

1

+CMTI: "ME",33 is the indication of the GSM module that a message has been received, you need to give a command to read the message. The commands may vary a little according to the module, but they are usually very similar.

You must:

  1. You must await the receipt of a: +CMTI: Mem, index (Mem->message storage location, index-> message position in memory);
  2. Give SMS read command: AT+CMGR=index[,mode] (index-> message position in memory, mode-> read mode, 0 for normal);
  3. Interpret the received message, it will come, +or-, in this pattern: +CMGR: "REC READ","+85291234567","07/02/18,00:12:05+32"

Hello, Welcome to our SMS tutorial.

OK

Here is the datasheet of a very common GSM module, which may look like your:http://www.espruino.com/datasheets/SIM900_AT.pdf

Browser other questions tagged

You are not signed in. Login or sign up in order to post.