This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Proxy is permanently disabled after mesh_stack_power_down()

With SDK For Mesh v5.0.0 the mesh_stack_power_down() was actually implemented but there is a bug that will disabled the proxy permanently.

For some unknown reason the mesh_stack_power_down() calls proxy_disable() which will set the internal m_enabled flag but also write this state to flash. On next boot this will be read back and thus the Proxy is now disabled despite it was enabled before the call to mesh_stack_power_down().

Based on the comment it was an attempt to prevent network beacons to be sent but those have already been disabled with proxy_stop().

The mesh_stack_power_down() starts by calling proxy_node_id_disable() which might start advertising Network beacons but will be directly stopped by proxy_stop(). Simply remove the call to proxy_node_id_disable() as it's redundant.

The following patch fixes this issue.

--- a/mesh/stack/src/mesh_stack.c
+++ b/mesh/stack/src/mesh_stack.c
@@ -360,13 +360,9 @@ void mesh_stack_power_down(void)
     scanner_disable();
 
 #if MESH_FEATURE_GATT_PROXY_ENABLED
-    /* disables the node ID beacons if there are any */
-    (void)proxy_node_id_disable();
     /* disconnect active connections if there are any */
     proxy_disconnect();
     (void)proxy_stop();
-    /* disable proxy to prevent restart of beaconing if it is enabled by default */
-    proxy_disable();
 #endif
 
     /* clean timers queue and turn off hw timer */

One interesting observation is that proxy_stop() violates the requirements of Mesh Config by modifying the "live value" (m_enabled) without going through the setter. As can be read in the mesh_config.md "- The live value must never be altered outside the state owner's `setter` callback.".

Thanks.

Related