diff options
| author | Scott Shawcroft <scott@tannewt.org> | 2018-08-16 13:34:12 -0700 |
|---|---|---|
| committer | Scott Shawcroft <scott@tannewt.org> | 2018-08-16 17:41:35 -0700 |
| commit | 2cd166b57370ab4877ec2d9666225faeac6127ce (patch) | |
| tree | 645f851b1121ce7f52f4b4cf894844e965c4584d /ports/nrf | |
| parent | 137a30ad75803255615a422c15ebcd35fbd31130 (diff) | |
Fix esp and samd
Diffstat (limited to 'ports/nrf')
| -rw-r--r-- | ports/nrf/drivers/bluetooth/ble_drv.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/ports/nrf/drivers/bluetooth/ble_drv.c b/ports/nrf/drivers/bluetooth/ble_drv.c index 28d728d71..6c8c75644 100644 --- a/ports/nrf/drivers/bluetooth/ble_drv.c +++ b/ports/nrf/drivers/bluetooth/ble_drv.c @@ -35,6 +35,7 @@ #endif #include "py/runtime.h" +#include "supervisor/shared/translate.h" #include "ble_drv.h" #include "mpconfigport.h" #include "nrf_sdm.h" @@ -195,7 +196,7 @@ uint32_t ble_drv_stack_enable(void) { (const uint8_t *)device_name, strlen(device_name))) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Cannot apply GAP parameters.")); + translate("Cannot apply GAP parameters."))); } // set connection parameters @@ -209,7 +210,7 @@ uint32_t ble_drv_stack_enable(void) { if (sd_ble_gap_ppcp_set(&gap_conn_params) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Cannot set PPCP parameters.")); + translate("Cannot set PPCP parameters."))); } return err_code; @@ -260,7 +261,7 @@ bool ble_drv_uuid_add_vs(uint8_t * p_uuid, uint8_t * idx) { if (sd_ble_uuid_vs_add((ble_uuid128_t const *)p_uuid, idx) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not add Vendor Specific 128-bit UUID.")); + translate("Can not add Vendor Specific 128-bit UUID."))); } return true; @@ -280,7 +281,7 @@ bool ble_drv_service_add(ubluepy_service_obj_t * p_service_obj) { &uuid, &p_service_obj->handle) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not add Service.")); + translate("Can not add Service."))); } } else if (p_service_obj->p_uuid->type == BLE_UUID_TYPE_BLE) { BLE_DRIVER_LOG("adding service\n"); @@ -294,7 +295,7 @@ bool ble_drv_service_add(ubluepy_service_obj_t * p_service_obj) { &uuid, &p_service_obj->handle) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not add Service.")); + translate("Can not add Service."))); } } return true; @@ -369,7 +370,7 @@ bool ble_drv_characteristic_add(ubluepy_characteristic_obj_t * p_char_obj) { &attr_char_value, &handles) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not add Characteristic.")); + translate("Can not add Characteristic."))); } // apply handles to object instance @@ -396,7 +397,7 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) { p_adv_params->p_device_name, p_adv_params->device_name_len) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not apply device name in the stack.")); + translate("Can not apply device name in the stack."))); } BLE_DRIVER_LOG("Device name applied\n"); @@ -460,13 +461,13 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) { // calculate total size of uuids if (sd_ble_uuid_encode(&uuid, &encoded_size, NULL) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not encode UUID, to check length.")); + translate("Can not encode UUID, to check length."))); } // do encoding into the adv buffer if (sd_ble_uuid_encode(&uuid, &encoded_size, &adv_data[byte_pos]) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can encode UUID into the advertisment packet.")); + translate("Can encode UUID into the advertisment packet."))); } BLE_DRIVER_LOG("encoded uuid for service %u: ", 0); @@ -510,13 +511,13 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) { // calculate total size of uuids if (sd_ble_uuid_encode(&uuid, &encoded_size, NULL) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not encode UUID, to check length.")); + translate("Can not encode UUID, to check length."))); } // do encoding into the adv buffer if (sd_ble_uuid_encode(&uuid, &encoded_size, &adv_data[byte_pos]) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can encode UUID into the advertisment packet.")); + translate("Can encode UUID into the advertisment packet."))); } BLE_DRIVER_LOG("encoded uuid for service %u: ", 0); @@ -541,7 +542,7 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) { if ((p_adv_params->data_len > 0) && (p_adv_params->p_data != NULL)) { if (p_adv_params->data_len + byte_pos > BLE_GAP_ADV_MAX_SIZE) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not fit data into the advertisment packet.")); + translate("Can not fit data into the advertisment packet."))); } memcpy(adv_data, p_adv_params->p_data, p_adv_params->data_len); @@ -554,7 +555,7 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) { if ((err_code = sd_ble_gap_adv_data_set(adv_data, byte_pos, NULL, 0)) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not apply advertisment data. status: 0x" HEX2_FMT, (uint16_t)err_code)); + translate("Can not apply advertisment data. status: 0x%02x"), (uint16_t)err_code)); } BLE_DRIVER_LOG("Set Adv data size: " UINT_FMT "\n", byte_pos); #endif @@ -600,7 +601,7 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) { if ((err_code = sd_ble_gap_adv_set_configure(&m_adv_handle, &ble_gap_adv_data, &m_adv_params)) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not apply advertisment data. status: 0x" HEX2_FMT, (uint16_t)err_code)); + translate("Can not apply advertisment data. status: 0x%02x"), (uint16_t)err_code)); } err_code = sd_ble_gap_adv_start(m_adv_handle, BLE_CONN_CFG_TAG_DEFAULT); #elif (BLUETOOTH_SD == 132 && BLE_API_VERSION == 4) @@ -610,7 +611,7 @@ bool ble_drv_advertise_data(ubluepy_advertise_data_t * p_adv_params) { #endif if (err_code != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not start advertisment. status: 0x" HEX2_FMT, (uint16_t)err_code)); + translate("Can not start advertisment. status: 0x%02x"), (uint16_t)err_code)); } m_adv_in_progress = true; @@ -627,7 +628,7 @@ void ble_drv_advertise_stop(void) { if ((err_code = sd_ble_gap_adv_stop()) != 0) { #endif nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not stop advertisment. status: 0x" HEX2_FMT, (uint16_t)err_code)); + translate("Can not stop advertisment. status: 0x%02x"), (uint16_t)err_code)); } } m_adv_in_progress = false; @@ -646,7 +647,7 @@ void ble_drv_attr_s_read(uint16_t conn_handle, uint16_t handle, uint16_t len, ui &gatts_value); if (err_code != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not read attribute value. status: 0x" HEX2_FMT, (uint16_t)err_code)); + translate("Can not read attribute value. status: 0x%02x"), (uint16_t)err_code)); } } @@ -663,7 +664,7 @@ void ble_drv_attr_s_write(uint16_t conn_handle, uint16_t handle, uint16_t len, u if (err_code != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not write attribute value. status: 0x" HEX2_FMT, (uint16_t)err_code)); + translate("Can not write attribute value. status: 0x%02x"), (uint16_t)err_code)); } } @@ -687,7 +688,7 @@ void ble_drv_attr_s_notify(uint16_t conn_handle, uint16_t handle, uint16_t len, uint32_t err_code; if ((err_code = sd_ble_gatts_hvx(conn_handle, &hvx_params)) != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not notify attribute value. status: 0x" HEX2_FMT, (uint16_t)err_code)); + translate("Can not notify attribute value. status: 0x%02x"), (uint16_t)err_code)); } } @@ -722,7 +723,7 @@ void ble_drv_attr_c_read(uint16_t conn_handle, uint16_t handle, mp_obj_t obj, bl 0); if (err_code != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not read attribute value. status: 0x" HEX2_FMT, (uint16_t)err_code)); + translate("Can not read attribute value. status: 0x%02x"), (uint16_t)err_code)); } while (gattc_char_data_handle != NULL) { @@ -752,7 +753,7 @@ void ble_drv_attr_c_write(uint16_t conn_handle, uint16_t handle, uint16_t len, u if (err_code != 0) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not write attribute value. status: 0x" HEX2_FMT, (uint16_t)err_code)); + translate("Can not write attribute value. status: 0x%02x"), (uint16_t)err_code)); } while (m_write_done != true) { @@ -780,7 +781,7 @@ void ble_drv_scan_start(void) { if ((err_code = sd_ble_gap_scan_start(&scan_params)) != 0) { #endif nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not start scanning. status: 0x" HEX2_FMT, (uint16_t)err_code)); + translate("Can not start scanning. status: 0x%02x"), (uint16_t)err_code)); } } @@ -825,7 +826,7 @@ void ble_drv_connect(uint8_t * p_addr, uint8_t addr_type) { if ((err_code = sd_ble_gap_connect(&addr, &scan_params, &conn_params, BLE_CONN_CFG_TAG_DEFAULT)) != 0) { #endif nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, - "Can not connect. status: 0x" HEX2_FMT, (uint16_t)err_code)); + translate("Can not connect. status: 0x%02x"), (uint16_t)err_code)); } } |
