Bluetooth: shell: Add Extended Scan command

Add shell scanx command to start Extended Scanning on 1M or
Coded PHY.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
Vinayak Kariappa Chettimada 2017-06-08 08:58:05 +02:00 committed by Johan Hedberg
commit dc11c9c315
3 changed files with 63 additions and 0 deletions

View file

@ -2043,6 +2043,7 @@ static const struct shell_cmd bt_commands[] = {
#endif
#if defined(CONFIG_BLUETOOTH_CONTROLLER_ADV_EXT)
{ "advx", cmd_advx, "<on off> [coded] [anon] [txp]" },
{ "scanx", cmd_scanx, "<on passive off> [coded]" },
#endif /* CONFIG_BLUETOOTH_CONTROLLER_ADV_EXT */
{ NULL, NULL, NULL }
};

View file

@ -30,6 +30,11 @@
#define ADV_SID 0
#define SCAN_REQ_NOT 0
#define SCAN_INTERVAL 0x0004
#define SCAN_WINDOW 0x0004
#define SCAN_OWN_ADDR_TYPE 1
#define SCAN_FILTER_POLICY 0
int cmd_advx(int argc, char *argv[])
{
u16_t evt_prop;
@ -102,6 +107,62 @@ disable:
goto exit;
}
exit:
printk("done (err= %d).\n", err);
return 0;
}
int cmd_scanx(int argc, char *argv[])
{
u8_t enable;
u8_t type;
s32_t err;
if (argc < 2) {
return -EINVAL;
}
if (argc > 1) {
if (!strcmp(argv[1], "on")) {
enable = 1;
type = 1;
} else if (!strcmp(argv[1], "passive")) {
enable = 1;
type = 0;
} else if (!strcmp(argv[1], "off")) {
enable = 0;
goto disable;
} else {
return -EINVAL;
}
}
type |= BIT(1);
if (argc > 2) {
if (!strcmp(argv[2], "coded")) {
type &= BIT(0);
type |= BIT(3);
} else {
return -EINVAL;
}
}
printk("scan param set...");
err = ll_scan_params_set(type, SCAN_INTERVAL, SCAN_WINDOW,
SCAN_OWN_ADDR_TYPE, SCAN_FILTER_POLICY);
if (err) {
goto exit;
}
disable:
printk("scan enable (%u)...", enable);
err = ll_scan_enable(enable);
if (err) {
goto exit;
}
exit:
printk("done (err= %d).\n", err);

View file

@ -14,5 +14,6 @@
#define __LL_H
int cmd_advx(int argc, char *argv[]);
int cmd_scanx(int argc, char *argv[]);
#endif /* __LL_H */