Linux-Bluetooth Archive on lore.kernel.org
 help / Atom feed
* [PATCH BlueZ] mesh: Add MGMT bypass when specifying controller
@ 2019-01-31 20:50 Brian Gix
  2019-02-04 20:11 ` Gix, Brian
  0 siblings, 1 reply; 2+ messages in thread
From: Brian Gix @ 2019-01-31 20:50 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: inga.stotland, johan.hedberg, 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(-)

diff --git a/mesh/mesh.c b/mesh/mesh.c
index 881b6ed73..e49653ef8 100644
--- a/mesh/mesh.c
+++ b/mesh/mesh.c
@@ -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;
 }
 
-- 
2.14.5


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH BlueZ] mesh: Add MGMT bypass when specifying controller
  2019-01-31 20:50 [PATCH BlueZ] mesh: Add MGMT bypass when specifying controller Brian Gix
@ 2019-02-04 20:11 ` Gix, Brian
  0 siblings, 0 replies; 2+ messages in thread
From: Gix, Brian @ 2019-02-04 20:11 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Hedberg, Johan, Stotland, Inga


Applied

On Thu, 2019-01-31 at 12:50 -0800, Brian Gix wrote:
> 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(-)
> 
> diff --git a/mesh/mesh.c b/mesh/mesh.c
> index 881b6ed73..e49653ef8 100644
> --- a/mesh/mesh.c
> +++ b/mesh/mesh.c
> @@ -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;
>  }
>  
^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-31 20:50 [PATCH BlueZ] mesh: Add MGMT bypass when specifying controller Brian Gix
2019-02-04 20:11 ` Gix, Brian

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org linux-bluetooth@archiver.kernel.org
	public-inbox-index linux-bluetooth


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/ public-inbox