From: Jakub Witowski <jakub.witowski@silvair.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 2/4] mesh: add cid/pid/vid setter
Date: Thu, 30 Jan 2020 15:34:23 +0100 [thread overview]
Message-ID: <20200130143425.5844-3-jakub.witowski@silvair.com> (raw)
In-Reply-To: <20200130143425.5844-1-jakub.witowski@silvair.com>
This patch adds the setter for the CID PID and VID.
---
mesh/mesh-config-json.c | 40 ++++++++++++++++++++++++++++++++--------
mesh/mesh-config.h | 2 ++
2 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c
index 5855149e3..0574c166e 100644
--- a/mesh/mesh-config-json.c
+++ b/mesh/mesh-config-json.c
@@ -1456,6 +1456,24 @@ static bool write_mode(json_object *jobj, const char *keyword, int value)
return true;
}
+static bool write_comp_id(json_object *jobj, uint16_t cid, uint16_t pid,
+ uint16_t vid)
+{
+ 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;
+
+ return true;
+}
+
bool mesh_config_write_mode(struct mesh_config *cfg, const char *keyword,
int value)
{
@@ -1595,16 +1613,10 @@ 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))
+ if (!write_comp_id(jnode, node->cid, node->pid, node->vid))
return NULL;
+ /* CRPL */
if (!write_uint16_hex(jnode, "crpl", node->crpl))
return NULL;
@@ -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_id(struct mesh_config *cfg, uint16_t cid,
+ uint16_t pid, uint16_t vid)
+{
+ if (!cfg)
+ return false;
+
+ if (!write_comp_id(cfg->jnode, cid, pid, vid))
+ 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..9a5d6e57a 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_id(struct mesh_config *cfg, uint16_t cid,
+ uint16_t pid, uint16_t vid);
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
next prev parent reply other threads:[~2020-01-30 14:34 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-30 14:34 [PATCH BlueZ v2 0/4] Allow to reattach with new composition data Jakub Witowski
2020-01-30 14:34 ` [PATCH BlueZ v2 1/4] mesh: use static node_comp instead of the pointer Jakub Witowski
2020-01-30 14:34 ` Jakub Witowski [this message]
2020-01-30 14:34 ` [PATCH BlueZ v2 3/4] mesh: remove unused node_set_device_key() Jakub Witowski
2020-01-30 14:34 ` [PATCH BlueZ v2 4/4] mesh: allow to reattach with new composition data Jakub Witowski
2020-01-31 18:30 ` [PATCH BlueZ v2 0/4] Allow " Gix, Brian
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200130143425.5844-3-jakub.witowski@silvair.com \
--to=jakub.witowski@silvair.com \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).