Skip to contentSkip to conversation

mesh: Add MGMT bypass when specifying controller

PATCH Applied Brian Gix 1 participant 2 messages Jan 31, 2019 – Feb 4, 2019 Bluetooth drivers

lore
Share & tools
lore

Brian Gix

author
#0 lore raw

PATCH 1/1 mesh: Add MGMT bypass when specifying controller

If Daemon is started with an explicit controller specified, the MGMT search for an unused shared controller is bypassed, and the controller is opened directly.

---
 mesh/mesh.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
mesh/mesh.c +13 -7
index 881b6ed73..e49653ef8 100644
@@ -304,7 +304,7 @@ bool mesh_init(uint16_t index, const char *config_dir)
 	if (initialized)
 		return true;
 
-	if (!init_mgmt()) {
+	if (index == MGMT_INDEX_NONE && !init_mgmt()) {
 		l_error("Failed to initialize mesh management");
 		return false;
 	}
@@ -326,12 +326,18 @@ bool mesh_init(uint16_t index, const char *config_dir)
 	if (!storage_load_nodes(config_dir))
 		return false;
 
-	l_debug("send read index_list");
-	if (mgmt_send(mgmt_mesh, MGMT_OP_READ_INDEX_LIST,
-				MGMT_INDEX_NONE, 0, NULL,
-				read_index_list_cb, NULL, NULL) <= 0)
-		return false;
-
+	if (index == MGMT_INDEX_NONE) {
+		/* Use MGMT to find a candidate controller */
+		l_debug("send read index_list");
+		if (mgmt_send(mgmt_mesh, MGMT_OP_READ_INDEX_LIST,
+					MGMT_INDEX_NONE, 0, NULL,
+					read_index_list_cb, NULL, NULL) <= 0)
+			return false;
+	} else {
+		/* Open specified controller without searching */
+		start_io(mesh.req_index);
+		return mesh.io != NULL;
+	}
 	return true;
 }
 
Signature · 1 line
2.14.5
author Applied
#1 lore raw

Applied

Quoted 45 lines · Brian Gix

If Daemon is started with an explicit controller specified, the MGMT search for an unused shared controller is bypassed, and the controller is opened directly.

---
 mesh/mesh.c | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
mesh/mesh.c +13 -7
index 881b6ed73..e49653ef8 100644
@@ -304,7 +304,7 @@ bool mesh_init(uint16_t index, const char *config_dir)
 	if (initialized)
 		return true;
 
-	if (!init_mgmt()) {
+	if (index == MGMT_INDEX_NONE && !init_mgmt()) {
 		l_error("Failed to initialize mesh management");
 		return false;
 	}
@@ -326,12 +326,18 @@ bool mesh_init(uint16_t index, const char *config_dir)
 	if (!storage_load_nodes(config_dir))
 		return false;
 
-	l_debug("send read index_list");
-	if (mgmt_send(mgmt_mesh, MGMT_OP_READ_INDEX_LIST,
-				MGMT_INDEX_NONE, 0, NULL,
-				read_index_list_cb, NULL, NULL) <= 0)
-		return false;
-
+	if (index == MGMT_INDEX_NONE) {
+		/* Use MGMT to find a candidate controller */
+		l_debug("send read index_list");
+		if (mgmt_send(mgmt_mesh, MGMT_OP_READ_INDEX_LIST,
+					MGMT_INDEX_NONE, 0, NULL,
+					read_index_list_cb, NULL, NULL) <= 0)
+			return false;
+	} else {
+		/* Open specified controller without searching */
+		start_io(mesh.req_index);
+		return mesh.io != NULL;
+	}
 	return true;
 }