Skip to content

Commit 58a596f

Browse files
DvdGiessendpgeorge
authored andcommitted
extmod/nimble: Check for active before setting address mode.
`BLE().config(addr_mode=...)` is not safe to call if the NimBLE stack is not yet active (because it tries to acquire mutexes which should be initialized first). Signed-off-by: Daniël van de Giessen <[email protected]>
1 parent bfc3dde commit 58a596f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

extmod/nimble/modbluetooth_nimble.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,9 @@ void mp_bluetooth_get_current_address(uint8_t *addr_type, uint8_t *addr) {
728728
}
729729

730730
void mp_bluetooth_set_address_mode(uint8_t addr_mode) {
731+
if (!mp_bluetooth_is_active()) {
732+
mp_raise_OSError(ERRNO_BLUETOOTH_NOT_ACTIVE);
733+
}
731734
switch (addr_mode) {
732735
case MP_BLUETOOTH_ADDRESS_MODE_PUBLIC:
733736
if (!has_public_address()) {

0 commit comments

Comments
 (0)