extmod/modbluetooth: Make BLE.irq() method positional only.

Simplifcation now that the trigger arg has been removed.
This commit is contained in:
Jim Mussared 2020-09-11 11:43:53 +10:00 committed by Damien George
parent 504522bd02
commit 6a6a5f9e15
1 changed files with 6 additions and 12 deletions

View File

@ -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_obj_t bluetooth_ble_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_handler };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_handler, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_NONE} },
};
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"));
STATIC mp_obj_t bluetooth_ble_irq(mp_obj_t self_in, mp_obj_t handler_in) {
(void)self_in;
if (handler_in != mp_const_none && !mp_obj_is_callable(handler_in)) {
mp_raise_ValueError(MP_ERROR_TEXT("invalid handler"));
}
// Update the callback.
MICROPY_PY_BLUETOOTH_ENTER
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
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