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 <daniel@dvdgiessen.nl>
pull/14074/head
Daniël van de Giessen 2024-03-12 15:11:23 +01:00 zatwierdzone przez Damien George
rodzic bfc3dde2c9
commit 58a596f4a9
1 zmienionych plików z 3 dodań i 0 usunięć

Wyświetl plik

@ -728,6 +728,9 @@ void mp_bluetooth_get_current_address(uint8_t *addr_type, uint8_t *addr) {
}
void mp_bluetooth_set_address_mode(uint8_t addr_mode) {
if (!mp_bluetooth_is_active()) {
mp_raise_OSError(ERRNO_BLUETOOTH_NOT_ACTIVE);
}
switch (addr_mode) {
case MP_BLUETOOTH_ADDRESS_MODE_PUBLIC:
if (!has_public_address()) {