ret = L2CA_RemoveFixedChnl(L2CAP_ATT_CID, p_tcb->peer_bda);
} else {
L2CA_CancelBleConnectReq(p_tcb->peer_bda);
- gatt_cleanup_upon_disc(p_tcb->peer_bda, HCI_ERR_CONN_CAUSE_LOCAL_HOST, p_tcb->transport);
+ gatt_cleanup_upon_disc(p_tcb->peer_bda, GATT_CONN_TERMINATE_LOCAL_HOST,
+ p_tcb->transport);
return true;
}
gatt_set_ch_state(p_tcb, GATT_CH_CLOSING);
bool check_srv_chg = false;
tGATTS_SRV_CHG* p_srv_chg_clt = NULL;
- /* ignore all fixed channel connect/disconnect on BR/EDR link for GATT */
- if (transport == BT_TRANSPORT_BR_EDR) return;
+ if (transport == BT_TRANSPORT_BR_EDR) {
+ LOG_WARN("Ignoring fixed channel connect/disconnect on br_edr for GATT");
+ return;
+ }
VLOG(1) << "GATT ATT protocol channel with BDA: " << bd_addr << " is "
<< ((connected) ? "connected" : "disconnected");
}
if (!connected) {
- gatt_cleanup_upon_disc(bd_addr, reason, transport);
- VLOG(1) << "ATT disconnected";
+ gatt_cleanup_upon_disc(bd_addr, static_cast<tGATT_DISCONN_REASON>(reason),
+ transport);
return;
}
tGATT_TCB* p_tcb = gatt_find_tcb_by_cid(lcid);
if (p_tcb == nullptr) return;
if (gatt_get_ch_state(p_tcb) == GATT_CH_CONN) {
- gatt_cleanup_upon_disc(p_tcb->peer_bda, result, BT_TRANSPORT_BR_EDR);
+ gatt_cleanup_upon_disc(p_tcb->peer_bda,
+ static_cast<tGATT_DISCONN_REASON>(result),
+ BT_TRANSPORT_BR_EDR);
} else {
gatt_l2cif_disconnect(lcid);
}
}
/* if ACL link is still up, no reason is logged, l2cap is disconnect from
* peer */
- uint16_t reason = L2CA_GetDisconnectReason(p_tcb->peer_bda, p_tcb->transport);
- if (reason == 0) reason = GATT_CONN_TERMINATE_PEER_USER;
+ tGATT_DISCONN_REASON reason = static_cast<tGATT_DISCONN_REASON>(
+ L2CA_GetDisconnectReason(p_tcb->peer_bda, p_tcb->transport));
+ if (reason == GATT_CONN_OK) reason = GATT_CONN_TERMINATE_PEER_USER;
/* send disconnect callback */
gatt_cleanup_upon_disc(p_tcb->peer_bda, reason, BT_TRANSPORT_BR_EDR);
/* send disconnect callback */
/* if ACL link is still up, no reason is logged, l2cap is disconnect from
* peer */
- uint16_t reason = L2CA_GetDisconnectReason(p_tcb->peer_bda, p_tcb->transport);
- if (reason == 0) reason = GATT_CONN_TERMINATE_LOCAL_HOST;
+ tGATT_DISCONN_REASON reason = static_cast<tGATT_DISCONN_REASON>(
+ L2CA_GetDisconnectReason(p_tcb->peer_bda, p_tcb->transport));
+ if (reason == GATT_CONN_OK) reason = GATT_CONN_TERMINATE_LOCAL_HOST;
gatt_cleanup_upon_disc(p_tcb->peer_bda, reason, BT_TRANSPORT_BR_EDR);
}
if (p_reg->app_cb.p_conn_cb) {
conn_id = GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_reg->gatt_if);
- (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, p_tcb->peer_bda, conn_id, true,
- 0, p_tcb->transport);
+ (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, p_tcb->peer_bda, conn_id,
+ kGattConnected, GATT_CONN_OK,
+ p_tcb->transport);
}
}
#define GATT_HANDLE_IS_VALID(x) ((x) != 0)
-#define GATT_CONN_UNKNOWN 0
-/* general L2cap failure */
-#define GATT_CONN_L2C_FAILURE 1
-/* 0x08 connection timeout */
-#define GATT_CONN_TIMEOUT HCI_ERR_CONNECTION_TOUT
-/* 0x13 connection terminate by peer user */
-#define GATT_CONN_TERMINATE_PEER_USER HCI_ERR_PEER_USER
-/* 0x16 connectionterminated by local host */
-#define GATT_CONN_TERMINATE_LOCAL_HOST HCI_ERR_CONN_CAUSE_LOCAL_HOST
-/* 0x22 connection fail for LMP response tout */
-#define GATT_CONN_LMP_TIMEOUT HCI_ERR_LMP_RESPONSE_TIMEOUT
-/* 0x0100 L2CAP connection cancelled */
-#define GATT_CONN_CANCEL L2CAP_CONN_CANCEL
-typedef uint16_t tGATT_DISCONN_REASON;
+typedef enum : uint16_t {
+ GATT_CONN_OK = 0,
+ GATT_CONN_UNKNOWN = 0,
+ /* general L2cap failure */
+ GATT_CONN_L2C_FAILURE = 1,
+ /* 0x08 connection timeout */
+ GATT_CONN_TIMEOUT = HCI_ERR_CONNECTION_TOUT,
+ /* 0x13 connection terminate by peer user */
+ GATT_CONN_TERMINATE_PEER_USER = HCI_ERR_PEER_USER,
+ /* 0x16 connectionterminated by local host */
+ GATT_CONN_TERMINATE_LOCAL_HOST = HCI_ERR_CONN_CAUSE_LOCAL_HOST,
+ /* 0x22 connection fail for LMP response tout */
+ GATT_CONN_LMP_TIMEOUT = HCI_ERR_LMP_RESPONSE_TIMEOUT,
+} tGATT_DISCONN_REASON;
/* MAX GATT MTU size
*/