diff mbox series

[BlueZ,3/5] monitor/ll: Add support for connection parameter command.

Message ID 20230729004552.1422547-4-lukasz.rymanowski@codecoup.pl (mailing list archive)
State Accepted
Commit af3549724b0ab3103e8379e5a2e0e653f5f31a99
Headers show
Series Couple of improvements to btmon | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch warning WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __packed over __attribute__((packed)) #141: FILE: monitor/bt.h:111: +} __attribute__ ((packed)); WARNING:PREFER_DEFINED_ATTRIBUTE_MACRO: Prefer __packed over __attribute__((packed)) #157: FILE: monitor/bt.h:127: +} __attribute__ ((packed)); /github/workspace/src/src/13332857.patch total: 0 errors, 2 warnings, 110 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. /github/workspace/src/src/13332857.patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
tedd_an/GitLint fail WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search 1: T3 Title has trailing punctuation (.): "[BlueZ,3/5] monitor/ll: Add support for connection parameter command."
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Łukasz Rymanowski July 29, 2023, 12:45 a.m. UTC
From: Szymon Czapracki <szymon.czapracki@codecoup.pl>

LL_CONNECTION_PARAM_REQ (0x0f)
  Interval min: 7.50 msec (0x0006)
  Interval max: 7.50 msec (0x0006)
  Latency: 0 (0x0000)
  Timeout: 5000 msec (0x01f4)
  Preffered periodicity: 0.00 (0x00)
  Reference connection event count: 4 (0x04)
  Offset 0: 0.00 msec (0x00)
  Offset 1: 0.00 msec (0x00)
  Offset 2: 1.25 msec (0x01)
  Offset 3: 0.00 msec (0x00)
  Offset 4: 2.50 msec (0x02)
  Offset 5: 0.00 msec (0x00)

LL_CONNECTION_PARAM_RSP (0x10)
  Interval min: 7.50 msec (0x0006)
  Interval max: 7.50 msec (0x0006)
  Latency: 0 (0x0000)
  Timeout: 5000 msec (0x01f4)
  Preffered periodicity: 0.00 (0x00)
  Reference connection event count: 4 (0x04)
  Offset 0: 318.75 msec (0xff)
  Offset 1: 318.75 msec (0xff)
  Offset 2: 318.75 msec (0xff)
  Offset 3: 318.75 msec (0xff)
  Offset 4: 318.75 msec (0xff)
  Offset 5: 318.75 msec (0xff)
---
 monitor/bt.h | 28 ++++++++++++++++++++++++
 monitor/ll.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 88 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/monitor/bt.h b/monitor/bt.h
index fcc5478bf..4482e6e2c 100644
--- a/monitor/bt.h
+++ b/monitor/bt.h
@@ -95,8 +95,36 @@  struct bt_ll_peripheral_feature_req {
 } __attribute__ ((packed));
 
 #define BT_LL_CONN_PARAM_REQ	0x0f
+struct bt_ll_conn_param_req {
+	uint16_t interval_min;
+	uint16_t interval_max;
+	uint16_t latency;
+	uint16_t timeout;
+	uint8_t pref_period;
+	uint16_t pref_conn_evt_count;
+	uint8_t offset_0;
+	uint8_t offset_1;
+	uint8_t offset_2;
+	uint8_t offset_3;
+	uint8_t offset_4;
+	uint8_t offset_5;
+} __attribute__ ((packed));
 
 #define BT_LL_CONN_PARAM_RSP	0x10
+struct bt_ll_conn_param_rsp {
+	uint16_t interval_min;
+	uint16_t interval_max;
+	uint16_t latency;
+	uint16_t timeout;
+	uint8_t pref_period;
+	uint16_t pref_conn_evt_count;
+	uint8_t offset_0;
+	uint8_t offset_1;
+	uint8_t offset_2;
+	uint8_t offset_3;
+	uint8_t offset_4;
+	uint8_t offset_5;
+} __attribute__ ((packed));
 
 #define BT_LL_REJECT_IND_EXT	0x11
 struct bt_ll_reject_ind_ext {
diff --git a/monitor/ll.c b/monitor/ll.c
index f588d5e99..feeb13e92 100644
--- a/monitor/ll.c
+++ b/monitor/ll.c
@@ -458,6 +458,64 @@  static void peripheral_feature_req(const void *data, uint8_t size)
 	packet_print_features_ll(pdu->features);
 }
 
