free event handlers on reset; fix typo in Broadcaster
This commit is contained in:
parent
de7cadb9b2
commit
ef39e72c7c
@ -175,7 +175,7 @@ SRC_COMMON_HAL += \
|
||||
bleio/Broadcaster.c \
|
||||
bleio/Characteristic.c \
|
||||
bleio/Descriptor.c \
|
||||
bleio/LocalPeripheral.c \
|
||||
bleio/Peripheral.c \
|
||||
bleio/Scanner.c \
|
||||
bleio/Service.c \
|
||||
bleio/UUID.c
|
||||
|
@ -48,7 +48,12 @@ typedef struct event_handler {
|
||||
static event_handler_t *m_event_handlers = NULL;
|
||||
|
||||
void ble_drv_reset() {
|
||||
// Linked-list members will be gc'd.
|
||||
event_handler_t *handler = m_event_handlers;
|
||||
while (handler != NULL) {
|
||||
event_handler_t *next = handler->next;
|
||||
m_free(handler);
|
||||
handler = next;
|
||||
}
|
||||
m_event_handlers = NULL;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
void common_hal_bleio_service_construct(bleio_service_obj_t *self) {
|
||||
}
|
||||
|
||||
// Call this after the Service has been added to the LocalPeripheral.
|
||||
// Call this after the Service has been added to the Peripheral.
|
||||
void common_hal_bleio_service_add_all_characteristics(bleio_service_obj_t *self) {
|
||||
// Add all the characteristics.
|
||||
const mp_obj_list_t *char_list = MP_OBJ_TO_PTR(self->char_list);
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "shared-bindings/bleio/__init__.h"
|
||||
#include "shared-bindings/bleio/Adapter.h"
|
||||
#include "shared-bindings/bleio/LocalPeripheral.h"
|
||||
#include "common-hal/bleio/__init__.h"
|
||||
|
||||
// Turn off BLE on a reset or reload.
|
||||
@ -44,25 +43,3 @@ const super_adapter_obj_t common_hal_bleio_adapter_obj = {
|
||||
.type = &bleio_adapter_type,
|
||||
},
|
||||
};
|
||||
|
||||
gatt_role_t common_hal_bleio_device_get_gatt_role(mp_obj_t device) {
|
||||
if (MP_OBJ_IS_TYPE(device, &bleio_local_peripheral_type)) {
|
||||
return ((bleio_local_peripheral_obj_t*) MP_OBJ_TO_PTR(device))->gatt_role;
|
||||
// Does not exist yet.
|
||||
// } else if (MP_OBJ_IS_TYPE(device, &bleio_local_central_type)) {
|
||||
// return ((bleio_local_central_obj_t*) MP_OBJ_TO_PTR(device))->gatt_role;
|
||||
} else {
|
||||
return GATT_ROLE_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t common_hal_bleio_device_get_conn_handle(mp_obj_t device) {
|
||||
if (MP_OBJ_IS_TYPE(device, &bleio_local_peripheral_type)) {
|
||||
return ((bleio_local_peripheral_obj_t*) MP_OBJ_TO_PTR(device))->conn_handle;
|
||||
// Does not exist yet.
|
||||
// } else if (MP_OBJ_IS_TYPE(device, &bleio_local_central_type)) {
|
||||
// return ((bleio_local_central_obj_t*) MP_OBJ_TO_PTR(device))->conn_handle;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,6 @@
|
||||
// 20 bytes max (23 - 3).
|
||||
#define GATT_MAX_DATA_LENGTH (BLE_GATT_ATT_MTU_DEFAULT - 3)
|
||||
|
||||
gatt_role_t common_hal_bleio_device_get_gatt_role(mp_obj_t device);
|
||||
uint16_t common_hal_bleio_device_get_conn_handle(mp_obj_t device);
|
||||
|
||||
#endif // MICROPY_INCLUDED_COMMON_HAL_BLEIO_INIT_H
|
||||
|
@ -134,7 +134,7 @@ STATIC MP_DEFINE_CONST_DICT(bleio_broadcaster_locals_dict, bleio_broadcaster_loc
|
||||
|
||||
const mp_obj_type_t bleio_broadcaster_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_LocalPeripheral,
|
||||
.name = MP_QSTR_Broadcaster,
|
||||
.make_new = bleio_broadcaster_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&bleio_broadcaster_locals_dict
|
||||
};
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "shared-bindings/bleio/Broadcaster.h"
|
||||
#include "shared-bindings/bleio/Characteristic.h"
|
||||
#include "shared-bindings/bleio/Descriptor.h"
|
||||
#include "shared-bindings/bleio/LocalPeripheral.h"
|
||||
#include "shared-bindings/bleio/PeripheralServer.h"
|
||||
#include "shared-bindings/bleio/ScanEntry.h"
|
||||
#include "shared-bindings/bleio/Scanner.h"
|
||||
#include "shared-bindings/bleio/Service.h"
|
||||
@ -78,7 +78,7 @@ STATIC const mp_rom_map_elem_t bleio_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR_Broadcaster), MP_ROM_PTR(&bleio_broadcaster_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Characteristic), MP_ROM_PTR(&bleio_characteristic_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Descriptor), MP_ROM_PTR(&bleio_descriptor_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_LocalPeripheral), MP_ROM_PTR(&bleio_local_peripheral_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_PeripheralServer), MP_ROM_PTR(&bleio_peripheral_server_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ScanEntry), MP_ROM_PTR(&bleio_scanentry_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Scanner), MP_ROM_PTR(&bleio_scanner_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_Service), MP_ROM_PTR(&bleio_service_type) },
|
||||
|
@ -34,7 +34,7 @@ typedef struct {
|
||||
uint16_t handle;
|
||||
bool is_secondary;
|
||||
bleio_uuid_obj_t *uuid;
|
||||
// May be a LocalPeripheral, RemotePeripheral, etc.
|
||||
// May be a PeripheralServer, CentralClient, etc.
|
||||
mp_obj_t *device;
|
||||
mp_obj_t char_list;
|
||||
uint16_t start_handle;
|
||||
|
@ -27,12 +27,6 @@
|
||||
#ifndef MICROPY_INCLUDED_SHARED_MODULE_BLEIO_INIT_H
|
||||
#define MICROPY_INCLUDED_SHARED_MODULE_BLEIO_INIT_H
|
||||
|
||||
typedef enum {
|
||||
GATT_ROLE_NONE,
|
||||
GATT_ROLE_SERVER,
|
||||
GATT_ROLE_CLIENT,
|
||||
} gatt_role_t;
|
||||
|
||||
extern void bleio_reset(void);
|
||||
|
||||
#endif // MICROPY_INCLUDED_SHARED_MODULE_BLEIO_INIT_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user