Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp606324pxa; Tue, 4 Aug 2020 13:18:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzuEpd6ImwpM5VUPyvT0dKs/lVrLJe92hs1SL5xCHFaOvnOrEX6bWPV8RFclRnyPFP916A X-Received: by 2002:a17:906:1f53:: with SMTP id d19mr22790407ejk.327.1596572316423; Tue, 04 Aug 2020 13:18:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596572316; cv=none; d=google.com; s=arc-20160816; b=mTN8FrDDyHT1yz6GNpTha4IXndG3pMrVKnHd5J1kdEW0Lf0QgcYfX4yqEReAYB0Umr FwY3p083icUd9DLK7+NJD3LSjKtFmPJiFXp4NfSDJrYWEVXfMZWa7qm5Y613D38qQ6lE lWOknjYoM8ZGG1y9AI2+yuTDhHKZm8HHtMh0Tuos4YDgnUkEGYUJ7eds+pAGivoa4kgk K8DcHX8QKIlGReWySNOrPdjjNIwCcyNcGBXqa7DYlO/SXHpuhLZD4tegAq1+8JzpkJp6 3Pf3t7couo29h2KSpXlRiS68mDQMIdyHytOiGhQ7tW8Nu3f5xHyYcv+UtHcm0G8DYl3X WizQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=9Y+gB60xt7+FgodmtpMmimz0e4zuF0MnP/3YebqCuoQ=; b=YFQM0mCfHryTb3BTUth8+Nx501AtR2TjdvIae58to88B+ei7YH8++wPATVpy5M5gZc Uj1q8kGSnpMdkyaCEy61AGABll+dvwjr7f/BbjZJ+XqIaYHgsZ3ge/GV5HhPTuvOfttK 607EJvMpCtVuAPhtTzoyU+0tmUp9SnArmVqWR75pXXwHiRCzXkrh0N3KEN9s9csgZ3L7 ptEmZyyaASC8T8+KBAqR5nfF58iwlE6UIwnRuMQaoqkNd/jm69ZiOKdsbKyUE4tbbjr2 ORUN+E8xSnrKmp8a6i1q3GP42s4txO23KVxXjmY8J+JJw5epPajV6DExRd5Y4STe0Dxx P36w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r10si10489568ejs.554.2020.08.04.13.17.58; Tue, 04 Aug 2020 13:18:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726804AbgHDURw (ORCPT + 99 others); Tue, 4 Aug 2020 16:17:52 -0400 Received: from mga09.intel.com ([134.134.136.24]:64989 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726534AbgHDURt (ORCPT ); Tue, 4 Aug 2020 16:17:49 -0400 IronPort-SDR: RBKp57p9NpxzVXaTp7QmSHWL4LrMyAZ+891ggqWrt5DTxPkfgfnEguibqRYoASBnbK/gxLmjC5 uq5qmzywjjSg== X-IronPort-AV: E=McAfee;i="6000,8403,9703"; a="153565395" X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="153565395" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Aug 2020 13:17:49 -0700 IronPort-SDR: O8d3fH5GhsfEP0PT2vZiN0L7SXonS2qEpD2QV5K/COWTfM2FZiKm7wZM2McnJvQKmXpxBocNKJ XnQTdlYwGMhg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,434,1589266800"; d="scan'208";a="324783849" Received: from unknown (HELO ingas-nuc1.intel.com) ([10.254.118.65]) by fmsmga002.fm.intel.com with ESMTP; 04 Aug 2020 13:17:49 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ v3 08/10] mesh: Clean up handling of config net transmit messages Date: Tue, 4 Aug 2020 13:17:42 -0700 Message-Id: <20200804201744.23327-8-inga.stotland@intel.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200804201744.23327-1-inga.stotland@intel.com> References: <20200804201744.23327-1-inga.stotland@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This modification allows using a single point for sending out the composed status messages by the Config Server. --- mesh/cfgmod-server.c | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 9b1375317..5b3ed3d97 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -657,6 +657,28 @@ static uint16_t cfg_poll_timeout_msg(struct mesh_node *node, const uint8_t *pkt) return n; } +static uint16_t cfg_net_tx_msg(struct mesh_node *node, const uint8_t *pkt, + int opcode) +{ + uint8_t cnt; + uint16_t interval, n; + struct mesh_net *net = node_get_net(node); + + cnt = (pkt[0] & 0x7) + 1; + interval = ((pkt[0] >> 3) + 1) * 10; + + if (opcode == OP_CONFIG_NETWORK_TRANSMIT_SET && + mesh_config_write_net_transmit(node_config_get(node), + cnt, interval)) + mesh_net_transmit_params_set(net, cnt, interval); + + n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, msg); + + mesh_net_transmit_params_get(net, &cnt, &interval); + msg[n++] = (cnt - 1) + ((interval/10 - 1) << 3); + return n; +} + static uint16_t get_composition(struct mesh_node *node, uint8_t page, uint8_t *buf) { @@ -699,8 +721,6 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, uint8_t state, status; uint8_t phase; bool virt = false; - uint8_t count; - uint16_t interval; uint16_t n; if (app_idx != APP_IDX_DEV_LOCAL) @@ -821,25 +841,13 @@ static bool cfg_srv_pkt(uint16_t src, uint16_t dst, uint16_t app_idx, case OP_CONFIG_NETWORK_TRANSMIT_SET: if (size != 1) return true; - - count = (pkt[0] & 0x7) + 1; - interval = ((pkt[0] >> 3) + 1) * 10; - - if (mesh_config_write_net_transmit(node_config_get(node), count, - interval)) - mesh_net_transmit_params_set(net, count, interval); /* Fall Through */ case OP_CONFIG_NETWORK_TRANSMIT_GET: if (opcode == OP_CONFIG_NETWORK_TRANSMIT_GET && size != 0) return true; - n = mesh_model_opcode_set(OP_CONFIG_NETWORK_TRANSMIT_STATUS, - msg); - mesh_net_transmit_params_get(net, &count, &interval); - msg[n++] = (count - 1) + ((interval/10 - 1) << 3); - - l_debug("Get/Set Network Transmit Config"); + n = cfg_net_tx_msg(node, pkt, opcode); break; case OP_CONFIG_PROXY_SET: -- 2.26.2