From a5ae267e9276f59ee3c90dad76986008844664ad Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Thu, 29 Jun 2017 14:13:39 +0300 Subject: [PATCH] Bluetooth: Introduce new BT_LE_ADV_OPT_ONE_TIME advertising option In some cases applications may want better control of advertising instead of the stack doing automated re-enablement. Introduce a new option that can be used to do more "manual" advertising control. Signed-off-by: Johan Hedberg --- include/bluetooth/bluetooth.h | 10 ++++++++++ subsys/bluetooth/host/hci_core.c | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/include/bluetooth/bluetooth.h b/include/bluetooth/bluetooth.h index 73d1242b7d0..54dd976e882 100644 --- a/include/bluetooth/bluetooth.h +++ b/include/bluetooth/bluetooth.h @@ -105,6 +105,16 @@ enum { * providing SCAN_RSP data and/or enabling local privacy support. */ BT_LE_ADV_OPT_CONNECTABLE = BIT(0), + + /** Don't try to resume connectable advertising after a connection. + * This option is only meaningful when used together with + * BT_LE_ADV_OPT_CONNECTABLE. If set the advertising will be stopped + * when bt_le_adv_stop() is called or when an incoming (slave) + * connection happens. If this option is not set the stack will + * take care of keeping advertising enabled even as connections + * occur. + */ + BT_LE_ADV_OPT_ONE_TIME = BIT(1), }; /** LE Advertising Parameters. */ diff --git a/subsys/bluetooth/host/hci_core.c b/subsys/bluetooth/host/hci_core.c index 74ff938a80f..aaf2ad3ae2f 100644 --- a/subsys/bluetooth/host/hci_core.c +++ b/subsys/bluetooth/host/hci_core.c @@ -4275,7 +4275,9 @@ int bt_le_adv_start(const struct bt_le_adv_param *param, return err; } - atomic_set_bit(bt_dev.flags, BT_DEV_KEEP_ADVERTISING); + if (!(param->options & BT_LE_ADV_OPT_ONE_TIME)) { + atomic_set_bit(bt_dev.flags, BT_DEV_KEEP_ADVERTISING); + } return 0; }