@@ -630,6 +630,13 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(bluetooth_ble_gatts_register_services_obj, blue
630630
631631#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
632632STATIC mp_obj_t bluetooth_ble_gap_connect (size_t n_args , const mp_obj_t * args ) {
633+ if (n_args == 2 ) {
634+ if (args [1 ] == mp_const_none ) {
635+ int err = mp_bluetooth_gap_peripheral_connect_cancel ();
636+ return bluetooth_handle_errno (err );
637+ }
638+ mp_raise_TypeError (MP_ERROR_TEXT ("invalid addr" ));
639+ }
633640 uint8_t addr_type = mp_obj_get_int (args [1 ]);
634641 mp_buffer_info_t bufinfo = {0 };
635642 mp_get_buffer_raise (args [2 ], & bufinfo , MP_BUFFER_READ );
@@ -652,7 +659,7 @@ STATIC mp_obj_t bluetooth_ble_gap_connect(size_t n_args, const mp_obj_t *args) {
652659 int err = mp_bluetooth_gap_peripheral_connect (addr_type , bufinfo .buf , scan_duration_ms , min_conn_interval_us , max_conn_interval_us );
653660 return bluetooth_handle_errno (err );
654661}
655- STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (bluetooth_ble_gap_connect_obj , 3 , 6 , bluetooth_ble_gap_connect );
662+ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (bluetooth_ble_gap_connect_obj , 2 , 6 , bluetooth_ble_gap_connect );
656663
657664STATIC mp_obj_t bluetooth_ble_gap_scan (size_t n_args , const mp_obj_t * args ) {
658665 // Default is indefinite scan, with the NimBLE "background scan" interval and window.
0 commit comments