Android Question BLE2 Scan SSID

fbritop

Active Member
Licensed User
Longtime User
I'm trying to connect to an ESP32 GATT service.

When I use BLE.Scan(Null) it scans for all services and later in the "DeviceFound" event I filter by the device Name.

I'm trying to restrict the scan with the UUID, but it never founds the device:

B4X:
    Dim SSID As List
    SSID.Initialize
    SSID.Add("5f6d4f53-5f52-5043-5f53-56435f49445f")
    BLE.Scan2(SSID, True)

I'm sure of the UUID as if I scan with null option, it readĀ“s it, and the UUID is defined clearly here:

Not sure what is the problem around
Thanks in advance
 

emexes

Expert
Licensed User
Not sure what is the problem around
You and me both. I've always copied UUIDs from DeviceFound and Connected directly, to make sure that I haven't accidentally got the formatting or letter-casing wrong.

Erel beat me to it, but here's the possibly-relevant BLE2 help with the easy-to-miss clue highlighted šŸ»

1594106582024.png
 
Last edited:
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
Thanks @Erel and @emexes but I pass over that too in the very start. The YML file in the ESP32 is configure to advertise (adv_enable=true):

JSON:
"bt": {
  "enable": true,             // Enabled by default. Disabled on first reboot with WiFi on
  "dev_name": "",             // Device name. If empty, value equals to device.id
  "adv_enable": true,         // Advertise our Bluetooth services
  "keep_enabled": true,       // Keep enabled after successful boot with WiFi on
  "scan_rsp_data_hex": "",    // Custom scan response data, as hex string (e.g. `48656c6c6f` for `Hello`)
  "allow_pairing": true,      // Allow pairingbonding with other devices
  "max_paired_devices": 10,   // Allow pairing with up to this many devices; -1 - no limit
  "gatts": {
    "min_sec_level": 0,       // Minimum security level for all attributes of all services.
                              // 0 - no auth required, 1 - encryption reqd, 2 - encryption + MITM reqd
    "require_pairing": false  // Require taht device is paired before accessing services
  }
}

More over, when I see the logs, it starts advertising:

1594127175701.png
 
Upvote 0

emexes

Expert
Licensed User
Does the UUID show up with:
B4X:
Sub Manager_Connected(Services As List)
    
    For Each S As String In Services
        Log("[" & S & "]")
    Next
    
End Sub
 
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
Does the UUID show up with:
B4X:
Sub Manager_Connected(Services As List)
   
    For Each S As String In Services
        Log("[" & S & "]")
    Next
   
End Sub

@emexes yes, it outputs the exact service IĀ“m seeking: 5f6d4f53-5f43-4647-5f53-56435f49445f. I have also tried upper and lower case (as you see in iOS/Android is diferent, also the status returns are diferent). Anyway the systems works with scanning all devices. ItĀ“s just a matter of being more efficient if there are too many BLE Devices arround

1594129900448.png
 
Upvote 0
Top