Skip to content
Snippets Groups Projects
Commit 0c18c8a0 authored by Jakub Rotkiewicz's avatar Jakub Rotkiewicz
Browse files

BQR: Fix event len for v5.0 incompatible devices

Bug: 293849013
Test: m libbtif-core
Test: manual - check BQR event logs

Change-Id: Ic9bced9c1f19527c586d9f62ee02fcda8e294fc8
parent 8b1686ef
No related branches found
No related tags found
No related merge requests found
......@@ -108,7 +108,7 @@ static constexpr uint16_t kMinReportIntervalMaxMs = 0xFFFF;
static constexpr uint16_t kLogDumpEventPerFile = 0x00FF;
// Total length of all parameters of the link Quality related event except
// Vendor Specific Parameters.
static constexpr uint8_t kLinkQualityParamTotalLen = 55;
static constexpr uint8_t kLinkQualityParamTotalLen = 48;
// 7.8.116 LE Read ISO Link Quality command
static constexpr uint8_t kISOLinkQualityParamTotalLen = 24;
// Total length of all parameters of the ROOT_INFLAMMATION event except Vendor
......@@ -117,6 +117,9 @@ static constexpr uint8_t kRootInflammationParamTotalLen = 3;
// Total length of all parameters of the Log Dump related event except Vendor
// Specific Parameters.
static constexpr uint8_t kLogDumpParamTotalLen = 3;
// Remote address and calibration failure count parameters len
// Added in BQR V5.0
static constexpr uint8_t kVersion5_0ParamsTotalLen = 7;
// Warning criteria of the RSSI value.
static constexpr int8_t kCriWarnRssi = -80;
// Warning criteria of the unused AFH channel count.
......@@ -166,6 +169,9 @@ static uint16_t BtSchedulingTraceCounter = 0;
static constexpr uint16_t kBqrIsoVersion = 0x101;
// The version supports vendor quality and trace log starting v1.02(258)
static constexpr uint16_t kBqrVndLogVersion = 0x102;
// The version supports remote address info and calibration failure count
// start from v1.03(259)
static constexpr uint16_t kBqrVersion5_0 = 0x103;
// Action definition
//
......
......@@ -83,8 +83,27 @@ void BqrVseSubEvt::ParseBqrLinkQualityEvt(uint8_t length,
STREAM_TO_UINT32(bqr_link_quality_event_.last_flow_on_timestamp, p_param_buf);
STREAM_TO_UINT32(bqr_link_quality_event_.buffer_overflow_bytes, p_param_buf);
STREAM_TO_UINT32(bqr_link_quality_event_.buffer_underflow_bytes, p_param_buf);
STREAM_TO_BDADDR(bqr_link_quality_event_.bdaddr, p_param_buf);
STREAM_TO_UINT8(bqr_link_quality_event_.cal_failed_item_count, p_param_buf);
if (vendor_cap_supported_version >= kBqrVersion5_0) {
if (length < kLinkQualityParamTotalLen + kISOLinkQualityParamTotalLen +
kVersion5_0ParamsTotalLen) {
LOG(WARNING) << __func__
<< ": Parameter total length: " << std::to_string(length)
<< " is abnormal. "
<< "vendor_cap_supported_version: "
<< vendor_cap_supported_version << " "
<< " (>= "
<< "kBqrVersion5_0=" << kBqrVersion5_0 << "), "
<< "It should not be shorter than: "
<< std::to_string(kLinkQualityParamTotalLen +
kISOLinkQualityParamTotalLen +
kVersion5_0ParamsTotalLen);
} else {
STREAM_TO_BDADDR(bqr_link_quality_event_.bdaddr, p_param_buf);
STREAM_TO_UINT8(bqr_link_quality_event_.cal_failed_item_count,
p_param_buf);
}
}
if (vendor_cap_supported_version >= kBqrIsoVersion) {
if (length < kLinkQualityParamTotalLen + kISOLinkQualityParamTotalLen) {
......@@ -180,12 +199,13 @@ std::string BqrVseSubEvt::ToString() const {
<< ", OverFlow: "
<< std::to_string(bqr_link_quality_event_.buffer_overflow_bytes)
<< ", UndFlow: "
<< std::to_string(bqr_link_quality_event_.buffer_underflow_bytes)
<< ", RemoteDevAddr: "
<< bqr_link_quality_event_.bdaddr.ToColonSepHexString()
<< ", CalFailedItems: "
<< std::to_string(bqr_link_quality_event_.cal_failed_item_count);
<< std::to_string(bqr_link_quality_event_.buffer_underflow_bytes);
if (vendor_cap_supported_version >= kBqrVersion5_0) {
ss << ", RemoteDevAddr: "
<< bqr_link_quality_event_.bdaddr.ToColonSepHexString()
<< ", CalFailedItems: "
<< std::to_string(bqr_link_quality_event_.cal_failed_item_count);
}
if (vendor_cap_supported_version >= kBqrIsoVersion) {
ss << ", TxTotal: "
<< std::to_string(bqr_link_quality_event_.tx_total_packets)
......@@ -587,13 +607,20 @@ void AddLinkQualityEventToQueue(uint8_t length,
if (bqrItf != NULL) {
bd_addr = p_bqr_event->bqr_link_quality_event_.bdaddr;
if (bd_addr.IsEmpty()) {
tBTM_SEC_DEV_REC* dev = btm_find_dev_by_handle(
p_bqr_event->bqr_link_quality_event_.connection_handle);
if (dev != NULL) {
bd_addr = dev->RemoteAddress();
}
}
if (!bd_addr.IsEmpty()) {
bqrItf->bqr_delivery_event(bd_addr, (uint8_t*)p_link_quality_event,
length);
} else {
LOG(WARNING) << __func__ << ": failed to deliver BQR, "
<< "bdaddr is empty, no address in packet";
<< "bdaddr is empty";
}
} else {
LOG(WARNING) << __func__ << ": failed to deliver BQR, bqrItf is NULL";
......@@ -752,6 +779,18 @@ class BluetoothQualityReportInterfaceImpl
raw_data.insert(raw_data.begin(), bqr_raw_data,
bqr_raw_data + bqr_raw_data_len);
if (vendor_cap_supported_version < kBqrVersion5_0 &&
bqr_raw_data_len <
kLinkQualityParamTotalLen + kVersion5_0ParamsTotalLen) {
std::vector<uint8_t>::iterator it =
raw_data.begin() + kLinkQualityParamTotalLen;
/**
* Insert zeros as remote address and calibration count
* for BQR 5.0 incompatible devices
*/
raw_data.insert(it, kVersion5_0ParamsTotalLen, 0);
}
uint8_t lmp_ver = 0;
uint16_t lmp_subver = 0;
uint16_t manufacturer_id = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment