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

Commit 5b390edc authored by William Escande's avatar William Escande Committed by Cherrypicker Worker
Browse files

GATT HANDLE: from build time to runtime config

replace GATT_DEFAULT_START_HANDLE and GATT_LAST_HANDLE with system
properties to allow configuration on wear target. New properties are:
  bluetooth.gatt.default_start_handle.value
  bluetooth.gatt.last_handle.value

Bug: 263323082
Test: Build + manual on watches / no-op for phone
Change-Id: I816766103db26bcfbbf3dd1bfc7544bdb491ea31
(cherry picked from commit 19b74ec9)
Merged-In: I816766103db26bcfbbf3dd1bfc7544bdb491ea31
parent f1b2021f
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -259,6 +259,8 @@ inline std::string gatt_channel_state_text(const tGATT_CH_STATE& state) {
}
#undef CASE_RETURN_TEXT

// If you change these values make sure to look at b/262219144 before.
// Some platform rely on this to never changes
#define GATT_GATT_START_HANDLE 1
#define GATT_GAP_START_HANDLE 20
#define GATT_GMCS_START_HANDLE 40
@@ -266,14 +268,6 @@ inline std::string gatt_channel_state_text(const tGATT_CH_STATE& state) {
#define GATT_TMAS_START_HANDLE 130
#define GATT_APP_START_HANDLE 134

#ifndef GATT_DEFAULT_START_HANDLE
#define GATT_DEFAULT_START_HANDLE GATT_GATT_START_HANDLE
#endif

#ifndef GATT_LAST_HANDLE
#define GATT_LAST_HANDLE 0xFFFF
#endif

typedef struct hdl_cfg {
  uint16_t gatt_start_hdl;
  uint16_t gap_start_hdl;
+9 −2
Original line number Diff line number Diff line
@@ -909,6 +909,13 @@ void gatt_add_a_bonded_dev_for_srv_chg(const RawAddress& bda) {
/** This function is called to send a service chnaged indication to the
 * specified bd address */
void gatt_send_srv_chg_ind(const RawAddress& peer_bda) {
  static const uint16_t sGATT_DEFAULT_START_HANDLE =
      (uint16_t)osi_property_get_int32(
          "bluetooth.gatt.default_start_handle_for_srvc_change.value",
          GATT_GATT_START_HANDLE);
  static const uint16_t sGATT_LAST_HANDLE = (uint16_t)osi_property_get_int32(
      "bluetooth.gatt.last_handle_for_srvc_change.value", 0xFFFF);

  VLOG(1) << __func__;

  if (!gatt_cb.handle_of_h_r) return;
@@ -921,8 +928,8 @@ void gatt_send_srv_chg_ind(const RawAddress& peer_bda) {

  uint8_t handle_range[GATT_SIZE_OF_SRV_CHG_HNDL_RANGE];
  uint8_t* p = handle_range;
  UINT16_TO_STREAM(p, GATT_DEFAULT_START_HANDLE);
  UINT16_TO_STREAM(p, GATT_LAST_HANDLE);
  UINT16_TO_STREAM(p, sGATT_DEFAULT_START_HANDLE);
  UINT16_TO_STREAM(p, sGATT_LAST_HANDLE);
  GATTS_HandleValueIndication(conn_id, gatt_cb.handle_of_h_r,
                              GATT_SIZE_OF_SRV_CHG_HNDL_RANGE, handle_range);
}