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 <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2017-06-29 14:13:39 +03:00 committed by Johan Hedberg
commit a5ae267e92
2 changed files with 13 additions and 1 deletions

View file

@ -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. */

View file

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