docs/library/ubluetooth.rst: Document BLE address modes.

This commit is contained in:
Jim Mussared 2020-08-14 15:17:14 +10:00 committed by Damien George
parent 26b66804e9
commit 67d8139e2b
1 changed files with 24 additions and 7 deletions

View File

@ -45,12 +45,22 @@ Configuration
Currently supported values are: Currently supported values are:
- ``'mac'``: Returns the device MAC address. If a device has a fixed address - ``'mac'``: The current address in use, depending on the current address mode.
(e.g. PYBD) then it will be returned. Otherwise (e.g. ESP32) a random This returns a tuple of ``(addr_type, addr)``.
address will be generated when the BLE interface is made active.
**Note:** on some ports, accessing this value requires that the interface is See :meth:`gatts_write <BLE.gap_scan>` for details about address type.
active (so that the MAC address can be queried from the controller).
This may only be queried while the interface is currently active.
- ``'addr_mode'``: Sets the address mode. Values can be:
* 0x00 - PUBLIC - Use the controller's public address.
* 0x01 - RANDOM - Use a generated static address.
* 0x02 - RPA - Use resolvable private addresses.
* 0x03 - NRPA - Use non-resolvable private addresses.
By default the interface mode will use a PUBLIC address if available, otherwise
it will use a RANDOM address.
- ``'gap_name'``: Get/set the GAP device name used by service 0x1800, - ``'gap_name'``: Get/set the GAP device name used by service 0x1800,
characteristic 0x2a00. This can be set at any time and changed multiple characteristic 0x2a00. This can be set at any time and changed multiple
@ -219,8 +229,13 @@ Observer Role (Scanner)
(background scanning). (background scanning).
For each scan result the ``_IRQ_SCAN_RESULT`` event will be raised, with event 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 data ``(addr_type, addr, adv_type, rssi, adv_data)``.
to the Bluetooth Specification:
``addr_type`` values indicate public or random addresses:
* 0x00 - PUBLIC
* 0x01 - RANDOM (either static, RPA, or NRPA, the type is encoded in the address itself)
``adv_type`` values correspond to the Bluetooth Specification:
* 0x00 - ADV_IND - connectable and scannable undirected advertising * 0x00 - ADV_IND - connectable and scannable undirected advertising
* 0x01 - ADV_DIRECT_IND - connectable directed advertising * 0x01 - ADV_DIRECT_IND - connectable directed advertising
@ -342,6 +357,8 @@ Central Role (GATT Client)
Connect to a peripheral. Connect to a peripheral.
See :meth:`gatts_write <BLE.gap_scan>` for details about address types.
On success, the ``_IRQ_PERIPHERAL_CONNECT`` event will be raised. On success, the ``_IRQ_PERIPHERAL_CONNECT`` event will be raised.
.. method:: BLE.gap_disconnect(conn_handle) .. method:: BLE.gap_disconnect(conn_handle)