aboutsummaryrefslogtreecommitdiff
path: root/extmod/modbluetooth.c
diff options
context:
space:
mode:
authorThomas Friebel <yaron.de@gmail.com>2020-01-01 22:22:08 +0100
committerDamien George <damien.p.george@gmail.com>2020-03-11 13:01:35 +1100
commit41a9f1dec8558f5272ebc090135d6d101f686fb9 (patch)
tree9175515b40e39f914d1b56dbc05ac7e7c73284aa /extmod/modbluetooth.c
parent1937fb22abc8e6192f6acfc037f2e9fd59fc6d8c (diff)
extmod/modbluetooth: Unify error handling in remaining places.
Most error handling is done via `bluetooth_handle_errno()` already. Replace the remaining few manual checks with calls to that function.
Diffstat (limited to 'extmod/modbluetooth.c')
-rw-r--r--extmod/modbluetooth.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/extmod/modbluetooth.c b/extmod/modbluetooth.c
index 37fa31476..f4b511211 100644
--- a/extmod/modbluetooth.c
+++ b/extmod/modbluetooth.c
@@ -267,9 +267,7 @@ STATIC mp_obj_t bluetooth_ble_active(size_t n_args, const mp_obj_t *args) {
// Boolean enable/disable argument supplied, set current state.
if (mp_obj_is_true(args[1])) {
int err = mp_bluetooth_init();
- if (err != 0) {
- mp_raise_OSError(err);
- }
+ bluetooth_handle_errno(err);
} else {
mp_bluetooth_deinit();
}
@@ -633,9 +631,7 @@ STATIC mp_obj_t bluetooth_ble_gatts_write(mp_obj_t self_in, mp_obj_t value_handl
mp_buffer_info_t bufinfo = {0};
mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ);
int err = mp_bluetooth_gatts_write(mp_obj_get_int(value_handle_in), bufinfo.buf, bufinfo.len);
- if (err != 0) {
- mp_raise_OSError(err);
- }
+ bluetooth_handle_errno(err);
return MP_OBJ_NEW_SMALL_INT(bufinfo.len);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_3(bluetooth_ble_gatts_write_obj, bluetooth_ble_gatts_write);
@@ -649,9 +645,7 @@ STATIC mp_obj_t bluetooth_ble_gatts_notify(size_t n_args, const mp_obj_t *args)
mp_get_buffer_raise(args[3], &bufinfo, MP_BUFFER_READ);
size_t len = bufinfo.len;
int err = mp_bluetooth_gatts_notify_send(conn_handle, value_handle, bufinfo.buf, &len);
- if (err != 0) {
- mp_raise_OSError(err);
- }
+ bluetooth_handle_errno(err);
return MP_OBJ_NEW_SMALL_INT(len);
} else {
int err = mp_bluetooth_gatts_notify(conn_handle, value_handle);