summaryrefslogtreecommitdiff
path: root/ports/nrf
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2018-08-16 19:22:45 -0700
committerGitHub <noreply@github.com>2018-08-16 19:22:45 -0700
commit5dd420f7ff2c87a5412a55fea29eb21615a89e14 (patch)
tree93c0afa00ee8f6317600301c01b1ddbf086d7e73 /ports/nrf
parent92ed5d7bf223212e8db04af3f6712770ec2c86ea (diff)
parente8cf6a907236bb06a6f8d734b8d829e3dba91825 (diff)
Merge pull request #1121 from tannewt/huffman
Compress all translated strings with Huffman coding.
Diffstat (limited to 'ports/nrf')
-rw-r--r--ports/nrf/common-hal/analogio/AnalogIn.c3
-rw-r--r--ports/nrf/common-hal/analogio/AnalogOut.c8
-rw-r--r--ports/nrf/common-hal/busio/I2C.c3
-rw-r--r--ports/nrf/common-hal/busio/UART.c19
-rw-r--r--ports/nrf/common-hal/digitalio/DigitalInOut.c3
-rw-r--r--ports/nrf/common-hal/microcontroller/Processor.c3
-rw-r--r--ports/nrf/common-hal/pulseio/PWMOut.c4
-rw-r--r--ports/nrf/common-hal/usb_hid/Device.c8
-rw-r--r--ports/nrf/drivers/bluetooth/ble_drv.c49
-rw-r--r--ports/nrf/modules/ubluepy/ubluepy_characteristic.c3
-rw-r--r--ports/nrf/modules/ubluepy/ubluepy_service.c7
-rw-r--r--ports/nrf/modules/ubluepy/ubluepy_uuid.c5
12 files changed, 62 insertions, 53 deletions
diff --git a/ports/nrf/common-hal/analogio/AnalogIn.c b/ports/nrf/common-hal/analogio/AnalogIn.c
index a2f452b35..795191084 100644
--- a/ports/nrf/common-hal/analogio/AnalogIn.c
+++ b/ports/nrf/common-hal/analogio/AnalogIn.c
@@ -27,6 +27,7 @@
#include "common-hal/analogio/AnalogIn.h"
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
#include "nrfx_saadc.h"
#include "nrf_gpio.h"
@@ -35,7 +36,7 @@
void common_hal_analogio_analogin_construct(analogio_analogin_obj_t *self, const mcu_pin_obj_t *pin) {
if (pin->adc_channel == 0)
- mp_raise_ValueError("Pin does not have ADC capabilities");
+ mp_raise_ValueError(translate("Pin does not have ADC capabilities"));
nrf_gpio_cfg_default(NRF_GPIO_PIN_MAP(pin->port, pin->pin));
diff --git a/ports/nrf/common-hal/analogio/AnalogOut.c b/ports/nrf/common-hal/analogio/AnalogOut.c
index d1fd4982b..654639b59 100644
--- a/ports/nrf/common-hal/analogio/AnalogOut.c
+++ b/ports/nrf/common-hal/analogio/AnalogOut.c
@@ -24,17 +24,17 @@
* THE SOFTWARE.
*/
+#include "shared-bindings/analogio/AnalogOut.h"
+
#include <stdint.h>
#include <string.h>
#include "py/mperrno.h"
#include "py/runtime.h"
-
-#include "shared-bindings/analogio/AnalogOut.h"
-
+#include "supervisor/shared/translate.h"
void common_hal_analogio_analogout_construct(analogio_analogout_obj_t* self, const mcu_pin_obj_t *pin) {
- mp_raise_RuntimeError("AnalogOut functionality not supported");
+ mp_raise_RuntimeError(translate("AnalogOut functionality not supported"));
}
bool common_hal_analogio_analogout_deinited(analogio_analogout_obj_t *self) {
diff --git a/ports/nrf/common-hal/busio/I2C.c b/ports/nrf/common-hal/busio/I2C.c
index f42189162..7a29da153 100644
--- a/ports/nrf/common-hal/busio/I2C.c
+++ b/ports/nrf/common-hal/busio/I2C.c
@@ -29,6 +29,7 @@
#include "shared-bindings/busio/I2C.h"
#include "py/mperrno.h"
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
#include "nrfx_twim.h"
#include "nrf_gpio.h"
@@ -54,7 +55,7 @@ static uint8_t twi_error_to_mp(const nrfx_err_t err) {
void common_hal_busio_i2c_construct(busio_i2c_obj_t *self, const mcu_pin_obj_t *scl, const mcu_pin_obj_t *sda, uint32_t frequency, uint32_t timeout) {
if (scl->pin == sda->pin)
- mp_raise_ValueError("Invalid pins");
+ mp_raise_ValueError(translate("Invalid pins"));
const nrfx_twim_t instance = NRFX_TWIM_INSTANCE(INST_NO);
self->twim = instance;
diff --git a/ports/nrf/common-hal/busio/UART.c b/ports/nrf/common-hal/busio/UART.c
index dbc6a8533..765c987b5 100644
--- a/ports/nrf/common-hal/busio/UART.c
+++ b/ports/nrf/common-hal/busio/UART.c
@@ -32,6 +32,7 @@
#include "py/mperrno.h"
#include "py/runtime.h"
#include "py/stream.h"
+#include "supervisor/shared/translate.h"
#include "tick.h"
@@ -41,15 +42,15 @@ void common_hal_busio_uart_construct(busio_uart_obj_t *self,
const mcu_pin_obj_t * tx, const mcu_pin_obj_t * rx, uint32_t baudrate,
uint8_t bits, uart_parity_t parity, uint8_t stop, uint32_t timeout,
uint8_t receiver_buffer_size) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
}
bool common_hal_busio_uart_deinited(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
}
void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
if (common_hal_busio_uart_deinited(self)) {
return;
}
@@ -58,32 +59,32 @@ void common_hal_busio_uart_deinit(busio_uart_obj_t *self) {
// Read characters.
size_t common_hal_busio_uart_read(busio_uart_obj_t *self, uint8_t *data, size_t len, int *errcode) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
return 0;
}
// Write characters.
size_t common_hal_busio_uart_write(busio_uart_obj_t *self, const uint8_t *data, size_t len, int *errcode) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
return 0;
}
uint32_t common_hal_busio_uart_get_baudrate(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
return self->baudrate;
}
void common_hal_busio_uart_set_baudrate(busio_uart_obj_t *self, uint32_t baudrate) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
self->baudrate = baudrate;
}
uint32_t common_hal_busio_uart_rx_characters_available(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
return 0;
}
bool common_hal_busio_uart_ready_to_tx(busio_uart_obj_t *self) {
- mp_raise_NotImplementedError("busio.UART not yet implemented");
+ mp_raise_NotImplementedError(translate("busio.UART not yet implemented"));
return false;
}
diff --git a/ports/nrf/common-hal/digitalio/DigitalInOut.c b/ports/nrf/common-hal/digitalio/DigitalInOut.c
index b84877703..4db9e5efa 100644
--- a/ports/nrf/common-hal/digitalio/DigitalInOut.c
+++ b/ports/nrf/common-hal/digitalio/DigitalInOut.c
@@ -26,6 +26,7 @@
#include "shared-bindings/digitalio/DigitalInOut.h"
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
#include "nrf_gpio.h"
@@ -154,7 +155,7 @@ digitalio_pull_t common_hal_digitalio_digitalinout_get_pull(
NRF_GPIO_Type *reg = nrf_gpio_pin_port_decode(&pin);
if (nrf_gpio_pin_dir_get(pin) == NRF_GPIO_PIN_DIR_OUTPUT) {
- mp_raise_AttributeError("Cannot get pull while in output mode");
+ mp_raise_AttributeError(translate("Cannot get pull while in output mode"));
return PULL_NONE;
}
diff --git a/ports/nrf/common-hal/microcontroller/Processor.c b/ports/nrf/common-hal/microcontroller/Processor.c
index 0cceb6a66..2ce3e8bf5 100644
--- a/ports/nrf/common-hal/microcontroller/Processor.c
+++ b/ports/nrf/common-hal/microcontroller/Processor.c
@@ -26,6 +26,7 @@
#include "common-hal/microcontroller/Processor.h"
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
#ifdef BLUETOOTH_SD
#include "nrf_sdm.h"
@@ -45,7 +46,7 @@ float common_hal_mcu_processor_get_temperature(void) {
uint32_t err_code = sd_temp_get(&temp);
if (err_code != NRF_SUCCESS) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not get temperature. status: 0x" HEX2_FMT, (uint16_t)err_code));
+ translate("Can not get temperature. status: 0x%02x"), (uint16_t)err_code));
return 0;
}
diff --git a/ports/nrf/common-hal/pulseio/PWMOut.c b/ports/nrf/common-hal/pulseio/PWMOut.c
index d23662948..c85b77fcd 100644
--- a/ports/nrf/common-hal/pulseio/PWMOut.c
+++ b/ports/nrf/common-hal/pulseio/PWMOut.c
@@ -32,6 +32,7 @@
#include "common-hal/pulseio/PWMOut.h"
#include "nrf_gpio.h"
#include "shared-bindings/pulseio/PWMOut.h"
+#include "supervisor/shared/translate.h"
#define PWM_MAX_MODULE 3
#define PWM_MAX_CHANNEL 4
@@ -223,7 +224,7 @@ uint16_t common_hal_pulseio_pwmout_get_duty_cycle(pulseio_pwmout_obj_t* self) {
void common_hal_pulseio_pwmout_set_frequency(pulseio_pwmout_obj_t* self, uint32_t frequency) {
if (frequency == 0 || frequency > 16000000) {
- mp_raise_ValueError("Invalid PWM frequency");
+ mp_raise_ValueError(translate("Invalid PWM frequency"));
}
self->freq = frequency;
@@ -238,4 +239,3 @@ uint32_t common_hal_pulseio_pwmout_get_frequency(pulseio_pwmout_obj_t* self) {
bool common_hal_pulseio_pwmout_get_variable_frequency(pulseio_pwmout_obj_t* self) {
return self->variable_freq;
}
-
diff --git a/ports/nrf/common-hal/usb_hid/Device.c b/ports/nrf/common-hal/usb_hid/Device.c
index c2fff7001..6acb2717f 100644
--- a/ports/nrf/common-hal/usb_hid/Device.c
+++ b/ports/nrf/common-hal/usb_hid/Device.c
@@ -29,6 +29,7 @@
#include "common-hal/usb_hid/Device.h"
#include "py/runtime.h"
#include "shared-bindings/usb_hid/Device.h"
+#include "supervisor/shared/translate.h"
#include "tusb.h"
uint8_t common_hal_usb_hid_device_get_usage_page(usb_hid_device_obj_t *self) {
@@ -41,7 +42,7 @@ uint8_t common_hal_usb_hid_device_get_usage(usb_hid_device_obj_t *self) {
void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t* report, uint8_t len) {
if (len != self->report_length) {
- mp_raise_ValueError_varg("Buffer incorrect size. Should be %d bytes.", self->report_length);
+ mp_raise_ValueError_varg(translate("Buffer incorrect size. Should be %d bytes."), self->report_length);
}
// Wait until interface is ready, timeout = 2 seconds
@@ -49,13 +50,13 @@ void common_hal_usb_hid_device_send_report(usb_hid_device_obj_t *self, uint8_t*
while ( (ticks_ms < end_ticks) && !tud_hid_generic_ready() ) { }
if ( !tud_hid_generic_ready() ) {
- mp_raise_msg(&mp_type_OSError, "USB Busy");
+ mp_raise_msg(&mp_type_OSError, translate("USB Busy"));
}
memcpy(self->report_buffer, report, len);
if ( !tud_hid_generic_report(self->report_id, self->report_buffer, len) ) {
- mp_raise_msg(&mp_type_OSError, "USB Error");
+ mp_raise_msg(&mp_type_OSError, translate("USB Error"));
}
}
@@ -85,4 +86,3 @@ void tud_hid_generic_set_report_cb(uint8_t report_id, hid_report_type_t report_t
}
}
}
-
diff --git a/ports/nrf/drivers/bluetooth/ble_drv.c b/ports/nrf/drivers/bluetooth/ble_drv.c
index 28d728d71..7e95c2eab 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;
@@ -241,7 +242,7 @@ void ble_drv_address_get(ble_drv_addr_t * p_addr) {
if (err_code != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
- "Can not query for the device address."));
+ translate("Can not query for the device address.")));
}
BLE_DRIVER_LOG("ble address, type: " HEX2_FMT ", " \
@@ -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));
}
}
diff --git a/ports/nrf/modules/ubluepy/ubluepy_characteristic.c b/ports/nrf/modules/ubluepy/ubluepy_characteristic.c
index 8e1d0eb1e..0935615a5 100644
--- a/ports/nrf/modules/ubluepy/ubluepy_characteristic.c
+++ b/ports/nrf/modules/ubluepy/ubluepy_characteristic.c
@@ -26,6 +26,7 @@
#include "py/obj.h"
#include "py/runtime.h"
+#include "supervisor/shared/translate.h"
#if MICROPY_PY_UBLUEPY_PERIPHERAL || MICROPY_PY_UBLUEPY_CENTRAL
@@ -64,7 +65,7 @@ STATIC mp_obj_t ubluepy_characteristic_make_new(const mp_obj_type_t *type, size_
// (void)sd_characterstic_add(s);
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- "Invalid UUID parameter"));
+ translate("Invalid UUID parameter")));
}
if (args[1].u_int > 0) {
diff --git a/ports/nrf/modules/ubluepy/ubluepy_service.c b/ports/nrf/modules/ubluepy/ubluepy_service.c
index 68d905743..59b81234f 100644
--- a/ports/nrf/modules/ubluepy/ubluepy_service.c
+++ b/ports/nrf/modules/ubluepy/ubluepy_service.c
@@ -27,6 +27,7 @@
#include "py/obj.h"
#include "py/runtime.h"
#include "py/objlist.h"
+#include "supervisor/shared/translate.h"
#if MICROPY_PY_UBLUEPY_PERIPHERAL || MICROPY_PY_UBLUEPY_CENTRAL
@@ -69,14 +70,14 @@ STATIC mp_obj_t ubluepy_service_make_new(const mp_obj_type_t *type, size_t n_arg
s->type = type;
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- "Invalid Service type"));
+ translate("Invalid Service type")));
}
(void)ble_drv_service_add(s);
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- "Invalid UUID parameter"));
+ translate("Invalid UUID parameter")));
}
// clear reference to peripheral
@@ -128,7 +129,7 @@ STATIC mp_obj_t service_get_characteristic(mp_obj_t self_in, mp_obj_t uuid) {
// validate that there is an UUID object passed in as parameter
if (!(MP_OBJ_IS_TYPE(uuid, &ubluepy_uuid_type))) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- "Invalid UUID parameter"));
+ translate("Invalid UUID parameter")));
}
mp_obj_t * chars = NULL;
diff --git a/ports/nrf/modules/ubluepy/ubluepy_uuid.c b/ports/nrf/modules/ubluepy/ubluepy_uuid.c
index 380d2e404..b45494e41 100644
--- a/ports/nrf/modules/ubluepy/ubluepy_uuid.c
+++ b/ports/nrf/modules/ubluepy/ubluepy_uuid.c
@@ -28,6 +28,7 @@
#include "py/runtime.h"
#include "py/objstr.h"
#include "py/misc.h"
+#include "supervisor/shared/translate.h"
#if MICROPY_PY_UBLUEPY
@@ -123,7 +124,7 @@ STATIC mp_obj_t ubluepy_uuid_make_new(const mp_obj_type_t *type, size_t n_args,
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"));
+ translate("Invalid UUID string length")));
}
} else if (MP_OBJ_IS_TYPE(uuid_obj, &ubluepy_uuid_type)) {
// deep copy instance
@@ -133,7 +134,7 @@ STATIC mp_obj_t ubluepy_uuid_make_new(const mp_obj_type_t *type, size_t n_args,
s->value[1] = p_old->value[1];
} else {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError,
- "Invalid UUID parameter"));
+ translate("Invalid UUID parameter")));
}
return MP_OBJ_FROM_PTR(s);