From 2306e3047105d612a090447ea8fcada1dd405705 Mon Sep 17 00:00:00 2001 From: Daniel Winkler Date: Thu, 29 Oct 2020 16:06:22 -0700 Subject: [PATCH] monitor: Add new MGMT adv commands and events to monitor This change adds the following to packet monitor: -Add Ext Adv Params command and response -Add Ext Adv Data command and response This patch was manually tested by registering advertisements with various features and verifying in btmon log. Signed-off-by: Anuj Jain Signed-off-by: Ayush Garg --- monitor/packet.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index 09e0493..f54d287 100755 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -11841,8 +11841,16 @@ static const struct bitfield_data mgmt_adv_flags_table[] = { { 7, "Advertise in 1M on Secondary channel" }, { 8, "Advertise in 2M on Secondary channel" }, { 9, "Advertise in CODED on Secondary channel" }, + { 12, "Use provided duration parameter" }, + { 13, "Use provided timeout parameter" }, + { 14, "Use provided interval parameters" }, + { 15, "Use provided tx power parameter" }, { } }; +#define MGMT_ADV_PARAM_DURATION (1 << 12) +#define MGMT_ADV_PARAM_TIMEOUT (1 << 13) +#define MGMT_ADV_PARAM_INTERVALS (1 << 14) +#define MGMT_ADV_PARAM_TX_POWER (1 << 15) static void mgmt_print_adv_flags(uint32_t flags) { @@ -13147,6 +13155,57 @@ static void mgmt_set_device_flags_rsp(const void *data, uint16_t size) mgmt_print_address(data, type); } +static void mgmt_add_ext_adv_params_cmd(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + uint32_t flags = get_le32(data + 1); + uint16_t duration = get_le16(data + 5); + uint16_t timeout = get_le16(data + 7); + uint8_t *min_interval = (uint8_t *)(data + 9); + uint8_t *max_interval = (uint8_t *)(data + 13); + int8_t tx_power = get_s8(data + 17); + + print_field("Instance: %u", instance); + mgmt_print_adv_flags(flags); + print_field("Duration: %u", duration); + print_field("Timeout: %u", timeout); + print_ext_slot_625("Min advertising interval", min_interval); + print_ext_slot_625("Max advertising interval", max_interval); + print_power_level(tx_power, NULL); +} + +static void mgmt_add_ext_adv_params_rsp(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + int8_t tx_power = get_s8(data + 1); + uint8_t max_adv_data_len = get_u8(data+2); + uint8_t max_scan_rsp_len = get_u8(data+3); + + print_field("Instance: %u", instance); + print_power_level(tx_power, NULL); + print_field("Available adv data len: %u", max_adv_data_len); + print_field("Available scan rsp data len: %u", max_scan_rsp_len); +} + +static void mgmt_add_ext_adv_data_cmd(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + uint8_t adv_data_len = get_u8(data + 1); + uint8_t scan_rsp_len = get_u8(data + 2); + + print_field("Instance: %u", instance); + print_field("Advertising data length: %u", adv_data_len); + print_eir(data + 3, adv_data_len, false); + print_field("Scan response length: %u", scan_rsp_len); + print_eir(data + 3 + adv_data_len, scan_rsp_len, false); +} + +static void mgmt_add_ext_adv_data_rsp(const void *data, uint16_t size) +{ + uint8_t instance = get_u8(data); + + print_field("Instance: %u", instance); +} static const struct bitfield_data mgmt_adv_monitor_features_table[] = { { 1, "OR Patterns" }, @@ -13484,6 +13543,12 @@ static const struct mgmt_data mgmt_command_table[] = { { 0x0053, "Remove Advertisement Monitor", mgmt_remove_adv_monitor_patterns_cmd, 2, true, mgmt_remove_adv_monitor_patterns_rsp, 2, true}, + { 0x0054, "Add Ext Adv Params", + mgmt_add_ext_adv_params_cmd, 18, false, + mgmt_add_ext_adv_params_rsp, 4, true }, + { 0x0055, "Add Ext Adv Data", + mgmt_add_ext_adv_data_cmd, 3, false, + mgmt_add_ext_adv_data_rsp, 1, true }, { } }; -- 2.7.4