Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7898ae38 authored by Chris Manton's avatar Chris Manton
Browse files

Add btif/include/btif_hh::btif_hh_status_text

Toward loggable code

Bug: 163134718
Test: gd/cert/run
Tag: #refactor
BYPASS_LONG_LINES_REASON: Bluetooth likes 120 lines

Change-Id: Iab6a4f33a3e498c33f4870abc5abd59e073d03f2
parent fc15bc80
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -46,7 +46,7 @@
 *  Type definitions and return values
 ******************************************************************************/

typedef enum {
typedef enum : unsigned {
  BTIF_HH_DISABLED = 0,
  BTIF_HH_ENABLED,
  BTIF_HH_DISABLING,
@@ -56,6 +56,25 @@ typedef enum {
  BTIF_HH_DEV_DISCONNECTED
} BTIF_HH_STATUS;

#define CASE_RETURN_TEXT(code) \
  case code:                   \
    return #code

inline std::string btif_hh_status_text(const BTIF_HH_STATUS& status) {
  switch (status) {
    CASE_RETURN_TEXT(BTIF_HH_DISABLED);
    CASE_RETURN_TEXT(BTIF_HH_ENABLED);
    CASE_RETURN_TEXT(BTIF_HH_DISABLING);
    CASE_RETURN_TEXT(BTIF_HH_DEV_UNKNOWN);
    CASE_RETURN_TEXT(BTIF_HH_DEV_CONNECTING);
    CASE_RETURN_TEXT(BTIF_HH_DEV_CONNECTED);
    CASE_RETURN_TEXT(BTIF_HH_DEV_DISCONNECTED);
    default:
      return std::string("UNKNOWN[%hhu]", status);
  }
}
#undef CASE_RETURN_TEXT

typedef struct {
  bthh_connection_state_t dev_status;
  uint8_t dev_handle;