From 614ed386db0b278f3bdaa9086007da14fe3fa070 Mon Sep 17 00:00:00 2001 From: Chris Manton Date: Mon, 3 May 2021 09:04:06 -0700 Subject: [PATCH] Add stack/gatt::gatt_security_action_text Bug: 163134718 Test: gd/cert/run Tag: #refactor Change-Id: Iecae9ca52a8660151de1ea4c4402f75a3790f43f --- stack/gatt/gatt_int.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/stack/gatt/gatt_int.h b/stack/gatt/gatt_int.h index ee0716d17..01e281166 100644 --- a/stack/gatt/gatt_int.h +++ b/stack/gatt/gatt_int.h @@ -51,6 +51,26 @@ typedef enum : uint8_t { GATT_SEC_ENC_PENDING = 6, /* wait for link encryption pending */ } tGATT_SEC_ACTION; +#define CASE_RETURN_TEXT(code) \ + case code: \ + return #code + +inline std::string gatt_security_action_text(const tGATT_SEC_ACTION& action) { + switch (action) { + CASE_RETURN_TEXT(GATT_SEC_NONE); + CASE_RETURN_TEXT(GATT_SEC_OK); + CASE_RETURN_TEXT(GATT_SEC_SIGN_DATA); + CASE_RETURN_TEXT(GATT_SEC_ENCRYPT); + CASE_RETURN_TEXT(GATT_SEC_ENCRYPT_NO_MITM); + CASE_RETURN_TEXT(GATT_SEC_ENCRYPT_MITM); + CASE_RETURN_TEXT(GATT_SEC_ENC_PENDING); + default: + return std::string("UNKNOWN[%hhu]", action); + } +} + +#undef CASE_RETURN_TEXT + #define GATT_INDEX_INVALID 0xff #define GATT_WRITE_CMD_MASK 0xc0 /*0x1100-0000*/ -- 2.11.0