Bluetooth: Mesh: Avoid indefinite timeout when duration less than zero

`struct bt_le_ext_adv_start_param.timeout` resolution is in 10ms. When
duration is less than 10ms, division will be evaluated to zero, which
will result in indefinite timeout. Set timeout to 10ms to avoid
indefinite timeout. The advertisement will end earlier anyway after the
event is finished.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
Pavel Vasilyev 2022-09-21 09:37:08 +02:00 committed by Carles Cufí
commit 326786efd6

View file

@ -417,7 +417,7 @@ int bt_mesh_adv_gatt_start(const struct bt_le_adv_param *param,
struct bt_mesh_ext_adv *adv = gatt_adv_get();
struct bt_le_ext_adv_start_param start = {
/* Timeout is set in 10 ms steps, with 0 indicating "forever" */
.timeout = (duration == SYS_FOREVER_MS) ? 0 : (duration / 10),
.timeout = (duration == SYS_FOREVER_MS) ? 0 : MAX(1, duration / 10),
};
BT_DBG("Start advertising %d ms", duration);