8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dd0bc26 commit 7bf6256Copy full SHA for 7bf6256
extmod/nimble/modbluetooth_nimble.c
@@ -339,7 +339,14 @@ bool mp_bluetooth_is_active(void) {
339
340
void mp_bluetooth_get_device_addr(uint8_t *addr) {
341
#if MICROPY_PY_BLUETOOTH_RANDOM_ADDR
342
- ble_hs_id_copy_addr(BLE_ADDR_RANDOM, addr, NULL);
+ uint8_t addr_le[6];
343
+ int rc = ble_hs_id_copy_addr(BLE_ADDR_RANDOM, addr_le, NULL);
344
+ if (rc != 0) {
345
+ // Even with MICROPY_PY_BLUETOOTH_RANDOM_ADDR enabled the public address may
346
+ // be used instead, in which case there is no random address.
347
+ ble_hs_id_copy_addr(BLE_ADDR_PUBLIC, addr_le, NULL);
348
+ }
349
+ reverse_addr_byte_order(addr, addr_le);
350
#else
351
mp_hal_get_mac(MP_HAL_MAC_BDADDR, addr);
352
#endif
0 commit comments