summaryrefslogtreecommitdiff
path: root/mesh
diff options
context:
space:
mode:
authorIsak Westin <isak.westin@loytec.com>2022-09-26 15:01:07 +0200
committerBrian Gix <brian.gix@intel.com>2022-09-26 13:14:47 -0700
commit5b569e3d14a38247c69a16d80c5f7c8b77482505 (patch)
tree2b435cb3a668c386f391a0f9698ff383d0618503 /mesh
parent9966cb8b6999a5f54fc13acbd7e1526512a84342 (diff)
downloadbluez-5b569e3d14a38247c69a16d80c5f7c8b77482505.tar.gz
mesh: Correct u32 to u8 log transformation
Fixed the log transformation to correctly follow the value mapping defined in the mesh profile (section 4.1.2).
Diffstat (limited to 'mesh')
-rw-r--r--mesh/cfgmod-server.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c
index 9bc2f1c97..33796d05a 100644
--- a/mesh/cfgmod-server.c
+++ b/mesh/cfgmod-server.c
@@ -455,14 +455,14 @@ done:
static uint8_t uint32_to_log(uint32_t value)
{
uint32_t val = 1;
- uint8_t ret = 1;
+ uint8_t ret = 0;
if (!value)
return 0;
else if (value > 0x10000)
return 0xff;
- while (val < value) {
+ while (val <= value) {
val <<= 1;
ret++;
}
@@ -495,7 +495,7 @@ static uint16_t hb_subscription_get(struct mesh_node *node, int status)
l_put_le16(sub->dst, msg + n);
n += 2;
msg[n++] = uint32_to_log(time_now.tv_sec);
- msg[n++] = uint32_to_log(sub->count);
+ msg[n++] = sub->count != 0xffff ? uint32_to_log(sub->count) : 0xff;
msg[n++] = sub->count ? sub->min_hops : 0;
msg[n++] = sub->max_hops;
@@ -538,7 +538,7 @@ static uint16_t hb_publication_get(struct mesh_node *node, int status)
msg[n++] = status;
l_put_le16(pub->dst, msg + n);
n += 2;
- msg[n++] = uint32_to_log(pub->count);
+ msg[n++] = pub->count != 0xffff ? uint32_to_log(pub->count) : 0xff;
msg[n++] = uint32_to_log(pub->period);
msg[n++] = pub->ttl;
l_put_le16(pub->features, msg + n);