diff options
author | Aurelien Jarno <aurelien@aurel32.net> | 2019-11-11 20:54:06 +0100 |
---|---|---|
committer | Brian Gix <brian.gix@intel.com> | 2019-12-02 12:07:28 -0800 |
commit | 73401290cfe79853d4957a2d603237b1e73c4b71 (patch) | |
tree | e7cf52384250b8322e2320b5b37d0f52701c6716 /mesh/cfgmod-server.c | |
parent | f246d31a775233578a7c4b721757e9fa9a49f69c (diff) | |
download | bluez-73401290cfe79853d4957a2d603237b1e73c4b71.tar.gz |
mesh: fix (re)transmit count & interval steps
The Foundation Model Layer uses little endian ordering. As a
consequence the (re)transmit count and interval steps in the Config
Relay, Config Model Publication and Config Network Transmit messages
use the lower 3 bits for the (re)transmission count and the higher 5
bits for the interval steps.
The figure 4.5 in section 4.3.2.16 of the Mesh Profile Bluetooth
Specification provides a good clarification.
This patch therefore fixes those messages for both the daemon and
configuration client parts.
Diffstat (limited to 'mesh/cfgmod-server.c')
-rw-r--r-- | mesh/cfgmod-server.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 55cc8e9eb..8acde95b9 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -211,8 +211,8 @@ static bool config_pub_set(struct mesh_node *node, uint16_t net_idx, .ttl = ttl, .credential = cred_flag, .period = period, - .count = retransmit >> 5, - .interval = ((0x1f & retransmit) + 1) * 50 + .count = retransmit & 0x7, + .interval = ((retransmit >> 3) + 1) * 50 }; if (b_virt) @@ -870,8 +870,8 @@ static bool cfg_srv_pkt(uint16_t src, uint32_t dst, uint16_t unicast, if (size != 2 || pkt[0] > 0x01) return true; - count = (pkt[1] >> 5) + 1; - interval = ((pkt[1] & 0x1f) + 1) * 10; + count = (pkt[1] & 0x7) + 1; + interval = ((pkt[1] >> 3) + 1) * 10; node_relay_mode_set(node, !!pkt[0], count, interval); /* Fall Through */ @@ -879,7 +879,7 @@ static bool cfg_srv_pkt(uint16_t src, uint32_t dst, uint16_t unicast, n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg); msg[n++] = node_relay_mode_get(node, &count, &interval); - msg[n++] = ((count - 1) << 5) + ((interval/10 - 1) & 0x1f); + msg[n++] = (count - 1) + ((interval/10 - 1) << 3); l_debug("Get/Set Relay Config (%d)", msg[n-1]); break; @@ -888,8 +888,8 @@ static bool cfg_srv_pkt(uint16_t src, uint32_t dst, uint16_t unicast, if (size != 1) return true; - count = (pkt[0] >> 5) + 1; - interval = ((pkt[0] & 0x1f) + 1) * 10; + count = (pkt[0] & 0x7) + 1; + interval = ((pkt[0] >> 3) + 1) * 10; if (mesh_config_write_net_transmit(node_config_get(node), count, interval)) @@ -900,7 +900,7 @@ static bool cfg_srv_pkt(uint16_t src, uint32_t dst, uint16_t unicast, n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, msg); mesh_net_transmit_params_get(net, &count, &interval); - msg[n++] = ((count - 1) << 5) + ((interval/10 - 1) & 0x1f); + msg[n++] = (count - 1) + ((interval/10 - 1) << 3); l_debug("Get/Set Network Transmit Config"); break; |