From: Chan-yeol Park <[email protected]>
Right after HCI mode command is sent, Bluez writes mode value
on the storage. but in case of DiscoverableTimeout, storage value
is not updated like adapter->mode value. So this logic is moved.
---
src/adapter.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index acb845e..1b8e3b0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -302,7 +302,6 @@ static int set_mode(struct btd_adapter *adapter, uint8_t new_mode,
done:
modestr = mode2str(new_mode);
- write_device_mode(&adapter->bdaddr, modestr);
DBG("%s", modestr);
@@ -2244,6 +2243,12 @@ static void set_mode_complete(struct btd_adapter *adapter)
adapter->mode_sessions = NULL;
}
+ modestr = mode2str(adapter->mode);
+
+ DBG("%s", modestr);
+
+ write_device_mode(&adapter->bdaddr, modestr);
+
if (adapter->pending_mode == NULL)
return;
@@ -2268,10 +2273,6 @@ static void set_mode_complete(struct btd_adapter *adapter)
g_dbus_send_message(connection, reply);
}
- modestr = mode2str(adapter->mode);
-
- DBG("%s", modestr);
-
/* restore if the mode doesn't matches the pending */
if (err != 0) {
write_device_mode(&adapter->bdaddr, modestr);
--
1.7.9.5
Hi Chanyeol,
On Mon, Aug 27, 2012 at 3:02 PM, <[email protected]> wrote:
> From: Chan-yeol Park <[email protected]>
>
> This patch fixes the problem that storage's Discoverable value is
> not updated like hciconfig when BlueZ receives the MGMT adapter mode
> changed event after DiscoverableTimeout has been expired.
>
> This problem occurs because no longer bluetoothd does not take on
> requesting part to disable discoverable when the timer expires.
> ---
> src/adapter.c | 15 +++++----------
> 1 file changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 69ec821..7d06633 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -2249,6 +2249,11 @@ static void set_mode_complete(struct btd_adapter *adapter)
> adapter->mode_sessions = NULL;
> }
>
> + modestr = mode2str(adapter->mode);
> + write_device_mode(&adapter->bdaddr, modestr);
> +
> + DBG("%s", modestr);
> +
> if (adapter->pending_mode == NULL)
> return;
>
> @@ -2273,16 +2278,6 @@ static void set_mode_complete(struct btd_adapter *adapter)
> g_dbus_send_message(connection, reply);
> }
>
> - modestr = mode2str(adapter->mode);
> -
> - DBG("%s", modestr);
> -
> - /* restore if the mode doesn't matches the pending */
> - if (err != 0) {
> - write_device_mode(&adapter->bdaddr, modestr);
> - error("unable to set mode: %s", mode2str(pending->mode));
> - }
> -
> session_unref(pending);
> }
>
> --
> 1.7.9.5
Ive changed a little bit the commit message to be more clear about
what we are fixing, but it is now pushed upstream.
--
Luiz Augusto von Dentz
From: Chan-yeol Park <[email protected]>
This patch fixes the problem that storage's Discoverable value is
not updated like hciconfig when BlueZ receives the MGMT adapter mode
changed event after DiscoverableTimeout has been expired.
This problem occurs because no longer bluetoothd does not take on
requesting part to disable discoverable when the timer expires.
---
src/adapter.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 69ec821..7d06633 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2249,6 +2249,11 @@ static void set_mode_complete(struct btd_adapter *adapter)
adapter->mode_sessions = NULL;
}
+ modestr = mode2str(adapter->mode);
+ write_device_mode(&adapter->bdaddr, modestr);
+
+ DBG("%s", modestr);
+
if (adapter->pending_mode == NULL)
return;
@@ -2273,16 +2278,6 @@ static void set_mode_complete(struct btd_adapter *adapter)
g_dbus_send_message(connection, reply);
}
- modestr = mode2str(adapter->mode);
-
- DBG("%s", modestr);
-
- /* restore if the mode doesn't matches the pending */
- if (err != 0) {
- write_device_mode(&adapter->bdaddr, modestr);
- error("unable to set mode: %s", mode2str(pending->mode));
- }
-
session_unref(pending);
}
--
1.7.9.5
From: Chan-yeol Park <[email protected]>
This patch fixes the problem that storage's Discoverable value is
not updated like hciconfig when BlueZ receives the MGMT adapter mode
changed event after DiscoverableTimeout has been expired.
---
src/adapter.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 69ec821..673cee8 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2249,6 +2249,11 @@ static void set_mode_complete(struct btd_adapter *adapter)
adapter->mode_sessions = NULL;
}
+ modestr = mode2str(adapter->mode);
+ write_device_mode(&adapter->bdaddr, modestr);
+
+ DBG("%s", modestr);
+
if (adapter->pending_mode == NULL)
return;
@@ -2273,10 +2278,6 @@ static void set_mode_complete(struct btd_adapter *adapter)
g_dbus_send_message(connection, reply);
}
- modestr = mode2str(adapter->mode);
-
- DBG("%s", modestr);
-
/* restore if the mode doesn't matches the pending */
if (err != 0) {
write_device_mode(&adapter->bdaddr, modestr);
--
1.7.9.5
Hello all,
I'm writing in order to discuss the point when bluez writes Discoverable
Mode value.
Currently BlueZ writes it on the storage right after it sends HCI command.
Except DiscoverableTimeout is 0 case. it works fine.
hciconfig, bluez Adapter.GetProperties 's value are the same with the
discoverable mode
on the storage.
But in case of DiscoverableTimeout is not 0 the value on the storage
should be updated
after BlueZ gets HCI Discoverable Mode change response. However the
change is not
applied on the storage , so it's skipped.
* Fortunately hciconfig, Adapter.GetProperties 's value are updated fine.
I think if we move the logic that writing the value on the storage FROM
the point before
bluez sends HCI commands TO the point after we get HCI response , this
problem
would be resolved naturally.
If you need more explanation, please ask me.
Regards
chanyeol
On 08/08/2012 10:03 PM, [email protected] wrote:
> From: Chan-yeol Park <[email protected]>
>
> Right after HCI mode command is sent, Bluez writes mode value
> on the storage. but in case of DiscoverableTimeout, storage value
> is not updated like adapter->mode value. So this logic is moved.
> ---
> src/adapter.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index acb845e..1b8e3b0 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -302,7 +302,6 @@ static int set_mode(struct btd_adapter *adapter, uint8_t new_mode,
>
> done:
> modestr = mode2str(new_mode);
> - write_device_mode(&adapter->bdaddr, modestr);
>
> DBG("%s", modestr);
>
> @@ -2244,6 +2243,12 @@ static void set_mode_complete(struct btd_adapter *adapter)
> adapter->mode_sessions = NULL;
> }
>
> + modestr = mode2str(adapter->mode);
> +
> + DBG("%s", modestr);
> +
> + write_device_mode(&adapter->bdaddr, modestr);
> +
> if (adapter->pending_mode == NULL)
> return;
>
> @@ -2268,10 +2273,6 @@ static void set_mode_complete(struct btd_adapter *adapter)
> g_dbus_send_message(connection, reply);
> }
>
> - modestr = mode2str(adapter->mode);
> -
> - DBG("%s", modestr);
> -
> /* restore if the mode doesn't matches the pending */
> if (err != 0) {
> write_device_mode(&adapter->bdaddr, modestr);