@@ -180,7 +180,7 @@ STATIC void add_generic_services(bleio_adapter_obj_t *adapter) {
180
180
181
181
STATIC void check_enabled (bleio_adapter_obj_t * adapter ) {
182
182
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" ));
184
184
}
185
185
}
186
186
@@ -297,18 +297,18 @@ STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) {
297
297
// Get version information.
298
298
if (hci_read_local_version (& self -> hci_version , & self -> hci_revision , & self -> lmp_version ,
299
299
& 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" ));
301
301
}
302
302
// Get supported features.
303
303
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" ));
305
305
}
306
306
307
307
// Enabled desired events.
308
308
// Most importantly, includes:
309
309
// BT_EVT_MASK_LE_META_EVENT BT_EVT_BIT(61)
310
310
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" ));
312
312
}
313
313
// The default events for LE are:
314
314
// 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) {
329
329
uint16_t acl_max_num ;
330
330
uint16_t sco_max_num ;
331
331
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" ));
333
333
}
334
334
self -> max_acl_buffer_len = acl_max_len ;
335
335
self -> max_acl_num_buffers = acl_max_num ;
@@ -339,7 +339,7 @@ STATIC void bleio_adapter_hci_init(bleio_adapter_obj_t *self) {
339
339
if (BT_FEAT_LE_EXT_ADV (self -> features )) {
340
340
uint16_t max_adv_data_len ;
341
341
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" ));
343
343
}
344
344
self -> max_adv_data_len = max_adv_data_len ;
345
345
} else {
@@ -472,7 +472,7 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t
472
472
473
473
if (self -> scan_results != NULL ) {
474
474
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." ));
476
476
}
477
477
self -> scan_results = NULL ;
478
478
}
@@ -601,7 +601,7 @@ mp_obj_t common_hal_bleio_adapter_connect(bleio_adapter_obj_t *self, bleio_addre
601
601
602
602
// uint16_t conn_handle = event_info.conn_handle;
603
603
// 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"));
605
605
// }
606
606
607
607
// // 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
622
622
// }
623
623
// }
624
624
625
- mp_raise_bleio_BluetoothError (translate ("Failed to connect: internal error" ));
625
+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Failed to connect: internal error" ));
626
626
627
627
return mp_const_none ;
628
628
}
629
629
630
630
STATIC void check_data_fit (size_t data_len , bool connectable ) {
631
631
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" ));
633
633
}
634
634
}
635
635
@@ -686,7 +686,7 @@ uint32_t _common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
686
686
687
687
if (extended ) {
688
688
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" ));
690
690
}
691
691
692
692
uint16_t props = 0 ;
@@ -801,7 +801,7 @@ void common_hal_bleio_adapter_start_advertising(bleio_adapter_obj_t *self,
801
801
check_data_fit (scan_response_data_bufinfo -> len , connectable );
802
802
803
803
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." ));
805
805
}
806
806
807
807
// 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,
811
811
timeout = MAX_ANONYMOUS_ADV_TIMEOUT_SECS ;
812
812
} else {
813
813
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" ),
815
815
MAX_LIMITED_DISCOVERABLE_ADV_TIMEOUT_SECS );
816
816
}
817
817
}
818
818
819
819
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" ));
821
821
}
822
822
823
823
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,
829
829
tx_power , directed_to );
830
830
831
831
if (result ) {
832
- mp_raise_bleio_BluetoothError (translate ("Already advertising" ));
832
+ mp_raise_bleio_BluetoothError (MP_ERROR_TEXT ("Already advertising" ));
833
833
}
834
834
self -> circuitpython_advertising = false;
835
835
}
0 commit comments