mesh: Fix to duplicated model Ids saved to storage
authorRafał Gajda <rafal.gajda@silvair.com>
Wed, 26 Jun 2019 15:49:02 +0000 (17:49 +0200)
committerAnupam Roy <anupam.r@samsung.com>
Tue, 17 Dec 2019 15:12:12 +0000 (20:42 +0530)
Mesh daemon internally implements the Config Server SIG model.

When generating node, if the Mesh Element in mesh application
returns modelId 0 among its supported models, it should be skipped,
otherwise it will be duplicated and saved in the storage file.

This patch fixes correctly skipping Config Server model during node
creation.

Change-Id: Ic2bc3df4e21ec5b2e4f5678a70443fa458f69aa4
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
mesh/node.c

index 7570268..a4bf10e 100644 (file)
@@ -1063,10 +1063,9 @@ static bool validate_model_property(struct node_element *ele,
                /* Bluetooth SIG defined models */
                while (l_dbus_message_iter_next_entry(&ids, &mod_id)) {
                        struct mesh_model *mod;
-                       uint32_t m = mod_id;
 
                        /* Skip internally implemented models */
-                       if (m == CONFIG_SRV_MODEL)
+                       if ((VENDOR_ID_MASK | mod_id) == CONFIG_SRV_MODEL)
                                continue;
 
                        mod = l_queue_find(ele->models, match_model_id,
@@ -1080,6 +1079,7 @@ static bool validate_model_property(struct node_element *ele,
                while (l_dbus_message_iter_next_entry(&ids, &vendor_id,
                                                                &mod_id)) {
                        struct mesh_model *mod;
+
                        mod = l_queue_find(ele->models, match_model_id,
                                L_UINT_TO_PTR((vendor_id << 16) | mod_id));
                        if (!mod)
@@ -1110,10 +1110,9 @@ static void get_models_from_properties(struct node_element *ele,
        if (!vendor) {
                while (l_dbus_message_iter_next_entry(&ids, &mod_id)) {
                        struct mesh_model *mod;
-                       uint32_t m = mod_id;
 
                        /* Skip internally implemented models */
-                       if (m == CONFIG_SRV_MODEL)
+                       if ((VENDOR_ID_MASK | mod_id) == CONFIG_SRV_MODEL)
                                continue;
 
                        mod = mesh_model_new(ele->idx, mod_id);