Skip to content

Commit 8f99947

Browse files
committed
ota: allow update after a2dp is disconnected
1 parent 00b1788 commit 8f99947

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

main/inc/core/os.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ typedef enum user_event_group_bits {
1515
OS_PWR_SLEEP_BIT = BIT0,
1616
OS_PWR_RESTART_BIT = BIT1,
1717

18-
BT_A2DP_IDLE_BIT = BIT2,
19-
BT_A2DP_DATA_BIT = BIT3,
18+
BT_SPP_IDLE_BIT = BIT2,
19+
BT_OTA_LOCK_BIT = BIT3,
2020

21-
BT_SPP_IDLE_BIT = BIT4,
22-
BT_OTA_LOCKED_BIT = BIT5,
21+
BT_A2DP_IDLE_BIT = BIT4,
22+
BT_A2DP_DATA_BIT = BIT5,
2323

2424
BLE_GATTS_IDLE_BIT = BIT6,
2525

main/src/user/bt_av.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ static void bt_av_hdl_a2d_evt(uint16_t event, void *p_param)
144144
#endif
145145

146146
xEventGroupSetBits(user_event_group, BT_A2DP_IDLE_BIT);
147+
xEventGroupClearBits(user_event_group, BT_OTA_LOCK_BIT);
147148
} else if (a2d->conn_stat.state == ESP_A2D_CONNECTION_STATE_CONNECTED) {
148149
xEventGroupClearBits(user_event_group, BT_A2DP_IDLE_BIT);
149-
xEventGroupSetBits(user_event_group, BT_OTA_LOCKED_BIT);
150+
xEventGroupSetBits(user_event_group, BT_OTA_LOCK_BIT);
150151

151152
memcpy(&a2d_remote_bda, a2d->conn_stat.remote_bda, sizeof(esp_bd_addr_t));
152153

main/src/user/ota.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ void ota_exec(esp_spp_cb_param_t *param)
196196
ESP_LOGI(OTA_TAG, "GET command: "CMD_FMT_UPD, data_length);
197197

198198
EventBits_t uxBits = xEventGroupGetBits(user_event_group);
199-
if (data_length != 0 && !(uxBits & BT_OTA_LOCKED_BIT)
199+
if (data_length != 0 && !(uxBits & BT_OTA_LOCK_BIT)
200200
#ifdef CONFIG_ENABLE_BLE_CONTROL_IF
201201
&& (uxBits & BLE_GATTS_IDLE_BIT)
202202
#endif
@@ -259,7 +259,7 @@ void ota_exec(esp_spp_cb_param_t *param)
259259

260260
xTaskCreatePinnedToCore(ota_write_task, "otaWriteT", 1920, NULL, 9, NULL, 1);
261261
}
262-
} else if (uxBits & BT_OTA_LOCKED_BIT
262+
} else if ((uxBits & BT_OTA_LOCK_BIT)
263263
#ifdef CONFIG_ENABLE_BLE_CONTROL_IF
264264
|| !(uxBits & BLE_GATTS_IDLE_BIT)
265265
#endif
@@ -274,7 +274,7 @@ void ota_exec(esp_spp_cb_param_t *param)
274274
case CMD_IDX_RST: {
275275
ESP_LOGI(OTA_TAG, "GET command: "CMD_FMT_RST);
276276

277-
xEventGroupSetBits(user_event_group, BT_OTA_LOCKED_BIT);
277+
xEventGroupSetBits(user_event_group, BT_OTA_LOCK_BIT);
278278

279279
memset(&last_remote_bda, 0x00, sizeof(esp_bd_addr_t));
280280
app_setenv("LAST_REMOTE_BDA", &last_remote_bda, sizeof(esp_bd_addr_t));

0 commit comments

Comments
 (0)