I'm using BLE2 to connect to a bluetooth device. I can "see" the device when scanning but it won't connect, the event is never raised.
Log:
Found: G0600387, 88:1B:99:0A:A8:8E, RSSI = -44, (MyMap) {1=[B@c78e873, 9=[B@2403330, 3=[B@c0e9ba9, 10=[B@35bf52e, 0=[B@26f98cf}
02
F0FF
4730363030333837
02
020102090947303630303338370303F0FF020A02000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Disconnected
I am using pretty much the same code in b4i and it works fine.. I have also tried not specifying the deviceid when scanning - but nothing changes.
Any advice would be much appreciated - here's the code I'm using...
Thanks!
Log:
Found: G0600387, 88:1B:99:0A:A8:8E, RSSI = -44, (MyMap) {1=[B@c78e873, 9=[B@2403330, 3=[B@c0e9ba9, 10=[B@35bf52e, 0=[B@26f98cf}
02
F0FF
4730363030333837
02
020102090947303630303338370303F0FF020A02000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Disconnected
I am using pretty much the same code in b4i and it works fine.. I have also tried not specifying the deviceid when scanning - but nothing changes.
Any advice would be much appreciated - here's the code I'm using...
Thanks!
B4X:
Private SID As String = "0000-fff0-0000-1000-8000-00805f9b34fb"
Public Sub StartScan
If manager.State <> manager.STATE_POWERED_ON Then
Log("Not powered on.")
Else If rp.Check(rp.PERMISSION_ACCESS_COARSE_LOCATION) = False Then
Log("No location permission.")
Else
manager.Scan2(Array(SID), False)
End If
End Sub
Sub Manager_DeviceFound (Name As String, Id As String, AdvertisingData As Map, RSSI As Double)
Log("Found: " & Name & ", " & Id & ", RSSI = " & RSSI & ", " & AdvertisingData)
Dim data1() As Byte = AdvertisingData.Get(1)
Dim data2() As Byte = AdvertisingData.Get(3)
Dim data3() As Byte = AdvertisingData.Get(9)
Dim data4() As Byte = AdvertisingData.Get(10)
Dim data5() As Byte = AdvertisingData.Get(0)
'you can use byte converter to convert to hex if you like:
Dim bc As ByteConverter
Log(bc.HexFromBytes(data1))
Log(bc.HexFromBytes(data2))
Log(bc.HexFromBytes(data3))
Log(bc.HexFromBytes(data4))
Log(bc.HexFromBytes(data5))
ConnectedName = Name
manager.StopScan
manager.Connect2(Id, False) 'disabling auto connect can make the connection quicker
End Sub
[code]