From: Chris Manton Date: Fri, 8 Jan 2021 06:52:53 +0000 (-0800) Subject: Add gatt_disconnection_reason_text X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=c60266a55c32cf2d3984ca2faa6f250f7dbe6269;p=android-x86%2Fsystem-bt.git Add gatt_disconnection_reason_text Towards loggable code Bug: 163134718 Tag: #refactor Test: gd/cert/run Change-Id: I7e053cff0cb1ca3c2a418e2d1ae362bbc02c22e4 --- diff --git a/stack/include/gatt_api.h b/stack/include/gatt_api.h index c23899327..ee256535c 100644 --- a/stack/include/gatt_api.h +++ b/stack/include/gatt_api.h @@ -18,6 +18,9 @@ #ifndef GATT_API_H #define GATT_API_H +#include +#include + #include "bt_target.h" #include "btm_ble_api.h" #include "gattdefs.h" @@ -206,6 +209,26 @@ typedef enum : uint16_t { GATT_CONN_LMP_TIMEOUT = HCI_ERR_LMP_RESPONSE_TIMEOUT, } tGATT_DISCONN_REASON; +inline std::string gatt_disconnection_reason_text( + const tGATT_DISCONN_REASON& reason) { + switch (reason) { + case GATT_CONN_OK: + return std::string("ok/unknown"); + case GATT_CONN_L2C_FAILURE: + return std::string("l2cap_failure"); + case GATT_CONN_TIMEOUT: + return std::string("timeout"); + case GATT_CONN_TERMINATE_PEER_USER: + return std::string("remote_terminated"); + case GATT_CONN_TERMINATE_LOCAL_HOST: + return std::string("local_terminated"); + case GATT_CONN_LMP_TIMEOUT: + return std::string("lmp_response_timeout"); + default: + return base::StringPrintf("UNKNOWN:[0x%04hx]", reason); + } +} + /* MAX GATT MTU size */ #ifndef GATT_MAX_MTU_SIZE