Android Question BLE2 Scan(ServiceUUID as Object)

SteveTerrell

Active Member
Licensed User
Longtime User
Hi,
I am using the BLE2 example program with a Texas SensorTag.

B4X:
    manager.Scan(Null)    ' find all devices

Will find the device when scan and Connect is pressed then ReadData

B4X:
Public Sub ReadData
    For Each s As String In ConnectedServices
        Log("ReadData:Service "&s)
        manager.ReadData(s)
    Next
End Sub

reports

B4X:
ReadData:Service 00001800-0000-1000-8000-00805f9b34fb
ReadData:Service 00001801-0000-1000-8000-00805f9b34fb
ReadData:Service 0000180a-0000-1000-8000-00805f9b34fb
ReadData:Service f000aa00-0451-4000-b000-000000000000
ReadData:Service f000aa20-0451-4000-b000-000000000000
ReadData:Service f000aa40-0451-4000-b000-000000000000
ReadData:Service f000aa80-0451-4000-b000-000000000000
ReadData:Service f000aa70-0451-4000-b000-000000000000
ReadData:Service 0000ffe0-0000-1000-8000-00805f9b34fb
ReadData:Service f000aa64-0451-4000-b000-000000000000
ReadData:Service f000ac00-0451-4000-b000-000000000000
ReadData:Service f000ccc0-0451-4000-b000-000000000000
ReadData:Service f000ffc0-0451-4000-b000-000000000000

If i change Scan to

B4X:
Public Sub Scan
    Private serviceUUIDs as List
    serviceUUIDs.Initialize
    serviceUUIDs.Add("00001800-0000-1000-8000-00805f9b34fb")
    manager.Scan(serviceUUIDs)
End Sub

Nothing is found.

Is that the correct ServiceUUID object format?

Steve
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Note that you can write: manager.Scan(Array("00001800-0000-1000-8000-00805f9b34fb"))

Your code is correct. The issue is probably related to this Android bug: https://code.google.com/p/android/issues/detail?id=59490

You will need to scan for all services and manually filter based on the Id or the data in the advertising data.
 
Upvote 0
Top