【问题标题】:Multiple sms send in AT commands VB.NET多个短信发送 AT 命令 VB.NET
【发布时间】:2016-04-05 21:49:58
【问题描述】:

我正在尝试使用 AT 命令发送多条或批量短信。我尝试发送数据网格内的所有号码,但只发送第一个号码。

这是我的代码

    Dim sql As New MySqlDataAdapter("select StudentID, StudentName,StudentContact, DueDate  FROM issue inner join student on student.StudentID = issue.Student  ", conn)
     Dim ds As New DataSet
    sql.Fill(ds, 0)
    For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
        Dim wholenum As String
        Dim wholesms As String
        wholenum = ds.Tables(0).Rows(i).Item(2).ToString
        wholesms = "Hello " & ds.Tables(0).Rows(i).Item(1).ToString & ",  this is your Due Date  " & ds.Tables(0).Rows(i).Item(3).ToString & " pls return it on your due date"

        If SerialPort1.IsOpen Then
            Try
                With SerialPort1
                    .Write("AT" & vbCrLf)
                    .Write("AT+CMGF=1" & vbCrLf)
                    .Write("AT+CMGS=" & Chr(34) & wholenum & Chr(34) & vbCrLf)
                    .Write(wholesms & Chr(26))



                    MsgBox("Success sa SEND")


                    'update one 

                    'Call ConnectDatabase()
                    'com = New MySqlCommand("UPDATE issue SET Sent='1' ", conn)
                    'com.ExecuteNonQuery()
                    'Call DisconnectDatabase()

                End With

            Catch ex As Exception
                MsgBox("Bad Signal or No load")
            End Try

        Else
            MsgBox("Pls insert a modem")
        End If

我认为循环正在工作,因为它显示了数据网格视图中有多少内部的成功消息。但它只发送第一个号码。

【问题讨论】:

    标签: vb.net at-command bulksms


    【解决方案1】:

    您需要大幅修复您的 AT 命令处理。首先,您需要读取并解析调制解调器在发送 AT 命令行后发回给您的所有内容(顺便说一下,该命令行应该以 "\r" 而不是 vbCrLf 来终止)。

    在收到最终结果代码之前,永远不要开始发送新的命令行。对于AT+CMGS,在收到"\r\n >" 前缀之前,您永远不应该发送短信有效负载。

    thisthis 回答中涵盖了这些问题。但是您首先应该阅读V.250 specification 中第 5 章中的所有文本。使用 AT 命令时为really important document

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多