Sub Class_Globals
Dim serial1 As Serial 'Bluetooth Serial Port
Dim AStream As AsyncStreams 'ASyncronous Streams returned by the scanner once connected
Dim et As Object 'EditText Object transferred by requesting Activity, used to return value to EditText on scanner return
End Sub
'Event Raised after we try to connect to Serial BT
'If connection succed then success boolean will return true
'we then can connect the async Stream to that Serial port
'if Success return False then we notify user that connection Failed and wait for his choice
Sub Serial1_Connected (Success As Boolean)
If Success = True Then
ToastMessageShow("Scanner Connecté",False)
Log("Scanner is now connected. Waiting for data...")
AStream.Initialize(serial1.InputStream, serial1.OutputStream, "AStream")
Else
If Starter.kvs.ContainsKey(Starter.MAC_ADDRESS_Scanner) Then
Log("Trying to connect to mac address : " & Starter.kvs.Get(Starter.MAC_ADDRESS_Scanner))
If Starter.firsttry Then
Starter.firsttry = False 'set to false has we have first try it once
ToastMessageShow("Tentative de connexion au scanner...",True)'----------------------------- toast message works
serial1.Connect(Starter.kvs.Get(Starter.MAC_ADDRESS_Scanner)) 'convert the name to mac address and connect
Else
Log("Ask user what he wanna do as we are not able to connect to the actual scanner")
Msgbox2Async("Connection Impossible, Verifiez que le scanner est allumé. Voulez vous réessayer ?","Erreur de connexion","Oui","Annuler","Choisir un autre scanner",Null,False)'----------------------------This line gives me the error I post erlier.
Wait For Msgbox_Result (result As Int)
Select Case result
Case DialogResponse.POSITIVE
Log("Trying to reconnect Scanner once again...")
' serial1.Connect(Starter.kvs.Get(Starter.MAC_ADDRESS_Scanner)) 'convert the name to mac address and connect
ConnectSerial 'Trying to reconnect
Case DialogResponse.NEGATIVE
Log("User want to change Scanner MAC Address")
ShowPairedDevices
Case DialogResponse.CANCEL
Log("Cancel selected so return")
Starter.kvs.Remove(Starter.MAC_ADDRESS_Scanner) '--------------------------------------------------debug only
Return
End Select
End If
Else
Log("As no scanner already connected ... ask user to choose a scanner")
ShowPairedDevices
End If
End If
End Sub