== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
+esp_err_t esp_ble_gap_disconnect(esp_bd_addr_t remote_device)
+{
+ btc_msg_t msg;
+ btc_ble_gap_args_t arg;
+
+ if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
+ return ESP_ERR_INVALID_STATE;
+ }
+
+ msg.sig = BTC_SIG_API_CALL;
+ msg.pid = BTC_PID_GAP_BLE;
+ msg.act = BTC_GAP_BLE_DISCONNECT_EVT;
+ memcpy(arg.disconnect.remote_device, remote_device, ESP_BD_ADDR_LEN);
+
+ return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
+}
+
+
*/
esp_err_t esp_ble_confirm_reply(esp_bd_addr_t bd_addr, bool accept);
+/**
+* @brief This function is to disconnect the physical connection of the peer device
+*
+* @param[in] remote_device : BD address of the peer device
+*
+* @return - ESP_OK : success
+* - other : failed
+*
+*/
+esp_err_t esp_ble_gap_disconnect(esp_bd_addr_t remote_device);
+
#ifdef __cplusplus
}
#endif
/// GATT Client callback function events
typedef enum {
- ESP_GATTC_REG_EVT = 0, /*!< When GATT client is registered, the event comes */
- ESP_GATTC_UNREG_EVT = 1, /*!< When GATT client is unregistered, the event comes */
- ESP_GATTC_OPEN_EVT = 2, /*!< When GATT connection is set up, the event comes */
- ESP_GATTC_READ_CHAR_EVT = 3, /*!< When GATT characteristic is read, the event comes */
- ESP_GATTC_WRITE_CHAR_EVT = 4, /*!< When GATT characteristic write operation completes, the event comes */
- ESP_GATTC_CLOSE_EVT = 5, /*!< When GATT connection is closed, the event comes */
- ESP_GATTC_SEARCH_CMPL_EVT = 6, /*!< When GATT service discovery is completed, the event comes */
- ESP_GATTC_SEARCH_RES_EVT = 7, /*!< When GATT service discovery result is got, the event comes */
- ESP_GATTC_READ_DESCR_EVT = 8, /*!< When GATT characteristic descriptor read completes, the event comes */
- ESP_GATTC_WRITE_DESCR_EVT = 9, /*!< When GATT characteristic descriptor write completes, the event comes */
- ESP_GATTC_NOTIFY_EVT = 10, /*!< When GATT notification or indication arrives, the event comes */
- ESP_GATTC_PREP_WRITE_EVT = 11, /*!< When GATT prepare-write operation completes, the event comes */
- ESP_GATTC_EXEC_EVT = 12, /*!< When write execution completes, the event comes */
- ESP_GATTC_ACL_EVT = 13, /*!< When ACL connection is up, the event comes */
- ESP_GATTC_CANCEL_OPEN_EVT = 14, /*!< When GATT client ongoing connection is cancelled, the event comes */
- ESP_GATTC_SRVC_CHG_EVT = 15, /*!< When "service changed" occurs, the event comes */
- ESP_GATTC_ENC_CMPL_CB_EVT = 17, /*!< When encryption procedure completes, the event comes */
- ESP_GATTC_CFG_MTU_EVT = 18, /*!< When configuration of MTU completes, the event comes */
- ESP_GATTC_ADV_DATA_EVT = 19, /*!< When advertising of data, the event comes */
- ESP_GATTC_MULT_ADV_ENB_EVT = 20, /*!< When multi-advertising is enabled, the event comes */
- ESP_GATTC_MULT_ADV_UPD_EVT = 21, /*!< When multi-advertising parameters are updated, the event comes */
- ESP_GATTC_MULT_ADV_DATA_EVT = 22, /*!< When multi-advertising data arrives, the event comes */
- ESP_GATTC_MULT_ADV_DIS_EVT = 23, /*!< When multi-advertising is disabled, the event comes */
- ESP_GATTC_CONGEST_EVT = 24, /*!< When GATT connection congestion comes, the event comes */
- ESP_GATTC_BTH_SCAN_ENB_EVT = 25, /*!< When batch scan is enabled, the event comes */
- ESP_GATTC_BTH_SCAN_CFG_EVT = 26, /*!< When batch scan storage is configured, the event comes */
- ESP_GATTC_BTH_SCAN_RD_EVT = 27, /*!< When Batch scan read event is reported, the event comes */
- ESP_GATTC_BTH_SCAN_THR_EVT = 28, /*!< When Batch scan threshold is set, the event comes */
- ESP_GATTC_BTH_SCAN_PARAM_EVT = 29, /*!< When Batch scan parameters are set, the event comes */
- ESP_GATTC_BTH_SCAN_DIS_EVT = 30, /*!< When Batch scan is disabled, the event comes */
- ESP_GATTC_SCAN_FLT_CFG_EVT = 31, /*!< When Scan filter configuration completes, the event comes */
- ESP_GATTC_SCAN_FLT_PARAM_EVT = 32, /*!< When Scan filter parameters are set, the event comes */
- ESP_GATTC_SCAN_FLT_STATUS_EVT = 33, /*!< When Scan filter status is reported, the event comes */
- ESP_GATTC_ADV_VSC_EVT = 34, /*!< When advertising vendor spec content event is reported, the event comes */
- ESP_GATTC_GET_CHAR_EVT = 35, /*!< When characteristic is got from GATT server, the event comes */
- ESP_GATTC_GET_DESCR_EVT = 36, /*!< When characteristic descriptor is got from GATT server, the event comes */
- ESP_GATTC_GET_INCL_SRVC_EVT = 37, /*!< When included service is got from GATT server, the event comes */
- ESP_GATTC_REG_FOR_NOTIFY_EVT = 38, /*!< When register for notification of a service completes, the event comes */
- ESP_GATTC_UNREG_FOR_NOTIFY_EVT = 39, /*!< When unregister for notification of a service completes, the event comes */
+ ESP_GATTC_REG_EVT = 0, /*!< When GATT client is registered, the event comes */
+ ESP_GATTC_UNREG_EVT = 1, /*!< When GATT client is unregistered, the event comes */
+ ESP_GATTC_OPEN_EVT = 2, /*!< When GATT virtual connection is set up, the event comes */
+ ESP_GATTC_READ_CHAR_EVT = 3, /*!< When GATT characteristic is read, the event comes */
+ ESP_GATTC_WRITE_CHAR_EVT = 4, /*!< When GATT characteristic write operation completes, the event comes */
+ ESP_GATTC_CLOSE_EVT = 5, /*!< When GATT virtual connection is closed, the event comes */
+ ESP_GATTC_SEARCH_CMPL_EVT = 6, /*!< When GATT service discovery is completed, the event comes */
+ ESP_GATTC_SEARCH_RES_EVT = 7, /*!< When GATT service discovery result is got, the event comes */
+ ESP_GATTC_READ_DESCR_EVT = 8, /*!< When GATT characteristic descriptor read completes, the event comes */
+ ESP_GATTC_WRITE_DESCR_EVT = 9, /*!< When GATT characteristic descriptor write completes, the event comes */
+ ESP_GATTC_NOTIFY_EVT = 10, /*!< When GATT notification or indication arrives, the event comes */
+ ESP_GATTC_PREP_WRITE_EVT = 11, /*!< When GATT prepare-write operation completes, the event comes */
+ ESP_GATTC_EXEC_EVT = 12, /*!< When write execution completes, the event comes */
+ ESP_GATTC_ACL_EVT = 13, /*!< When ACL connection is up, the event comes */
+ ESP_GATTC_CANCEL_OPEN_EVT = 14, /*!< When GATT client ongoing connection is cancelled, the event comes */
+ ESP_GATTC_SRVC_CHG_EVT = 15, /*!< When "service changed" occurs, the event comes */
+ ESP_GATTC_ENC_CMPL_CB_EVT = 17, /*!< When encryption procedure completes, the event comes */
+ ESP_GATTC_CFG_MTU_EVT = 18, /*!< When configuration of MTU completes, the event comes */
+ ESP_GATTC_ADV_DATA_EVT = 19, /*!< When advertising of data, the event comes */
+ ESP_GATTC_MULT_ADV_ENB_EVT = 20, /*!< When multi-advertising is enabled, the event comes */
+ ESP_GATTC_MULT_ADV_UPD_EVT = 21, /*!< When multi-advertising parameters are updated, the event comes */
+ ESP_GATTC_MULT_ADV_DATA_EVT = 22, /*!< When multi-advertising data arrives, the event comes */
+ ESP_GATTC_MULT_ADV_DIS_EVT = 23, /*!< When multi-advertising is disabled, the event comes */
+ ESP_GATTC_CONGEST_EVT = 24, /*!< When GATT connection congestion comes, the event comes */
+ ESP_GATTC_BTH_SCAN_ENB_EVT = 25, /*!< When batch scan is enabled, the event comes */
+ ESP_GATTC_BTH_SCAN_CFG_EVT = 26, /*!< When batch scan storage is configured, the event comes */
+ ESP_GATTC_BTH_SCAN_RD_EVT = 27, /*!< When Batch scan read event is reported, the event comes */
+ ESP_GATTC_BTH_SCAN_THR_EVT = 28, /*!< When Batch scan threshold is set, the event comes */
+ ESP_GATTC_BTH_SCAN_PARAM_EVT = 29, /*!< When Batch scan parameters are set, the event comes */
+ ESP_GATTC_BTH_SCAN_DIS_EVT = 30, /*!< When Batch scan is disabled, the event comes */
+ ESP_GATTC_SCAN_FLT_CFG_EVT = 31, /*!< When Scan filter configuration completes, the event comes */
+ ESP_GATTC_SCAN_FLT_PARAM_EVT = 32, /*!< When Scan filter parameters are set, the event comes */
+ ESP_GATTC_SCAN_FLT_STATUS_EVT = 33, /*!< When Scan filter status is reported, the event comes */
+ ESP_GATTC_ADV_VSC_EVT = 34, /*!< When advertising vendor spec content event is reported, the event comes */
+ ESP_GATTC_GET_CHAR_EVT = 35, /*!< When characteristic is got from GATT server, the event comes */
+ ESP_GATTC_GET_DESCR_EVT = 36, /*!< When characteristic descriptor is got from GATT server, the event comes */
+ ESP_GATTC_GET_INCL_SRVC_EVT = 37, /*!< When included service is got from GATT server, the event comes */
+ ESP_GATTC_REG_FOR_NOTIFY_EVT = 38, /*!< When register for notification of a service completes, the event comes */
+ ESP_GATTC_UNREG_FOR_NOTIFY_EVT = 39, /*!< When unregister for notification of a service completes, the event comes */
+ ESP_GATTC_CONNECT_EVT = 40, /*!< When the ble physical connection is set up, the event comes */
+ ESP_GATTC_DISCONNECT_EVT = 41, /*!< When the ble physical connection disconnected, the event comes */
} esp_gattc_cb_event_t;
/// Maximum Transmission Unit used in GATT
esp_gatt_id_t char_id; /*!< Characteristic id, include characteristic uuid and other information */
} unreg_for_notify; /*!< Gatt client callback param of ESP_GATTC_UNREG_FOR_NOTIFY_EVT */
+ /**
+ * @brief ESP_GATTC_CONNECT_EVT
+ */
+ struct gattc_connect_evt_param {
+ esp_gatt_status_t status; /*!< Operation status */
+ uint16_t conn_id; /*!< Connection id */
+ esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
+ } connect; /*!< Gatt client callback param of ESP_GATTC_CONNECT_EVT */
+
+ /**
+ * @brief ESP_GATTC_DISCONNECT_EVT
+ */
+ struct gattc_disconnect_evt_param {
+ esp_gatt_status_t status; /*!< Operation status */
+ uint16_t conn_id; /*!< Connection id */
+ esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
+ } disconnect; /*!< Gatt client callback param of ESP_GATTC_DISCONNECT_EVT */
} esp_ble_gattc_cb_param_t; /*!< GATT client callback parameter union type */
/**
- * @brief Close a connection to a GATT server.
+ * @brief Close a virtual connection to a GATT server. gattc maybe have multiple virtual GATT server connections when multiple app_id registed,
+ * this API only close one virtual GATT server connection. if there exist other virtual GATT server connections,
+ * it does not disconnect the physical connection.
+ * if you want to disconnect the physical connection directly, you can use esp_ble_gap_disconnect(esp_bd_addr_t remote_device).
*
* @param[in] gattc_if: Gatt client access interface.
* @param[in] conn_id: connection ID to be closed.
APPL_TRACE_ERROR("Update connection parameters failed!");
}
}
+/*******************************************************************************
+**
+** Function bta_dm_ble_disconnect
+**
+** Description This function disconnect the ble connection.
+**
+** Parameters:
+**
+*******************************************************************************/
+void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data)
+{
+ L2CA_RemoveFixedChnl(L2CAP_ATT_CID, p_data->ble_disconnect.remote_bda);
+}
/*******************************************************************************
**
bta_sys_sendmsg(p_msg);
}
}
+/*******************************************************************************
+**
+** Function BTA_DmBleDisconnect
+**
+** Description Disconnect the ble connection, can only be used when connection is up.
+**
+** Parameters: bd_addr - BD address of the peer
+**
+** Returns void
+**
+*******************************************************************************/
+void BTA_DmBleDisconnect(BD_ADDR bd_addr)
+{
+ tBTA_DM_API_BLE_DISCONNECT *p_msg;
+
+ if ((p_msg = (tBTA_DM_API_BLE_DISCONNECT *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_DISCONNECT))) != NULL) {
+ memset (p_msg, 0, sizeof(tBTA_DM_API_BLE_DISCONNECT));
+
+ p_msg->hdr.event = BTA_DM_API_BLE_DISCONNECT_EVT;
+ bdcpy(p_msg->remote_bda, bd_addr);
+ bta_sys_sendmsg(p_msg);
+ }
+}
/*******************************************************************************
**
** Function BTA_DmBleSetDataLength
BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT,
BTA_DM_API_BLE_TRACK_ADVERTISER_EVT,
BTA_DM_API_BLE_ENERGY_INFO_EVT,
+ BTA_DM_API_BLE_DISCONNECT_EVT,
#endif
tBTA_BLE_ENERGY_INFO_CBACK *p_energy_info_cback;
} tBTA_DM_API_ENERGY_INFO;
+typedef struct {
+ BT_HDR hdr;
+ BD_ADDR remote_bda;
+} tBTA_DM_API_BLE_DISCONNECT;
+
#endif /* BLE_INCLUDED */
/* data type for BTA_DM_API_REMOVE_ACL_EVT */
tBTA_DM_API_DISABLE_SCAN ble_disable_scan;
tBTA_DM_API_TRACK_ADVERTISER ble_track_advert;
tBTA_DM_API_ENERGY_INFO ble_energy_info;
+ tBTA_DM_API_BLE_DISCONNECT ble_disconnect;
#endif
tBTA_DM_API_REMOVE_ACL remove_acl;
extern void bta_dm_close_gatt_conn(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_observe (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_update_conn_params (tBTA_DM_MSG *p_data);
+extern void bta_dm_ble_disconnect (tBTA_DM_MSG *p_data);
extern void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data);
extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data);
bta_dm_ble_read_scan_reports, /* BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT */
bta_dm_ble_track_advertiser, /* BTA_DM_API_BLE_TRACK_ADVERTISER_EVT */
bta_dm_ble_get_energy_info, /* BTA_DM_API_BLE_ENERGY_INFO_EVT */
+ bta_dm_ble_disconnect, /* BTA_DM_API_BLE_DISCONNECT_EVT */
#endif
bta_dm_enable_test_mode, /* BTA_DM_API_ENABLE_TEST_MODE_EVT */
p_clcb->bta_conn_id,
p_clcb->transport,
p_clcb->p_srcb->mtu);
+
+ }
+}
+/*******************************************************************************
+**
+** Function bta_gattc_conncback
+**
+** Description receive connection callback from stack
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_gattc_conncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data)
+{
+ if (p_rcb) {
+ bta_gattc_send_connect_cback(p_rcb,
+ BTA_GATT_OK,
+ p_data->int_conn.remote_bda,
+ p_data->int_conn.hdr.layer_specific);
+
+ }
+}
+/*******************************************************************************
+**
+** Function bta_gattc_disconncback
+**
+** Description receive disconnection callback from stack
+**
+** Returns void
+**
+*******************************************************************************/
+void bta_gattc_disconncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data)
+{
+ if (p_rcb) {
+ bta_gattc_send_disconnect_cback(p_rcb,
+ BTA_GATT_OK,
+ p_data->int_conn.remote_bda,
+ p_data->int_conn.hdr.layer_specific);
+
}
}
/*******************************************************************************
default:
if (p_msg->event == BTA_GATTC_INT_CONN_EVT) {
p_clcb = bta_gattc_find_int_conn_clcb((tBTA_GATTC_DATA *) p_msg);
+ p_clreg = bta_gattc_cl_get_regcb(((tBTA_GATTC_DATA *)p_msg)->int_conn.client_if);
+ if (p_clreg != NULL){
+ bta_gattc_conncback(p_clreg, (tBTA_GATTC_DATA *) p_msg);
+ }
+
} else if (p_msg->event == BTA_GATTC_INT_DISCONN_EVT) {
+ p_clreg = bta_gattc_cl_get_regcb(((tBTA_GATTC_DATA *)p_msg)->int_conn.client_if);
+ if (p_clreg != NULL){
+ bta_gattc_disconncback(p_clreg, (tBTA_GATTC_DATA *) p_msg);
+ }
p_clcb = bta_gattc_find_int_disconn_clcb((tBTA_GATTC_DATA *) p_msg);
} else {
p_clcb = bta_gattc_find_clcb_by_conn_id(p_msg->layer_specific);
(*p_clreg->p_cback)(BTA_GATTC_OPEN_EVT, &cb_data);
}
}
+
+/*******************************************************************************
+**
+** Function bta_gattc_send_connect_cback
+**
+** Description send connect callback
+**
+** Returns
+**
+*******************************************************************************/
+void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
+ BD_ADDR remote_bda, UINT16 conn_id)
+{
+ tBTA_GATTC cb_data;
+
+ if (p_clreg->p_cback) {
+ memset(&cb_data, 0, sizeof(tBTA_GATTC));
+
+ cb_data.connect.status = status;
+ cb_data.connect.client_if = p_clreg->client_if;
+ cb_data.connect.conn_id = conn_id;
+ bdcpy(cb_data.connect.remote_bda, remote_bda);
+
+ (*p_clreg->p_cback)(BTA_GATTC_CONNECT_EVT, &cb_data);
+ }
+}
+
+/*******************************************************************************
+**
+** Function bta_gattc_send_disconnect_cback
+**
+** Description send disconnect callback
+**
+** Returns
+**
+*******************************************************************************/
+void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
+ BD_ADDR remote_bda, UINT16 conn_id)
+{
+ tBTA_GATTC cb_data;
+
+ if (p_clreg->p_cback) {
+ memset(&cb_data, 0, sizeof(tBTA_GATTC));
+
+ cb_data.disconnect.status = status;
+ cb_data.disconnect.client_if = p_clreg->client_if;
+ cb_data.disconnect.conn_id = conn_id;
+ bdcpy(cb_data.disconnect.remote_bda, remote_bda);
+
+ (*p_clreg->p_cback)(BTA_GATTC_DISCONNECT_EVT, &cb_data);
+ }
+}
/*******************************************************************************
**
** Function bta_gattc_conn_alloc
extern void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int,
UINT16 max_int, UINT16 latency, UINT16 timeout);
+/*******************************************************************************
+**
+** Function BTA_DmBleDisconnect
+**
+** Description This function is to disconnect the ble connection
+**
+** Returns void
+**
+*******************************************************************************/
+extern void BTA_DmBleDisconnect(BD_ADDR bd_addr);
+
/*******************************************************************************
**
** Function BTA_DmBleSetDataLength
#define BTA_GATTC_SCAN_FLT_PARAM_EVT 32 /* Param filter event */
#define BTA_GATTC_SCAN_FLT_STATUS_EVT 33 /* Filter status event */
#define BTA_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */
+#define BTA_GATTC_CONNECT_EVT 35 /* GATTC CONNECT event */
+#define BTA_GATTC_DISCONNECT_EVT 36 /* GATTC DISCONNECT event */
typedef UINT8 tBTA_GATTC_EVT;
BD_ADDR remote_bda;
} tBTA_GATTC_ENC_CMPL_CB;
+typedef struct {
+ tBTA_GATT_STATUS status;
+ UINT16 conn_id;
+ tBTA_GATTC_IF client_if;
+ BD_ADDR remote_bda;
+} tBTA_GATTC_CONNECT;
+
+typedef struct {
+ tBTA_GATT_STATUS status;
+ UINT16 conn_id;
+ tBTA_GATTC_IF client_if;
+ BD_ADDR remote_bda;
+} tBTA_GATTC_DISCONNECT;
+
typedef union {
tBTA_GATT_STATUS status;
tBTA_GATTC_SRVC_RES srvc_res; /* discovery result */
tBTA_GATTC_REG reg_oper; /* registration data */
tBTA_GATTC_OPEN open;
+ tBTA_GATTC_CONNECT connect;
tBTA_GATTC_CLOSE close;
+ tBTA_GATTC_DISCONNECT disconnect;
tBTA_GATTC_READ read; /* read attribute/descriptor data */
tBTA_GATTC_WRITE write; /* write complete data */
tBTA_GATTC_EXEC_CMPL exec_cmpl; /* execute complete */
extern void bta_gattc_cancel_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
-
+extern void bta_gattc_conncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data);
+extern void bta_gattc_disconncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_close_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_disc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data);
extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
BD_ADDR remote_bda, UINT16 conn_id, tBTA_TRANSPORT transport, UINT16 mtu);
+extern void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
+ BD_ADDR remote_bda, UINT16 conn_id);
+extern void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
+ BD_ADDR remote_bda, UINT16 conn_id);
extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
#if BLE_INCLUDED == TRUE
BTA_DmBleConfigLocalPrivacy(privacy_enable);
}
+static void btc_ble_disconnect(BD_ADDR bd_addr)
+{
+ BTA_DmBleDisconnect(bd_addr);
+}
void btc_gap_ble_cb_handler(btc_msg_t *msg)
{
break;
}
#endif ///SMP_INCLUDED == TRUE
+ case BTC_GAP_BLE_DISCONNECT_EVT:
+ btc_ble_disconnect(arg->disconnect.remote_device);
+ break;
default:
break;
}
btc_gattc_cb_to_app(ESP_GATTC_OPEN_EVT, gattc_if, ¶m);
break;
}
+ case BTA_GATTC_CONNECT_EVT: {
+ tBTA_GATTC_CONNECT *connect = &arg->connect;
+
+ gattc_if = connect->client_if;
+ param.connect.status = connect->status;
+ param.connect.conn_id = BTC_GATT_GET_CONN_ID(connect->conn_id);
+ memcpy(param.connect.remote_bda, connect->remote_bda, sizeof(esp_bd_addr_t));
+ btc_gattc_cb_to_app(ESP_GATTC_CONNECT_EVT, gattc_if, ¶m);
+ break;
+ }
case BTA_GATTC_CLOSE_EVT: {
tBTA_GATTC_CLOSE *close = &arg->close;
btc_gattc_cb_to_app(ESP_GATTC_CLOSE_EVT, gattc_if, ¶m);
break;
}
+ case BTA_GATTC_DISCONNECT_EVT: {
+ tBTA_GATTC_DISCONNECT *disconnect = &arg->disconnect;
+ gattc_if = disconnect->client_if;
+ param.disconnect.status = disconnect->status;
+ param.disconnect.conn_id = BTC_GATT_GET_CONN_ID(disconnect->conn_id);
+ memcpy(param.disconnect.remote_bda, disconnect->remote_bda, sizeof(esp_bd_addr_t));
+ btc_gattc_cb_to_app(ESP_GATTC_DISCONNECT_EVT, gattc_if, ¶m);
+ break;
+ }
case BTA_GATTC_CFG_MTU_EVT: {
tBTA_GATTC_CFG_MTU *cfg_mtu = &arg->cfg_mtu;
BTC_GAP_BLE_SECURITY_RSP_EVT,
BTC_GAP_BLE_PASSKEY_REPLY_EVT,
BTC_GAP_BLE_CONFIRM_REPLY_EVT,
+ BTC_GAP_BLE_DISCONNECT_EVT,
} btc_gap_ble_act_t;
/* btc_ble_gap_args_t */
esp_bd_addr_t bd_addr;
bool accept;
} enc_comfirm_replay;
+
+ //BTC_GAP_BLE_DISCONNECT_EVT
+ struct disconnect_args {
+ esp_bd_addr_t remote_device;
+ } disconnect;
+
} btc_ble_gap_args_t;
void btc_gap_ble_call_handler(btc_msg_t *msg);