BLE scan() not returning complete advertisement payload
Posted: Sun Feb 21, 2021 5:25 pm
020106111695fe30585b05015646d238c1a4280100
020106111695FE30585B05015646D238C1A42801000B094C5957534430334D4D43
BLE Scan() not returning complete advertisement payload
Summary: Micropython Bluetooth BLE scan() does not return the complete advertisement payload, specifically missing "Complete Local Name".
Setup:
Broken up, this decodes to the following details
The last element is the 0x09 (Complete Local Name), but the problem is that Micropython ble.scan() does not return the complete advert. payload. When scanning in Micropythin, the last element (name) is missing. The raw data returned in `adv_data` is:
I just made a small modification to `_irq(...)` ble_simple_central.py to simply display all discovered devices and to illustrate the problem:
The output (for the Xiaomi device) is:
Am I forgetting something?
Does the Xiaomi misbehave?
(edited: typos and details)
020106111695FE30585B05015646D238C1A42801000B094C5957534430334D4D43
BLE Scan() not returning complete advertisement payload
Summary: Micropython Bluetooth BLE scan() does not return the complete advertisement payload, specifically missing "Complete Local Name".
Setup:
- ESP32-WROOM-32
- esp32-idf4-20210202-v1.14
- Micropython GitHub examples/bluetooth/ble_simple_central.py (as basis)
Code: Select all
020106111695FE30585B05015646D238C1A42801000B094C5957534430334D4D43
Code: Select all
len==2, 0x01==FLAGS: 0201 06
len==17, 0x16==SERVICE_DATA: 1116 95FE30585B05015646D238C1A4280100
len==11, 0x09==NAME: 0B09 4C5957534430334D4D43
Code: Select all
020106111695fe30585b05015646d238c1a4280100
Code: Select all
def _irq(self, event, data):
if event == _IRQ_SCAN_RESULT:
addr_type, addr, adv_type, rssi, adv_data = data
addr_h = binascii.hexlify(bytes(addr)).decode('utf-8')
adv_data_h = binascii.hexlify(bytes(adv_data)).decode('utf-8')
print('addr_type: {}, addr: {}, adv_type: {}, rssi: {}, adv_data: {}'.format(addr_type, addr_h, adv_type, rssi, adv_data_h))
Code: Select all
addr_type: 0, addr: a4c138d24656, adv_type: 0, rssi: -68, adv_data: 020106111695fe30585b05015646d238c1a4280100
Does the Xiaomi misbehave?
(edited: typos and details)