Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2723843ybl; Mon, 20 Jan 2020 08:11:57 -0800 (PST) X-Google-Smtp-Source: APXvYqwV7C9vLiPxWIUN7Px+oUGobESG+YOrco2CkDYiS8R7u1pIvQYY7G1dXCio8ZI7w+77YGCe X-Received: by 2002:a05:6808:2d2:: with SMTP id a18mr40969oid.120.1579536717094; Mon, 20 Jan 2020 08:11:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579536717; cv=none; d=google.com; s=arc-20160816; b=zus1dRuxpACEIjdtQ7XXr184Z1W4KY38eJGpUwWCddLemiljcdTpGjjRUl5vjsv7BX sQaruYm2jiJ+lAJaxzQOu2YPP0btQiZ0Wrh88Fp4RlUuj31fVpgFY3p9s8lBx6zAJ1y+ /6g8AKtguAkJjHOhd6P2/WblQoNoZtBCI6M5RUZk4+joP5oe0dUX/zWdb6u9WPJqG/sN Z8iTY6UQnS48lRi2OWsX/M2kd9vaV9Czv+qSFzGSsPFt1EUn3Yib4+BXYuCmWsJ2FC3P MQWmemejx/TeZdJq7d63Tks/tJR4JSmjpW3cTaHaDWUBhXDavd4Zg3wT4FYbkhdfGzyB QlBA== 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:to:from :dkim-signature; bh=Q345sRkXB8jCpvGazeS2vquZ1v6LwwTS+aDG6XXw6h8=; b=ofbo4eHHM0Xc9PsembR6JcvidttVk7wHU35Y94I7NDOABMHhoI9xogEJcUMzQNiYzz fUBkHdUo2wdD7vAbsiFyWeV0mGTHcao3MaV2vt1FIxSMFhlFES8MY/Wycj1aVVAUVeG0 DuEOnrucLqqq+U+P+8PSSVQeKTQGXPgMk6a2w2dM8poNu0r+A7WAkkQpewsUsKiJ7qnp YILZf1X1zHKTQYG1DVZTU6PXt9IDe+dp2ql3s0lJBKoTBY5+QHgrY4sVAgslMVaAnA4D QKVH0bj8zaUTUafB3GMeJr+vdAPz9wI1UP7WW3kqwO/RpBgqSE9xXuFBLcc5vUOEiR0t 6LQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=i6NCIIVc; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y26si20606044otk.315.2020.01.20.08.11.30; Mon, 20 Jan 2020 08:11:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=i6NCIIVc; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727048AbgATQLZ (ORCPT + 99 others); Mon, 20 Jan 2020 11:11:25 -0500 Received: from mail-wm1-f49.google.com ([209.85.128.49]:51858 "EHLO mail-wm1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726642AbgATQLZ (ORCPT ); Mon, 20 Jan 2020 11:11:25 -0500 Received: by mail-wm1-f49.google.com with SMTP id d73so157005wmd.1 for ; Mon, 20 Jan 2020 08:11:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Q345sRkXB8jCpvGazeS2vquZ1v6LwwTS+aDG6XXw6h8=; b=i6NCIIVcpKCiKdulIp8QvS7QaoNJ81keYe7jTSmRtEYv4IR4C9wYUY2k8AcmxK1OmD /a7vYxIq9ulOEX6Ojb4SizVtj1boraIsSm+og1r3LEqtnxjqw4HWMLvMh1reRWtJOSrV gVuErUU84C6KL7WNjq5fAhA+AVB+vHsD6c0rZLSfPJHoTstCEYUiKShwH8VthwbqmD0Z 8YlMhTno+oBks6L1RKKbGswu9iGMzki9XssNxHJbEsZIgYhB+0nvFvwx+/1xrstNHtKM ZbZ9GF3kwGXTGfOjiystXu2+iYWH6JOvP860OuORUbTLmPS7nc3GYtrQ+GUDXEhewjZU iA2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Q345sRkXB8jCpvGazeS2vquZ1v6LwwTS+aDG6XXw6h8=; b=XP5ZiHud3mUBUMYYSA3TyNci9faMeAcgKM7YJDRtLcPLZDZwSajBS9tLS8mDBZ+Mq+ L7oC5ToZs+LDHv3Zuvey62ugyFNy5ph87geL7CTaErkxbHGwRBpKs9RRPOs7aYwOtvqg dUB+Ggb3HYinPSD0fvpMf7NlwQGn1D21CmmmWGmN5lx9cwL4pUJu5hDyf2CjesPa/eBs 9A/PmYR4EVcUoCILbn1Avt+R/+bcmaT0HEHRNrPVlShhm7Z5XQsHddUDOMDbB5Vq/QYr JbatqX26k+0uhtlY/ih2KSFbGGmSzxwM6orBmmRRlp0lMeCIdZJTqsFQDjXvDFPMrSTq +yQw== X-Gm-Message-State: APjAAAWCU/zDnXQlFU6ZJYZ9fUy7ylG6rj5Dvo7u/x3O/qVyzJ7ZhX4y 99GwX4TbjJkUHSze7UW38VhOtDPLLhWObg== X-Received: by 2002:a1c:541b:: with SMTP id i27mr71457wmb.137.1579536683814; Mon, 20 Jan 2020 08:11:23 -0800 (PST) Received: from localhost.localdomain ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id 16sm22564602wmi.0.2020.01.20.08.11.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2020 08:11:23 -0800 (PST) From: Jakub Witowski To: linux-bluetooth@vger.kernel.org Subject: [PATCH 2/3] mesh: add composition data setter Date: Mon, 20 Jan 2020 17:11:13 +0100 Message-Id: <20200120161114.6757-3-jakub.witowski@silvair.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200120161114.6757-1-jakub.witowski@silvair.com> References: <20200120161114.6757-1-jakub.witowski@silvair.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 --- mesh/mesh-config-json.c | 46 +++++++++++++++++++++++++++++++---------- mesh/mesh-config.h | 2 ++ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c index 5855149e3..ee42cf7df 100644 --- a/mesh/mesh-config-json.c +++ b/mesh/mesh-config-json.c @@ -1456,6 +1456,27 @@ static bool write_mode(json_object *jobj, const char *keyword, int value) return true; } +static bool write_comp(json_object *jobj, uint16_t cid, uint16_t pid, + uint16_t vid, uint16_t crpl) +{ + if (!jobj) + return false; + + if (!write_uint16_hex(jobj, "cid", cid)) + return false; + + if (!write_uint16_hex(jobj, "pid", pid)) + return false; + + if (!write_uint16_hex(jobj, "vid", vid)) + return false; + + if (!write_uint16_hex(jobj, "crpl", crpl)) + return false; + + return true; +} + bool mesh_config_write_mode(struct mesh_config *cfg, const char *keyword, int value) { @@ -1595,17 +1616,8 @@ static struct mesh_config *create_config(const char *cfg_path, jnode = json_object_new_object(); - /* CID, PID, VID, crpl */ - if (!write_uint16_hex(jnode, "cid", node->cid)) - return NULL; - - if (!write_uint16_hex(jnode, "pid", node->pid)) - return NULL; - - if (!write_uint16_hex(jnode, "vid", node->vid)) - return NULL; - - if (!write_uint16_hex(jnode, "crpl", node->crpl)) + /* CID, PID, VID, CRPL */ + if (!write_comp(jnode, node->cid, node->pid, node->vid, node->crpl)) return NULL; /* Features: relay, LPN, friend, proxy*/ @@ -2052,6 +2064,18 @@ bool mesh_config_write_ttl(struct mesh_config *cfg, uint8_t ttl) return save_config(cfg->jnode, cfg->node_dir_path); } +bool mesh_config_write_comp(struct mesh_config *cfg, uint16_t cid, uint16_t pid, + uint16_t vid, uint16_t crpl) +{ + if (!cfg) + return false; + + if (!write_comp(cfg->jnode, cid, pid, vid, crpl)) + return false; + + return true; +} + static bool load_node(const char *fname, const uint8_t uuid[16], mesh_config_node_func_t cb, void *user_data) { diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h index a5b12bbad..5a003b95c 100644 --- a/mesh/mesh-config.h +++ b/mesh/mesh-config.h @@ -135,6 +135,8 @@ bool mesh_config_write_unicast(struct mesh_config *cfg, uint16_t unicast); bool mesh_config_write_relay_mode(struct mesh_config *cfg, uint8_t mode, uint8_t count, uint16_t interval); bool mesh_config_write_ttl(struct mesh_config *cfg, uint8_t ttl); +bool mesh_config_write_comp(struct mesh_config *cfg, uint16_t cid, uint16_t pid, + uint16_t vid, uint16_t crpl); bool mesh_config_write_mode(struct mesh_config *cfg, const char *keyword, int value); bool mesh_config_model_binding_add(struct mesh_config *cfg, uint16_t ele_addr, -- 2.20.1