summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDaniël van de Giessen <daniel@dvdgiessen.nl>2024-03-12 15:11:23 +0100
committerDamien George <damien@micropython.org>2024-03-15 12:59:58 +1100
commit58a596f4a9b11a4043a96e5b90b2cff982d2a48c (patch)
tree222b29220377b69dd149c1163c2902d3cab0775d
parentbfc3dde2c9cee31c85f838d0e89780378170551d (diff)
downloadmicropython-58a596f4a9b11a4043a96e5b90b2cff982d2a48c.tar.gz
micropython-58a596f4a9b11a4043a96e5b90b2cff982d2a48c.zip
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>
-rw-r--r--extmod/nimble/modbluetooth_nimble.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/extmod/nimble/modbluetooth_nimble.c b/extmod/nimble/modbluetooth_nimble.c
index 92bc6764ed..8d555f1124 100644
--- a/extmod/nimble/modbluetooth_nimble.c
+++ b/extmod/nimble/modbluetooth_nimble.c
@@ -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()) {