Skip to content

Commit 0965623

Browse files
committed
bt_ota: fix ota locked state when ble is not enabled
1 parent 16b596f commit 0965623

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

main/src/user/bt_spp.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,8 @@ void bt_app_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
155155
if (!(uxBits & BLE_GATTS_IDLE_BIT)) {
156156
esp_ble_gatts_close(gl_profile_tab[PROFILE_A_APP_ID].gatts_if,
157157
gl_profile_tab[PROFILE_A_APP_ID].conn_id);
158+
esp_ble_gatts_close(gl_profile_tab[PROFILE_B_APP_ID].gatts_if,
159+
gl_profile_tab[PROFILE_B_APP_ID].conn_id);
158160
}
159161
os_power_restart_wait(BT_SPP_IDLE_BIT | BT_A2DP_IDLE_BIT | BLE_GATTS_IDLE_BIT);
160162
#else
@@ -181,7 +183,11 @@ void bt_app_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
181183
ESP_LOGI(BT_SPP_TAG, "GET command: FW+UPD:%ld", image_length);
182184

183185
EventBits_t uxBits = xEventGroupGetBits(user_event_group);
184-
if (image_length != 0 && !(uxBits & BT_OTA_LOCKED_BIT) && uxBits & BLE_GATTS_IDLE_BIT) {
186+
if (image_length != 0 && !(uxBits & BT_OTA_LOCKED_BIT)
187+
#ifdef CONFIG_ENABLE_BLE_CONTROL_IF
188+
&& (uxBits & BLE_GATTS_IDLE_BIT)
189+
#endif
190+
) {
185191
xEventGroupClearBits(user_event_group, KEY_SCAN_RUN_BIT);
186192

187193
esp_bt_gap_set_scan_mode(ESP_BT_NON_CONNECTABLE, ESP_BT_NON_DISCOVERABLE);
@@ -227,7 +233,11 @@ void bt_app_spp_cb(esp_spp_cb_event_t event, esp_spp_cb_param_t *param)
227233
data_recv = 0;
228234

229235
esp_spp_write(param->write.handle, strlen(rsp_str[0]), (uint8_t *)rsp_str[0]);
230-
} else if (uxBits & BT_OTA_LOCKED_BIT || !(uxBits & BLE_GATTS_IDLE_BIT)) {
236+
} else if (uxBits & BT_OTA_LOCKED_BIT
237+
#ifdef CONFIG_ENABLE_BLE_CONTROL_IF
238+
|| !(uxBits & BLE_GATTS_IDLE_BIT)
239+
#endif
240+
) {
231241
esp_spp_write(param->write.handle, strlen(rsp_str[3]), (uint8_t *)rsp_str[3]);
232242
} else {
233243
esp_spp_write(param->write.handle, strlen(rsp_str[2]), (uint8_t *)rsp_str[2]);

0 commit comments

Comments
 (0)