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

Commit 802e4687 authored by Chris Manton's avatar Chris Manton
Browse files

Rearrange enumify stack/btm/btm_sco::SCO_ST_

Towards readable code

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

Change-Id: Ia68644821a23772e43746036d890de979cee1d84
parent db313722
Loading
Loading
Loading
Loading
+3 −10
Original line number Diff line number Diff line
@@ -40,16 +40,6 @@ extern tBTM_CB btm_cb;
/*               L O C A L    D A T A    D E F I N I T I O N S                */
/******************************************************************************/

#define SCO_ST_UNUSED 0
#define SCO_ST_LISTENING 1
#define SCO_ST_W4_CONN_RSP 2
#define SCO_ST_CONNECTING 3
#define SCO_ST_CONNECTED 4
#define SCO_ST_DISCONNECTING 5
#define SCO_ST_PEND_UNPARK 6
#define SCO_ST_PEND_ROLECHANGE 7
#define SCO_ST_PEND_MODECHANGE 8

#define BTM_SCO_PKT_TYPE_MASK \
  (HCI_PKT_TYPES_MASK_HV1 | HCI_PKT_TYPES_MASK_HV2 | HCI_PKT_TYPES_MASK_HV3)

@@ -1163,6 +1153,9 @@ uint8_t BTM_GetNumScoLinks(void) {
      case SCO_ST_DISCONNECTING:
      case SCO_ST_PEND_UNPARK:
        num_scos++;
        break;
      default:
        break;
    }
  }
  return (num_scos);
+37 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#pragma once

#include <cstdint>
#include <string>

#include "device/include/esco_parameters.h"
#include "stack/include/btm_api_types.h"
@@ -24,6 +25,41 @@
/* Define the structures needed by sco
 */

typedef enum : uint16_t {
  SCO_ST_UNUSED = 0,
  SCO_ST_LISTENING = 1,
  SCO_ST_W4_CONN_RSP = 2,
  SCO_ST_CONNECTING = 3,
  SCO_ST_CONNECTED = 4,
  SCO_ST_DISCONNECTING = 5,
  SCO_ST_PEND_UNPARK = 6,
  SCO_ST_PEND_ROLECHANGE = 7,
  SCO_ST_PEND_MODECHANGE = 8,
} tSCO_STATE;

inline std::string sco_state_text(const tSCO_STATE& state) {
  switch (state) {
    case SCO_ST_UNUSED:
      return std::string("unused");
    case SCO_ST_LISTENING:
      return std::string("listening");
    case SCO_ST_W4_CONN_RSP:
      return std::string("connect_response");
    case SCO_ST_CONNECTING:
      return std::string("connecting");
    case SCO_ST_CONNECTED:
      return std::string("connected");
    case SCO_ST_DISCONNECTING:
      return std::string("disconnecting");
    case SCO_ST_PEND_UNPARK:
      return std::string("pending_unpark");
    case SCO_ST_PEND_ROLECHANGE:
      return std::string("pending_role_change");
    case SCO_ST_PEND_MODECHANGE:
      return std::string("pending_mode_change");
  }
}

typedef void(tBTM_SCO_IND_CBACK)(uint16_t sco_inx);

/* Define the structure that contains (e)SCO data */
@@ -40,7 +76,7 @@ typedef struct {
  tBTM_ESCO_INFO esco;    /* Current settings             */
  tBTM_SCO_CB* p_conn_cb; /* Callback for when connected  */
  tBTM_SCO_CB* p_disc_cb; /* Callback for when disconnect */
  uint16_t state;         /* The state of the SCO link    */
  tSCO_STATE state;       /* The state of the SCO link    */
  uint16_t hci_handle;    /* HCI Handle                   */
  bool is_orig;           /* true if the originator       */
  bool rem_bd_known;      /* true if remote BD addr known */