summaryrefslogtreecommitdiff
path: root/mesh/cfgmod-server.c
diff options
context:
space:
mode:
authorInga Stotland <inga.stotland@intel.com>2020-08-06 18:38:30 -0700
committerBrian Gix <brian.gix@intel.com>2020-08-10 14:47:09 -0700
commit531806c353e998c22948975005728b7c2302f769 (patch)
treed3adca00025723d309fbc1f3e7ec45453095dd4c /mesh/cfgmod-server.c
parent000cd8e3c327e14f8fb7513252dd0ef68b0b4d9d (diff)
downloadbluez-531806c353e998c22948975005728b7c2302f769.tar.gz
mesh: Clean up handling of config relay messages
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.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c
index 2797de8ab..8e3da79d5 100644
--- a/mesh/cfgmod-server.c
+++ b/mesh/cfgmod-server.c
@@ -396,6 +396,27 @@ static uint16_t model_app_bind(struct mesh_node *node, const uint8_t *pkt,
return n;
}
+static uint16_t cfg_relay_msg(struct mesh_node *node, const uint8_t *pkt,
+ int opcode)
+{
+ uint8_t count;
+ uint16_t interval;
+ uint16_t n;
+
+ if (opcode == OP_CONFIG_RELAY_SET) {
+ count = (pkt[1] & 0x7) + 1;
+ interval = ((pkt[1] >> 3) + 1) * 10;
+ node_relay_mode_set(node, !!pkt[0], count, interval);
+ }
+
+ n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg);
+
+ msg[n++] = node_relay_mode_get(node, &count, &interval);
+ msg[n++] = (count - 1) + ((interval/10 - 1) << 3);
+
+ return n;
+}
+
static void hb_pub_timeout_func(struct l_timeout *timeout, void *user_data)
{
struct mesh_net *net = user_data;
@@ -775,22 +796,13 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx,
case OP_CONFIG_RELAY_SET:
if (size != 2 || pkt[0] > 0x01)
return true;
-
- count = (pkt[1] & 0x7) + 1;
- interval = ((pkt[1] >> 3) + 1) * 10;
- node_relay_mode_set(node, !!pkt[0], count, interval);
/* Fall Through */
case OP_CONFIG_RELAY_GET:
if (opcode == OP_CONFIG_RELAY_GET && size != 0)
return true;
- n = mesh_model_opcode_set(OP_CONFIG_RELAY_STATUS, msg);
-
- msg[n++] = node_relay_mode_get(node, &count, &interval);
- msg[n++] = (count - 1) + ((interval/10 - 1) << 3);
-
- l_debug("Get/Set Relay Config (%d)", msg[n-1]);
+ n = cfg_relay_msg(node, pkt, opcode);
break;
case OP_CONFIG_NETWORK_TRANSMIT_SET: