Hi,
I’m trying to port a software of mine (vb6) to b4j
but I don’t understand how to send AT commands to my 3g modem (I see it in com3 in Windows)
Could you please help me?
To send AT commands and handle modem responses I suggest you look at the AsyncStreamsText class. I have found it very good and easy to implement when you just need to send and receive strings (text).
Here's a skeleton of some B4J code which you could use to send AT commands and then process the responses:
B4X:
Sub Process_Globals
Private sp As Serial
Private ast As AsyncStreamsText
End Sub
Sub AppStart (Form1 As Form, Args() As String)
sp.SetParams(115200,8,1,0) ' Set speed, etc.
ast.Initialize(Me, "ast", sp.GetInputStream, sp.GetOutputStream)
End Sub
Sub ast_NewText(Text As String)
Log (Text) ' Process received string here
End Sub
Sub btnAT_Click
ast.Write("AT..." & Chr(10) & Chr(13)) ' Send AT command as a string here
End Sub