btmgmt: Add support for setting PHY in add-adv
authorJaganath Kanakkassery <jaganath.k.os@gmail.com>
Thu, 14 Jun 2018 12:21:19 +0000 (17:51 +0530)
committerhimanshu <h.himanshu@samsung.com>
Tue, 11 Feb 2020 08:58:20 +0000 (14:28 +0530)
Change-Id: Ibb2bc77463913a87edc44d36d29b2646efe54388
Signed-off-by: himanshu <h.himanshu@samsung.com>
tools/btmgmt.c

index 4bbad38..2812a72 100755 (executable)
@@ -3626,6 +3626,9 @@ static const char *adv_flags_str[] = {
                                "tx-power",
                                "scan-rsp-appearance",
                                "scan-rsp-local-name",
+                               "Secondary-channel-1M",
+                               "Secondary-channel-2M",
+                               "Secondary-channel-CODED",
 };
 
 static const char *adv_flags2str(uint32_t flags)
@@ -3843,6 +3846,7 @@ static void add_adv_usage(void)
                "\t -s, --scan-rsp <data>     Scan Response Data bytes\n"
                "\t -t, --timeout <timeout>   Timeout in seconds\n"
                "\t -D, --duration <duration> Duration in seconds\n"
+               "\t -P, --phy <phy>           Phy type, Specify 1M/2M/CODED\n"
                "\t -c, --connectable         \"connectable\" flag\n"
                "\t -g, --general-discov      \"general-discoverable\" flag\n"
                "\t -l, --limited-discov      \"limited-discoverable\" flag\n"
@@ -3861,6 +3865,7 @@ static struct option add_adv_options[] = {
        { "scan-rsp",           1, 0, 's' },
        { "timeout",            1, 0, 't' },
        { "duration",           1, 0, 'D' },
+       { "phy",                1, 0, 'P' },
        { "connectable",        0, 0, 'c' },
        { "general-discov",     0, 0, 'g' },
        { "limited-discov",     0, 0, 'l' },
@@ -3929,7 +3934,7 @@ static void cmd_add_adv(int argc, char **argv)
        uint32_t flags = 0;
        uint16_t index;
 
-       while ((opt = getopt_long(argc, argv, "+u:d:s:t:D:cglmphna",
+       while ((opt = getopt_long(argc, argv, "+u:d:s:t:D:P:cglmphna",
                                                add_adv_options, NULL)) != -1) {
                switch (opt) {
                case 'u':
@@ -4014,6 +4019,16 @@ static void cmd_add_adv(int argc, char **argv)
                case 'a':
                        flags |= MGMT_ADV_FLAG_APPEARANCE;
                        break;
+               case 'P':
+                       if (strcasecmp(optarg, "1M") == 0)
+                               flags |= MGMT_ADV_FLAG_SEC_1M;
+                       else if (strcasecmp(optarg, "2M") == 0)
+                               flags |= MGMT_ADV_FLAG_SEC_2M;
+                       else if (strcasecmp(optarg, "CODED") == 0)
+                               flags |= MGMT_ADV_FLAG_SEC_CODED;
+                       else
+                               goto done;
+                       break;
                case 'h':
                        success = true;
                        /* fall through */