All of lore.kernel.org
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@codecoup.pl>
To: linux-bluetooth@vger.kernel.org
Cc: Szymon Janc <szymon.janc@codecoup.pl>
Subject: [PATCH 2/3] monitor: Decode LE Periodic Advertising Report Event
Date: Wed, 22 May 2019 11:24:02 +0200	[thread overview]
Message-ID: <20190522092403.20927-2-szymon.janc@codecoup.pl> (raw)
In-Reply-To: <20190522092403.20927-1-szymon.janc@codecoup.pl>

> HCI Event: LE Meta Event (0x3e) plen 18                                                                                                                                                               #19 [hci2] 16.562639
      LE Periodic Advertising Report (0x0f)
        Sync handle: 0
        TX power: -4 dbm (0xfc)
        RSSI: -55 dBm (0xc9)
        Unused: (0xff)
        Data status: Complete
        Data length: 0x0a
        b0 b1 b2 b3 b4 b5 b6 b7 b8 b9
---
 monitor/bt.h     | 11 +++++++++++
 monitor/packet.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/monitor/bt.h b/monitor/bt.h
index 6494c928f..8622ea4d4 100644
--- a/monitor/bt.h
+++ b/monitor/bt.h
@@ -3103,6 +3103,17 @@ struct bt_hci_evt_le_per_sync_established {
 	uint8_t  clock_accuracy;
 } __attribute__ ((packed));
 
+#define BT_HCI_EVT_LE_PER_ADV_REPORT	0x0f
+struct bt_hci_le_per_adv_report {
+	uint16_t handle;
+	uint8_t  tx_power;
+	int8_t   rssi;
+	uint8_t  unused;
+	uint8_t  data_status;
+	uint8_t  data_len;
+	uint8_t  data[0];
+} __attribute__ ((packed));
+
 #define BT_HCI_EVT_LE_ADV_SET_TERM		0x12
 struct bt_hci_evt_le_adv_set_term {
 	uint8_t  status;
diff --git a/monitor/packet.c b/monitor/packet.c
index 3235ad004..8b2671edb 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -9631,6 +9631,49 @@ static void le_per_adv_sync(const void *data, uint8_t size)
 	print_field("Advertiser clock accuracy: 0x%2.2x", evt->clock_accuracy);
 }
 
+static void le_per_adv_report_evt(const void *data, uint8_t size)
+{
+	const struct bt_hci_le_per_adv_report *evt = data;
+	const char *color_on;
+	const char *str;
+
+	print_field("Sync handle: %d", evt->handle);
+	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);
+	print_field("Unused: (0x%2.2x)", evt->unused);
+
+	switch (evt->data_status) {
+	case 0x00:
+		str = "Complete";
+		color_on = COLOR_GREEN;
+		break;
+	case 0x01:
+		str = "Incomplete, more data to come";
+		color_on = COLOR_YELLOW;
+		break;
+	case 0x02:
+		str = "Incomplete, data truncated, no more to come";
+		color_on = COLOR_RED;
+		break;
+	default:
+		str = "Reserved";
+		color_on = COLOR_RED;
+		break;
+	}
+
+	print_field("Data status: %s%s%s", color_on, str, COLOR_OFF);
+	print_field("Data length: 0x%2.2x", evt->data_len);
+	packet_hexdump(evt->data, evt->data_len);
+}
+
 static void le_adv_set_term_evt(const void *data, uint8_t size)
 {
 	const struct bt_hci_evt_le_adv_set_term *evt = data;
@@ -9746,7 +9789,8 @@ static const struct subevent_data le_meta_event_table[] = {
 				le_ext_adv_report_evt, 1, false},
 	{ 0x0e, "LE Periodic Advertising Sync Established",
 				le_per_adv_sync, 15, true },
-	{ 0x0f, "LE Periodic Advertising Report" },
+	{ 0x0f, "LE Periodic Advertising Report",
+				le_per_adv_report_evt, 7, false},
 	{ 0x10, "LE Periodic Advertising Sync Lost" },
 	{ 0x11, "LE Scan Timeout" },
 	{ 0x12, "LE Advertising Set Terminated",
-- 
2.20.1


  reply	other threads:[~2019-05-22  9:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22  9:24 [PATCH 1/3] monitor: Decode LE Periodic Advertising Sync Established Event Szymon Janc
2019-05-22  9:24 ` Szymon Janc [this message]
2019-05-22  9:24 ` [PATCH 3/3] monitor: Decode LE Periodic Advertising Sync Lost Event Szymon Janc
2019-05-24  8:50 ` [PATCH 1/3] monitor: Decode LE Periodic Advertising Sync Established Event Luiz Augusto von Dentz

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=20190522092403.20927-2-szymon.janc@codecoup.pl \
    --to=szymon.janc@codecoup.pl \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.