This adds key file with default settings for the mesh daemon.
The following settings are included:
Beacon: Default setting for to indicate whether
secure network beaconing is enabled for a
node whose Beacon state hasn't been configured
by a configuration client, i.e., this setting
apllies to a newly provisioned, created or
imported node.
Relay: Default setting for supporting relay
Friendship: Default setting for supporting Friendship
CRPL: Default depth of replay protection list.
FriendQueueSize: Default size of friend queue: the number
of messages that each Friend node can store
for the Low Power node.
ProvTimeout: Provisioning timeout in seconds.
Change-Id: Ia5f40ef9d5d866e8d94a2ff5cac7cf6339015eca
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
mesh/bluetooth-mesh.service
EXTRA_DIST += mesh/bluetooth-mesh.conf mesh/bluetooth-mesh.service.in \
- mesh/org.bluez.mesh.service
+ mesh/org.bluez.mesh.service mesh/mesh-main.conf
CLEANFILES += mesh/bluetooth-mesh.service
bool dbus_debug = false;
struct l_dbus *dbus = NULL;
const char *config_dir = NULL;
+ static const char *mesh_conf_fname;
int index = MGMT_INDEX_NONE;
if (!l_main_init())
int opt;
const char *str;
- opt = getopt_long(argc, argv, "i:c:ndbh", main_options, NULL);
+ opt = getopt_long(argc, argv, "i:c:f:ndbh", main_options, NULL);
if (opt < 0)
break;
case 'c':
config_dir = optarg;
break;
+ case 'f':
+ mesh_conf_fname = optarg;
+ break;
case 'b':
dbus_debug = true;
break;
}
}
-
- if (!mesh_init(config_dir, MESH_IO_TYPE_GENERIC, &index)) {
+ if (!mesh_init(config_dir, mesh_conf_fname, MESH_IO_TYPE_GENERIC,
+ &ctlr_index, mesh_ready_callback, dbus)) {
l_error("Failed to initialize mesh");
status = EXIT_FAILURE;
goto done;
--- /dev/null
+[General]
+
+# Default setting for to indicate whether secure network beaconing
+# is enabled for a node whose Beacon state hasn't been configured
+# by a configuration client, i.e., for a newly provisioned, created
+# or imported node.
+# Defaults to true.
+#Beacon = true
+
+# Default setting for supporting relay. The setting applies
+# to all local nodes.
+# If the value is true, then a configuration client can either enable or disable
+# the relay feature per local node.
+# If the value is false, then the relay feature cannot be configured for
+# any local node.
+# Defaults to true.
+#Relay = true
+
+# Default setting for supporting Friendship. The setting applies
+# to all local nodes.
+# If the value is true, then a configuration client can either enable or disable
+# the Friendship feature per local node.
+# If the value is false, then the Friendship feature cannot be configured for
+# any local node.
+# Defaults to true.
+#Friendship = true
+
+# Default depth of replay protection list. This setting applies to
+# each individual node.
+# Valid range 1-65535.
+# Defaults to 100.
+#CRPL = 100
+
+# Default size of friend queue: the number of messages that each Friend node can
+# store for the Low Power node.
+# Valid range: 0-32.
+# Defaults to 32.
+#FriendQueueSize = 32
+
+# Provisioning timeout in seconds.
+# Setting this value to zero means there's no timeout.
+# Defaults to 60.
+#ProvTimeout = 60
/*
* The default values for mesh configuration. Can be
- * overwritten by values from mesh.conf
+ * overwritten by values from mesh-main.conf
*/
#define DEFAULT_PROV_TIMEOUT 60
-#define DEFAULT_ALGORITHMS 0x0001
+#define DEFAULT_CRPL 100
+#define DEFAULT_FRIEND_QUEUE_SZ 32
-/* TODO: add more default values */
+#define DEFAULT_ALGORITHMS 0x0001
struct scan_filter {
uint8_t id;
prov_rx_cb_t prov_rx;
void *prov_data;
uint32_t prov_timeout;
+ bool beacon_enabled;
+ bool friend_support;
+ bool relay_support;
+ bool lpn_support;
+ bool proxy_support;
+ uint16_t crpl;
uint16_t algorithms;
uint16_t req_index;
+ uint8_t friend_queue_sz;
uint8_t max_filters;
};
uint8_t *uuid;
};
-static struct bt_mesh mesh;
+static struct bt_mesh mesh = {
+ .algorithms = DEFAULT_ALGORITHMS,
+ .prov_timeout = DEFAULT_PROV_TIMEOUT,
+ .beacon_enabled = true,
+ .friend_support = true,
+ .relay_support = true,
+ .lpn_support = false,
+ .proxy_support = false,
+ .crpl = DEFAULT_CRPL,
+ .friend_queue_sz = DEFAULT_FRIEND_QUEUE_SZ
+};
/* We allow only one outstanding Join request */
static struct join_data *join_pending;
mesh_io_deregister_recv_cb(mesh.io, MESH_IO_FILTER_PROV);
}
-bool mesh_init(const char *config_dir, enum mesh_io_type type, void *opts)
+bool mesh_beacon_enabled(void)
+{
+ return mesh.beacon_enabled;
+}
+
+bool mesh_relay_supported(void)
+{
+ return mesh.relay_support;
+}
+
+bool mesh_friendship_supported(void)
+{
+ return mesh.friend_support;
+}
+
+uint16_t mesh_get_crpl(void)
+{
+ return mesh.crpl;
+}
+
+uint8_t mesh_get_friend_queue_size(void)
+{
+ return mesh.friend_queue_sz;
+}
+
+static void parse_settings(const char *mesh_conf_fname)
+{
+ struct l_settings *settings;
+ char *str;
+ uint32_t value;
+
+ settings = l_settings_new();
+ if (!l_settings_load_from_file(settings, mesh_conf_fname))
+ return;
+
+ str = l_settings_get_string(settings, "General", "Beacon");
+ if (str) {
+ if (!strcasecmp(str, "true"))
+ mesh.beacon_enabled = true;
+ l_free(str);
+ }
+
+ str = l_settings_get_string(settings, "General", "Relay");
+ if (str) {
+ if (!strcasecmp(str, "false"))
+ mesh.relay_support = false;
+ l_free(str);
+ }
+
+ str = l_settings_get_string(settings, "General", "Friendship");
+ if (str) {
+ if (!strcasecmp(str, "false"))
+ mesh.friend_support = false;
+ l_free(str);
+ }
+
+ if (l_settings_get_uint(settings, "General", "CRPL", &value) &&
+ value <= 65535)
+ mesh.crpl = value;
+
+ if (l_settings_get_uint(settings, "General", "FriendQueueSize", &value)
+ && value < 127)
+ mesh.friend_queue_sz = value;
+
+ if (l_settings_get_uint(settings, "General", "ProvTimeout", &value))
+ mesh.prov_timeout = value;
+}
+
+bool mesh_init(const char *config_dir, const char *mesh_conf_fname,
+ enum mesh_io_type type, void *opts,
+ mesh_ready_func_t cb, void *user_data)
{
struct mesh_io_caps caps;
l_info("Loading node configuration from %s", storage_dir);
+ if (!mesh_conf_fname)
+ mesh_conf_fname = CONFIGDIR "/mesh-main.conf";
+
+ parse_settings(mesh_conf_fname);
+
if (!node_load_from_storage(storage_dir))
return false;
enum mesh_io_type;
+typedef void (*mesh_ready_func_t)(void *user_data, bool success);
typedef void (*prov_rx_cb_t)(void *user_data, const uint8_t *data,
uint16_t len);
-bool mesh_init(const char *in_config_name, enum mesh_io_type type, void *opts);
+
+bool mesh_init(const char *config_dir, const char *mesh_conf_fname,
+ enum mesh_io_type type, void *opts,
+ mesh_ready_func_t cb, void *user_data);
void mesh_cleanup(void);
bool mesh_dbus_init(struct l_dbus *dbus);
void mesh_unreg_prov_rx(prov_rx_cb_t cb);
const char *mesh_prov_status_str(uint8_t status);
const char *mesh_get_storage_dir(void);
+bool mesh_beacon_enabled(void);
+bool mesh_relay_supported(void);
+bool mesh_friendship_supported(void);
+uint16_t mesh_get_crpl(void);
+uint8_t mesh_get_friend_queue_size(void);
static void set_defaults(struct mesh_node *node)
{
- /* TODO: these values should come from mesh.conf */
node->lpn = MESH_MODE_UNSUPPORTED;
node->proxy = MESH_MODE_UNSUPPORTED;
- node->friend = MESH_MODE_UNSUPPORTED;
- node->beacon = MESH_MODE_DISABLED;
- node->relay.mode = MESH_MODE_DISABLED;
+ node->friend = (mesh_friendship_supported()) ? MESH_MODE_DISABLED :
+ MESH_MODE_UNSUPPORTED;
+ node->beacon = (mesh_beacon_enabled()) ? MESH_MODE_ENABLED :
+ MESH_MODE_DISABLED;
+ node->relay.mode = (mesh_relay_supported()) ? MESH_MODE_DISABLED :
+ MESH_MODE_UNSUPPORTED;
node->ttl = TTL_MASK;
node->seq_number = DEFAULT_SEQUENCE_NUMBER;
}
l_debug("path %s", path);
node->comp = l_new(struct node_composition, 1);
- node->comp->crpl = DEFAULT_CRPL;
+ node->comp->crpl = mesh_get_crpl();
while (l_dbus_message_iter_next_entry(properties, &key, &variant)) {
if (!cid && !strcmp(key, "CompanyID")) {