nrf: ubluepy: Provide visiblity of the BLE UART connect status
Signed-off-by: Daniel Thompson <daniel@redfelineninja.org.uk>wasp-os
parent
13f086deeb
commit
9d5e23fc71
|
@ -37,6 +37,24 @@ extern const mp_obj_type_t ubluepy_constants_type;
|
|||
extern const mp_obj_type_t ubluepy_scanner_type;
|
||||
extern const mp_obj_type_t ubluepy_scan_entry_type;
|
||||
|
||||
#if MICROPY_PY_BLE_NUS
|
||||
#include "drivers/bluetooth/ble_uart.h"
|
||||
|
||||
STATIC mp_obj_t ubluepy_uart_connected(void)
|
||||
{
|
||||
return mp_obj_new_bool(ble_uart_connected());
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(ubluepy_uart_connected_obj,
|
||||
ubluepy_uart_connected);
|
||||
|
||||
STATIC mp_obj_t ubluepy_uart_enabled(void)
|
||||
{
|
||||
return mp_obj_new_bool(ble_uart_enabled());
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(ubluepy_uart_enabled_obj,
|
||||
ubluepy_uart_enabled);
|
||||
#endif
|
||||
|
||||
STATIC const mp_rom_map_elem_t mp_module_ubluepy_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_ubluepy) },
|
||||
#if MICROPY_PY_UBLUEPY_PERIPHERAL
|
||||
|
@ -57,9 +75,12 @@ STATIC const mp_rom_map_elem_t mp_module_ubluepy_globals_table[] = {
|
|||
#if MICROPY_PY_UBLUEPY_DESCRIPTOR
|
||||
{ MP_ROM_QSTR(MP_QSTR_Descriptor), MP_ROM_PTR(&ubluepy_descriptor_type) },
|
||||
#endif
|
||||
#if MICROPY_PY_BLE_NUS
|
||||
{ MP_ROM_QSTR(MP_QSTR_uart_connected), MP_ROM_PTR(&ubluepy_uart_connected_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_uart_enabled), MP_ROM_PTR(&ubluepy_uart_enabled_obj) },
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(mp_module_ubluepy_globals, mp_module_ubluepy_globals_table);
|
||||
|
||||
const mp_obj_module_t mp_module_ubluepy = {
|
||||
|
|
Loading…
Reference in New Issue