@@ -180,7 +180,7 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
180180
181181STATIC void check_enabled (bleio_adapter_obj_t * adapter ) {
182182 if (!common_hal_bleio_adapter_get_enabled (adapter )) {
183- mp_raise_bleio_BluetoothError (translate ("Adapter not enabled" ));
183+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Adapter not enabled" ));
184184 }
185185}
186186
@@ -297,18 +297,18 @@ STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) {
297297 // Get version information.
298298 if (hci_read_local_version (& self -> hci_version , & self -> hci_revision , & self -> lmp_version ,
299299 & self -> manufacturer , & self -> lmp_subversion ) != HCI_OK ) {
300- mp_raise_bleio_BluetoothError (translate ("Could not read HCI version" ));
300+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Could not read HCI version" ));
301301 }
302302 // Get supported features.
303303 if (hci_le_read_local_supported_features (self -> features ) != HCI_OK ) {
304- mp_raise_bleio_BluetoothError (translate ("Could not read BLE features" ));
304+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Could not read BLE features" ));
305305 }
306306
307307 // Enabled desired events.
308308 // Most importantly, includes:
309309 // BT_EVT_MASK_LE_META_EVENT BT_EVT_BIT(61)
310310 if (hci_set_event_mask (0x3FFFFFFFFFFFFFFF ) != HCI_OK ) {
311- mp_raise_bleio_BluetoothError (translate ("Could not set event mask" ));
311+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Could not set event mask" ));
312312 }
313313 // The default events for LE are:
314314 // BT_EVT_MASK_LE_CONN_COMPLETE, BT_EVT_MASK_LE_ADVERTISING_REPORT,
@@ -329,7 +329,7 @@ STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) {
329329 uint16_t acl_max_num ;
330330 uint16_t sco_max_num ;
331331 if (hci_read_buffer_size (& acl_max_len , & sco_max_len , & acl_max_num , & sco_max_num ) != HCI_OK ) {
332- mp_raise_bleio_BluetoothError (translate ("Could not read BLE buffer info" ));
332+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Could not read BLE buffer info" ));
333333 }
334334 self -> max_acl_buffer_len = acl_max_len ;
335335 self -> max_acl_num_buffers = acl_max_num ;
@@ -339,7 +339,7 @@ STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) {
339339 if (BT_FEAT_LE_EXT_ADV (self -> features )) {
340340 uint16_t max_adv_data_len ;
341341 if (hci_le_read_maximum_advertising_data_length (& max_adv_data_len ) != HCI_OK ) {
342- mp_raise_bleio_BluetoothError (translate ("Could not get max advertising length" ));
342+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Could not get max advertising length" ));
343343 }
344344 self -> max_adv_data_len = max_adv_data_len ;
345345 } else {
@@ -472,7 +472,7 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t
472472
473473 if (self -> scan_results != NULL ) {
474474 if (!shared_module_bleio_scanresults_get_done (self -> scan_results )) {
475- mp_raise_bleio_BluetoothError (translate ("Scan already in progress. Stop with stop_scan." ));
475+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Scan already in progress. Stop with stop_scan." ));
476476 }
477477 self -> scan_results = NULL ;
478478 }
@@ -601,7 +601,7 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre
601601
602602 // uint16_t conn_handle = event_info.conn_handle;
603603 // if (conn_handle == BLE_CONN_HANDLE_INVALID) {
604- // mp_raise_bleio_BluetoothError(translate ("Failed to connect: timeout"));
604+ // mp_raise_bleio_BluetoothError(MP_ERROR_TEXT ("Failed to connect: timeout"));
605605 // }
606606
607607 // // Negotiate for better PHY, larger MTU and data lengths since we are the central. These are
@@ -622,14 +622,14 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre
622622 // }
623623 // }
624624
625- mp_raise_bleio_BluetoothError (translate ("Failed to connect: internal error" ));
625+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Failed to connect: internal error" ));
626626
627627 return mp_const_none ;
628628}
629629
630630STATIC void check_data_fit (size_t data_len , bool connectable ) {
631631 if (data_len > MAX_ADVERTISEMENT_SIZE ) {
632- mp_raise_ValueError (translate ("Data too large for advertisement packet" ));
632+ mp_raise_ValueError (MP_ERROR_TEXT ("Data too large for advertisement packet" ));
633633 }
634634}
635635
@@ -686,7 +686,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
686686
687687 if (extended ) {
688688 if (!BT_FEAT_LE_EXT_ADV (self -> features )) {
689- mp_raise_bleio_BluetoothError (translate ("Data length needs extended advertising, but this adapter does not support it" ));
689+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Data length needs extended advertising, but this adapter does not support it" ));
690690 }
691691
692692 uint16_t props = 0 ;
@@ -801,7 +801,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
801801 check_data_fit (scan_response_data_bufinfo -> len , connectable );
802802
803803 if (advertising_data_bufinfo -> len > MAX_ADVERTISEMENT_SIZE && scan_response_data_bufinfo -> len > 0 ) {
804- mp_raise_bleio_BluetoothError (translate ("Extended advertisements with scan response not supported." ));
804+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Extended advertisements with scan response not supported." ));
805805 }
806806
807807 // Anonymous mode requires a timeout so that we don't continue to broadcast
@@ -811,13 +811,13 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
811811 timeout = MAX_ANONYMOUS_ADV_TIMEOUT_SECS ;
812812 } else {
813813 if (timeout > MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS ) {
814- mp_raise_bleio_BluetoothError (translate ("Timeout is too long: Maximum timeout length is %d seconds" ),
814+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Timeout is too long: Maximum timeout length is %d seconds" ),
815815 MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS );
816816 }
817817 }
818818
819819 if (tx_power != 0 ) {
820- mp_raise_NotImplementedError (translate ("Only tx_power=0 supported" ));
820+ mp_raise_NotImplementedError (MP_ERROR_TEXT ("Only tx_power=0 supported" ));
821821 }
822822
823823 const uint32_t result = _common_hal_bleio_adapter_start_advertising (
@@ -829,7 +829,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
829829 tx_power , directed_to );
830830
831831 if (result ) {
832- mp_raise_bleio_BluetoothError (translate ("Already advertising" ));
832+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Already advertising" ));
833833 }
834834 self -> circuitpython_advertising = false;
835835}
0 commit comments