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

Commit ca818226 authored by Jack He's avatar Jack He Committed by android-build-merger
Browse files

BQR: Cleanup BQR header definititon

am: d1b4efbe

Change-Id: Ie3780d6f6382ca82f2f809d4359ee20aa84f0cc3
parents cc2ef35e d1b4efbe
Loading
Loading
Loading
Loading
+31 −27
Original line number Original line Diff line number Diff line
@@ -69,10 +69,10 @@ static constexpr uint8_t kCriWarnUnusedCh = 55;
static constexpr uint8_t kBqrEventQueueSize = 25;
static constexpr uint8_t kBqrEventQueueSize = 25;
// The Property of BQR event mask configuration.
// The Property of BQR event mask configuration.
static constexpr const char* kpPropertyEventMask =
static constexpr const char* kpPropertyEventMask =
    "persist.bluetooth.bqr.eventmask";
    "persist.bluetooth.bqr.event_mask";
// The Property of BQR minimum report interval configuration.
// The Property of BQR minimum report interval configuration.
static constexpr const char* kpPropertyReportInt =
static constexpr const char* kpPropertyMinReportIntervalMs =
    "persist.bluetooth.bqr.interval";
    "persist.bluetooth.bqr.min_interval_ms";


// Action definition
// Action definition
//
//
@@ -129,7 +129,7 @@ enum BqrPacketType : uint8_t {
typedef struct {
typedef struct {
  BqrReportAction report_action;
  BqrReportAction report_action;
  uint32_t quality_event_mask;
  uint32_t quality_event_mask;
  uint16_t minimum_report_interval;
  uint16_t minimum_report_interval_ms;
} BqrConfiguration;
} BqrConfiguration;


// BQR sub-event of Vendor Specific Event
// BQR sub-event of Vendor Specific Event
@@ -155,52 +155,56 @@ class BqrVseSubEvt {
  virtual ~BqrVseSubEvt() = default;
  virtual ~BqrVseSubEvt() = default;


  // Quality report ID.
  // Quality report ID.
  uint8_t quality_report_id_;
  uint8_t quality_report_id_ = 0;
  // Packet type of the connection.
  // Packet type of the connection.
  uint8_t packet_types_;
  uint8_t packet_types_ = 0;
  // Connection handle of the connection.
  // Connection handle of the connection.
  uint16_t connection_handle_;
  uint16_t connection_handle_ = 0;
  // Performing Role for the connection.
  // Performing Role for the connection.
  uint8_t connection_role_;
  uint8_t connection_role_ = 0;
  // Current Transmit Power Level for the connection. This value is the same as
  // Current Transmit Power Level for the connection. This value is the same as
  // the controller's response to the HCI_Read_Transmit_Power_Level HCI command.
  // the controller's response to the HCI_Read_Transmit_Power_Level HCI command.
  uint8_t tx_power_level_;
  uint8_t tx_power_level_ = 0;
  // Received Signal Strength Indication (RSSI) value for the connection. This
  // Received Signal Strength Indication (RSSI) value for the connection. This
  // value is an absolute receiver signal strength value.
  // value is an absolute receiver signal strength value.
  int8_t rssi_;
  int8_t rssi_ = 0;
  // Signal-to-Noise Ratio (SNR) value for the connection. It is the average
  // Signal-to-Noise Ratio (SNR) value for the connection. It is the average
  // SNR of all the channels used by the link currently.
  // SNR of all the channels used by the link currently.
  uint8_t snr_;
  uint8_t snr_ = 0;
  // Indicates the number of unused channels in AFH_channel_map.
  // Indicates the number of unused channels in AFH_channel_map.
  uint8_t unused_afh_channel_count_;
  uint8_t unused_afh_channel_count_ = 0;
  // Indicates the number of the channels which are interfered and quality is
  // Indicates the number of the channels which are interfered and quality is
  // bad but are still selected for AFH.
  // bad but are still selected for AFH.
  uint8_t afh_select_unideal_channel_count_;
  uint8_t afh_select_unideal_channel_count_ = 0;
  // Current Link Supervision Timeout Setting.
  // Current Link Supervision Timeout Setting.
  uint16_t lsto_;
  // Unit: N * 0.3125 ms (1 Bluetooth Clock)
  uint16_t lsto_ = 0;
  // Piconet Clock for the specified Connection_Handle. This value is the same
  // Piconet Clock for the specified Connection_Handle. This value is the same
  // as the controller's response to HCI_Read_Clock HCI command with the
  // as the controller's response to HCI_Read_Clock HCI command with the
  // parameter "Which_Clock" of 0x01 (Piconet Clock).
  // parameter "Which_Clock" of 0x01 (Piconet Clock).
  uint32_t connection_piconet_clock_;
  // Unit: N * 0.3125 ms (1 Bluetooth Clock)
  uint32_t connection_piconet_clock_ = 0;
  // The count of retransmission.
  // The count of retransmission.
  uint32_t retransmission_count_;
  uint32_t retransmission_count_ = 0;
  // The count of no RX.
  // The count of no RX.
  uint32_t no_rx_count_;
  uint32_t no_rx_count_ = 0;
  // The count of NAK (Negative Acknowledge).
  // The count of NAK (Negative Acknowledge).
  uint32_t nak_count_;
  uint32_t nak_count_ = 0;
  // Timestamp of last TX ACK.
  // Timestamp of last TX ACK.
  uint32_t last_tx_ack_timestamp_;
  // Unit: N * 0.3125 ms (1 Bluetooth Clock)
  uint32_t last_tx_ack_timestamp_ = 0;
  // The count of Flow-off (STOP).
  // The count of Flow-off (STOP).
  uint32_t flow_off_count_;
  uint32_t flow_off_count_ = 0;
  // Timestamp of last Flow-on (GO).
  // Timestamp of last Flow-on (GO).
  uint32_t last_flow_on_timestamp_;
  // Unit: N * 0.3125 ms (1 Bluetooth Clock)
  uint32_t last_flow_on_timestamp_ = 0;
  // Buffer overflow count (how many bytes of TX data are dropped) since the
  // Buffer overflow count (how many bytes of TX data are dropped) since the
  // last event.
  // last event.
  uint32_t buffer_overflow_bytes_;
  uint32_t buffer_overflow_bytes_ = 0;
  // Buffer underflow count (in byte).
  // Buffer underflow count (in byte).
  uint32_t buffer_underflow_bytes_;
  uint32_t buffer_underflow_bytes_ = 0;
  // Timestamp of receiving BQR VSE sub-event
  // Local wall clock timestamp of receiving BQR VSE sub-event
  std::tm tm_timestamp_;
  std::tm tm_timestamp_ = {};
};
};


