mesh: Always set net modes based on node feature settings
authorInga Stotland <inga.stotland@intel.com>
Tue, 18 Aug 2020 22:22:07 +0000 (15:22 -0700)
committerAbhay Agarwal <ay.agarwal@samsung.com>
Mon, 28 Dec 2020 06:20:04 +0000 (11:50 +0530)
The network settings such as relay, beacon, proxy and friend are
always set based on local node feature settings. This change makes
the net modes initialization unconditional, to include the "No Support"
setting on node level which should result in the disabled mode in net.c

Change-Id: Ie3d31cb8a4af91ee712c6f6fe49da854ba0c0345
Signed-off-by: anuj.bhumiya <anuj.bhumiya@samsung.com>
mesh/node.c

index 546cd7b..1ecdbd8 100644 (file)
@@ -415,24 +415,16 @@ static bool init_storage_dir(struct mesh_node *node)
 
 static void update_net_settings(struct mesh_node *node)
 {
-       uint8_t mode;
+       struct mesh_net *net = node->net;
 
-       mode = node->proxy;
-       if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED)
-               mesh_net_set_proxy_mode(node->net, mode == MESH_MODE_ENABLED);
+       mesh_net_set_proxy_mode(net, node->proxy == MESH_MODE_ENABLED);
 
-       mode = node->friend;
-       if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED)
-               mesh_net_set_friend_mode(node->net, mode == MESH_MODE_ENABLED);
+       mesh_net_set_friend_mode(net, node->friend == MESH_MODE_ENABLED);
 
-       mode = node->relay.mode;
-       if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED)
-               mesh_net_set_relay_mode(node->net, mode == MESH_MODE_ENABLED,
+       mesh_net_set_relay_mode(net, node->relay.mode == MESH_MODE_ENABLED,
                                        node->relay.cnt, node->relay.interval);
 
-       mode = node->beacon;
-       if (mode == MESH_MODE_ENABLED || mode == MESH_MODE_DISABLED)
-               mesh_net_set_beacon_mode(node->net, mode == MESH_MODE_ENABLED);
+       mesh_net_set_beacon_mode(net, node->beacon == MESH_MODE_ENABLED);
 }
 
 static bool init_from_storage(struct mesh_config_node *db_node,