From patchwork Wed Mar 4 07:39:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Stotland, Inga" X-Patchwork-Id: 11419451 X-Patchwork-Delegate: brian.gix@gmail.com Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 74D33139A for ; Wed, 4 Mar 2020 07:39:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5E095207FD for ; Wed, 4 Mar 2020 07:39:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728560AbgCDHjR (ORCPT ); Wed, 4 Mar 2020 02:39:17 -0500 Received: from mga12.intel.com ([192.55.52.136]:1980 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728458AbgCDHjR (ORCPT ); Wed, 4 Mar 2020 02:39:17 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Mar 2020 23:39:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,513,1574150400"; d="scan'208";a="263514579" Received: from ingas-nuc1.sea.intel.com ([10.251.135.221]) by fmsmga004.fm.intel.com with ESMTP; 03 Mar 2020 23:39:16 -0800 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ] tools/mesh-cfgclient: Record remote node's default TTL Date: Tue, 3 Mar 2020 23:39:15 -0800 Message-Id: <20200304073915.24964-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.1 MIME-Version: 1.0 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This adds code to save the value of a remote node's default TTL upon receiving Config Default TTL Status message. Also, cleanup leftover "#if 0" clause --- tools/mesh/cfgcli.c | 1 + tools/mesh/mesh-db.c | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/tools/mesh/cfgcli.c b/tools/mesh/cfgcli.c index 0aea7e553..33e77d878 100644 --- a/tools/mesh/cfgcli.c +++ b/tools/mesh/cfgcli.c @@ -557,6 +557,7 @@ static bool msg_recvd(uint16_t src, uint16_t idx, uint8_t *data, return true; bt_shell_printf("Node %4.4x Default TTL %d\n", src, data[0]); + mesh_db_node_ttl_set(src, data[0]); break; diff --git a/tools/mesh/mesh-db.c b/tools/mesh/mesh-db.c index 41114f40f..4a26a667e 100644 --- a/tools/mesh/mesh-db.c +++ b/tools/mesh/mesh-db.c @@ -434,6 +434,24 @@ bool mesh_db_node_net_key_add(uint16_t unicast, uint16_t idx) return add_node_key(jnode, "netKeys", idx); } +bool mesh_db_node_ttl_set(uint16_t unicast, uint8_t ttl) +{ + json_object *jnode; + + if (!cfg || !cfg->jcfg) + return false; + + jnode = get_node_by_unicast(unicast); + if (!jnode) + return false; + + if (!write_int(jnode, "defaultTTL", ttl)) + return false; + + return mesh_config_save((struct mesh_config *) cfg, true, + NULL, NULL); +} + static void jarray_key_del(json_object *jarray, int16_t idx) { int i, sz = json_object_array_length(jarray); @@ -923,13 +941,6 @@ bool mesh_db_create(const char *fname, const uint8_t token[8], goto fail; json_object_object_add(jcfg, "appKeys", jarray); -#if 0 - jarray = json_object_new_array(); - if (!jarray) - goto fail; - - json_object_object_add(jcfg, "groups", jarray); -#endif if (!mesh_config_save((struct mesh_config *) cfg, true, NULL, NULL)) goto fail;