summaryrefslogtreecommitdiff
path: root/mesh/cfgmod-server.c
diff options
context:
space:
mode:
authorInga Stotland <inga.stotland@intel.com>2020-08-06 18:38:31 -0700
committerBrian Gix <brian.gix@intel.com>2020-08-10 14:47:09 -0700
commit91d25c115d5a377bca11908bcddf6efa36ba00cc (patch)
treeab5ee95fdefbeeb56a252e409537b6abfe2a52e1 /mesh/cfgmod-server.c
parent531806c353e998c22948975005728b7c2302f769 (diff)
downloadbluez-91d25c115d5a377bca11908bcddf6efa36ba00cc.tar.gz
mesh: Clean up handling of config poll timeout message
This modification allows using a single point for sending out the composed status messages by the Config Server.
Diffstat (limited to 'mesh/cfgmod-server.c')
-rw-r--r--mesh/cfgmod-server.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c
index 8e3da79d5..f3cc18ae0 100644
--- a/mesh/cfgmod-server.c
+++ b/mesh/cfgmod-server.c
@@ -643,6 +643,25 @@ static uint16_t cfg_get_appkeys_msg(struct mesh_node *node, const uint8_t *pkt)
return n + 3 + sz;
}
+static uint16_t cfg_poll_timeout_msg(struct mesh_node *node, const uint8_t *pkt)
+{
+ uint16_t n, addr = l_get_le16(pkt);
+ uint32_t poll_to;
+
+ if (!IS_UNICAST(addr))
+ return 0;
+
+ n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg);
+ l_put_le16(addr, msg + n);
+ n += 2;
+
+ poll_to = mesh_net_friend_timeout(node_get_net(node), addr);
+ msg[n++] = poll_to;
+ msg[n++] = poll_to >> 8;
+ msg[n++] = poll_to >> 16;
+ return n;
+}
+
static uint16_t get_composition(struct mesh_node *node, uint8_t page,
uint8_t *buf)
{
@@ -678,7 +697,7 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx,
struct mesh_net *net;
const uint8_t *pkt = data;
struct timeval time_now;
- uint32_t opcode, tmp32;
+ uint32_t opcode;
int b_res = MESH_STATUS_SUCCESS;
struct mesh_net_heartbeat *hb;
uint16_t n_idx;
@@ -1117,18 +1136,11 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx,
msg[n++] = hb->sub_max_hops;
break;
- case OP_CONFIG_POLL_TIMEOUT_LIST:
- if (size != 2 || l_get_le16(pkt) == 0 ||
- l_get_le16(pkt) > 0x7fff)
+ case OP_CONFIG_POLL_TIMEOUT_GET:
+ if (size != 2)
return true;
- n = mesh_model_opcode_set(OP_CONFIG_POLL_TIMEOUT_STATUS, msg);
- l_put_le16(l_get_le16(pkt), msg + n);
- n += 2;
- tmp32 = mesh_net_friend_timeout(net, l_get_le16(pkt));
- msg[n++] = tmp32;
- msg[n++] = tmp32 >> 8;
- msg[n++] = tmp32 >> 16;
+ n = cfg_poll_timeout_msg(node, pkt);
break;
case OP_NODE_RESET: