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; }