@@ -663,12 +663,21 @@ void mp_bluetooth_gap_scan_timer_start(int32_t duration_ms) {
663663void print_bd_address (wiced_bt_device_address_t bdadr ) {
664664 printf ("%02X:%02X:%02X:%02X:%02X:%02X \n" , bdadr [0 ], bdadr [1 ], bdadr [2 ], bdadr [3 ], bdadr [4 ], bdadr [5 ]);
665665}
666+ bool device_found = false;
666667
667- void ctss_scan_result_cback (wiced_bt_ble_scan_results_t * p_scan_result ,
668- uint8_t * p_adv_data ) {
669- printf ("Yayy\r\n" );
668+ void ctss_scan_result_cback (wiced_bt_ble_scan_results_t * p_scan_result , uint8_t * p_adv_data ) {
669+ printf ("Scan result callback called!\n" );
670+ if (p_scan_result ) {
671+ print_bd_address (p_scan_result -> remote_bd_addr );
672+ }
670673}
671674
675+ /*void ctss_scan_result_cback(wiced_bt_ble_scan_results_t *p_scan_result,
676+ uint8_t *p_adv_data) {
677+ device_found = true;
678+
679+ }*/
680+
672681// void ctss_scan_result_cback(wiced_bt_ble_scan_results_t *p_scan_result,
673682// uint8_t *p_adv_data )
674683// {
@@ -726,24 +735,15 @@ void ctss_scan_result_cback(wiced_bt_ble_scan_results_t *p_scan_result,
726735
727736int mp_bluetooth_gap_scan_start (int32_t duration_ms , int32_t interval_us , int32_t window_us , bool active_scan ) {
728737 // Stop any ongoing GAP scan.
729- wiced_result_t result ;
738+ // wiced_result_t result;
730739 /*int ret = mp_bluetooth_gap_scan_stop();
731740 if (ret) {
732741 return ret;
733742 }*/
734- mp_bluetooth_gap_scan_timer_start (duration_ms );
735-
736- for (;;) {
737- result = wiced_bt_ble_scan (BTM_BLE_SCAN_TYPE_HIGH_DUTY , WICED_TRUE , ctss_scan_result_cback );
738- if ((WICED_BT_PENDING == result ) || (WICED_BT_BUSY == result )) {
739- printf ("Scanning...\r\n" );
740- // vTaskDelay(10);
741- // cyhal_system_delay_ms(1);
742- } else {
743- printf ("\rError: Starting scan failed. Error code: %d\n" , result );
744- return -1 ;
745- }
746- }
743+ // mp_bluetooth_gap_scan_timer_start(duration_ms);
744+
745+ wiced_bt_ble_scan (BTM_BLE_SCAN_TYPE_HIGH_DUTY , WICED_TRUE , ctss_scan_result_cback );
746+ printf ("Scan started \r\n" );
747747
748748 return 0 ;
749749}
0 commit comments