Usuario
Consulta mensajeria sms

Pregunta
-
Buenas estoy haciendo una aplicacion en la cual envio y recibo mensajes de texto con un celular o un chip del celular conectados al usb y convirtiendolo en un puerto, el problema es que ya envio los mensajes pero no puedo ver los recibidos, la aplicacion la estoy realizando en vb.net 2010, gracias por su ayuda
Todas las respuestas
-
Hola Fernando,
Deberias ampliar la explicacion... con dicha información es dificil entender como responder a tus dudas.
Se entiende que el 'celular' dispone de un protoco concreto y que estas enviando la trama para leer los mensajes recibidos... quizas no esta respondiendo porque le falta algun requisito... la suma de verificacion, la terminacion de trama...etc.
Saludos,
PepLluis,
MVP - Visual Developer -
Yo lo solucioné de la siguiente manera, pero no estoy conforme aún.
Lista es un MSFlexGrid
Sub leer(Puerto As Integer)
On Error GoTo lbl_error
Timerinterval.Interval = 0
Lista.Clear
Lista.Rows = 0
Dim s As Integer
s = 0
If GSMComm.PortOpen = False Then
GSMComm.CommPort = Puerto
GSMComm.PortOpen = True
End If
smsdata = "AT"
GSMComm.Output = smsdata & Chr(13)
Sleep 300
smsdata = "AT+MODE=2"
GSMComm.Output = smsdata & Chr(13)
Sleep 300
smsdata = "AT+CMGF=1" & Chr(13)
GSMComm.Output = smsdata
Sleep 300
smsdata = "AT+CMGL = ""ALL""" & Chr(13)
GSMComm.Output = smsdata
Sleep 1000
buffe = Empty
Do
DoEvents
buffe = buffe & GSMComm.Input
If InStr(buffe, "ERROR" & vbCrLf) Then
GSMComm.InputMode() = InputModeConstants.comInputModeText 'Borrar el búfer de recepción
Exit Do
End If
'Debug.Print buffe
Loop Until InStr(buffe, "OK" & vbCrLf)
If InStr(buffe, "OK" & vbCrLf) Then
GSMComm.InputMode() = InputModeConstants.comInputModeText 'Borrar el búfer de recepción
arreglo = Split(buffe, Chr(13))
'pantalla = buffe
buffe = ""
End If
smsdata = Empty
buffe = Empty: flag = 0
If IsArray(arreglo) Then
For k = 11 To UBound(arreglo)
If arreglo(k) <> "" And Len(arreglo(k)) > 10 Or k > 11 Then
linea = Replace(arreglo(k), vbCrLf, "")
linea = Replace(linea, vbCrLf & vbCrLf, "")
linea = Replace(linea, vbCrLf, "")
linea = Replace(linea, "?", "")
linea = Replace(linea, vbTab, "")
linea = Replace(linea, vbNewLine, "")
linea = Replace(linea, vbCr, "")
linea = Replace(linea, vbLf, "")
linea = Replace(linea, vbNullChar, "")
linea = Replace(linea, Chr$(10), "")
linea = Replace(linea, Chr$(13), "")
linea = Replace(linea, Chr$(13) & Chr$(10), "")
linea = Replace(linea, vbCr & vbLf, "")
linea = Replace(linea, vbLf & vbCr, "")
linea = Replace(linea, ";", "-")
linea = Replace(linea, ".", "")
If linea <> "" And InStr(linea, "+CMGL: ") > 0 Then
Lista.Rows = Lista.Rows + 1
linea = Replace(linea, Empty, "")
linea = Replace(linea, vbTab, "")
linea = Replace(linea, Chr(13), "")
If aux <> "" Then
linea = Replace(linea, ",", ".")
Else
linea = Replace(linea, ",", "</*>")
End If
linea = Replace(linea, Chr(34), "")
linea = Replace(linea, vbNullChar, "")
ElseIf flag = 1 Then
linea = ""
GoTo lbl_sigue
End If
'....
If Len(Trim(linea)) > 0 Then
If aux = "" Then
If k Mod 2 And flag = 0 Then
aux = linea
If InStr(aux, "+CMGL: ") > 0 Then
aux = Replace(aux, "+CMGL: ", "")
Else
aux = ""
flag = 0
GoTo lbl_sigue
End If
ElseIf aux <> "" Then
aux = aux & "," & linea
vector = Split(aux, "</*>")
cadena = ""
For h = 0 To UBound(vector)
'cadena = cadena & vector(h) & ";"
Lista.TextMatrix(s, h) = vector(h)
Next h
s = s + 1
If h = 2 Then cadena = cadena & "???;"
cadena = Replace(cadena, """", "")
cadena = Replace(cadena, ",", ";")
aux = ""
flag = 0
Else
aux = linea
aux = Replace(aux, "+CMGL: ", "")
End If
Else
flag = 1
If Not k Mod 2 Then
aux = aux & "</*>" & linea
vector = Split(aux, "</*>")
cadena = ""
For h = 0 To UBound(vector)
'cadena = cadena & vector(h) & ";"
Lista.TextMatrix(s, h) = vector(h)
Next h
s = s + 1
aux = ""
flag = 0
ElseIf aux <> "" Then
aux = linea
aux = Replace(aux, "+CMGL: ", "")
End If
End If
Else
aux = ""
End If
End If
lbl_sigue:
Next k
End If
GSMComm.PortOpen = False
Me.Timerinterval.Interval = 5000
lbl_exit:
Exit Sub
lbl_error:
MsgBox Err.Description & Err.Number, vbExclamation, titulo
Resume lbl_exit
End SubAGREGO:
si deseas ver un ejemplo, que puede darte alguna idea: http://www.tucondominioaldia.com.ve/sms.php
- Editado guarracuco miércoles, 28 de diciembre de 2011 12:40