From dd0bc26e65734b8a4fafa3769008e92e2ec6645d Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 10 Mar 2020 11:45:03 +1100 Subject: extmod/modbluetooth: Change scan result's "connectable" to "adv_type". This commit changes the BLE _IRQ_SCAN_RESULT data from: addr_type, addr, connectable, rssi, adv_data to: addr_type, addr, adv_type, rssi, adv_data This allows _IRQ_SCAN_RESULT to handle all scan result types (not just connectable and non-connectable passive scans), and to distinguish between them using adv_type which is an integer taking values 0x00-0x04 per the BT specification. This is a breaking change to the API, albeit a very minor one: the existing connectable value was a boolean and True now becomes 0x00, False becomes 0x02. Documentation is updated and a test added. Fixes #5738. --- docs/library/ubluetooth.rst | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/library/ubluetooth.rst b/docs/library/ubluetooth.rst index 88dc98eca..a16019e60 100644 --- a/docs/library/ubluetooth.rst +++ b/docs/library/ubluetooth.rst @@ -93,7 +93,7 @@ Event Handling conn_handle, attr_handle = data elif event == _IRQ_SCAN_RESULT: # A single scan result. - addr_type, addr, connectable, rssi, adv_data = data + addr_type, addr, adv_type, rssi, adv_data = data elif event == _IRQ_SCAN_COMPLETE: # Scan duration finished or manually stopped. pass @@ -185,7 +185,15 @@ Observer Role (Scanner) interval and window are 1.28 seconds and 11.25 milliseconds respectively (background scanning). - For each scan result, the ``_IRQ_SCAN_RESULT`` event will be raised. + For each scan result the ``_IRQ_SCAN_RESULT`` event will be raised, with event + data ``(addr_type, addr, adv_type, rssi, adv_data)``. ``adv_type`` values correspond + to the Bluetooth Specification: + + * 0x00 - ADV_IND - connectable and scannable undirected advertising + * 0x01 - ADV_DIRECT_IND - connectable directed advertising + * 0x02 - ADV_SCAN_IND - scannable undirected advertising + * 0x03 - ADV_NONCONN_IND - non-connectable undirected advertising + * 0x04 - SCAN_RSP - scan response When scanning is stopped (either due to the duration finishing or when explicitly stopped), the ``_IRQ_SCAN_COMPLETE`` event will be raised. -- cgit v1.2.3