+static void conn_param_req(const void *data, uint8_t size)
+{
+	const struct bt_ll_conn_param_req *pdu = data;
+
+	print_field("Interval min: %.2f msec (0x%4.4x)",
+				pdu->interval_min * 1.25, pdu->interval_min);
+	print_field("Interval max: %.2f msec (0x%4.4x)",
+				pdu->interval_max * 1.25, pdu->interval_max);
+	print_field("Latency: %d (0x%4.4x)", pdu->latency, pdu->latency);
+	print_field("Timeout: %d msec (0x%4.4x)", pdu->timeout * 10,
+								pdu->timeout);
+	print_field("Preffered periodicity: %.2f (0x%2.2x)",
+				pdu->pref_period * 1.25, pdu->pref_period);
+	print_field("Reference connection event count: %d (0x%2.2x)",
+			pdu->pref_conn_evt_count, pdu->pref_conn_evt_count);
+	print_field("Offset 0: %.2f msec (0x%2.2x)", pdu->offset_0 * 1.25,
+								pdu->offset_0);
+	print_field("Offset 1: %.2f msec (0x%2.2x)", pdu->offset_1 * 1.25,
+								pdu->offset_1);
+	print_field("Offset 2: %.2f msec (0x%2.2x)", pdu->offset_2 * 1.25,
+								pdu->offset_2);
+	print_field("Offset 3: %.2f msec (0x%2.2x)", pdu->offset_3 * 1.25,
+								pdu->offset_3);
+	print_field("Offset 4: %.2f msec (0x%2.2x)", pdu->offset_4 * 1.25,
+								pdu->offset_4);
+	print_field("Offset 5: %.2f msec (0x%2.2x)", pdu->offset_5 * 1.25,
+								pdu->offset_5);
+}
+
+static void conn_param_rsp(const void *data, uint8_t size)
+{
+	const struct bt_ll_conn_param_rsp *pdu = data;
+
+	print_field("Interval min: %.2f msec (0x%4.4x)",
+				pdu->interval_min * 1.25, pdu->interval_min);
+	print_field("Interval max: %.2f msec (0x%4.4x)",
+				pdu->interval_max * 1.25, pdu->interval_max);
+	print_field("Latency: %d (0x%4.4x)", pdu->latency, pdu->latency);
+	print_field("Timeout: %d msec (0x%4.4x)", pdu->timeout * 10,
+								pdu->timeout);
+	print_field("Preffered periodicity: %.2f (0x%2.2x)",
+				pdu->pref_period * 1.25, pdu->pref_period);
+	print_field("Reference connection event count: %d (0x%2.2x)",
+			pdu->pref_conn_evt_count, pdu->pref_conn_evt_count);
+	print_field("Offset 0: %.2f msec (0x%2.2x)", pdu->offset_0 * 1.25,
+								pdu->offset_0);
+	print_field("Offset 1: %.2f msec (0x%2.2x)", pdu->offset_1 * 1.25,
+								pdu->offset_1);
+	print_field("Offset 2: %.2f msec (0x%2.2x)", pdu->offset_2 * 1.25,
+								pdu->offset_2);
+	print_field("Offset 3: %.2f msec (0x%2.2x)", pdu->offset_3 * 1.25,
+								pdu->offset_3);
+	print_field("Offset 4: %.2f msec (0x%2.2x)", pdu->offset_4 * 1.25,
+								pdu->offset_4);
+	print_field("Offset 5: %.2f msec (0x%2.2x)", pdu->offset_5 * 1.25,
+								pdu->offset_5);
+}
+
 static void reject_ind_ext(const void *data, uint8_t size)
 {
 	const struct bt_ll_reject_ind_ext *pdu = data;
@@ -707,8 +765,8 @@  static const struct llcp_data llcp_table[] = {
 	{ 0x0c, "LL_VERSION_IND",           version_ind,        5, true },
 	{ 0x0d, "LL_REJECT_IND",            reject_ind,         1, true },
 	{ 0x0e, "LL_PERIPHERAL_FEATURE_REQ", peripheral_feature_req, 8, true },
-	{ 0x0f, "LL_CONNECTION_PARAM_REQ",  NULL,              23, true },
-	{ 0x10, "LL_CONNECTION_PARAM_RSP",  NULL,              23, true },
+	{ 0x0f, "LL_CONNECTION_PARAM_REQ",  conn_param_req,    23, true },
+	{ 0x10, "LL_CONNECTION_PARAM_RSP",  conn_param_rsp,    23, true },
 	{ 0x11, "LL_REJECT_IND_EXT",        reject_ind_ext,     2, true },
 	{ 0x12, "LL_PING_REQ",              null_pdu,           0, true },
 	{ 0x13, "LL_PING_RSP",              null_pdu,           0, true },