Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Mobile Development
  3. Mobile
  4. Sending SMS in PDu mode programatically in VB.Net

Sending SMS in PDu mode programatically in VB.Net

Scheduled Pinned Locked Moved Mobile
csharpvisual-studiohelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    JayKhatri
    wrote on last edited by
    #1

    Hi, I have been struggling to send sms using pdu mode in vb.net, My code is working fine for Text Mode, even I am sending sms from Hyperterminal with PDU command. When I try the same PDU in VB.Net code. The same is not working. I trying waiting for the port to respond. Used Thread.Sleep upto 10000ms but not succeed. Below is my code in VS 2005 (2.0 Framework) Dim firstarg As Integer = Convert.ToInt32(pdudata.Substring(0, 2)) firstarg = firstarg * 2 tmp = pdudata.Substring(2) tmp = tmp.Substring(firstarg) firstarg = tmp.Length \ 2 port.WriteLine("atz" & vbCrLf) port.WriteLine("ate0" & vbCrLf) port.WriteLine("AT+CMGF=0" & vbCrLf) read = New Byte(port.BytesToRead - 1) {} port.Read(read, 0, read.Length) 'txtsms.Text += Encoding.ASCII.GetString(inbuf); tmp = port.ReadExisting() port.WriteLine("AT+CMGS=15" & vbCrLf) Thread.Sleep(1000) port.WriteLine("0021000C91190910153570000002E834" & Chr(26)) Thread.Sleep(5000) port.DiscardOutBuffer() 'read = New Byte(port.BytesToRead - 1) {} 'port.Read(read, 0, read.Length) I tried using msgbox and found that everything is going perfect except the last command i.e. 0021.... chr(26) The given pdu is working in hyperterminal. Can u figure out the problem for me. Your solution will be highly appreciable as I am tired trying various combinations. Thanking you in the meantime. Jaidev Khatri

    A 1 Reply Last reply
    0
    • J JayKhatri

      Hi, I have been struggling to send sms using pdu mode in vb.net, My code is working fine for Text Mode, even I am sending sms from Hyperterminal with PDU command. When I try the same PDU in VB.Net code. The same is not working. I trying waiting for the port to respond. Used Thread.Sleep upto 10000ms but not succeed. Below is my code in VS 2005 (2.0 Framework) Dim firstarg As Integer = Convert.ToInt32(pdudata.Substring(0, 2)) firstarg = firstarg * 2 tmp = pdudata.Substring(2) tmp = tmp.Substring(firstarg) firstarg = tmp.Length \ 2 port.WriteLine("atz" & vbCrLf) port.WriteLine("ate0" & vbCrLf) port.WriteLine("AT+CMGF=0" & vbCrLf) read = New Byte(port.BytesToRead - 1) {} port.Read(read, 0, read.Length) 'txtsms.Text += Encoding.ASCII.GetString(inbuf); tmp = port.ReadExisting() port.WriteLine("AT+CMGS=15" & vbCrLf) Thread.Sleep(1000) port.WriteLine("0021000C91190910153570000002E834" & Chr(26)) Thread.Sleep(5000) port.DiscardOutBuffer() 'read = New Byte(port.BytesToRead - 1) {} 'port.Read(read, 0, read.Length) I tried using msgbox and found that everything is going perfect except the last command i.e. 0021.... chr(26) The given pdu is working in hyperterminal. Can u figure out the problem for me. Your solution will be highly appreciable as I am tired trying various combinations. Thanking you in the meantime. Jaidev Khatri

      A Offline
      A Offline
      a mlw walker
      wrote on last edited by
      #2

      This function worked for me. It sends a PDU message.

      Private Sub PDUSMS()
      If Comport = "" Then MsgBox("Please Choose A connection") : Return
      smsPort.PortName = Comport
      smsPort.BaudRate = "115200"
      smsPort.Parity = Parity.None
      smsPort.DataBits = 8
      smsPort.StopBits = StopBits.One
      smsPort.Handshake = Handshake.RequestToSend
      smsPort.DtrEnable = True
      smsPort.RtsEnable = True
      smsPort.NewLine = vbCrLf

          If Not (smsPort.IsOpen = True) Then
              smsPort.Open()
          End If
          At\_length = "17"
          PDU\_code = "079144772800800011000C914477529628010000AA03E8721E"
          'smsPort.WriteLine("AT" & vbCrLf)
          'System.Threading.Thread.Sleep(2000) 'Pause to allow last command to get to phone
          smsPort.WriteLine("AT+CMGF=0" & vbCrLf) 'open space for new message
          System.Threading.Thread.Sleep(2000) 'Pause to allow last command to get to phone
          smsPort.WriteLine("AT+CSMS=0" & vbCrLf) 'open space for new message
          System.Threading.Thread.Sleep(2000) 'Pause to allow last command to get to phone
          smsPort.WriteLine("AT+CMGS=" + At\_length + vbCrLf) '+ Chr(34) + At\_length + Chr(34) +
          System.Threading.Thread.Sleep(2000) 'Pause to allow last command to get to phone
          smsPort.WriteLine(PDU\_code + Chr(26)) 'number to send message to  + vbCrLf +
          System.Threading.Thread.Sleep(2000)
      
          If smsPort.IsOpen = True Then
              smsPort.Close()
          End If
      End Sub
      
      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups