diff mbox series

[Bluez,v1,4/6] monitor: Add support for decoding LE Set Advertising Interval

Message ID 20200330150424.Bluez.v1.4.I0a98775e764e9f8dba1652853b6e7ba440f4c75b@changeid (mailing list archive)
State New, archived
Headers show
Series Add support of setting advertiing intervals. | expand

Commit Message

Howard Chung March 30, 2020, 7:04 a.m. UTC
The following lines will show in btmon:
bluetoothd: Set Advertising Intervals: 0x0140, 0x0280

@ MGMT Command: LE Set Advertising Interval (0x0060) plen 4
        Min advertising interval: 0x0140
        Max advertising interval: 0x0280
@ MGMT Event: Command Complete (0x0001) plen 7
      LE Set Advertising Interval (0x0060) plen 4
        Status: Success (0x00)
        Current settings: 0x00040ad0

Signed-off-by: Howard Chung <howardchung@google.com>
---

 monitor/control.c |  1 +
 monitor/packet.c  | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)
diff mbox series

Patch

diff --git a/monitor/control.c b/monitor/control.c
index 790890fb4..cbf8d41da 100644
--- a/monitor/control.c
+++ b/monitor/control.c
@@ -201,6 +201,7 @@  static const char *settings_str[] = {
 	"bondable", "link-security", "ssp", "br/edr", "hs", "le",
 	"advertising", "secure-conn", "debug-keys", "privacy",
 	"configuration", "static-addr", "phy-configuration", "wide-band-speech",
+	"advertising-intervals",
 };
 
 static void mgmt_new_settings(uint16_t len, const void *buf)
diff --git a/monitor/packet.c b/monitor/packet.c
index 3d32563e6..00825cbb4 100644
--- a/monitor/packet.c
+++ b/monitor/packet.c
@@ -11669,6 +11669,7 @@  static const struct bitfield_data mgmt_settings_table[] = {
 	{ 15, "Static Address"		},
 	{ 16, "PHY Configuration"	},
 	{ 17, "Wideband Speech"		},
+	{ 18, "Advertising Intervals"	},
 	{ }
 };
 
@@ -12988,6 +12989,23 @@  static void mgmt_set_phy_cmd(const void *data, uint16_t size)
 	mgmt_print_phys("Selected PHYs", selected_phys);
 }
 
+static void mgmt_set_adv_interval_cmd(const void *data, uint16_t size)
+{
+	uint16_t min_adv_interval = get_le16(data);
+	uint16_t max_adv_interval = get_le16(data+2);
+
+	print_field("Min advertising interval: 0x%4.4x", min_adv_interval);
+	print_field("Max advertising interval: 0x%4.4x", max_adv_interval);
+}
+
+static void mgmt_set_adv_interval_rsp(const void *data, uint16_t size)
+{
+	uint32_t current_settings = get_le32(data);
+
+	print_field("Current settings: 0x%8.8x", current_settings);
+}
+
+
 struct mgmt_data {
 	uint16_t opcode;
 	const char *str;
@@ -13207,6 +13225,9 @@  static const struct mgmt_data mgmt_command_table[] = {
 	{ 0x0045, "Set PHY Configuration",
 				mgmt_set_phy_cmd, 4, true,
 				mgmt_null_rsp, 0, true },
+	{ 0x0060, "LE Set Advertising Interval",
+				mgmt_set_adv_interval_cmd, 4, true,
+				mgmt_set_adv_interval_rsp, 4, true},
 	{ }
 };