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

Commit 41668080 authored by Chienyuan's avatar Chienyuan
Browse files

GD HCI: define PDL for BQR command/event

Bug: 145193384
Test: run bluetooth_test_gd
Change-Id: Ifa5f7faba405509d9cc4e6b345db897dd60ae4c8
parent 278071d6
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -650,6 +650,8 @@ struct Controller::impl {
        return vendor_capabilities_.debug_logging_supported_ == 0x01;
      case OpCode::CONTROLLER_A2DP_OPCODE:
        return vendor_capabilities_.a2dp_source_offload_capability_mask_ != 0x00;
      case OpCode::CONTROLLER_BQR:
        return vendor_capabilities_.bluetooth_quality_report_support_ == 0x01;
      // undefined in local_supported_commands_
      case OpCode::CREATE_NEW_UNIT_KEY:
      case OpCode::READ_LOCAL_SUPPORTED_COMMANDS:
+143 −0
Original line number Diff line number Diff line
@@ -315,6 +315,7 @@ enum OpCode : 16 {
  LE_EXTENDED_SCAN_PARAMS = 0xFD5A,
  CONTROLLER_DEBUG_INFO = 0xFD5B,
  CONTROLLER_A2DP_OPCODE = 0xFD5D,
  CONTROLLER_BQR = 0xFD5E,
}

// For mapping Local Supported Commands command
@@ -641,6 +642,14 @@ enum SubeventCode : 8 {
  SCAN_REQUEST_RECEIVED = 0x13,
}

// Vendor specific events
enum VseSubeventCode : 8 {
  BLE_THRESHOLD = 0x54,
  BLE_TRACKING = 0x56,
  DEBUG_INFO = 0x57,
  BQR_EVENT = 0x58,
}

// Common definitions for commands and events

enum FeatureFlag : 1 {
@@ -3102,6 +3111,23 @@ packet ControllerA2DPOpcode : VendorCommand (op_code = CONTROLLER_A2DP_OPCODE) {
  _payload_,  // placeholder (unimplemented)
}

enum BqrReportAction : 8 {
  ADD = 0x00,
  DELETE = 0x01,
  CLEAR = 0x02,
}

packet ControllerBqr : VendorCommand(op_code = CONTROLLER_BQR) {
  bqr_report_action : BqrReportAction,
  bqr_quality_event_mask : 32,
  bqr_minimum_report_interval : 16,
}

packet ControllerBqrComplete : CommandComplete (command_op_code = CONTROLLER_BQR) {
  status : ErrorCode,
  current_quality_event_mask : 32
}

// HCI Event Packets

packet InquiryComplete : EventPacket (event_code = INQUIRY_COMPLETE){
@@ -3665,3 +3691,120 @@ packet LeScanRequestReceived : LeMetaEvent (subevent_code = SCAN_REQUEST_RECEIVE
  scanner_address_type : AddressType,
  scanner_address : Address,
}

// Vendor specific events

packet VendorSpecificEvent : EventPacket (event_code = VENDOR_SPECIFIC) {
  subevent_code : VseSubeventCode,
  _payload_,
}

enum qualityReportId : 8 {
  MONITOR_MODE = 0x01,
  APPROACH_LSTO = 0x02,
  A2DP_AUDIO_CHOPPY = 0x03,
  SCO_VOICE_CHOPPY = 0x04,
  ROOT_INFLAMMATION = 0x05,
  LMP_LL_MESSAGE_TRACE = 0x11,
  BT_SCHEDULING_TRACE = 0x12,
  CONTROLLER_DBG_INFO = 0x13,
}

packet BqrEvent : VendorSpecificEvent (subevent_code = BQR_EVENT) {
  quality_report_id : qualityReportId,
  _payload_,
}

enum BqrPacketType : 8 {
  TYPE_ID = 0x01,
  TYPE_NULL = 0x02,
  TYPE_POLL = 0x03,
  TYPE_FHS = 0x04,
  TYPE_HV1 = 0x05,
  TYPE_HV2 = 0x06,
  TYPE_HV3 = 0x07,
  TYPE_DV = 0x08,
  TYPE_EV3 = 0x09,
  TYPE_EV4 = 0x0A,
  TYPE_EV5 = 0x0B,
  TYPE_2EV3 = 0x0C,
  TYPE_2EV5 = 0x0D,
  TYPE_3EV3 = 0x0E,
  TYPE_3EV5 = 0x0F,
  TYPE_DM1 = 0x10,
  TYPE_DH1 = 0x11,
  TYPE_DM3 = 0x12,
  TYPE_DH3 = 0x13,
  TYPE_DM5 = 0x14,
  TYPE_DH5 = 0x15,
  TYPE_AUX1 = 0x16,
  TYPE_2DH1 = 0x17,
  TYPE_2DH3 = 0x18,
  TYPE_2DH5 = 0x19,
  TYPE_3DH1 = 0x1A,
  TYPE_3DH3 = 0x1B,
  TYPE_3DH5 = 0x1C,
}

packet BqrLinkQualityEvent : BqrEvent {
  packet_type : BqrPacketType,
  connection_handle : 12,
  _reserved_ : 4,
  connection_role : Role,
  tx_power_level : 8,
  rssi : 8,
  snr : 8,
  unused_afh_channel_count : 8,
  afh_select_unideal_channel_count : 8,
  lsto : 16,
  connection_piconet_clock : 32,
  retransmission_count : 32,
  no_rx_count : 32,
  nak_count : 32,
  last_tx_ack_timestamp : 32,
  flow_off_count : 32,
  last_flow_on_timestamp : 32,
  buffer_overflow_bytes : 32,
  buffer_underflow_bytes : 32,
  _payload_,
}

packet BqrMonitorModeEvent : BqrLinkQualityEvent (quality_report_id = MONITOR_MODE) {
 _payload_, // vendor specific parameter
}

packet BqrApproachLstoEvent : BqrLinkQualityEvent (quality_report_id = APPROACH_LSTO) {
 _payload_, // vendor specific parameter
}

packet BqrA2dpAudioChoppyEvent : BqrLinkQualityEvent (quality_report_id = A2DP_AUDIO_CHOPPY) {
  _payload_, // vendor specific parameter
}

packet BqrScoVoiceChoppyEvent : BqrLinkQualityEvent (quality_report_id = SCO_VOICE_CHOPPY) {
 _payload_, // vendor specific parameter
}

packet BqrRootInflammationEvent : BqrEvent (quality_report_id = ROOT_INFLAMMATION) {
  error_code : 8,
  vendor_specific_error_code : 8,
  _payload_, // vendor specific parameter
}

packet BqrLogDumpEvent : BqrEvent {
  connection_handle : 12,
  _reserved_ : 4,
  _payload_,
}

packet BqrLmpLlMessageTraceEvent : BqrLogDumpEvent (quality_report_id = LMP_LL_MESSAGE_TRACE) {
  _payload_, // vendor specific parameter
}

packet BqrBtSchedulingTraceEvent : BqrLogDumpEvent (quality_report_id = BT_SCHEDULING_TRACE) {
 _payload_, // vendor specific parameter
}

packet BqrControllerDbgInfoEvent : BqrLogDumpEvent (quality_report_id = CONTROLLER_DBG_INFO) {
 _payload_, // vendor specific parameter
}
+45 −0
Original line number Diff line number Diff line
@@ -670,5 +670,50 @@ TEST(HciPacketsTest, testLeMultiAdvSetScanResponseDataBuilderLength) {
  ASSERT(view.IsValid());
}

std::vector<uint8_t> controller_bqr = {0x5e, 0xfd, 0x07, 0x00, 0x1f, 0x00, 0x07, 0x00, 0x88, 0x13};
DEFINE_AND_INSTANTIATE_ControllerBqrReflectionTest(controller_bqr);

std::vector<uint8_t> controller_bqr_complete = {0x0e, 0x08, 0x01, 0x5e, 0xfd, 0x00, 0x1f, 0x00, 0x07, 0x00};
DEFINE_AND_INSTANTIATE_ControllerBqrCompleteReflectionTest(controller_bqr_complete);

std::vector<uint8_t> bqr_monitor_mode_event = {
    0xff, 0x31, 0x58, 0x01, 0x10, 0x02, 0x00, 0x00, 0x07, 0xd5, 0x00, 0x14, 0x00, 0x40, 0x1f, 0xed, 0x41,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x3c, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
DEFINE_AND_INSTANTIATE_BqrMonitorModeEventReflectionTest(bqr_monitor_mode_event);

std::vector<uint8_t> bqr_approach_lsto_event = {
    0xff, 0x48, 0x58, 0x02, 0x10, 0x02, 0x00, 0x01, 0x09, 0xaf, 0x00, 0x2d, 0x00, 0x00, 0x7d, 0x94, 0xe9, 0x03, 0x01,
    0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x30, 0xa8, 0x0f, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x81, 0x9b, 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xcc, 0xcc, 0xcc, 0xcc, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x4e, 0x11, 0x00, 0x0c, 0x54, 0x10, 0x00};
DEFINE_AND_INSTANTIATE_BqrApproachLstoEventReflectionTest(bqr_approach_lsto_event);

std::vector<uint8_t> bqr_a2dp_audio_choppy_event = {
    0xff, 0x41, 0x58, 0x03, 0x19, 0x09, 0x00, 0x00, 0x07, 0xcb, 0x00, 0x3a, 0x01, 0x40, 0x1f, 0x7e, 0xce,
    0x58, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x7e, 0xce, 0x58,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0xd1, 0x57, 0x00, 0x30, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x0d, 0xce, 0x58, 0x00, 0x3a, 0xce, 0x58, 0x00, 0x01, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x01};
DEFINE_AND_INSTANTIATE_BqrA2dpAudioChoppyEventReflectionTest(bqr_a2dp_audio_choppy_event);

std::vector<uint8_t> bqr_sco_voice_choppy_event = {
    0xff, 0x4a, 0x58, 0x04, 0x09, 0x08, 0x00, 0x00, 0x08, 0xbf, 0x00, 0x03, 0x00, 0x40, 0x1f, 0x92, 0x6c, 0x0a, 0x0d,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x06, 0x02, 0x02, 0x0b,
    0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00};
DEFINE_AND_INSTANTIATE_BqrScoVoiceChoppyEventReflectionTest(bqr_sco_voice_choppy_event);

std::vector<uint8_t> bqr_root_inflammation_event = {0xff, 0x04, 0x58, 0x05, 0x00, 0xfe};
DEFINE_AND_INSTANTIATE_BqrRootInflammationEventReflectionTest(bqr_root_inflammation_event);

std::vector<uint8_t> bqr_lmp_ll_message_trace_event = {0xff, 0x11, 0x58, 0x11, 0x03, 0x00, 0x01, 0xff, 0x11, 0x55,
                                                       0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55};
DEFINE_AND_INSTANTIATE_BqrLmpLlMessageTraceEventReflectionTest(bqr_lmp_ll_message_trace_event);

std::vector<uint8_t> bqr_bt_scheduling_trace_event = {0xff, 0x1d, 0x58, 0x12, 0x05, 0x00, 0x02, 0xd9, 0xae, 0x08, 0x01,
                                                      0x05, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11,
                                                      0x00, 0x01, 0x0c, 0x00, 0x36, 0x3c, 0x00, 0x00, 0x00};
DEFINE_AND_INSTANTIATE_BqrBtSchedulingTraceEventReflectionTest(bqr_bt_scheduling_trace_event);

}  // namespace hci
}  // namespace bluetooth