component/bt: fix Blufi sends data after disconnect the seq still increase(backport v4.0)

This commit is contained in:
XieWenxiang 2020-09-01 09:26:32 +08:00
parent 26d7fb7744
commit 2832f5f6f2

View File

@ -287,6 +287,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
memcpy(blufi_env.remote_bda, p_data->conn.remote_bda, sizeof(esp_bd_addr_t));
blufi_env.conn_id = p_data->conn.conn_id;
blufi_env.is_connected = true;
blufi_env.recv_seq = blufi_env.send_seq = 0;
msg.sig = BTC_SIG_API_CB;
msg.pid = BTC_PID_BLUFI;
@ -309,7 +310,6 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
memcpy(blufi_env.remote_bda, p_data->conn.remote_bda, sizeof(esp_bd_addr_t));
blufi_env.conn_id = p_data->conn.conn_id;
blufi_env.is_connected = false;
blufi_env.recv_seq = blufi_env.send_seq = 0;
blufi_env.sec_mode = 0x0;
@ -467,6 +467,11 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
uint16_t checksum;
int ret;
if (blufi_env.is_connected == false) {
BTC_TRACE_ERROR("blufi connection has been disconnected \n");
return;
}
while (remain_len > 0) {
if (remain_len > blufi_env.frag_size) {
hdr = osi_malloc(sizeof(struct blufi_hdr) + 2 + blufi_env.frag_size + 2);