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

Commit 854d0609 authored by Chris Manton's avatar Chris Manton
Browse files

Enum-ify tSMP_STATUS

Toward readable code

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

Change-Id: I613ee010fef7211edb51592efcc385f3999a7ba4
parent f7f31e4b
Loading
Loading
Loading
Loading
+37 −35
Original line number Diff line number Diff line
@@ -19,7 +19,9 @@
#ifndef SMP_API_TYPES_H
#define SMP_API_TYPES_H

#include "bt_target.h"
#include "bt_target.h"  // Must be first to define build configuration

#include "stack/include/btm_status.h"
#include "types/ble_address_with_type.h"

/* SMP command code */
@@ -64,40 +66,40 @@ typedef enum : uint8_t {
typedef uint8_t tSMP_EVT;

/* pairing failure reason code */
#define SMP_PASSKEY_ENTRY_FAIL 0x01
#define SMP_OOB_FAIL 0x02
#define SMP_PAIR_AUTH_FAIL 0x03
#define SMP_CONFIRM_VALUE_ERR 0x04
#define SMP_PAIR_NOT_SUPPORT 0x05
#define SMP_ENC_KEY_SIZE 0x06
#define SMP_INVALID_CMD 0x07
#define SMP_PAIR_FAIL_UNKNOWN 0x08
#define SMP_REPEATED_ATTEMPTS 0x09
#define SMP_INVALID_PARAMETERS 0x0A
#define SMP_DHKEY_CHK_FAIL 0x0B
#define SMP_NUMERIC_COMPAR_FAIL 0x0C
#define SMP_BR_PARING_IN_PROGR 0x0D
#define SMP_XTRANS_DERIVE_NOT_ALLOW 0x0E
#define SMP_MAX_FAIL_RSN_PER_SPEC SMP_XTRANS_DERIVE_NOT_ALLOW
typedef enum : uint8_t {
  SMP_SUCCESS = 0,
  SMP_PASSKEY_ENTRY_FAIL = 0x01,
  SMP_OOB_FAIL = 0x02,
  SMP_PAIR_AUTH_FAIL = 0x03,
  SMP_CONFIRM_VALUE_ERR = 0x04,
  SMP_PAIR_NOT_SUPPORT = 0x05,
  SMP_ENC_KEY_SIZE = 0x06,
  SMP_INVALID_CMD = 0x07,
  SMP_PAIR_FAIL_UNKNOWN = 0x08,
  SMP_REPEATED_ATTEMPTS = 0x09,
  SMP_INVALID_PARAMETERS = 0x0A,
  SMP_DHKEY_CHK_FAIL = 0x0B,
  SMP_NUMERIC_COMPAR_FAIL = 0x0C,
  SMP_BR_PARING_IN_PROGR = 0x0D,
  SMP_XTRANS_DERIVE_NOT_ALLOW = 0x0E,
  SMP_MAX_FAIL_RSN_PER_SPEC = SMP_XTRANS_DERIVE_NOT_ALLOW,

  /* self defined error code */
#define SMP_PAIR_INTERNAL_ERR (SMP_MAX_FAIL_RSN_PER_SPEC + 0x01) /* 0x0F */
  SMP_PAIR_INTERNAL_ERR = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x01), /* 0x0F */

  /* Unknown IO capability, unable to decide association model */
#define SMP_UNKNOWN_IO_CAP (SMP_MAX_FAIL_RSN_PER_SPEC + 0x02) /* 0x10 */
  SMP_UNKNOWN_IO_CAP = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x02), /* 0x10 */

#define SMP_BUSY (SMP_MAX_FAIL_RSN_PER_SPEC + 0x05)          /* 0x13 */
#define SMP_ENC_FAIL (SMP_MAX_FAIL_RSN_PER_SPEC + 0x06)      /* 0x14 */
#define SMP_STARTED (SMP_MAX_FAIL_RSN_PER_SPEC + 0x07)       /* 0x15 */
#define SMP_RSP_TIMEOUT (SMP_MAX_FAIL_RSN_PER_SPEC + 0x08)   /* 0x16 */
  SMP_BUSY = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x05),        /* 0x13 */
  SMP_ENC_FAIL = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x06),    /* 0x14 */
  SMP_STARTED = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x07),     /* 0x15 */
  SMP_RSP_TIMEOUT = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x08), /* 0x16 */

  /* Unspecified failure reason */
#define SMP_FAIL (SMP_MAX_FAIL_RSN_PER_SPEC + 0x0A) /* 0x18 */

#define SMP_CONN_TOUT (SMP_MAX_FAIL_RSN_PER_SPEC + 0x0B) /* 0x19 */
#define SMP_SUCCESS 0
  SMP_FAIL = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x0A), /* 0x18 */

typedef uint8_t tSMP_STATUS;
  SMP_CONN_TOUT = (SMP_MAX_FAIL_RSN_PER_SPEC + 0x0B), /* 0x19 */
} tSMP_STATUS;

/* Device IO capability */
#define SMP_IO_CAP_IO BTM_IO_CAP_IO         /* DisplayYesNo */