@@ -502,15 +502,15 @@ STATIC MP_DEFINE_CONST_OBJ_TYPE(pb_type_BLE,
502502/**
503503 * Creates a new instance of the BLE class.
504504 *
505- * Do not call this function more than once unless pb_type_BLE_cleanup () is called first.
505+ * Do not call this function more than once unless pb_type_ble_start_cleanup () is called first.
506506 *
507507 * @param [in] broadcast_channel_in (int) The channel number to use for broadcasting.
508508 * @param [in] observe_channels_in (list[int]) A list of channels numbers to observe.
509509 * @returns A newly allocated object.
510510 * @throws ValueError If either parameter contains an out of range channel number.
511511 */
512512mp_obj_t pb_type_BLE_new (mp_obj_t broadcast_channel_in , mp_obj_t observe_channels_in ) {
513- // making the assumption that this is only called once before each pb_type_BLE_cleanup ()
513+ // making the assumption that this is only called once before each pb_type_ble_start_cleanup ()
514514 assert (observed_data == NULL );
515515
516516 mp_int_t broadcast_channel = mp_obj_get_int (broadcast_channel_in );
@@ -558,17 +558,14 @@ mp_obj_t pb_type_BLE_new(mp_obj_t broadcast_channel_in, mp_obj_t observe_channel
558558 return MP_OBJ_FROM_PTR (self );
559559}
560560
561- void pb_type_BLE_cleanup (void ) {
561+ void pb_type_ble_start_cleanup (void ) {
562562 static pbio_task_t stop_broadcasting_task ;
563563 static pbio_task_t stop_observing_task ;
564564 pbdrv_bluetooth_stop_broadcasting (& stop_broadcasting_task );
565565 pbdrv_bluetooth_stop_observing (& stop_observing_task );
566566 observed_data = NULL ;
567567 num_observed_data = 0 ;
568-
569- while (stop_broadcasting_task .status == PBIO_ERROR_AGAIN || stop_observing_task .status == PBIO_ERROR_AGAIN ) {
570- MICROPY_VM_HOOK_LOOP
571- }
568+ // Tasks awaited in pybricks de-init.
572569}
573570
574571#endif // PYBRICKS_PY_COMMON_BLE
0 commit comments