8000 extmod/modbluetooth: Make BLE.irq() method positional only. · codemee/micropython@6a6a5f9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6a6a5f9

Browse 8000 files
jimmodpgeorge
authored andcommitted
extmod/modbluetooth: Make BLE.irq() method positional only.
Simplifcation now that the trigger arg has been removed.
1 parent 504522b commit 6a6a5f9

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

extmod/modbluetooth.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -384,27 +384,21 @@ STATIC mp_obj_t bluetooth_ble_config(size_t n_args, const mp_obj_t *args, mp_map
384384
}
385385
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bluetooth_ble_config_obj, 1, bluetooth_ble_config);
386386

387-
STATIC mp_obj_t bluetooth_ble_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
388-
enum { ARG_handler };
389-
static const mp_arg_t allowed_args[] = {
390-
{ MP_QSTR_handler, MP_ARG_OBJ | MP_ARG_REQUIRED, {.u_rom_obj = MP_ROM_NONE} },
391-
};
392-
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
393-
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
394-
mp_obj_t callback = args[ARG_handler].u_obj;
395-
if (callback != mp_const_none && !mp_obj_is_callable(callback)) {
396-
mp_raise_ValueError(MP_ERROR_TEXT("invalid callback"));
387+
STATIC mp_obj_t bluetooth_ble_irq(mp_obj_t self_in, mp_obj_t handler_in) {
388+
(void)self_in;
389+
if (handler_in != mp_const_none && !mp_obj_is_callable(handler_in)) {
390+
mp_raise_ValueError(MP_ERROR_TEXT("invalid handler"));
397391
}
398392

399393
// Update the callback.
400394
MICROPY_PY_BLUETOOTH_ENTER
401395
mp_obj_bluetooth_ble_t *o = MP_OBJ_TO_PTR(MP_STATE_VM(bluetooth));
402-
o->irq_handler = callback;
396+
o->irq_handler = handler_in;
403397
MICROPY_PY_BLUETOOTH_EXIT
404398

405399
return mp_const_none;
406400
}
407-
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bluetooth_ble_irq_obj, 1, bluetooth_ble_irq);
401+
STATIC MP_DEFINE_CONST_FUN_OBJ_2(bluetooth_ble_irq_obj, bluetooth_ble_irq);
408402

409403
// ----------------------------------------------------------------------------
410404
// Bluetooth object: GAP

0 commit comments

Comments
 (0)
0