From: Roland Schober <rolandschober1968@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Roland Schober <rolandschober1968@gmail.com>
Subject: [PATCH BlueZ v3 7/9] monitor: Split LE PA Report decoding into helpers
Date: Thu, 19 Nov 2026 09:16:19 +0100 [thread overview]
Message-ID: <20261119081621.112623-8-rolandschober1968@gmail.com> (raw)
In-Reply-To: <20261119081621.112623-1-rolandschober1968@gmail.com>
Move the decoding of the reception information (handle, TX power, RSSI
and CTE type) and of the data (status, length and AD structures) of the
LE Periodic Advertising Report event into helpers, and the TX power,
the RSSI and the CTE type names into functions of their own.
This is a preparation for decoding the events added by Periodic
Advertising with Responses, which carry the same information, and
does not change the output.
Assisted-by: Claude:claude-opus-5-5
Assisted-by: Claude:claude-fable-5-2
---
monitor/packet.c | 100 +++++++++++++++++++++++++++++------------------
1 file changed, 62 insertions(+), 38 deletions(-)
diff --git a/monitor/packet.c b/monitor/packet.c
index 015392713..fa19139d9 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -13916,49 +13916,62 @@ static void le_pa_sync_evt(struct timeval *tv, uint16_t index,
print_field("Advertiser clock accuracy: 0x%2.2x", evt->clock_accuracy);
}
-static void le_pa_report_evt(struct timeval *tv, uint16_t index,
- const void *data, uint8_t size)
+static const char *pa_cte_type_str(uint8_t cte_type)
{
- const struct bt_hci_le_pa_report *evt = data;
- const char *color_on;
- const char *str;
-
- print_field("Sync handle: %d", evt->handle);
- if (evt->tx_power == 127)
- print_field("TX power: not available (0x7f)");
- else
- print_power_level(evt->tx_power, NULL);
- if (evt->rssi == 127)
- print_field("RSSI: not available (0x%2.2x)",
- (uint8_t) evt->rssi);
- else if (evt->rssi >= -127 && evt->rssi <= 20)
- print_field("RSSI: %d dBm (0x%2.2x)",
- evt->rssi, (uint8_t) evt->rssi);
- else
- print_field("RSSI: reserved (0x%2.2x)",
- (uint8_t) evt->rssi);
-
- switch (evt->cte_type) {
+ switch (cte_type) {
case 0x00:
- str = "AoA Constant Tone Extension";
- break;
+ return "AoA Constant Tone Extension";
case 0x01:
- str = "AoD Constant Tone Extension with 1us slots";
- break;
+ return "AoD Constant Tone Extension with 1us slots";
case 0x02:
- str = "AoD Constant Tone Extension with 2us slots";
- break;
+ return "AoD Constant Tone Extension with 2us slots";
case 0xff:
- str = "No Constant Tone Extension";
- break;
+ return "No Constant Tone Extension";
default:
- str = "Reserved";
- break;
+ return "Reserved";
}
+}
- print_field("CTE Type: %s (0x%2.2x)", str, evt->cte_type);
+static void print_pa_rssi(const char *prefix, int8_t rssi)
+{
+ if (rssi == 127)
+ print_field("%sRSSI: not available (0x%2.2x)", prefix,
+ (uint8_t) rssi);
+ else if (rssi >= -127 && rssi <= 20)
+ print_field("%sRSSI: %d dBm (0x%2.2x)", prefix, rssi,
+ (uint8_t) rssi);
+ else
+ print_field("%sRSSI: reserved (0x%2.2x)", prefix,
+ (uint8_t) rssi);
+}
- switch (evt->data_status) {
+static void print_pa_tx_power(const char *prefix, int8_t tx_power)
+{
+ if (tx_power == 127)
+ print_field("%sTX power: not available (0x7f)", prefix);
+ else
+ print_field("%sTX power: %d dbm (0x%2.2x)", prefix, tx_power,
+ (uint8_t) tx_power);
+}
+
+static void print_pa_report_info(uint16_t handle, uint8_t tx_power,
+ int8_t rssi, uint8_t cte_type)
+{
+ print_field("Sync handle: %d", handle);
+ print_pa_tx_power("", tx_power);
+ print_pa_rssi("", rssi);
+
+ print_field("CTE Type: %s (0x%2.2x)", pa_cte_type_str(cte_type),
+ cte_type);
+}
+
+static void print_pa_report_data(uint8_t data_status, uint8_t data_len,
+ const uint8_t *data, uint8_t size)
+{
+ const char *color_on;
+ const char *str;
+
+ switch (data_status) {
case 0x00:
str = "Complete";
color_on = COLOR_GREEN;
@@ -13978,15 +13991,26 @@ static void le_pa_report_evt(struct timeval *tv, uint16_t index,
}
print_field("Data status: %s%s%s", color_on, str, COLOR_OFF);
- print_field("Data length: %u", evt->data_len);
+ print_field("Data length: %u", data_len);
- if (evt->data_len != size - sizeof(*evt)) {
+ if (data_len != size) {
print_text(COLOR_ERROR, "invalid data length");
- packet_hexdump(evt->data, size - sizeof(*evt));
+ packet_hexdump(data, size);
return;
}
- print_eir("Data", evt->data, evt->data_len, true);
+ print_eir("Data", data, data_len, true);
+}
+
+static void le_pa_report_evt(struct timeval *tv, uint16_t index,
+ const void *data, uint8_t size)
+{
+ const struct bt_hci_le_pa_report *evt = data;
+
+ print_pa_report_info(evt->handle, evt->tx_power, evt->rssi,
+ evt->cte_type);
+ print_pa_report_data(evt->data_status, evt->data_len, evt->data,
+ size - sizeof(*evt));
}
static void le_pa_sync_lost_evt(struct timeval *tv, uint16_t index,
--
2.47.3
next prev parent reply other threads:[~2026-11-19 8:16 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 8:16 [PATCH BlueZ v3 0/9] monitor: Decode Periodic Advertising with Responses Roland Schober
2026-11-19 8:16 ` [PATCH BlueZ v3 1/9] monitor: Fix handle decoding of status_handle_rsp Roland Schober
2026-11-19 9:53 ` monitor: Decode Periodic Advertising with Responses bluez.test.bot
2026-11-19 8:16 ` [PATCH BlueZ v3 2/9] monitor: Fix data length of LE PA Report decoding Roland Schober
2026-11-19 8:16 ` [PATCH BlueZ v3 3/9] monitor: Fix PHY decoding of LE Ext Create Connection Roland Schober
2026-11-19 8:16 ` [PATCH BlueZ v3 4/9] monitor: Fix advertising handle of LE PA commands Roland Schober
2026-11-19 8:16 ` [PATCH BlueZ v3 5/9] monitor: Fix TX power and CTE Type of LE PA Report Roland Schober
2026-11-19 8:16 ` [PATCH BlueZ v3 6/9] monitor: Fix LE PAST Received decoding Roland Schober
2026-11-19 8:16 ` Roland Schober [this message]
2026-11-19 8:16 ` [PATCH BlueZ v3 8/9] monitor: Add PAwR HCI commands decoding Roland Schober
2026-11-19 8:16 ` [PATCH BlueZ v3 9/9] monitor: Add PAwR HCI events decoding Roland Schober
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119081621.112623-8-rolandschober1968@gmail.com \
--to=rolandschober1968@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox