From: Brian Gix <brian.gix@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: brian.gix@intel.com, inga.stotland@intel.com
Subject: [PATCH BlueZ v5 06/14] mesh: Add storage of Mesh Private Beacon settings
Date: Mon, 30 Jan 2023 15:52:02 -0800 [thread overview]
Message-ID: <20230130235210.94385-7-brian.gix@gmail.com> (raw)
In-Reply-To: <20230130235210.94385-1-brian.gix@gmail.com>
From: Brian Gix <brian.gix@intel.com>
If current storage does not exist in node.json, the Mesh Private
Beacon will be disabled.
---
mesh/mesh-config-json.c | 48 +++++++++++++++++++++++++++++++++++++++++
mesh/mesh-config.h | 6 ++++++
2 files changed, 54 insertions(+)
diff --git a/mesh/mesh-config-json.c b/mesh/mesh-config-json.c
index 8f321a731..c198627c6 100644
--- a/mesh/mesh-config-json.c
+++ b/mesh/mesh-config-json.c
@@ -1337,6 +1337,19 @@ static void parse_features(json_object *jconfig, struct mesh_config_node *node)
node->modes.beacon = mode;
}
+ if (json_object_object_get_ex(jconfig, "mpb", &jvalue)) {
+ mode = get_mode(jvalue);
+ if (mode <= MESH_MODE_UNSUPPORTED)
+ node->modes.mpb = mode;
+
+ if (node->modes.mpb == MESH_MODE_ENABLED) {
+ if (json_object_object_get_ex(jconfig, "mpbPeriod",
+ &jvalue))
+ node->modes.mpb_period =
+ json_object_get_int(jvalue);
+ }
+ }
+
if (!json_object_object_get_ex(jconfig, "relay", &jrelay))
return;
@@ -1576,6 +1589,18 @@ bool mesh_config_write_mode(struct mesh_config *cfg, const char *keyword,
return save_config(cfg->jnode, cfg->node_dir_path);
}
+bool mesh_config_write_mode_ex(struct mesh_config *cfg, const char *keyword,
+ int value, bool save)
+{
+ if (!cfg)
+ return false;
+
+ if (save)
+ return mesh_config_write_mode(cfg, keyword, value);
+ else
+ return write_mode(cfg->jnode, keyword, value);
+}
+
static bool write_relay_mode(json_object *jobj, uint8_t mode,
uint8_t count, uint16_t interval)
{
@@ -1622,6 +1647,21 @@ bool mesh_config_write_relay_mode(struct mesh_config *cfg, uint8_t mode,
return save_config(cfg->jnode, cfg->node_dir_path);
}
+bool mesh_config_write_mpb(struct mesh_config *cfg, uint8_t mode,
+ uint8_t period)
+{
+
+ if (!cfg || !write_mode(cfg->jnode, "mpb", mode))
+ return false;
+
+ if (mode) {
+ if (!write_int(cfg->jnode, "mpbPeriod", period))
+ return false;
+ }
+
+ return save_config(cfg->jnode, cfg->node_dir_path);
+}
+
bool mesh_config_write_net_transmit(struct mesh_config *cfg, uint8_t cnt,
uint16_t interval)
{
@@ -1746,6 +1786,14 @@ static struct mesh_config *create_config(const char *cfg_path,
if (!write_mode(jnode, "beacon", modes->beacon))
return NULL;
+ if (!write_mode(jnode, "mpb", modes->mpb))
+ return NULL;
+
+ if (modes->mpb) {
+ if (!write_int(jnode, "mpbPeriod", modes->mpb_period))
+ return NULL;
+ }
+
/* Sequence number */
json_object_object_add(jnode, sequenceNumber,
json_object_new_int(node->seq_number));
diff --git a/mesh/mesh-config.h b/mesh/mesh-config.h
index ed1b610de..3cb20b85d 100644
--- a/mesh/mesh-config.h
+++ b/mesh/mesh-config.h
@@ -60,6 +60,8 @@ struct mesh_config_modes {
uint8_t friend;
uint8_t proxy;
uint8_t beacon;
+ uint8_t mpb;
+ uint8_t mpb_period;
};
struct mesh_config_netkey {
@@ -140,9 +142,13 @@ bool mesh_config_write_seq_number(struct mesh_config *cfg, uint32_t seq,
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_mpb(struct mesh_config *cfg, uint8_t mode,
+ uint8_t period);
bool mesh_config_write_ttl(struct mesh_config *cfg, uint8_t ttl);
bool mesh_config_write_mode(struct mesh_config *cfg, const char *keyword,
int value);
+bool mesh_config_write_mode_ex(struct mesh_config *cfg, const char *keyword,
+ int value, bool save);
bool mesh_config_comp_page_add(struct mesh_config *cfg, uint8_t page,
uint8_t *data, uint16_t size);
void mesh_config_comp_page_del(struct mesh_config *cfg, uint8_t page);
--
2.39.1
next prev parent reply other threads:[~2023-01-30 23:52 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 23:51 [PATCH BlueZ v5 00/14] Mesh v1.1 additions Brian Gix
2023-01-30 23:51 ` [PATCH BlueZ v5 01/14] doc/mesh: Add Remote Provisioning DBus APIs Brian Gix
2023-01-31 5:39 ` Mesh v1.1 additions bluez.test.bot
2023-01-30 23:51 ` [PATCH BlueZ v5 02/14] mesh: Add Remote Provisioning Brian Gix
2023-01-30 23:51 ` [PATCH BlueZ v5 03/14] tools/mesh: Optimize for multiple RPR servers and NPPI Brian Gix
2023-01-30 23:52 ` [PATCH BlueZ v5 04/14] mesh: Rename parameter list per crypto usage Brian Gix
2023-01-30 23:52 ` [PATCH BlueZ v5 05/14] unit/mesh: Add unit testing of Mesh Private Beaconing Brian Gix
2023-01-30 23:52 ` Brian Gix [this message]
2023-01-30 23:52 ` [PATCH BlueZ v5 07/14] mesh: Add Mesh Private Beacon server Brian Gix
2023-01-30 23:52 ` [PATCH BlueZ v5 08/14] mesh: Add Tx/Rx support of Mesh Private Beacons Brian Gix
2023-01-30 23:52 ` [PATCH BlueZ v5 09/14] mesh: Add internal Mesh Private Beacon model Brian Gix
2023-01-30 23:52 ` [PATCH BlueZ v5 10/14] tools/mesh: Add support for Mesh Private Beacons Brian Gix
2023-01-30 23:52 ` [PATCH BlueZ v5 11/14] mesh: Switch beaconing net key Brian Gix
2023-01-30 23:52 ` [PATCH BlueZ v5 12/14] mesh: Fix Checksmatch warning Brian Gix
2023-01-30 23:52 ` [PATCH BlueZ v5 13/14] mesh: Remove unused byte swap for ScanBuild Brian Gix
2023-01-30 23:52 ` [PATCH BlueZ v5 14/14] tools/mesh-cfgtest: Support extended device composition Brian Gix
2023-01-31 17:30 ` [PATCH BlueZ v5 00/14] Mesh v1.1 additions patchwork-bot+bluetooth
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=20230130235210.94385-7-brian.gix@gmail.com \
--to=brian.gix@gmail.com \
--cc=brian.gix@intel.com \
--cc=inga.stotland@intel.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).