extmod/modbluetooth: Make BLE.irq() method positional only.
Simplifcation now that the trigger arg has been removed.
This commit is contained in:
parent
504522bd02
commit
6a6a5f9e15
@ -384,27 +384,21 @@ STATIC mp_obj_t bluetooth_ble_config(size_t n_args, const mp_obj_t *args, mp_map
|
|||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bluetooth_ble_config_obj, 1, bluetooth_ble_config);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bluetooth_ble_config_obj, 1, bluetooth_ble_config);
|
||||||
|
|
||||||
STATIC mp_obj_t bluetooth_ble_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
|
STATIC mp_obj_t bluetooth_ble_irq(mp_obj_t self_in, mp_obj_t handler_in) {
|
||||||
enum { ARG_handler };
|
(void)self_in;
|
||||||
static const mp_arg_t allowed_args[] = {
|
if (handler_in != mp_const_none && !mp_obj_is_callable(handler_in)) {
|
||||||
{ MP_QSTR_handler, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_NONE} },
|
mp_raise_ValueError(MP_ERROR_TEXT("invalid handler"));
|
||||||
};
|
|
||||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
|
||||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
|
||||||
mp_obj_t callback = args[ARG_handler].u_obj;
|
|
||||||
if (callback != mp_const_none && !mp_obj_is_callable(callback)) {
|
|
||||||
mp_raise_ValueError(MP_ERROR_TEXT("invalid callback"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the callback.
|
// Update the callback.
|
||||||
MICROPY_PY_BLUETOOTH_ENTER
|
MICROPY_PY_BLUETOOTH_ENTER
|
||||||
mp_obj_bluetooth_ble_t *o = MP_OBJ_TO_PTR(MP_STATE_VM(bluetooth));
|
mp_obj_bluetooth_ble_t *o = MP_OBJ_TO_PTR(MP_STATE_VM(bluetooth));
|
||||||
o->irq_handler = callback;
|
o->irq_handler = handler_in;
|
||||||
MICROPY_PY_BLUETOOTH_EXIT
|
MICROPY_PY_BLUETOOTH_EXIT
|
||||||
|
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bluetooth_ble_irq_obj, 1, bluetooth_ble_irq);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bluetooth_ble_irq_obj, bluetooth_ble_irq);
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Bluetooth object: GAP
|
// Bluetooth object: GAP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user