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

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

Enum-ify stack/gatt::tGATTC_OPTYPE

Towards readable code

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

Change-Id: Ib44fdf887a41bdf7bbc3e8a7496b8c59800f7e19
parent 4de7f0ab
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -572,7 +572,8 @@ static void gatt_cl_op_cmpl_cback(uint16_t conn_id, tGATTC_OPTYPE op,
                                  tGATT_CL_COMPLETE* p_data) {
  auto iter = OngoingOps.find(conn_id);

  VLOG(1) << __func__ << " opcode: " << loghex(op) << " status: " << status
  VLOG(1) << __func__ << " opcode: " << loghex(static_cast<uint8_t>(op))
          << " status: " << status
          << " conn id: " << loghex(static_cast<uint8_t>(conn_id));

  if (op != GATTC_OPTYPE_READ) return;
+3 −3
Original line number Diff line number Diff line
@@ -626,7 +626,7 @@ void gatt_process_notification(tGATT_TCB& tcb, uint16_t cid, uint8_t op_code,
  tGATT_STATUS encrypt_status;
  uint8_t* p = p_data;
  uint8_t i;
  uint8_t event = (op_code == GATT_HANDLE_VALUE_IND)
  tGATTC_OPTYPE event = (op_code == GATT_HANDLE_VALUE_IND)
                            ? GATTC_OPTYPE_INDICATION
                            : GATTC_OPTYPE_NOTIFICATION;

+1 −1
Original line number Diff line number Diff line
@@ -342,7 +342,7 @@ struct tGATT_CLCB {
  uint16_t counter; /* used as offset, attribute length, num of prepare write */
  uint16_t start_offset;
  tGATT_AUTH_REQ auth_req; /* authentication requirement */
  uint8_t operation;       /* one logic channel can have one operation active */
  tGATTC_OPTYPE operation; /* one logic channel can have one operation active */
  uint8_t op_subtype;      /* operation subtype */
  tGATT_STATUS status;     /* operation status */
  bool first_read_blob_after_read;
+1 −1
Original line number Diff line number Diff line
@@ -1480,7 +1480,7 @@ void gatt_end_operation(tGATT_CLCB* p_clcb, tGATT_STATUS status, void* p_data) {
  tGATT_CL_COMPLETE cb_data;
  tGATT_CMPL_CBACK* p_cmpl_cb =
      (p_clcb->p_reg) ? p_clcb->p_reg->app_cb.p_cmpl_cb : NULL;
  uint8_t op = p_clcb->operation;
  tGATTC_OPTYPE op = p_clcb->operation;
  tGATT_DISC_TYPE disc_type = GATT_DISC_MAX;
  tGATT_DISC_CMPL_CB* p_disc_cmpl_cb =
      (p_clcb->p_reg) ? p_clcb->p_reg->app_cb.p_disc_cmpl_cb : NULL;
+10 −9
Original line number Diff line number Diff line
@@ -576,15 +576,16 @@ typedef union {

/* GATT client operation type, used in client callback function
*/
#define GATTC_OPTYPE_NONE 0
#define GATTC_OPTYPE_DISCOVERY 1
#define GATTC_OPTYPE_READ 2
#define GATTC_OPTYPE_WRITE 3
#define GATTC_OPTYPE_EXE_WRITE 4
#define GATTC_OPTYPE_CONFIG 5
#define GATTC_OPTYPE_NOTIFICATION 6
#define GATTC_OPTYPE_INDICATION 7
typedef uint8_t tGATTC_OPTYPE;
typedef enum : uint8_t {
  GATTC_OPTYPE_NONE = 0,
  GATTC_OPTYPE_DISCOVERY = 1,
  GATTC_OPTYPE_READ = 2,
  GATTC_OPTYPE_WRITE = 3,
  GATTC_OPTYPE_EXE_WRITE = 4,
  GATTC_OPTYPE_CONFIG = 5,
  GATTC_OPTYPE_NOTIFICATION = 6,
  GATTC_OPTYPE_INDICATION = 7,
} tGATTC_OPTYPE;

/* characteristic declaration
*/