diff --git a/apps/btshell/src/btshell.h b/apps/btshell/src/btshell.h index 83dadede5a..f823862a86 100644 --- a/apps/btshell/src/btshell.h +++ b/apps/btshell/src/btshell.h @@ -92,6 +92,7 @@ struct btshell_scan_opts { uint16_t limit; uint8_t ignore_legacy:1; uint8_t periodic_only:1; + uint8_t silent:1; uint8_t name_filter_len; char name_filter[NAME_FILTER_LEN_MAX]; }; diff --git a/apps/btshell/src/cmd.c b/apps/btshell/src/cmd.c index ee28b57ae6..3f8ad5a412 100644 --- a/apps/btshell/src/cmd.c +++ b/apps/btshell/src/cmd.c @@ -1110,6 +1110,7 @@ static struct btshell_scan_opts g_scan_opts = { .limit = UINT16_MAX, .ignore_legacy = 0, .periodic_only = 0, + .silent = 0, .name_filter_len = 0, }; @@ -1136,6 +1137,12 @@ cmd_set_scan_opts(int argc, char **argv) return rc; } + g_scan_opts.silent = parse_arg_bool_dflt("silent", 0, &rc); + if (rc != 0) { + console_printf("invalid 'silent' parameter\n"); + return rc; + } + g_scan_opts.periodic_only = parse_arg_bool_dflt("periodic_only", 0, &rc); if (rc != 0) { console_printf("invalid 'periodic_only' parameter\n"); @@ -1160,6 +1167,7 @@ static const struct shell_param set_scan_opts_params[] = { {"decode_limit", "usage: =[0-UINT16_MAX], default: UINT16_MAX"}, {"ignore_legacy", "usage: =[0-1], default: 0"}, {"periodic_only", "usage: =[0-1], default: 0"}, + {"silent", "usage: =[0-1], default: 0"}, {"name_filter", "usage: =name, default: {none}"}, {NULL, NULL} }; diff --git a/apps/btshell/src/main.c b/apps/btshell/src/main.c index 0f87b5c236..6424bf6b86 100644 --- a/apps/btshell/src/main.c +++ b/apps/btshell/src/main.c @@ -1315,11 +1315,23 @@ btshell_gap_event(struct ble_gap_event *event, void *arg) return btshell_restart_adv(event); #if MYNEWT_VAL(BLE_EXT_ADV) - case BLE_GAP_EVENT_EXT_DISC: - btshell_decode_event_type(&event->ext_disc, arg); + case BLE_GAP_EVENT_EXT_DISC: { + struct btshell_scan_opts *scan_opts = arg; + + if (!scan_opts->silent) { + btshell_decode_event_type(&event->ext_disc, arg); + } + return 0; + } #endif - case BLE_GAP_EVENT_DISC: + case BLE_GAP_EVENT_DISC: { + struct btshell_scan_opts *scan_opts = arg; + + if (scan_opts->silent) { + return 0; + } + console_printf("received advertisement; event_type=%d rssi=%d " "addr_type=%d addr=", event->disc.event_type, event->disc.rssi, event->disc.addr.type); @@ -1337,6 +1349,7 @@ btshell_gap_event(struct ble_gap_event *event, void *arg) btshell_decode_adv_data(event->disc.data, event->disc.length_data, arg); return 0; + } case BLE_GAP_EVENT_CONN_UPDATE: console_printf("connection updated; status=%d ",