Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Main As Panel
Dim Serial1 As Serial
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Utilities")
Serial1.Initialize("Serial1")
End Sub
Sub ConnectToBlueTooth
Dim PairedDevices As Map
PairedDevices.Initialize
PairedDevices = Serial1.GetPairedDevices
Dim List1 As List
List1.Initialize
For i = 0 To PairedDevices.Size - 1
List1.Add(PairedDevices.GetKeyAt(i)) 'add the friendly name to the list
Next
Dim res As Int
res = InputList(List1, "Choose device", -1) 'show list with paired devices
If res <> DialogResponse.CANCEL Then
Serial1.Connect(PairedDevices.Get(List1.Get(res))) 'convert the name to mac address
End If
End Sub
Sub Serial1_Connected (Success As Boolean)
If Success Then
ToastMessageShow("Connected successfully", False)
Else
Msgbox(LastException.Message, "Error connecting.")
End If
End Sub
Log="java.io.IOException: Service discovery failed"
---------------------------------------------------
Hello:
I'm trying the Bluetooth sample but:
It lists the paired devices but it fails to connect:
Am I missing something?
Thank you:
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Main As Panel
Dim Serial1 As Serial
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Utilities")
Serial1.Initialize("Serial1")
End Sub
Sub ConnectToBlueTooth
Dim PairedDevices As Map
PairedDevices.Initialize
PairedDevices = Serial1.GetPairedDevices
Dim List1 As List
List1.Initialize
For i = 0 To PairedDevices.Size - 1
List1.Add(PairedDevices.GetKeyAt(i)) 'add the friendly name to the list
Next
Dim res As Int
res = InputList(List1, "Choose device", -1) 'show list with paired devices
If res <> DialogResponse.CANCEL Then
Serial1.Connect(PairedDevices.Get(List1.Get(res))) 'convert the name to mac address
End If
End Sub
Sub Serial1_Connected (Success As Boolean)
If Success Then
ToastMessageShow("Connected successfully", False)
Else
Msgbox(LastException.Message, "Error connecting.")
End If
End Sub
Log="java.io.IOException: Service discovery failed"
---------------------------------------------------
Hello:
I'm trying the Bluetooth sample but:
It lists the paired devices but it fails to connect:
Am I missing something?
Thank you:
Last edited: