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

Commit db1c2f1f authored by Chris Manton's avatar Chris Manton
Browse files

Add stack/include/btm_status::btm_status_text

Towards loggable code

Bug: 163134718
Tag: #refactor
Test: gd/cert/run --host

Change-Id: I0c28b56845e4d0c37931842ee882a4c55c5ab98a
parent 87280bcd
Loading
Loading
Loading
Loading
+52 −1
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

#pragma once

#include <base/strings/stringprintf.h>
#include <cstdint>

/* BTM application return status codes */
@@ -44,5 +45,55 @@ enum : uint8_t {
                                     supported */
  BTM_DEV_BLACKLISTED             /* 21 The device is Blacklisted */
};

typedef uint8_t tBTM_STATUS;

inline std::string btm_status_text(tBTM_STATUS status) {
  switch (status) {
    case BTM_SUCCESS:
      return std::string("success");
    case BTM_CMD_STARTED:
      return std::string("command_started");
    case BTM_BUSY:
      return std::string("busy");
    case BTM_NO_RESOURCES:
      return std::string("no_resources");
    case BTM_MODE_UNSUPPORTED:
      return std::string("unsupported_mode");
    case BTM_ILLEGAL_VALUE:
      return std::string("illegal_value");
    case BTM_WRONG_MODE:
      return std::string("wrong_mode");
    case BTM_UNKNOWN_ADDR:
      return std::string("unknown_address");
    case BTM_DEVICE_TIMEOUT:
      return std::string("device_timeout");
    case BTM_BAD_VALUE_RET:
      return std::string("bad_hci_value");
    case BTM_ERR_PROCESSING:
      return std::string("processing_error");
    case BTM_NOT_AUTHORIZED:
      return std::string("unauthorized");
    case BTM_DEV_RESET:
      return std::string("device_reset");
    case BTM_CMD_STORED:
      return std::string("command_stored");
    case BTM_ILLEGAL_ACTION:
      return std::string("illegal_action");
    case BTM_DELAY_CHECK:
      return std::string("delay_check");
    case BTM_SCO_BAD_LENGTH:
      return std::string("sco_bad_length");
    case BTM_SUCCESS_NO_SECURITY:
      return std::string("success_no_security");
    case BTM_FAILED_ON_SECURITY:
      return std::string("failed_security");
    case BTM_REPEATED_ATTEMPTS:
      return std::string("repeated_attempts");
    case BTM_MODE4_LEVEL4_NOT_SUPPORTED:
      return std::string("level4_security_unsupported");
    case BTM_DEV_BLACKLISTED:
      return std::string("reject_listed");
    default:
      return base::StringPrintf("UNKNOWN[%u]", status);
  }
}