From e862f704eeff14818fcc00a57271bd6907285ad7 Mon Sep 17 00:00:00 2001 From: Jaganath Kanakkassery Date: Thu, 14 Jun 2018 17:51:16 +0530 Subject: [PATCH] monitor: Add support PHY management commands and event --- monitor/packet.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/monitor/packet.c b/monitor/packet.c index 7705d2ed5..7046b9229 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -97,6 +97,7 @@ #define COLOR_UNKNOWN_ADDRESS_TYPE COLOR_WHITE_BG #define COLOR_UNKNOWN_DEVICE_FLAG COLOR_WHITE_BG #define COLOR_UNKNOWN_ADV_FLAG COLOR_WHITE_BG +#define COLOR_UNKNOWN_PHY COLOR_WHITE_BG #define COLOR_PHY_PACKET COLOR_BLUE @@ -10692,6 +10693,7 @@ static const struct { { 13, "Privacy" }, { 14, "Controller Configuration"}, { 15, "Static Address" }, + { 16, "PHY Configuration" }, { } }; @@ -11986,6 +11988,54 @@ static void mgmt_set_apperance_cmd(const void *data, uint16_t size) print_appearance(appearance); } +static const struct { + uint8_t bit; + const char *str; +} mgmt_phy_table[] = { + { 0, "1MTX" }, + { 1, "1MRX" }, + { 2, "2MTX" }, + { 3, "2MRX" }, + { 4, "CODEDTX" }, + { 5, "CODEDRX" }, + { } +}; + +static void mgmt_print_phys(const char *label, uint16_t phys) +{ + uint16_t mask = phys; + int i; + + print_field("%s: 0x%4.4x", label, phys); + + for (i = 0; mgmt_phy_table[i].str; i++) { + if (phys & (1 << mgmt_phy_table[i].bit)) { + print_field(" %s", mgmt_phy_table[i].str); + mask &= ~(1 << mgmt_phy_table[i].bit); + } + } + + if (mask) + print_text(COLOR_UNKNOWN_PHY, " Unknown PHYs" + " (0x%8.8x)", mask); +} + +static void mgmt_get_phy_rsp(const void *data, uint16_t size) +{ + uint16_t supported_phys = get_le16(data); + uint16_t selected_phys = get_le16(data + 2); + + mgmt_print_phys("Supported PHYs", supported_phys); + mgmt_print_phys("Selected PHYs", selected_phys); +} + +static void mgmt_set_phy_cmd(const void *data, uint16_t size) +{ + uint16_t default_phys = get_le16(data); + + mgmt_print_phys("Default PHYs", default_phys); +} + struct mgmt_data { uint16_t opcode; const char *str; @@ -12199,6 +12249,12 @@ static const struct mgmt_data mgmt_command_table[] = { { 0x0043, "Set Appearance", mgmt_set_apperance_cmd, 2, true, mgmt_null_rsp, 0, true }, + { 0x0044, "Get PHY Configuration", + mgmt_null_cmd, 0, true, + mgmt_get_phy_rsp, 4, true }, + { 0x0045, "Set PHY Configuration", + mgmt_set_phy_cmd, 2, true, + mgmt_null_rsp, 0, true }, { } }; @@ -12577,6 +12633,13 @@ static void mgmt_ext_controller_info_changed_evt(const void *data, uint16_t size print_eir(data + 2, size - 2, false); } +static void mgmt_phy_changed_evt(const void *data, uint16_t size) +{ + uint16_t selected_phys = get_le16(data); + + mgmt_print_phys("Selected PHYs", selected_phys); +} + static const struct mgmt_data mgmt_event_table[] = { { 0x0001, "Command Complete", mgmt_command_complete_evt, 3, false }, @@ -12652,6 +12715,8 @@ static const struct mgmt_data mgmt_event_table[] = { mgmt_advertising_removed_evt, 1, true }, { 0x0025, "Extended Controller Information Changed", mgmt_ext_controller_info_changed_evt, 2, false }, + { 0x0026, "PHY Configuration Changed", + mgmt_phy_changed_evt, 2, true }, { } }; -- 2.47.3