Android Question serial connection

jinyistudio

Well-Known Member
Licensed User
Longtime User
How to detect serial object "connection" or "disconnection" ? serial object haven't "connected" property,could tell me it is connecting or disconnecting now !
 
Sub Globals
Dim SerialConnected As Boolean
End Sub

SerialConnected = true
AStream.Initialize(serial1.InputStream, serial1.OutputStream, "AStream")

if SerialConnected Then
......
End if

Sub AStream_Error
SerialConnected = False
End Sub

Sub AStream_Terminated
SerialConnected = False
End Sub
 
Upvote 0
If serial is connected it raises the event just set some boolean there

Code: Copy
Sub Serial1_Connected (Success As Boolean)
    'ProgressDialogHide
    'ToastMessageShow("connected: " & Success, True)
    If Success = False Then
        'Log(LastException.Message)
        ToastMessageShow("Error connecting: " & LastException.Message, True)
        Main.blue_connected = False
       
    Else
        Main.blue_connected = True
        serial1.Listen
        Asyx.InitializePrefix(serial1.InputStream, False, serial1.OutputStream, "Asyx")
    End If
End Sub
 
Upvote 0
Back
Top