// Get a string representation of the Quality Report ID.
// Get a string representation of the Quality Report ID.
@@ -218,9 +222,9 @@ std::string PacketTypeToString(uint8_t packet_type);
// Enable/Disable Bluetooth Quality Report mechanism.
// Enable/Disable Bluetooth Quality Report mechanism.
//
//
// Which Quality event will be enabled is according to the setting of the
// Which Quality event will be enabled is according to the setting of the
// property "persist.bluetooth.bqr.eventmask".
// property "persist.bluetooth.bqr.event_mask".
// And the minimum time interval of quality event reporting depends on the
// And the minimum time interval of quality event reporting depends on the
// setting of property "persist.bluetooth.bqr.interval".
// setting of property "persist.bluetooth.bqr.min_interval_ms".
//
//
// @param is_enable True/False to enable/disable Bluetooth Quality Report
// @param is_enable True/False to enable/disable Bluetooth Quality Report
//   mechanism in the Bluetooth controller.
//   mechanism in the Bluetooth controller.
+12 −12
Original line number Original line Diff line number Diff line
@@ -191,14 +191,14 @@ void EnableBtQualityReport(bool is_enable) {
  LOG(INFO) << __func__ << ": is_enable: " << logbool(is_enable);
  LOG(INFO) << __func__ << ": is_enable: " << logbool(is_enable);


  char bqr_prop_evtmask[PROPERTY_VALUE_MAX] = {0};
  char bqr_prop_evtmask[PROPERTY_VALUE_MAX] = {0};
  char bqr_prop_interval[PROPERTY_VALUE_MAX] = {0};
  char bqr_prop_interval_ms[PROPERTY_VALUE_MAX] = {0};
  osi_property_get(kpPropertyEventMask, bqr_prop_evtmask, "");
  osi_property_get(kpPropertyEventMask, bqr_prop_evtmask, "");
  osi_property_get(kpPropertyReportInt, bqr_prop_interval, "");
  osi_property_get(kpPropertyMinReportIntervalMs, bqr_prop_interval_ms, "");


  if (strlen(bqr_prop_evtmask) == 0 || strlen(bqr_prop_interval) == 0) {
  if (strlen(bqr_prop_evtmask) == 0 || strlen(bqr_prop_interval_ms) == 0) {
    LOG(WARNING) << __func__ << ": Bluetooth Quality Report is disabled."
    LOG(WARNING) << __func__ << ": Bluetooth Quality Report is disabled."
                 << " bqr_prop_evtmask: " << bqr_prop_evtmask
                 << " bqr_prop_evtmask: " << bqr_prop_evtmask
                 << ", bqr_prop_interval: " << bqr_prop_interval;
                 << ", bqr_prop_interval_ms: " << bqr_prop_interval_ms;
    return;
    return;
  }
  }


@@ -208,17 +208,17 @@ void EnableBtQualityReport(bool is_enable) {
    bqr_config.report_action = REPORT_ACTION_ADD;
    bqr_config.report_action = REPORT_ACTION_ADD;
    bqr_config.quality_event_mask =
    bqr_config.quality_event_mask =
        static_cast<uint32_t>(atoi(bqr_prop_evtmask));
        static_cast<uint32_t>(atoi(bqr_prop_evtmask));
    bqr_config.minimum_report_interval =
    bqr_config.minimum_report_interval_ms =
        static_cast<uint16_t>(atoi(bqr_prop_interval));
        static_cast<uint16_t>(atoi(bqr_prop_interval_ms));
  } else {
  } else {
    bqr_config.report_action = REPORT_ACTION_CLEAR;
    bqr_config.report_action = REPORT_ACTION_CLEAR;
    bqr_config.quality_event_mask = kQualityEventMaskAllOff;
    bqr_config.quality_event_mask = kQualityEventMaskAllOff;
    bqr_config.minimum_report_interval = kMinReportIntervalNoLimit;
    bqr_config.minimum_report_interval_ms = kMinReportIntervalNoLimit;
  }
  }


  LOG(INFO) << __func__
  LOG(INFO) << __func__
            << ": Event Mask: " << loghex(bqr_config.quality_event_mask)
            << ": Event Mask: " << loghex(bqr_config.quality_event_mask)
            << ", Interval: " << bqr_config.minimum_report_interval;
            << ", Interval: " << bqr_config.minimum_report_interval_ms;
  ConfigureBqr(bqr_config);
  ConfigureBqr(bqr_config);
}
}


