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

Commit 9453863d authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Revert "Add dumpsys support for LE connection parameter updates"

Reverting for now after talking to Jacky because this causes  circular dependencies as lower layer (stack/) functions are calling higher layer APIs (btif/) directly.

To restore a change like this, the data should be collected at a lower layer in the stack and reported through polling or a callback.

This reverts commit bc2c403c.

Change-Id: I748843864ae7198ea021fe70d2643a62097ab029
parent 5c34433b
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ btifCommonSrc += \
  src/btif_debug.cc \
  src/btif_debug_btsnoop.cc \
  src/btif_debug_conn.cc \
  src/btif_debug_l2c.cc \
  src/btif_dm.cc \
  src/btif_gatt.cc \
  src/btif_gatt_client.cc \
+0 −62
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright (C) 2016 Google Inc.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

#pragma once

#include <stdint.h>

#include <hardware/bluetooth.h>

#ifdef __cplusplus
extern "C" {
#endif

// Captures a BLE connection parameter update request (Section 4.20 of
// Bluetooth Core V4.2 specification):
//
// min_interval and max_interval define the minimum and maximum values for the
// connection event interval (in units of 1.25ms and should be in the
// [6, 3200] range).
// slave_latency_param is the slave latency parameter for the connection in
// number of connection events (unitless and should be less than 500).
// timeout_multiplier is the connection timeout parameter (in units of 10ms
// and should be in the [10, 3200] range).
void btif_debug_ble_connection_update_request(bt_bdaddr_t bda,
    uint16_t min_interval, uint16_t max_interval, uint16_t slave_latency_param,
    uint16_t timeout_multiplier);

// Captures a BLE connection parameter update response ((Section 4.21 of
// Bluetooth Core V4.2 specification):
//
// interval defines the minimum and maximum values for the
// connection event interval (in units of 1.25ms and should be in the
// [6, 3200] range).
// slave_latency_param is the slave latency parameter for the connection in
// number of connection events (unitless and should be less than 500).
// timeout_multiplier is the connection timeout parameter (in units of 10ms
// and should be in the [10, 3200] range).
void btif_debug_ble_connection_update_response(bt_bdaddr_t bda, uint8_t status,
    uint16_t interval, uint16_t slave_latency_param,
    uint16_t timeout_multiplier);

// Dumps captured L2C information.
void btif_debug_l2c_dump(int fd);

#ifdef __cplusplus
}
#endif
+0 −2
Original line number Diff line number Diff line
@@ -62,7 +62,6 @@
#include "btif_storage.h"
#include "btif/include/btif_debug_btsnoop.h"
#include "btif/include/btif_debug_conn.h"
#include "btif/include/btif_debug_l2c.h"
#include "btif/include/btif_media.h"

/************************************************************************************
@@ -354,7 +353,6 @@ static void dump(int fd, const char **arguments)
    btif_debug_conn_dump(fd);
    btif_debug_bond_event_dump(fd);
    btif_debug_a2dp_dump(fd);
    btif_debug_l2c_dump(fd);
    btif_debug_config_dump(fd);
    wakelock_debug_dump(fd);
    alarm_debug_dump(fd);

system/btif/src/btif_debug_l2c.cc

deleted100644 → 0
+0 −159
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright (C) 2016 Google Inc.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <time.h>

#include "btcore/include/bdaddr.h"
#include "btif/include/btif_debug.h"
#include "btif/include/btif_debug_l2c.h"

#define NUM_UPDATE_REQUESTS 5
#define NUM_UPDATE_RESPONSES 5

#define INTERVAL_1_25_MS_MULTIPLIER 1.25f
#define TIMEOUT_10_MS_MULTIPLIER 10

typedef enum {
  BTIF_DEBUG_CONNECTION_UPDATE_REQUEST,
  BTIF_DEBUG_CONNECTION_UPDATE_RESPONSE,
} btif_debug_ble_conn_update_t;

/* Shared Connection update record for both request and response. */
typedef struct ble_conn_update_t {
  uint64_t timestamp_ms;
  bt_bdaddr_t bda;
  btif_debug_ble_conn_update_t type;
  uint8_t status;         /* Not populated for request. */
  uint16_t min_interval;  /* Not populated for response. */
  uint16_t max_interval;
  uint16_t latency;
  uint16_t timeout;
} ble_conn_update_t;

static int update_request_index;
static int update_response_index;
static ble_conn_update_t last_ble_conn_update_requests[NUM_UPDATE_REQUESTS];
static ble_conn_update_t last_ble_conn_update_responses[NUM_UPDATE_RESPONSES];

