mesh: Reply to HB pub set with same fields
authorIsak Westin <isak.westin@loytec.com>
Mon, 26 Sep 2022 13:01:08 +0000 (15:01 +0200)
committerAyush Garg <ayush.garg@samsung.com>
Mon, 15 May 2023 09:25:55 +0000 (14:55 +0530)
If a Config Heartbeat Publication Set message is unsuccessfully
processed, the fields in the status reply should be the same as in the
original message. See MshPRFv1.0.1 section 4.4.1.2.15.

Signed-off-by: Manika Shrivastava <manika.sh@samsung.com>
Signed-off-by: Ayush Garg <ayush.garg@samsung.com>
mesh/cfgmod-server.c

index 33796d0..9c5edf5 100644 (file)
@@ -575,7 +575,17 @@ static uint16_t hb_publication_set(struct mesh_node *node, const uint8_t *pkt)
        status = mesh_net_set_heartbeat_pub(net, dst, features, net_idx, ttl,
                                                count_log, period_log);
 
-       return hb_publication_get(node, status);
+       if (status != MESH_STATUS_SUCCESS) {
+               uint16_t n;
+
+               n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_PUB_STATUS, msg);
+               msg[n++] = status;
+               memcpy(msg + n, pkt, 9);
+               n += 9;
+
+               return n;
+       } else
+               return hb_publication_get(node, status);
 }
 
 static void node_reset(void *user_data)