Results 1 to 1 of 1

Thread: Help my me please with at command im using 3g usb dongle

  1. #1

    Thread Starter
    Registered User
    Join Date
    Jan 2015
    Posts
    2

    Help my me please with at command im using 3g usb dongle

    HERE'S MY CODE

    Imports System.Management
    Imports System.Threading

    Public Class Form6

    Private Sub serialport1_datareceived(sender As Object, e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
    Dim datain As String = ""
    Dim numbytes As Integer = SerialPort1.BytesToRead
    For i As Integer = 1 To numbytes
    datain &= Chr(SerialPort1.ReadChar)
    Next
    test(datain)
    End Sub

    Private Sub test(indata As String)
    rcvdata &= indata

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Try
    With SerialPort1
    .PortName = Label1.Text
    .BaudRate = 9600
    .Parity = IO.Ports.Parity.None
    .DataBits = 8
    .StopBits = IO.Ports.StopBits.One
    .Handshake = IO.Ports.Handshake.None
    .RtsEnable = True
    .ReceivedBytesThreshold = 1
    .NewLine = vbCr
    .ReadTimeout = 1000
    .Open()
    End With

    If SerialPort1.IsOpen Then
    Label3.Text = "Connected"
    Else
    Label3.Text = "Got Some Error"

    End If
    Catch ex As Exception
    MsgBox(ex.Message)
    End Try
    End Sub

    Private Sub Form6_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim ports() As String
    ports = Split(ModemsConnected(), "***")
    For i As Integer = 0 To ports.Length - 2
    ComboBox1.Items.Add(ports(i))
    Next
    End Sub

    Dim rcvdata As String = ""
    Public Function ModemsConnected() As String
    Dim modems As String = ""
    Try
    Dim searcher As New ManagementObjectSearcher( _
    "root\CIMV2", _
    "SELECT * FROM Win32_POTSModem")

    For Each queryObj As ManagementObject In searcher.Get()
    If queryObj("Status") = "OK" Then
    modems = modems & (queryObj("AttachedTo") & " - " & queryObj("Description") & "***")
    End If
    Next
    Catch err As ManagementException
    MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
    Return ""
    End Try
    Return modems
    End Function

    Private Sub ComboBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedIndexChanged

    End Sub

    Private Sub ComboBox1_SelectedValueChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedValueChanged
    Label1.Text = Trim(Mid(ComboBox1.Text, 1, 5))
    End Sub

    Private Sub cmdsend_Click(sender As Object, e As EventArgs) Handles cmdsend.Click
    Try
    With SerialPort1
    .Write("at" & vbCrLf)
    Threading.Thread.Sleep(1000)
    .Write("at+cmgf=1" & vbCrLf)
    Threading.Thread.Sleep(1000)
    .Write("at+cmgf=" & Chr(34) & txtnumber.Text & Chr(34) & vbCrLf)
    .Write(txtmessage.Text & Chr(26))
    Threading.Thread.Sleep(1000)
    MsgBox(rcvdata.ToString)
    End With
    If rcvdata.ToString.Contains(">") Then
    MsgBox("Message Sent")
    Else
    MsgBox("Got some Error")
    End If

    Catch ex As Exception

    End Try
    End Sub
    End Class
    Attached Images Attached Images  

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width