@@ -259,23 +259,23 @@ void BqrVscCompleteCallback(tBTM_VSC_CMPL* p_vsc_cmpl_params) {
void ConfigureBqr(const BqrConfiguration& bqr_config) {
void ConfigureBqr(const BqrConfiguration& bqr_config) {
  if (bqr_config.report_action > REPORT_ACTION_CLEAR ||
  if (bqr_config.report_action > REPORT_ACTION_CLEAR ||
      bqr_config.quality_event_mask > kQualityEventMaskAll ||
      bqr_config.quality_event_mask > kQualityEventMaskAll ||
      bqr_config.minimum_report_interval > kMinReportIntervalMaxMs) {
      bqr_config.minimum_report_interval_ms > kMinReportIntervalMaxMs) {
    LOG(FATAL) << __func__ << ": Invalid Parameter"
    LOG(FATAL) << __func__ << ": Invalid Parameter"
               << ", Action: " << bqr_config.report_action
               << ", Action: " << bqr_config.report_action
               << ", Mask: " << loghex(bqr_config.quality_event_mask)
               << ", Mask: " << loghex(bqr_config.quality_event_mask)
               << ", Interval: " << bqr_config.minimum_report_interval;
               << ", Interval: " << bqr_config.minimum_report_interval_ms;
    return;
    return;
  }
  }


  LOG(INFO) << __func__ << ": Action: " << bqr_config.report_action
  LOG(INFO) << __func__ << ": Action: " << bqr_config.report_action
            << ", Mask: " << loghex(bqr_config.quality_event_mask)
            << ", Mask: " << loghex(bqr_config.quality_event_mask)
            << ", Interval: " << bqr_config.minimum_report_interval;
            << ", Interval: " << bqr_config.minimum_report_interval_ms;


  uint8_t param[sizeof(BqrConfiguration)];
  uint8_t param[sizeof(BqrConfiguration)];
  uint8_t* p_param = param;
  uint8_t* p_param = param;
  UINT8_TO_STREAM(p_param, bqr_config.report_action);
  UINT8_TO_STREAM(p_param, bqr_config.report_action);
  UINT32_TO_STREAM(p_param, bqr_config.quality_event_mask);
  UINT32_TO_STREAM(p_param, bqr_config.quality_event_mask);
  UINT16_TO_STREAM(p_param, bqr_config.minimum_report_interval);
  UINT16_TO_STREAM(p_param, bqr_config.minimum_report_interval_ms);


  BTM_VendorSpecificCommand(HCI_CONTROLLER_BQR_OPCODE_OCF, p_param - param,
  BTM_VendorSpecificCommand(HCI_CONTROLLER_BQR_OPCODE_OCF, p_param - param,
                            param, BqrVscCompleteCallback);
                            param, BqrVscCompleteCallback);