linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/3] adapter: Fix unplugging adapter bug
@ 2012-12-06 23:41 Andre Guedes
  2012-12-06 23:41 ` [PATCH BlueZ 2/3] adapter: Don't store Discoverable value if DiscoverableTimeout is set Andre Guedes
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Andre Guedes @ 2012-12-06 23:41 UTC (permalink / raw)
  To: linux-bluetooth

If we unplug an adapter in powered on state, once it is plugged
again, it doesn't go to powered on state as expected. This bug
happens because Powered info is stored when the adapter is
unplugged from the system.

This patch fixes this bug by only storing adapter info if mode
changing was requested by user application via D-Bus interface.
This patch basically reverts the changes in commit
985d8ac397a7c332c1badcb95430a167ec93e9e7 where the bug was
introduced.
---
 src/adapter.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index 0a0e6f0..25501c4 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2230,8 +2230,6 @@ static void set_mode_complete(struct btd_adapter *adapter)
 	struct session_req *pending;
 	int err;
 
-	store_adapter_info(adapter);
-
 	DBG("%s", mode2str(adapter->mode));
 
 	if (adapter->mode == MODE_OFF) {
@@ -2271,6 +2269,8 @@ static void set_mode_complete(struct btd_adapter *adapter)
 	if (err != 0)
 		error("unable to set mode: %s", mode2str(pending->mode));
 
+	store_adapter_info(adapter);
+
 	session_unref(pending);
 }
 
-- 
1.8.0.1


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

* [PATCH BlueZ 2/3] adapter: Don't store Discoverable value if DiscoverableTimeout is set
  2012-12-06 23:41 [PATCH BlueZ 1/3] adapter: Fix unplugging adapter bug Andre Guedes
@ 2012-12-06 23:41 ` Andre Guedes
  2012-12-06 23:41 ` [PATCH BlueZ 3/3] adapter: Discoverable storage Andre Guedes
  2012-12-07  9:22 ` [PATCH BlueZ 1/3] adapter: Fix unplugging adapter bug Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Andre Guedes @ 2012-12-06 23:41 UTC (permalink / raw)
  To: linux-bluetooth

If adapter was set to Discoverable and DiscoverableTimeout is greater
than zero we should not store the Discoverable adapter info as long as
it is a non-persistent state. This way, we don't need to worry about
updating the Discoverable stored value once the timeout expires.
---
 src/adapter.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index 25501c4..35a4715 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2269,8 +2269,12 @@ static void set_mode_complete(struct btd_adapter *adapter)
 	if (err != 0)
 		error("unable to set mode: %s", mode2str(pending->mode));
 
+	if (adapter->mode == MODE_DISCOVERABLE && adapter->discov_timeout > 0)
+		goto done;
+
 	store_adapter_info(adapter);
 
+done:
 	session_unref(pending);
 }
 
-- 
1.8.0.1


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

* [PATCH BlueZ 3/3] adapter: Discoverable storage
  2012-12-06 23:41 [PATCH BlueZ 1/3] adapter: Fix unplugging adapter bug Andre Guedes
  2012-12-06 23:41 ` [PATCH BlueZ 2/3] adapter: Don't store Discoverable value if DiscoverableTimeout is set Andre Guedes
@ 2012-12-06 23:41 ` Andre Guedes
  2012-12-07  9:22 ` [PATCH BlueZ 1/3] adapter: Fix unplugging adapter bug Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Andre Guedes @ 2012-12-06 23:41 UTC (permalink / raw)
  To: linux-bluetooth

This patch changes store_adapter_info helper so it stores Discoverable
value according to discov_timeout. If discov_timeout is greater than
zero, we store "false" for Discoverable. This change covers the case
when DiscoverableTimeout value is set when Discoverable is true.
---
 src/adapter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/adapter.c b/src/adapter.c
index 35a4715..fb6c570 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -231,7 +231,8 @@ static void store_adapter_info(struct btd_adapter *adapter)
 					adapter->pairable_timeout);
 
 	g_key_file_set_boolean(key_file, "General", "Discoverable",
-				adapter->discoverable);
+				adapter->discov_timeout ?
+				FALSE : adapter->discoverable);
 
 	if (adapter->discov_timeout != main_opts.discovto)
 		g_key_file_set_integer(key_file, "General",
-- 
1.8.0.1


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

* Re: [PATCH BlueZ 1/3] adapter: Fix unplugging adapter bug
  2012-12-06 23:41 [PATCH BlueZ 1/3] adapter: Fix unplugging adapter bug Andre Guedes
  2012-12-06 23:41 ` [PATCH BlueZ 2/3] adapter: Don't store Discoverable value if DiscoverableTimeout is set Andre Guedes
  2012-12-06 23:41 ` [PATCH BlueZ 3/3] adapter: Discoverable storage Andre Guedes
@ 2012-12-07  9:22 ` Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2012-12-07  9:22 UTC (permalink / raw)
  To: Andre Guedes; +Cc: linux-bluetooth

Hi Andre,

On Thu, Dec 06, 2012, Andre Guedes wrote:
> If we unplug an adapter in powered on state, once it is plugged
> again, it doesn't go to powered on state as expected. This bug
> happens because Powered info is stored when the adapter is
> unplugged from the system.
> 
> This patch fixes this bug by only storing adapter info if mode
> changing was requested by user application via D-Bus interface.
> This patch basically reverts the changes in commit
> 985d8ac397a7c332c1badcb95430a167ec93e9e7 where the bug was
> introduced.
> ---
>  src/adapter.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

All three patches have been applied (with a couple of coding style
improvements which don't change the logic). Thanks.

Johan

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

end of thread, other threads:[~2012-12-07  9:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-06 23:41 [PATCH BlueZ 1/3] adapter: Fix unplugging adapter bug Andre Guedes
2012-12-06 23:41 ` [PATCH BlueZ 2/3] adapter: Don't store Discoverable value if DiscoverableTimeout is set Andre Guedes
2012-12-06 23:41 ` [PATCH BlueZ 3/3] adapter: Discoverable storage Andre Guedes
2012-12-07  9:22 ` [PATCH BlueZ 1/3] adapter: Fix unplugging adapter bug Johan Hedberg

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).