mirror of
https://github.com/W3SLAV/micropython.git
synced 2025-06-19 20:15:33 -04:00
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>
This commit is contained in:
parent
bfc3dde2c9
commit
58a596f4a9
@ -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) {
|
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) {
|
switch (addr_mode) {
|
||||||
case MP_BLUETOOTH_ADDRESS_MODE_PUBLIC:
|
case MP_BLUETOOTH_ADDRESS_MODE_PUBLIC:
|
||||||
if (!has_public_address()) {
|
if (!has_public_address()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user