@@ -138,6 +138,8 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
138138
139139 EventBits_t uxBits = xEventGroupGetBits (user_event_group );
140140 if (!(uxBits & OS_PWR_SLEEP_BIT ) && !(uxBits & OS_PWR_RESET_BIT )) {
141+ xEventGroupSetBits (user_event_group , KEY_SCAN_RUN_BIT | KEY_SCAN_CLR_BIT );
142+
141143 esp_bt_gap_set_scan_mode (ESP_BT_CONNECTABLE , ESP_BT_GENERAL_DISCOVERABLE );
142144 }
143145
@@ -152,6 +154,11 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
152154 } else if (a2d -> conn_stat .state == ESP_A2D_CONNECTION_STATE_CONNECTED ) {
153155 xEventGroupClearBits (user_event_group , BT_A2DP_IDLE_BIT );
154156
157+ EventBits_t uxBits = xEventGroupGetBits (user_event_group );
158+ if (!(uxBits & OS_PWR_SLEEP_BIT ) && !(uxBits & OS_PWR_RESET_BIT )) {
159+ xEventGroupSetBits (user_event_group , KEY_SCAN_RUN_BIT | KEY_SCAN_CLR_BIT );
160+ }
161+
155162 memcpy (& a2d_remote_bda , a2d -> conn_stat .remote_bda , sizeof (esp_bd_addr_t ));
156163
157164 if (memcmp (& last_remote_bda , & a2d_remote_bda , sizeof (esp_bd_addr_t )) != 0 ) {
@@ -168,7 +175,7 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
168175 led_set_mode (2 );
169176#endif
170177 } else {
171- xEventGroupClearBits (user_event_group , BT_A2DP_IDLE_BIT );
178+ xEventGroupClearBits (user_event_group , BT_A2DP_IDLE_BIT | KEY_SCAN_RUN_BIT );
172179 }
173180 break ;
174181 }
0 commit comments