diff --git a/ports/nrf/Makefile b/ports/nrf/Makefile index 58db910c17..f7e4a29884 100755 --- a/ports/nrf/Makefile +++ b/ports/nrf/Makefile @@ -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 diff --git a/ports/nrf/bluetooth/ble_drv.c b/ports/nrf/bluetooth/ble_drv.c index 41d51cfb4e..57a433f704 100644 --- a/ports/nrf/bluetooth/ble_drv.c +++ b/ports/nrf/bluetooth/ble_drv.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; } diff --git a/ports/nrf/common-hal/bleio/Service.c b/ports/nrf/common-hal/bleio/Service.c index e6aab8563c..c913c02aea 100644 --- a/ports/nrf/common-hal/bleio/Service.c +++ b/ports/nrf/common-hal/bleio/Service.c @@ -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); diff --git a/ports/nrf/common-hal/bleio/__init__.c b/ports/nrf/common-hal/bleio/__init__.c index 5a8a7ff16c..9429aaf447 100644 --- a/ports/nrf/common-hal/bleio/__init__.c +++ b/ports/nrf/common-hal/bleio/__init__.c @@ -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; - } -} diff --git a/ports/nrf/common-hal/bleio/__init__.h b/ports/nrf/common-hal/bleio/__init__.h index 9e044f37c1..aed5df5e76 100644 --- a/ports/nrf/common-hal/bleio/__init__.h +++ b/ports/nrf/common-hal/bleio/__init__.h @@ -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 diff --git a/shared-bindings/bleio/Broadcaster.c b/shared-bindings/bleio/Broadcaster.c index e24d157ecf..ae4f28b74a 100644 --- a/shared-bindings/bleio/Broadcaster.c +++ b/shared-bindings/bleio/Broadcaster.c @@ -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 }; diff --git a/shared-bindings/bleio/__init__.c b/shared-bindings/bleio/__init__.c index 7e36eaa469..b359071595 100644 --- a/shared-bindings/bleio/__init__.c +++ b/shared-bindings/bleio/__init__.c @@ -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) }, diff --git a/shared-module/bleio/Service.h b/shared-module/bleio/Service.h index 540749793a..7fee57f1d0 100644 --- a/shared-module/bleio/Service.h +++ b/shared-module/bleio/Service.h @@ -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; diff --git a/shared-module/bleio/__init__.h b/shared-module/bleio/__init__.h index 07d1485946..f8f0e06606 100644 --- a/shared-module/bleio/__init__.h +++ b/shared-module/bleio/__init__.h @@ -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