Bluetooth: Mesh: Added support for randomly delaying publications

The section 3.7.3.1 of the mesh specification recommends to delay
a message publication in certain cases:
- at power-up or upon state change for a time between 20 to 500 ms
- for periodic publications for a time between 20 to 50 ms

This change implements this recommendation by adding the
`CONFIG_BT_MESH_DELAYABLE_PUBLICATION` Kconfig option which enables
the randomization code and by adding the `bt_mesh_model_pub.delayable`
bit field which allows each model decide whether the publications
should be delayed for this model or not.

Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
Pavel Vasilyev 2023-12-11 23:29:36 +01:00 committed by Carles Cufí
commit fe70e50d41
7 changed files with 311 additions and 16 deletions

View file

@ -672,6 +672,15 @@ config BT_MESH_ACCESS_DELAYABLE_MSG_CHUNK_COUNT
endif # BT_MESH_ACCESS_DELAYABLE_MSG
config BT_MESH_DELAYABLE_PUBLICATION
bool "Delayable publication"
default y
help
When enabled, the periodic publications are randomly delayed by 20 to 50ms. Publications
triggered at the start of the stack or by the bt_mesh_model_publish() call are delayed by
20 to 500ms. This option reduces the probability of collisions when multiple nodes publish
at the same time.
endmenu # Access layer
menu "Models"