4646// ******************************************************************************
4747#if MICROPY_PY_BLUETOOTH
4848#define NUM_ADV_PACKETS (3u)
49- #define MAX_ADV_ELEMENTS (10u)
5049#define ERRNO_BLUETOOTH_NOT_ACTIVE MP_ENODEV
5150#define CASE_RETURN_STR (const ) case const: \
5251 return #const;
@@ -60,12 +59,6 @@ extern uint8_t app_gap_device_name[];
6059
6160wiced_bt_ble_advert_elem_t cy_bt_adv_pkt [8 ]; // Max 8 elements possible
6261
63-
64- // static wiced_bt_ble_advert_elem_t bt_ad_data[8];
65- // static size_t bt_ad_len = 0;
66- // static wiced_bt_ble_advert_elem_t bt_sd_data[8];
67- // static size_t bt_sd_len = 0;
68-
6962// MPY defines and variables
7063volatile int mp_bluetooth_ble_stack_state = MP_BLUETOOTH_BLE_STATE_OFF ;
7164static uint8_t address_mode = BLE_ADDR_PUBLIC ;
@@ -374,19 +367,6 @@ wiced_result_t bt_management_callback(wiced_bt_management_evt_t event,
374367 }
375368 break ;
376369
377- case BTM_BLE_SCAN_STATE_CHANGED_EVT :
378-
379- if (p_event_data -> ble_scan_state_changed == BTM_BLE_SCAN_TYPE_HIGH_DUTY ) {
380- printf ("Scan State Change: BTM_BLE_SCAN_TYPE_HIGH_DUTY\n" );
381- } else if (p_event_data -> ble_scan_state_changed == BTM_BLE_SCAN_TYPE_LOW_DUTY ) {
382- printf ("Scan State Change: BTM_BLE_SCAN_TYPE_LOW_DUTY\n" );
383- } else if (p_event_data -> ble_scan_state_changed == BTM_BLE_SCAN_TYPE_NONE ) {
384- printf ("Scan stopped\n" );
385- } else {
386- printf ("Invalid scan state\n" );
387- }
388- break ;
389-
390370 default :
391371 break ;
392372 }
@@ -610,46 +590,12 @@ void mp_bluetooth_gap_advertise_stop(void) {
610590
611591#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
612592
613- int get_adv_data_length (const uint8_t * p_adv_data ) {
614- int offset = 0 ;
615- while (offset < 31 ) { // BLE adv max length is 31 bytes
616- uint8_t field_len = p_adv_data [offset ];
617- if (field_len == 0 || (offset + field_len + 1 ) > 31 ) {
618- break ;
619- }
620- offset += field_len + 1 ;
621- }
622- return offset ;
623- }
624-
625- void mp_scan_result_callback (wiced_bt_ble_scan_results_t * p_scan_result ,
626- uint8_t * p_adv_data ) {
627- printf ("Scan works\r\n" );
628- if (p_scan_result ) {
629- mp_bluetooth_gap_on_scan_complete ();
630- } else {
631- mp_printf (& mp_plat_print , "No device found\n" );
632- }
633- // Calculate actual length of adv data
634- int adv_data_len = get_adv_data_length (p_adv_data );
635- mp_bluetooth_gap_on_scan_result (p_scan_result -> ble_addr_type , p_scan_result -> remote_bd_addr , p_scan_result -> ble_evt_type , p_scan_result -> rssi , p_adv_data , adv_data_len );
636-
637- }
638-
639593int mp_bluetooth_gap_scan_start (int32_t duration_ms , int32_t interval_us , int32_t window_us , bool active_scan ) {
640594 return 0 ;
641595}
642596
643597// Stop discovery
644598int mp_bluetooth_gap_scan_stop (void ) {
645- wiced_result_t result = wiced_bt_ble_scan (
646- BTM_BLE_SCAN_TYPE_NONE ,
647- WICED_TRUE ,
648- NULL
649- );
650-
651- bluetooth_assert_raise_val ("Stopping Bluetooth LE scanning failed with error: " , result , WICED_SUCCESS );
652-
653599 return 0 ;
654600}
655601
0 commit comments