From 163c2bc316da5797d6cc7401df9cb8906b921618 Mon Sep 17 00:00:00 2001 From: Pavel Vasilyev Date: Wed, 7 Dec 2022 12:27:16 +0100 Subject: [PATCH] Bluetooth: Mesh: Warn log mode incompatibility with friendship Log modes other than the deferred may cause unintended delays during processing of log messages. This in turns will affect scheduling of the receive delay and receive window for both, Friend and LPN. Adding a compilation warning instead of assert as a user may still want to compile a code with friendship feature enabled without actually establishing a friendship. Signed-off-by: Pavel Vasilyev --- doc/connectivity/bluetooth/api/mesh/core.rst | 6 ++++++ subsys/bluetooth/mesh/friend.c | 11 +++++++++++ subsys/bluetooth/mesh/lpn.c | 11 +++++++++++ 3 files changed, 28 insertions(+) diff --git a/doc/connectivity/bluetooth/api/mesh/core.rst b/doc/connectivity/bluetooth/api/mesh/core.rst index 5e48a6becee..df49cccea13 100644 --- a/doc/connectivity/bluetooth/api/mesh/core.rst +++ b/doc/connectivity/bluetooth/api/mesh/core.rst @@ -21,6 +21,12 @@ the LPN API allows the application to trigger the polling at any time through interval, poll event timing and Friend requirements is controlled through the :kconfig:option:`CONFIG_BT_MESH_LOW_POWER` option and related configuration options. +When using the LPN feature with logging, it is strongly recommended to only use +the :kconfig:option:`CONFIG_LOG_MODE_DEFERRED` option. Log modes other than the +deferred may cause unintended delays during processing of log messages. This in +turns will affect scheduling of the receive delay and receive window. The same +limitation applies for the :kconfig:option:`CONFIG_BT_MESH_FRIEND` option. + Replay Protection List ********************** diff --git a/subsys/bluetooth/mesh/friend.c b/subsys/bluetooth/mesh/friend.c index 6cf2ea6ea48..5a2670d7176 100644 --- a/subsys/bluetooth/mesh/friend.c +++ b/subsys/bluetooth/mesh/friend.c @@ -26,6 +26,17 @@ #include LOG_MODULE_REGISTER(bt_mesh_friend); +/** + * Log modes other than the deferred may cause unintended delays during processing of log messages. + * This in turns will affect scheduling of the receive delay and receive window. + */ +#if !defined(CONFIG_TEST) && !defined(CONFIG_ARCH_POSIX) && \ + defined(CONFIG_LOG) && !defined(CONFIG_LOG_MODE_DEFERRED) && \ + (LOG_LEVEL >= LOG_LEVEL_INF) +#warning Frienship feature may work unstable when non-deferred log mode is selected. Use the \ + CONFIG_LOG_MODE_DEFERRED Kconfig option when Friend feature is enabled. +#endif + /* We reserve one extra buffer for each friendship, since we need to be able * to resend the last sent PDU, which sits separately outside of the queue. */ diff --git a/subsys/bluetooth/mesh/lpn.c b/subsys/bluetooth/mesh/lpn.c index 7c43a5d58cd..4b0f910d262 100644 --- a/subsys/bluetooth/mesh/lpn.c +++ b/subsys/bluetooth/mesh/lpn.c @@ -27,6 +27,17 @@ #include LOG_MODULE_REGISTER(bt_mesh_lpn); +/** + * Log modes other than the deferred may cause unintended delays during processing of log messages. + * This in turns will affect scheduling of the receive delay and receive window. + */ +#if !defined(CONFIG_TEST) && !defined(CONFIG_ARCH_POSIX) && \ + defined(CONFIG_LOG) && !defined(CONFIG_LOG_MODE_DEFERRED) && \ + (LOG_LEVEL >= LOG_LEVEL_INF) +#warning Frienship feature may work unstable when non-deferred log mode is selected. Use the \ + CONFIG_LOG_MODE_DEFERRED Kconfig option when Low Power node feature is enabled. +#endif + #if defined(CONFIG_BT_MESH_LPN_AUTO) #define LPN_AUTO_TIMEOUT (CONFIG_BT_MESH_LPN_AUTO_TIMEOUT * MSEC_PER_SEC) #else