summaryrefslogtreecommitdiff
path: root/ports/nrf/common-hal/_bleio/UUID.c
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-11-20 13:53:50 -0800
committerScott Shawcroft <scott@tannewt.org>2019-11-20 14:02:15 -0800
commit5e857fdb67c2d92836d7ed73a179fcb6c5298fed (patch)
treeb6b92c61aec920324cf31928ea9934ee5b9b1ead /ports/nrf/common-hal/_bleio/UUID.c
parent372f22c0b3a8715f695902bffb8aeaeb242abcc9 (diff)
Use BluetoothError in _bleio
This better differentiates errors than using OSError everywhere.
Diffstat (limited to 'ports/nrf/common-hal/_bleio/UUID.c')
-rw-r--r--ports/nrf/common-hal/_bleio/UUID.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/ports/nrf/common-hal/_bleio/UUID.c b/ports/nrf/common-hal/_bleio/UUID.c
index 5bf35e6a5..6a3d64305 100644
--- a/ports/nrf/common-hal/_bleio/UUID.c
+++ b/ports/nrf/common-hal/_bleio/UUID.c
@@ -49,10 +49,7 @@ void common_hal_bleio_uuid_construct(bleio_uuid_obj_t *self, uint32_t uuid16, co
memcpy(vs_uuid.uuid128, uuid128, sizeof(vs_uuid.uuid128));
// Register this vendor-specific UUID. Bytes 12 and 13 will be zero.
- const uint32_t err_code = sd_ble_uuid_vs_add(&vs_uuid, &self->nrf_ble_uuid.type);
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg_varg(translate("Failed to register Vendor-Specific UUID, err 0x%04x"), err_code);
- }
+ check_nrf_error(sd_ble_uuid_vs_add(&vs_uuid, &self->nrf_ble_uuid.type));
vm_used_ble = true;
}
}
@@ -67,11 +64,7 @@ uint32_t common_hal_bleio_uuid_get_uuid16(bleio_uuid_obj_t *self) {
void common_hal_bleio_uuid_get_uuid128(bleio_uuid_obj_t *self, uint8_t uuid128[16]) {
uint8_t length;
- const uint32_t err_code = sd_ble_uuid_encode(&self->nrf_ble_uuid, &length, uuid128);
-
- if (err_code != NRF_SUCCESS) {
- mp_raise_OSError_msg_varg(translate("Could not decode ble_uuid, err 0x%04x"), err_code);
- }
+ check_nrf_error(sd_ble_uuid_encode(&self->nrf_ble_uuid, &length, uuid128));
}
void common_hal_bleio_uuid_pack_into(bleio_uuid_obj_t *self, uint8_t* buf) {
@@ -85,7 +78,7 @@ void common_hal_bleio_uuid_pack_into(bleio_uuid_obj_t *self, uint8_t* buf) {
void bleio_uuid_construct_from_nrf_ble_uuid(bleio_uuid_obj_t *self, ble_uuid_t *nrf_ble_uuid) {
if (nrf_ble_uuid->type == BLE_UUID_TYPE_UNKNOWN) {
- mp_raise_RuntimeError(translate("Unexpected nrfx uuid type"));
+ mp_raise_bleio_BluetoothError(translate("Unexpected nrfx uuid type"));
}
self->nrf_ble_uuid.uuid = nrf_ble_uuid->uuid;
self->nrf_ble_uuid.type = nrf_ble_uuid->type;