btmgmt: Add BREDR PHYs in PHY Configuration commands
authorJaganath Kanakkassery <jaganath.k.os@gmail.com>
Fri, 9 Nov 2018 06:37:09 +0000 (12:07 +0530)
committerhimanshu <h.himanshu@samsung.com>
Tue, 21 Jan 2020 12:05:26 +0000 (17:35 +0530)
This basically adds BREDR packet types also in the PHY confiuration
commands & events and makes the PHYs 32 bit so that it can be
extended in future. This also add configurable PHYs in the GetPhy
command wherein only those can be selected or deselected in SetPhy.

This also adds LE prefix for LE phys to make it more
descriptive

Change-Id: I77442839d02acc308078f355037820c11f026d00
Signed-off-by: himanshu <h.himanshu@samsung.com>
lib/mgmt.h
tools/btmgmt.c

index 2b75196..98fe5b2 100644 (file)
@@ -589,6 +589,8 @@ struct mgmt_rp_get_phy_confguration {
 #define MGMT_OP_SET_PHY_CONFIGURATION  0x0045
 struct mgmt_cp_set_phy_confguration {
        uint32_t        default_phys;
+       uint32_t        configurable_phys;
+       uint32_t        selected_phys;
 } __packed;
 
 
index aea2d55..7b2b992 100755 (executable)
@@ -4166,15 +4166,24 @@ static void cmd_appearance(int argc, char **argv)
 }
 
 static const char *phys_str[] = {
-       "1MTX",
-       "1MRX",
-       "2MTX",
-       "2MRX",
-       "CODEDTX",
-       "CODEDRX",
+       "BR1M1SLOT",
+       "BR1M3SLOT",
+       "BR1M5SLOT",
+       "EDR2M1SLOT",
+       "EDR2M3SLOT",
+       "EDR2M5SLOT",
+       "EDR3M1SLOT",
+       "EDR3M3SLOT",
+       "EDR3M5SLOT",
+       "LE1MTX",
+       "LE1MRX",
+       "LE2MTX",
+       "LE2MRX",
+       "LECODEDTX",
+       "LECODEDRX",
 };
 
-static const char *phys2str(uint16_t phys)
+static const char *phys2str(uint32_t phys)
 {
        static char str[256];
        unsigned int i;
@@ -4192,11 +4201,25 @@ static const char *phys2str(uint16_t phys)
        return str;
 }
 
+static bool str2phy(const char *phy_str, uint32_t *phy_val)
+{
+       unsigned int i;
+
+       for (i = 0; i < NELEM(phys_str); i++) {
+               if (strcasecmp(phys_str[i], phy_str) == 0) {
+                       *phy_val = (1 << i);
+                       return true;
+               }
+       }
+
+       return false;
+}
+
 static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
                                                        void *user_data)
 {
        const struct mgmt_rp_get_phy_confguration *rp = param;
-       uint16_t supported_flags, selected_phys;
+       uint32_t supported_phys, selected_phys, configurable_phys;
 
        if (status != 0) {
                error("Get PHY Configuration failed with status 0x%02x (%s)",
@@ -4209,13 +4232,14 @@ static void get_phy_rsp(uint8_t status, uint16_t len, const void *param,
                return bt_shell_noninteractive_quit(EXIT_FAILURE);
        }
 
-       supported_flags = get_le16(&rp->supported_phys);
-       selected_phys = get_le16(&rp->selected_phys);
+       supported_phys = get_le32(&rp->supported_phys);
+       configurable_phys = get_le32(&rp->configurable_phys);
+       selected_phys = get_le32(&rp->selected_phys);
 
-       print("@@Anupam:Supported phys: 0x%x", supported_flags);
        print("@@Anupam:Selected phys: 0x%x", selected_phys);
 
-       print("Supported phys: %s", phys2str(supported_flags));
+       print("Supported phys: %s", phys2str(supported_phys));
+       print("Configurable phys: %s", phys2str(configurable_phys));
        print("Selected phys: %s", phys2str(selected_phys));
 
        bt_shell_noninteractive_quit(EXIT_SUCCESS);
@@ -4254,33 +4278,20 @@ static void cmd_phy(int argc, char **argv)
 {
        struct mgmt_cp_set_phy_confguration cp;
        int i;
-       uint16_t phys = 0;
+       uint32_t phys = 0;
        uint16_t index;
 
        if (argc < 2)
                return get_phy();
 
        for (i = 1; i < argc; i++) {
-               if (strcasecmp(argv[i], "1MTX") == 0)
-                       phys |= MGMT_PHY_LE_1M_TX;
-
-               if (strcasecmp(argv[i], "1MRX") == 0)
-                       phys |= MGMT_PHY_LE_1M_RX;
-
-               if (strcasecmp(argv[i], "2MTX") == 0)
-                       phys |= MGMT_PHY_LE_2M_TX;
-
-               if (strcasecmp(argv[i], "2MRX") == 0)
-                       phys |= MGMT_PHY_LE_2M_RX;
-
-               if (strcasecmp(argv[i], "CODEDTX") == 0)
-                       phys |= MGMT_PHY_LE_CODED_TX;
+               uint32_t phy_val;
 
-               if (strcasecmp(argv[i], "CODEDRX") == 0)
-                       phys |= MGMT_PHY_LE_CODED_RX;
+               if (str2phy(argv[i], &phy_val))
+                       phys |= phy_val;
        }
 
-       cp.default_phys = cpu_to_le16(phys);
+       cp.selected_phys = cpu_to_le32(phys);
 
        index = mgmt_index;
        if (index == MGMT_INDEX_NONE)
@@ -4489,8 +4500,9 @@ static const struct bt_shell_menu main_menu = {
                cmd_clr_adv,            "Clear advertising instances"   },
        { "appearance",         "<appearance>",
                cmd_appearance,         "Set appearance"                },
-       { "phy",                "[1MTX] [1MRX] [2MTX] [2MRX] [CODEDTX] "
-                               "[CODEDRX] [BR1M1SLOT] [BR1M3SLOT] [BR1M5SLOT]"
+       { "phy",                "[LE1MTX] [LE1MRX] [LE2MTX] [LE2MRX] "
+                               "[LECODEDTX] [LECODEDRX] "
+                               "[BR1M1SLOT] [BR1M3SLOT] [BR1M5SLOT]"
                                "[EDR2M1SLOT] [EDR2M3SLOT] [EDR2M5SLOT]"
                                "[EDR3M1SLOT] [EDR3M3SLOT] [EDR3M5SLOT]",
                cmd_phy,                "Get/Set PHY Configuration"     },