diff --git a/components/bt/host/bluedroid/btc/profile/esp/blufi/blufi_prf.c b/components/bt/host/bluedroid/btc/profile/esp/blufi/blufi_prf.c index 0dcea413e6..15e0a9e36c 100644 --- a/components/bt/host/bluedroid/btc/profile/esp/blufi/blufi_prf.c +++ b/components/bt/host/bluedroid/btc/profile/esp/blufi/blufi_prf.c @@ -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);