Page 1 of 1

BLE scan not picking up device.

Posted: Sat Dec 05, 2020 8:58 pm
by pedg

I have a BLE device that controls a string of coloured LEDs. I can control this with the app and I can find it using the BLE scanner on my phone:


Luckily someone has decoded the commands and I was also able to send a command via a byte array from the scanner to change the colour.

I want to try and send command from with micropython on an esp32 however I cannot get the BLE scan function to find it, or anything else. I have used the from the examples/bluetooth folder. But it comes back saying nothing found. Tried a number of esp32 boards but the same result in all of them.

I switched one of them to arduino and flashed with the BLE scan program and get the following output

Advertised Device: Name: ELK-BLEDOM , Address: be:89:a0:00:b0:4e
Advertised Device: Name: , Address: 7d:2e:0e:f5:a7:59, manufacturer data: e00000f2ca6ddba0, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb
Advertised Device: Name: , Address: 7c:5b:88:e2:ee:af, manufacturer data: e00000c8ca900a60, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb
Advertised Device: Name: , Address: 64:74:57:c3:3f:e1, serviceUUID: 0000fd6f-0000-1000-8000-00805f9b34fb
Advertised Device: Name: , Address: 72:a0:1e:5e:b4:39, manufacturer data: e0000081ca692e38, serviceUUID: 0000fe9f-0000-1000-8000-00805f9b34fb

Is there something obvious I am missing about why I can't get this to appear in micropython? My first attempt at doing anything with BLE so quite possible.


Should also say tried a number of different stock firmwares. 1.12, 1.13 & 1.13 latest unstable idf v3 and 1.13 idf v4.

Re: BLE scan not picking up device.

Posted: Tue Dec 08, 2020 2:33 pm
by pedg
Ignore me as I appear to have got it working now. As often with something totally confusing it was 2 separate problems, one a copying error, the other not really understanding what the ble_simple_central will find and connect to:

In a minimal program I had managed to copy values for the _IRQ_* events from another thread off here that were completely wrong for the current BLE class as it had things like:

Code: Select all

_IRQ_SCAN_RESULT = const(1 << 4) 
whereas ble_simple_central has:

Code: Select all

_IRQ_SCAN_RESULT = const(5)
and 1 << 4 is 16. I assume these values were used an early/alternative version of the Bluetooth module? Once I replaced the constants with the right values from ble_simple_central that program worked.

For ble_simple_central there is the following for progressing something from a scan result:

Code: Select all

            addr_type, addr, adv_type, rssi, adv_data = data
            if adv_type in (_ADV_IND, _ADV_DIRECT_IND) and _UART_SERVICE_UUID in decode_services(
and what I wanted to connect to did not get past this.

I have now modified the example to read the temperature from a sensor such that it instead now sends a random colour to the controller every second and that works as expected.