diff options
author | Isak Westin <isak.westin@loytec.com> | 2022-09-26 15:01:10 +0200 |
---|---|---|
committer | Brian Gix <brian.gix@intel.com> | 2022-09-26 13:14:47 -0700 |
commit | d763bfa4d0892b4b3b004577491d2493a999648e (patch) | |
tree | 5521250c94f462655536a25d9a6caf9602496f4e /mesh | |
parent | 902389f3e7a33e5730d7e2318b1f1868170dc092 (diff) | |
download | bluez-d763bfa4d0892b4b3b004577491d2493a999648e.tar.gz |
mesh: Clear HB sub status field if disabled
When replying to a HB subscription get message, and the current state of
source or destination fields is zero (which means that HB subscription
is disabled), all fields in the status reply should be zero.
Diffstat (limited to 'mesh')
-rw-r--r-- | mesh/cfgmod-server.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 55a2d896b..7044b670d 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -470,7 +470,7 @@ static uint8_t uint32_to_log(uint32_t value) return ret; } -static uint16_t hb_subscription_get(struct mesh_node *node, int status) +static uint16_t hb_subscription_status(struct mesh_node *node, int status) { struct mesh_net *net = node_get_net(node); struct mesh_net_heartbeat_sub *sub = mesh_net_get_heartbeat_sub(net); @@ -502,6 +502,28 @@ static uint16_t hb_subscription_get(struct mesh_node *node, int status) return n; } +static uint16_t hb_subscription_get(struct mesh_node *node, int status) +{ + struct mesh_net *net = node_get_net(node); + struct mesh_net_heartbeat_sub *sub = mesh_net_get_heartbeat_sub(net); + + /* + * MshPRFv1.0.1 section 4.4.1.2.16, Heartbeat Subscription state: + * If this is a GET request and the source or destination is unassigned, + * all fields shall be set to zero in the status reply. + */ + if (IS_UNASSIGNED(sub->src) || IS_UNASSIGNED(sub->dst)) { + uint16_t n; + + n = mesh_model_opcode_set(OP_CONFIG_HEARTBEAT_SUB_STATUS, msg); + memset(msg + n, 0, 9); + n += 9; + return n; + } + + return hb_subscription_status(node, status); +} + static uint16_t hb_subscription_set(struct mesh_node *node, const uint8_t *pkt) { uint16_t src, dst; @@ -525,7 +547,7 @@ static uint16_t hb_subscription_set(struct mesh_node *node, const uint8_t *pkt) status = mesh_net_set_heartbeat_sub(net, src, dst, period_log); - return hb_subscription_get(node, status); + return hb_subscription_status(node, status); } static uint16_t hb_publication_get(struct mesh_node *node, int status) |