static int dump_connection_update(int fd, const ble_conn_update_t *update) {
  if (!update || update->timestamp_ms == 0) {
    return -1;
  }

  /* Format timestamp */
  const uint64_t msecs = update->timestamp_ms / 1000;
  const time_t secs = msecs / 1000;
  struct tm *ptm = localtime(&secs);
  char time_buf[20] = {0};
  strftime(time_buf, sizeof(time_buf), "%m-%d %H:%M:%S", ptm);
  snprintf(time_buf, sizeof(time_buf), "%s.%03u", time_buf,
      (uint16_t)(msecs % 1000));

  /* Format address */
  char addr_buf[18] = {0};
  bdaddr_to_string(&update->bda, addr_buf, sizeof(addr_buf));

  if (update->type == BTIF_DEBUG_CONNECTION_UPDATE_REQUEST) {
    dprintf(fd,
        "  %s %s min interval=%d (%.2fms) max interval=%d (%.2fms) "
        "latency parameter=%d timeout multiplier=%d (%dms)\n",
        time_buf, addr_buf, update->min_interval,
        (float)update->min_interval * INTERVAL_1_25_MS_MULTIPLIER,
        update->max_interval,
        (float)update->max_interval * INTERVAL_1_25_MS_MULTIPLIER,
        update->latency, update->timeout,
        update->timeout * TIMEOUT_10_MS_MULTIPLIER);
  } else {
    dprintf(fd,
        "  %s %s status=%d interval=%d (%.2fms) latency parameter=%d "
        "timeout multiplier=%d (%dms)\n", time_buf,
        addr_buf, update->status, update->max_interval,
        (float)update->max_interval * INTERVAL_1_25_MS_MULTIPLIER,
        update->latency, update->timeout,
        update->timeout * TIMEOUT_10_MS_MULTIPLIER);
  }

  return 0;
}

static void record_connection_update(bt_bdaddr_t bda, uint8_t status,
    uint16_t min_interval, uint16_t max_interval, uint16_t latency,
    uint16_t timeout, btif_debug_ble_conn_update_t type,
    ble_conn_update_t* update) {

  memcpy(&update->bda, &bda, sizeof(bt_bdaddr_t));
  update->type = type;
  update->timestamp_ms = btif_debug_ts();
  update->min_interval = min_interval;
  update->max_interval = max_interval;
  update->latency = latency;
  update->timeout = timeout;
  update->status = 0;
}

void btif_debug_ble_connection_update_request(bt_bdaddr_t bda,
    uint16_t min_interval, uint16_t max_interval, uint16_t slave_latency_param,
    uint16_t timeout_multiplier) {
  ble_conn_update_t *request =
      &last_ble_conn_update_requests[update_request_index];

  record_connection_update(bda, 0, min_interval, max_interval, slave_latency_param,
      timeout_multiplier, BTIF_DEBUG_CONNECTION_UPDATE_REQUEST, request);

  update_request_index = (update_request_index == NUM_UPDATE_REQUESTS - 1) ?
      0 : update_request_index + 1;
}

void btif_debug_ble_connection_update_response(bt_bdaddr_t bda, uint8_t status,
    uint16_t interval, uint16_t slave_latency_param,
    uint16_t timeout_multiplier) {
  ble_conn_update_t *response =
      &last_ble_conn_update_responses[update_response_index];

  record_connection_update(bda, status, 0, interval, slave_latency_param,
      timeout_multiplier, BTIF_DEBUG_CONNECTION_UPDATE_RESPONSE, response);

  update_response_index = (update_response_index == NUM_UPDATE_RESPONSES - 1) ?
      0 : update_response_index + 1;
}

void btif_debug_l2c_dump(int fd) {
  dprintf(fd, "\nLE Connection Parameter Updates:\n");

  int i;
  dprintf(fd, "  Last %d Request(s):\n", NUM_UPDATE_REQUESTS);
  for (i = 0; i < NUM_UPDATE_REQUESTS; ++i) {
    if (dump_connection_update(fd, &last_ble_conn_update_requests[i]) < 0 &&
        i == 0) {
      dprintf(fd, "  None\n");
      break;
    }
  }

  dprintf(fd, "\n  Last %d Response(s):\n", NUM_UPDATE_RESPONSES);
  for (i = 0; i < NUM_UPDATE_RESPONSES; ++i) {
    if (dump_connection_update(fd, &last_ble_conn_update_responses[i]) < 0 &&
        i == 0) {
      dprintf(fd, "  None\n");
      break;
    }
  }
}
+0 −15
Original line number Diff line number Diff line
@@ -32,7 +32,6 @@
#include "hcimsgs.h"
#include "device/include/controller.h"
#include "stack_config.h"
#include "btif_debug_l2c.h"

#if (BLE_INCLUDED == TRUE)

@@ -569,14 +568,6 @@ static void l2cble_start_conn_update (tL2C_LCB *p_lcb)
            p_lcb->conn_update_mask |= L2C_BLE_NOT_DEFAULT_PARAM;
        }
    }

    /* Record the BLE connection update request. */
    if (p_lcb->conn_update_mask & L2C_BLE_UPDATE_PENDING) {
      bt_bdaddr_t bd_addr;
      bdcpy(bd_addr.address, p_lcb->remote_bd_addr);
      btif_debug_ble_connection_update_request(bd_addr, min_conn_int, max_conn_int, slave_latency,
          supervision_tout);
    }
}

/*******************************************************************************
@@ -611,12 +602,6 @@ void l2cble_process_conn_update_evt (uint16_t handle, uint8_t status,

    l2cble_start_conn_update(p_lcb);

    /* Record the BLE connection update response. */
    bt_bdaddr_t bd_addr;
    bdcpy(bd_addr.address, p_lcb->remote_bd_addr);
    btif_debug_ble_connection_update_response(bd_addr, status, interval,
        latency, timeout);

    L2CAP_TRACE_DEBUG("%s: conn_update_mask=%d", __func__, p_lcb->conn_update_mask);
}