diff --git a/nrf5/modules/ubluepy/ubluepy_peripheral.c b/nrf5/modules/ubluepy/ubluepy_peripheral.c index 6c9e2a751c..285132964c 100644 --- a/nrf5/modules/ubluepy/ubluepy_peripheral.c +++ b/nrf5/modules/ubluepy/ubluepy_peripheral.c @@ -79,7 +79,7 @@ STATIC mp_obj_t ubluepy_peripheral_make_new(const mp_obj_type_t *type, size_t n_ ubluepy_peripheral_obj_t *s = m_new_obj(ubluepy_peripheral_obj_t); s->base.type = type; - sd_gap_event_handler_set(MP_OBJ_FROM_PTR(s), gap_event_handler); + ble_drv_gap_event_handler_set(MP_OBJ_FROM_PTR(s), gap_event_handler); s->delegate = mp_const_none; s->conn_handler = mp_const_none; @@ -169,7 +169,7 @@ STATIC mp_obj_t peripheral_advertise(mp_uint_t n_args, const mp_obj_t *pos_args, } - (void)sd_advertise_data(&adv_data); + (void)ble_drv_advertise_data(&adv_data); return mp_const_none; } diff --git a/nrf5/modules/ubluepy/ubluepy_service.c b/nrf5/modules/ubluepy/ubluepy_service.c index a365f410c3..c051c59c8a 100644 --- a/nrf5/modules/ubluepy/ubluepy_service.c +++ b/nrf5/modules/ubluepy/ubluepy_service.c @@ -71,7 +71,7 @@ STATIC mp_obj_t ubluepy_service_make_new(const mp_obj_type_t *type, size_t n_arg "Invalid Service type")); } - (void)sd_service_add(s); + (void)ble_drv_service_add(s); } else { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, @@ -90,7 +90,7 @@ STATIC mp_obj_t service_add_characteristic(mp_obj_t self_in, mp_obj_t characteri p_char->service_handle = self->handle; - bool retval = sd_characteristic_add(p_char); + bool retval = ble_drv_characteristic_add(p_char); return mp_obj_new_bool(retval); } diff --git a/nrf5/modules/ubluepy/ubluepy_uuid.c b/nrf5/modules/ubluepy/ubluepy_uuid.c index 11f54c7045..b6575cd2e5 100644 --- a/nrf5/modules/ubluepy/ubluepy_uuid.c +++ b/nrf5/modules/ubluepy/ubluepy_uuid.c @@ -120,7 +120,7 @@ STATIC mp_obj_t ubluepy_uuid_make_new(const mp_obj_type_t *type, size_t n_args, buffer[15] = unichar_xdigit_value(str_data[1]); buffer[15] += unichar_xdigit_value(str_data[0]) << 4; - sd_uuid_add_vs(buffer, &s->uuid_vs_idx); + ble_drv_uuid_add_vs(buffer, &s->uuid_vs_idx); } else { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "Invalid UUID string length")); diff --git a/nrf5/sdk/modble.c b/nrf5/sdk/modble.c index 07655b0f83..40443a59df 100644 --- a/nrf5/sdk/modble.c +++ b/nrf5/sdk/modble.c @@ -38,7 +38,7 @@ /// Enable BLE softdevice. mp_obj_t ble_obj_enable(void) { printf("SoftDevice enabled\n"); - uint32_t err_code = sd_enable(); + uint32_t err_code = ble_drv_stack_enable(); if (err_code < 0) { // TODO: raise exception. } @@ -48,14 +48,14 @@ mp_obj_t ble_obj_enable(void) { /// \method disable() /// Disable BLE softdevice. mp_obj_t ble_obj_disable(void) { - sd_disable(); + ble_drv_stack_disable(); return mp_const_none; } /// \method enabled() /// Get state of whether the softdevice is enabled or not. mp_obj_t ble_obj_enabled(void) { - uint8_t is_enabled = sd_enabled(); + uint8_t is_enabled = ble_drv_stack_enabled(); mp_int_t enabled = is_enabled; return MP_OBJ_NEW_SMALL_INT(enabled); } @@ -63,14 +63,14 @@ mp_obj_t ble_obj_enabled(void) { /// \method address_print() /// Print device address. mp_obj_t ble_obj_address_print(void) { - sd_address_get(); + ble_drv_address_get(); return mp_const_none; } /// \method advertise() /// Bluetooth Low Energy advertise. mp_obj_t ble_obj_advertise(void) { - sd_advertise(); + ble_drv_advertise(); return mp_const_none; } diff --git a/nrf5/sdk/softdevice.c b/nrf5/sdk/softdevice.c index 37200874dc..480274df5a 100644 --- a/nrf5/sdk/softdevice.c +++ b/nrf5/sdk/softdevice.c @@ -45,8 +45,8 @@ #define SD_TEST_OR_ENABLE() \ -if (sd_enabled() == 0) { \ - (void)sd_enable(); \ +if (ble_drv_stack_enabled() == 0) { \ + (void)ble_drv_stack_enable(); \ } static bool m_adv_in_progress = false; @@ -74,7 +74,7 @@ void softdevice_assert_handler(uint32_t id, uint32_t pc, uint32_t info) { BLE_DRIVER_LOG("ERROR: SoftDevice assert!!!"); } #endif -uint32_t sd_enable(void) { +uint32_t ble_drv_stack_enable(void) { #if (BLUETOOTH_SD != 100) && (BLUETOOTH_SD != 110) memset(&nrf_nvic_state, 0, sizeof(nrf_nvic_state_t)); #endif @@ -134,11 +134,11 @@ uint32_t sd_enable(void) { return err_code; } -void sd_disable(void) { +void ble_drv_stack_disable(void) { sd_softdevice_disable(); } -uint8_t sd_enabled(void) { +uint8_t ble_drv_stack_enabled(void) { uint8_t is_enabled; uint32_t err_code = sd_softdevice_is_enabled(&is_enabled); (void)err_code; @@ -148,7 +148,7 @@ uint8_t sd_enabled(void) { return is_enabled; } -void sd_address_get(void) { +void ble_drv_address_get(void) { ble_gap_addr_t local_ble_addr; #if (BLUETOOTH_SD != 132) uint32_t err_code = sd_ble_gap_address_get(&local_ble_addr); @@ -182,7 +182,7 @@ void sd_address_get(void) { #define APP_CFG_NON_CONN_ADV_TIMEOUT 0 // Disable timeout. #define NON_CONNECTABLE_ADV_INTERVAL MSEC_TO_UNITS(100, UNIT_0_625_MS) -void sd_advertise(void) { +void ble_drv_advertise(void) { ble_uuid_t adv_uuids[] = {{.uuid = EDDYSTONE_UUID, .type = BLE_UUID_TYPE_BLE}}; uint8_t encoded_size; uint8_t uuid_encoded[2]; @@ -226,7 +226,7 @@ void sd_advertise(void) { BLE_DRIVER_LOG("Advertisment start status: " UINT_FMT "\n", (uint16_t)err_code); } -bool sd_uuid_add_vs(uint8_t * p_uuid, uint8_t * idx) { +bool ble_drv_uuid_add_vs(uint8_t * p_uuid, uint8_t * idx) { SD_TEST_OR_ENABLE(); if (sd_ble_uuid_vs_add((ble_uuid128_t const *)p_uuid, idx) != 0) { @@ -237,7 +237,7 @@ bool sd_uuid_add_vs(uint8_t * p_uuid, uint8_t * idx) { return true; } -bool sd_service_add(ubluepy_service_obj_t * p_service_obj) { +bool ble_drv_service_add(ubluepy_service_obj_t * p_service_obj) { SD_TEST_OR_ENABLE(); if (p_service_obj->p_uuid->type > BLE_UUID_TYPE_BLE) { @@ -270,7 +270,7 @@ bool sd_service_add(ubluepy_service_obj_t * p_service_obj) { return true; } -bool sd_characteristic_add(ubluepy_characteristic_obj_t * p_char_obj) { +bool ble_drv_characteristic_add(ubluepy_characteristic_obj_t * p_char_obj) { ble_gatts_char_md_t char_md; ble_gatts_attr_md_t cccd_md; ble_gatts_attr_t attr_char_value; @@ -334,7 +334,7 @@ bool sd_characteristic_add(ubluepy_characteristic_obj_t * p_char_obj) { return true; } -bool sd_advertise_data(ubluepy_advertise_data_t * p_adv_params) { +bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) { SD_TEST_OR_ENABLE(); uint8_t byte_pos = 0; @@ -457,7 +457,7 @@ bool sd_advertise_data(ubluepy_advertise_data_t * p_adv_params) { return true; } -void sd_gap_event_handler_set(mp_obj_t obj, ubluepy_gap_evt_callback_t evt_handler) { +void ble_drv_gap_event_handler_set(mp_obj_t obj, ubluepy_gap_evt_callback_t evt_handler) { mp_observer = obj; ubluepy_gap_event_handler = evt_handler; } diff --git a/nrf5/sdk/softdevice.h b/nrf5/sdk/softdevice.h index f3311c8054..5fdb675fad 100644 --- a/nrf5/sdk/softdevice.h +++ b/nrf5/sdk/softdevice.h @@ -32,24 +32,24 @@ #include "modubluepy.h" -uint32_t sd_enable(void); +uint32_t ble_drv_stack_enable(void); -void sd_disable(void); +void ble_drv_stack_disable(void); -uint8_t sd_enabled(void); +uint8_t ble_drv_stack_enabled(void); -void sd_address_get(void); +void ble_drv_address_get(void); -void sd_advertise(void); +void ble_drv_advertise(void); -bool sd_uuid_add_vs(uint8_t * p_uuid, uint8_t * idx); +bool ble_drv_uuid_add_vs(uint8_t * p_uuid, uint8_t * idx); -bool sd_service_add(ubluepy_service_obj_t * p_service_obj); +bool ble_drv_service_add(ubluepy_service_obj_t * p_service_obj); -bool sd_characteristic_add(ubluepy_characteristic_obj_t * p_char_obj); +bool ble_drv_characteristic_add(ubluepy_characteristic_obj_t * p_char_obj); -bool sd_advertise_data(ubluepy_advertise_data_t * p_adv_params); +bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params); -void sd_gap_event_handler_set(mp_obj_t obs, ubluepy_gap_evt_callback_t evt_handler); +void ble_drv_gap_event_handler_set(mp_obj_t obs, ubluepy_gap_evt_callback_t evt_handler); #endif // BLUETOOTH_LE_DRIVER_H__