* Re: [PATCH BlueZ 1/4] obex-client: Port MAP module to use D-Bus properties interface
From: Johan Hedberg @ 2012-12-16 11:28 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1355520720-11731-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Fri, Dec 14, 2012, Luiz Augusto von Dentz wrote:
> ---
> obexd/client/map.c | 315 ++++++++++++++++++++++++++++++-----------------------
> 1 file changed, 178 insertions(+), 137 deletions(-)
All patches in this set have been applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH v2 1/5] device : Add EndGroupHandle key in attributes storage
From: Johan Hedberg @ 2012-12-16 11:33 UTC (permalink / raw)
To: Frédéric Danis; +Cc: linux-bluetooth
In-Reply-To: <1355561991-7906-1-git-send-email-frederic.danis@linux.intel.com>
Hi Frédéric,
On Sat, Dec 15, 2012, Frédéric Danis wrote:
> End group handle should also be converted/saved for each
> group in device's attributes file.
> ---
> doc/settings-storage.txt | 8 +++++---
> src/adapter.c | 8 +++++---
> src/device.c | 10 ++++++++++
> 3 files changed, 20 insertions(+), 6 deletions(-)
All patches in this set have been applied. Thanks.
Johan
^ permalink raw reply
* PSCAN and ISCAN flags in hciconfig
From: Kevin Wilson @ 2012-12-16 17:58 UTC (permalink / raw)
To: linux-bluetooth
Hello,
I have 2 PC with Linux which once used to recognize each other by
"hcitool scan" and to create
a PAND-based connection.
Now I fail to see each other with "hcitool scan".
My question is :
I see now only the PSCAN flag when running "hciconfig" on both of then.
Is the ISCAN flag (inquiry) mandatory so that a device will be discoverable ?
following is full output on one of them:
hci0: Type: BR/EDR Bus: USB
BD Address: 00:23:4E:E5:70:3A ACL MTU: 1021:8 SCO MTU: 64:1
UP RUNNING PSCAN
RX bytes:1857 acl:0 sco:0 events:65 errors:0
TX bytes:762 acl:0 sco:0 commands:57 errors:0
Features: 0xff 0xff 0x8f 0xfe 0x9b 0xff 0x79 0x83
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF PARK
Link mode: SLAVE ACCEPT
Name: 'n-0'
Class: 0x400100
Service Classes: Telephony
Device Class: Computer, Uncategorized
HCI Version: 2.1 (0x4) Revision: 0x5259
LMP Version: 2.1 (0x4) Subversion: 0x424c
Manufacturer: Broadcom Corporation (15)
rgs,
Kevin
^ permalink raw reply
* Re: PSCAN and ISCAN flags in hciconfig
From: Frederic Danis @ 2012-12-16 21:10 UTC (permalink / raw)
To: Kevin Wilson; +Cc: linux-bluetooth
In-Reply-To: <CAGXs5wWXOLpn1O77RMiQ-Cvp3vXEKm3KCbRvz07dN6jJwFoe-A@mail.gmail.com>
On 16/12/2012 18:58, Kevin Wilson wrote:
> Hello,
> I have 2 PC with Linux which once used to recognize each other by
> "hcitool scan" and to create
> a PAND-based connection.
>
> Now I fail to see each other with "hcitool scan".
> My question is :
> I see now only the PSCAN flag when running "hciconfig" on both of then.
> Is the ISCAN flag (inquiry) mandatory so that a device will be discoverable ?
Yes, ISCAN means that your adapter will respond to inquiry scan, so it
will be discoverable.
Regards
Fred
--
Frederic Danis Open Source Technology Center
frederic.danis@intel.com Intel Corporation
^ permalink raw reply
* Re: [PATCH v5 00/16] mSBC tests
From: Siarhei Siamashka @ 2012-12-17 0:33 UTC (permalink / raw)
To: Frédéric Dalleau; +Cc: linux-bluetooth
In-Reply-To: <1355497417-10357-1-git-send-email-frederic.dalleau@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 2455 bytes --]
On Fri, 14 Dec 2012 16:03:21 +0100
Frédéric Dalleau <frederic.dalleau@linux.intel.com> wrote:
> Hi,
>
> v5 shoudl fix the few remaining issues. I could test neon and armv6
> and raised verbosity of commit messages.
Thanks for the update. The verbose commit messages make a really big
difference.
> However, before releasing a new version of the library, I believe we should
> write some sort of automated testing and test against another implementation.
> Siarhei shared a script some time ago, it could be a good start.
> But where could we store some decent audio materials? Should we use generators
> like sine wave, or just record ambient sound??
It is a good idea to make use of autotools test framework (a simple
one, not dejagnu based):
http://www.gnu.org/software/automake/manual/html_node/Tests.html
The tests could generate some deterministic pseudorandom data and
encode it with the sbc encoder.
Testing for potential overflows and the other bugs in the code is quite
effective with the plain uniformly distributed random data. The
checksums (CRC32 or some cryptographic hashes) can be calculated for
the encoded data and compared with the reference values. This test
ensures that the code works exactly as it used to work before (no
regressions, no improvements).
Additionally some sine waves (or more complex signals consisting
of multiple pseudorandom sine waves) can be used for one more test,
which could check the errors accumulated for the encoding/decoding
roundtrip.
And finally, an integrated benchmark would be also useful in this
sbc test framework. Compressing/decompressing white noise may not
provide relevant results, but maybe some sine waves can be selected
which represent more "realistic" audio data. Or one can be compared
to each other, and if there are no significant differences in
performance for different data, then it's easier for us.
An example of an autotools based test framework employing pseudorandom
data generation and checksums verification can be found in the pixman
library:
http://cgit.freedesktop.org/pixman
Coincidentally, I looked into pseudorandom number generators recently
and found this one to be quite good:
http://burtleburtle.net/bob/rand/smallprng.html
As for comparing with the reference sbc encoder/decoder (win32
binary), I used to have one more script. It is attached.
--
Best regards,
Siarhei Siamashka
[-- Attachment #2: sbc_encode_test.rb --]
[-- Type: application/x-ruby, Size: 3067 bytes --]
^ permalink raw reply
* Re: PSCAN and ISCAN flags in hciconfig
From: Kevin Wilson @ 2012-12-17 3:37 UTC (permalink / raw)
To: Frederic Danis; +Cc: linux-bluetooth
In-Reply-To: <50CE38D1.8010303@linux.intel.com>
Hi,
Thanks Frederic.
Ok, so I rebooted the machine and still
hciconfig shows:
UP RUNNING PSCAN
and also after 'hciconfig hci0 reset"
It stays "UP RUNNING PSCAN".
So what sould I do to make the ISCAN flag set ?
systemctl status bluetooth.service
shows that it is "active (running)"
rgs,
Kevin
On Sun, Dec 16, 2012 at 11:10 PM, Frederic Danis
<frederic.danis@linux.intel.com> wrote:
> On 16/12/2012 18:58, Kevin Wilson wrote:
>>
>> Hello,
>> I have 2 PC with Linux which once used to recognize each other by
>> "hcitool scan" and to create
>> a PAND-based connection.
>>
>> Now I fail to see each other with "hcitool scan".
>> My question is :
>> I see now only the PSCAN flag when running "hciconfig" on both of then.
>> Is the ISCAN flag (inquiry) mandatory so that a device will be
>> discoverable ?
>
>
> Yes, ISCAN means that your adapter will respond to inquiry scan, so it will
> be discoverable.
>
> Regards
>
> Fred
>
> --
> Frederic Danis Open Source Technology Center
> frederic.danis@intel.com Intel Corporation
>
^ permalink raw reply
* Re: PSCAN and ISCAN flags in hciconfig
From: Andrei Emeltchenko @ 2012-12-17 9:02 UTC (permalink / raw)
To: Kevin Wilson; +Cc: Frederic Danis, linux-bluetooth
In-Reply-To: <CAGXs5wXfwHME+XpVUq4rMmK_u=Sw2qG_snCC6iLEbKBYeZ0VTA@mail.gmail.com>
Hi Kevin
On Mon, Dec 17, 2012 at 05:37:09AM +0200, Kevin Wilson wrote:
> Hi,
> Thanks Frederic.
> Ok, so I rebooted the machine and still
> hciconfig shows:
> UP RUNNING PSCAN
> and also after 'hciconfig hci0 reset"
> It stays "UP RUNNING PSCAN".
>
> So what sould I do to make the ISCAN flag set ?
hciconfig hciX piscan
Best regards
Andrei Emeltchenko
>
> systemctl status bluetooth.service
> shows that it is "active (running)"
>
> rgs,
> Kevin
>
>
> On Sun, Dec 16, 2012 at 11:10 PM, Frederic Danis
> <frederic.danis@linux.intel.com> wrote:
> > On 16/12/2012 18:58, Kevin Wilson wrote:
> >>
> >> Hello,
> >> I have 2 PC with Linux which once used to recognize each other by
> >> "hcitool scan" and to create
> >> a PAND-based connection.
> >>
> >> Now I fail to see each other with "hcitool scan".
> >> My question is :
> >> I see now only the PSCAN flag when running "hciconfig" on both of then.
> >> Is the ISCAN flag (inquiry) mandatory so that a device will be
> >> discoverable ?
> >
> >
> > Yes, ISCAN means that your adapter will respond to inquiry scan, so it will
> > be discoverable.
> >
> > Regards
> >
> > Fred
> >
> > --
> > Frederic Danis Open Source Technology Center
> > frederic.danis@intel.com Intel Corporation
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH BlueZ] gdbus: Fix crash error when calling g_dbus_remove_all_watches
From: Tomasz Bursztyka @ 2012-12-17 11:33 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <20121128122318.GA30710@x220.ger.corp.intel.com>
Hi Johan,
this bug never hasn't hit anyone since the function
g_dbus_remove_all_watches() is not used anywhere (but in my project)
I will resend the patch with the backtrace.
Tomasz
> It seems this patch never got applied. Is it so that no-one else has
> seen the issue. Could someone (through basic static analysis) confirm if
> the patch is correct? It'd be nice if we could also have a back trace of
> the crash in the commit message.
>
> Johan
>
^ permalink raw reply
* [PATCH BlueZ 1/5] obexd: Port session interface to use D-Bus Properties
From: Luiz Augusto von Dentz @ 2012-12-17 11:50 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
doc/obexd-api.txt | 12 ++++--------
obexd/src/manager.c | 50 ++++++++++++++++++--------------------------------
2 files changed, 22 insertions(+), 40 deletions(-)
diff --git a/doc/obexd-api.txt b/doc/obexd-api.txt
index 680febe..53e61f5 100644
--- a/doc/obexd-api.txt
+++ b/doc/obexd-api.txt
@@ -74,14 +74,10 @@ Service org.bluez.obex
Interface org.bluez.obex.Session
Object path /session{0, 1, 2, ...}
-Methods
- dict GetProperties()
-
-
-Signals TBD
+Properties string Target [readonly]
+ Target UUID
-Properties
- string Address [readonly]
+ string Root [readonly]
- Bluetooth device address or USB
+ Root path
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 02dc999..85aa965 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -255,42 +255,29 @@ static char *target2str(const uint8_t *t)
t[8], t[9], t[10], t[11], t[12], t[13], t[14], t[15]);
}
-static DBusMessage *get_properties(DBusConnection *conn,
- DBusMessage *msg, void *data)
+static gboolean get_target(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
{
struct obex_session *os = data;
- DBusMessage *reply;
- DBusMessageIter iter;
- DBusMessageIter dict;
char *uuid;
- const char *root;
-
- reply = dbus_message_new_method_return(msg);
- if (!reply)
- return NULL;
- dbus_message_iter_init_append(reply, &iter);
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
- DBUS_TYPE_STRING_AS_STRING DBUS_TYPE_VARIANT_AS_STRING
- DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &dict);
-
- /* Target */
uuid = target2str(os->service->target);
- dbus_message_iter_append_dict_entry(&dict, "Target",
- DBUS_TYPE_STRING, &uuid);
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &uuid);
g_free(uuid);
- /* Root folder */
- root = obex_option_root_folder();
- dbus_message_iter_append_dict_entry(&dict, "Root",
- DBUS_TYPE_STRING, &root);
+ return TRUE;
+}
- /* FIXME: Added Remote Address or USB */
+static gboolean get_root(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct obex_session *os = data;
+ const char *root;
- dbus_message_iter_close_container(&iter, &dict);
+ root = obex_option_root_folder();
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &root);
- return reply;
+ return TRUE;
}
static DBusMessage *transfer_cancel(DBusConnection *connection,
@@ -339,10 +326,9 @@ static const GDBusSignalTable transfer_signals[] = {
{ }
};
-static const GDBusMethodTable session_methods[] = {
- { GDBUS_METHOD("GetProperties",
- NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
- get_properties) },
+static const GDBusPropertyTable session_properties[] = {
+ { "Target", "s", get_target },
+ { "Root", "s", get_root },
{ }
};
@@ -610,8 +596,8 @@ void manager_register_session(struct obex_session *os)
if (!g_dbus_register_interface(connection, path,
SESSION_INTERFACE,
- session_methods, NULL,
- NULL, os, NULL)) {
+ NULL, NULL,
+ session_properties, os, NULL)) {
error("Cannot register Session interface.");
goto done;
}
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 2/5] obexd: Enable ObjectManager
From: Luiz Augusto von Dentz @ 2012-12-17 11:50 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1355745007-1493-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
obexd/src/manager.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 85aa965..034f6ab 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -350,6 +350,8 @@ gboolean manager_init(void)
return FALSE;
}
+ g_dbus_attach_object_manager(connection);
+
return g_dbus_register_interface(connection, OBEX_MANAGER_PATH,
OBEX_MANAGER_INTERFACE,
manager_methods, manager_signals, NULL,
@@ -368,6 +370,8 @@ void manager_cleanup(void)
if (agent)
agent_free(agent);
+ g_dbus_detach_object_manager(connection);
+
dbus_connection_unref(connection);
}
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 3/5] obexd: Remove SessionCreated and SessionRemoved signals
From: Luiz Augusto von Dentz @ 2012-12-17 11:50 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1355745007-1493-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
With ObjectManager these signals no longer are necessary.
---
doc/obexd-api.txt | 12 +-----------
obexd/src/manager.c | 12 ------------
2 files changed, 1 insertion(+), 23 deletions(-)
diff --git a/doc/obexd-api.txt b/doc/obexd-api.txt
index 53e61f5..822157d 100644
--- a/doc/obexd-api.txt
+++ b/doc/obexd-api.txt
@@ -29,17 +29,7 @@ Methods
Possible errors: org.bluez.obex.Error.DoesNotExist
-Signals SessionCreated(object session)
-
- Signal sent when OBEX connection has been accepted.
- (FTP only)
-
- SessionRemoved(object session)
-
- Sent when the transport is disconnected
- (FTP only)
-
- TransferStarted(object transfer)
+Signals TransferStarted(object transfer)
Signal sent when an object push operation starts.
(OPP only)
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 034f6ab..c585aa1 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -310,8 +310,6 @@ static const GDBusSignalTable manager_signals[] = {
{ GDBUS_SIGNAL("TransferStarted", GDBUS_ARGS({ "transfer", "o"})) },
{ GDBUS_SIGNAL("TransferCompleted", GDBUS_ARGS({ "transfer", "o" },
{ "success", "b" })) },
- { GDBUS_SIGNAL("SessionCreated", GDBUS_ARGS({ "session", "o" })) },
- { GDBUS_SIGNAL("SessionRemoved", GDBUS_ARGS({ "session", "o" })) },
{ }
};
@@ -606,11 +604,6 @@ void manager_register_session(struct obex_session *os)
goto done;
}
- g_dbus_emit_signal(connection, OBEX_MANAGER_PATH,
- OBEX_MANAGER_INTERFACE, "SessionCreated",
- DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-
done:
g_free(path);
}
@@ -619,11 +612,6 @@ void manager_unregister_session(struct obex_session *os)
{
char *path = g_strdup_printf("/session%u", GPOINTER_TO_UINT(os));
- g_dbus_emit_signal(connection, OBEX_MANAGER_PATH,
- OBEX_MANAGER_INTERFACE, "SessionRemoved",
- DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-
g_dbus_unregister_interface(connection, path,
SESSION_INTERFACE);
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 4/5] obex-client: Enable ObjectManager
From: Luiz Augusto von Dentz @ 2012-12-17 11:50 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1355745007-1493-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
obexd/client/manager.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/obexd/client/manager.c b/obexd/client/manager.c
index 7a7c33f..4929383 100644
--- a/obexd/client/manager.c
+++ b/obexd/client/manager.c
@@ -269,6 +269,8 @@ int manager_init(void)
return -1;
}
+ g_dbus_attach_object_manager(conn);
+
if (g_dbus_register_interface(conn, CLIENT_PATH, CLIENT_INTERFACE,
client_methods, NULL, NULL,
NULL, NULL) == FALSE) {
@@ -299,5 +301,6 @@ void manager_exit(void)
module->exit();
g_dbus_unregister_interface(conn, CLIENT_PATH, CLIENT_INTERFACE);
+ g_dbus_detach_object_manager(conn);
dbus_connection_unref(conn);
}
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 5/5] TODO: Mark Convert obexd & obex-client to ObjectManager/Properties as done
From: Luiz Augusto von Dentz @ 2012-12-17 11:50 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1355745007-1493-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
TODO | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/TODO b/TODO
index d9a708b..5a70e40 100644
--- a/TODO
+++ b/TODO
@@ -60,8 +60,6 @@ BlueZ 5
Priority/Complexity omitted as all items are required before 5.0 is
released.
-- Convert obexd & obex-client to ObjectManager/Properties
-
- [pending] Convert storage to user per-remote device directories and
ini-file format
@@ -87,6 +85,8 @@ Completed items:
- Convert obexd to use org.bluez.Profile
+- Convert obexd & obex-client to ObjectManager/Properties
+
- Remove org.bluez.Service interface (it has become unnecessary thanks
to org.bluez.Profile). obexd needs to be converted to use the new
interface first.
--
1.7.11.7
^ permalink raw reply related
* Re: [PATCH BlueZ 1/5] obexd: Port session interface to use D-Bus Properties
From: Johan Hedberg @ 2012-12-17 12:11 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1355745007-1493-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Mon, Dec 17, 2012, Luiz Augusto von Dentz wrote:
> ---
> doc/obexd-api.txt | 12 ++++--------
> obexd/src/manager.c | 50 ++++++++++++++++++--------------------------------
> 2 files changed, 22 insertions(+), 40 deletions(-)
All patches in this set have been applied. Thanks.
Johan
^ permalink raw reply
* [PATCH BlueZ 1/2] obex-client: Make use of g_dbus_get_properties to get transfer properties
From: Luiz Augusto von Dentz @ 2012-12-17 13:25 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In addition fix the reply generated by obc_transfer_create_dbus_reply to
not use a structure container instead use object, dict 'oa{sv}' as
indicated in the documentation.
---
obexd/client/transfer.c | 46 ++++------------------------------------------
1 file changed, 4 insertions(+), 42 deletions(-)
diff --git a/obexd/client/transfer.c b/obexd/client/transfer.c
index 29d61f3..fc3f87b 100644
--- a/obexd/client/transfer.c
+++ b/obexd/client/transfer.c
@@ -97,47 +97,6 @@ static void obc_transfer_append_dbus_properties(struct obc_transfer *transfer,
&transfer->progress);
}
-static DBusMessage *obc_transfer_get_properties(DBusConnection *connection,
- DBusMessage *message, void *user_data)
-{
- struct obc_transfer *transfer = user_data;
- DBusMessage *reply;
- DBusMessageIter iter, dict;
-
- reply = dbus_message_new_method_return(message);
- if (!reply)
- return NULL;
-
- dbus_message_iter_init_append(reply, &iter);
- dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
- OBC_PROPERTIES_ARRAY_SIGNATURE,
- &dict);
-
- obc_transfer_append_dbus_properties(transfer, &dict);
-
- dbus_message_iter_close_container(&iter, &dict);
-
- return reply;
-}
-
-static void obc_transfer_append_dbus_data(struct obc_transfer *transfer,
- DBusMessageIter *iter)
-{
- const char *path = transfer->path;
- DBusMessageIter entry, dict;
-
- dbus_message_iter_open_container(iter, DBUS_TYPE_STRUCT, NULL, &entry);
- dbus_message_iter_append_basic(&entry, DBUS_TYPE_OBJECT_PATH, &path);
- dbus_message_iter_open_container(&entry, DBUS_TYPE_ARRAY,
- OBC_PROPERTIES_ARRAY_SIGNATURE,
- &dict);
-
- obc_transfer_append_dbus_properties(transfer, &dict);
-
- dbus_message_iter_close_container(&entry, &dict);
- dbus_message_iter_close_container(iter, &entry);
-}
-
DBusMessage *obc_transfer_create_dbus_reply(struct obc_transfer *transfer,
DBusMessage *message)
{
@@ -149,7 +108,10 @@ DBusMessage *obc_transfer_create_dbus_reply(struct obc_transfer *transfer,
return NULL;
dbus_message_iter_init_append(reply, &iter);
- obc_transfer_append_dbus_data(transfer, &iter);
+ dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH,
+ &transfer->path);
+ g_dbus_get_properties(transfer->conn, transfer->path,
+ TRANSFER_INTERFACE, &iter);
return reply;
}
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 2/2] test: Fix pbap-client to handle PullAll reply properly
From: Luiz Augusto von Dentz @ 2012-12-17 13:25 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1355750727-23222-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
PullAll reply consist in 2 parameters, the transfer object followed by
its properties not a structure containing both.
---
test/pbap-client | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/test/pbap-client b/test/pbap-client
index fbe930c..7be8bad 100755
--- a/test/pbap-client
+++ b/test/pbap-client
@@ -33,8 +33,7 @@ class PbapClient:
signal_name="Error",
path_keyword="path")
- def register(self, reply, transfer):
- (path, properties) = reply
+ def register(self, path, properties, transfer):
transfer.path = path
transfer.filename = properties["Filename"]
self.props[path] = transfer
@@ -73,15 +72,15 @@ class PbapClient:
def pull(self, vcard, params, func):
req = Transfer(func)
self.pbap.Pull(vcard, "", params,
- reply_handler=lambda r: self.register(r, req),
- error_handler=self.error)
+ reply_handler=lambda o, p: self.register(o, p, req),
+ error_handler=self.error)
self.transfers += 1
def pull_all(self, params, func):
req = Transfer(func)
self.pbap.PullAll("", params,
- reply_handler=lambda r: self.register(r, req),
- error_handler=self.error)
+ reply_handler=lambda o, p: self.register(o, p, req),
+ error_handler=self.error)
self.transfers += 1
def flush_transfers(self, func):
--
1.7.11.7
^ permalink raw reply related
* Re: [PATCH BlueZ 1/2] obex-client: Make use of g_dbus_get_properties to get transfer properties
From: Johan Hedberg @ 2012-12-17 14:32 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1355750727-23222-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Mon, Dec 17, 2012, Luiz Augusto von Dentz wrote:
> In addition fix the reply generated by obc_transfer_create_dbus_reply to
> not use a structure container instead use object, dict 'oa{sv}' as
> indicated in the documentation.
> ---
> obexd/client/transfer.c | 46 ++++------------------------------------------
> 1 file changed, 4 insertions(+), 42 deletions(-)
Both patches have been applied. Thanks.
Johan
^ permalink raw reply
* [PATCH 01/11] adapter: Rename btd_adapter *up members to *powered
From: Szymon Janc @ 2012-12-17 14:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This better describes those members purpose.
---
src/adapter.c | 36 ++++++++++++++++++------------------
src/adapter.h | 2 +-
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index d9b841d..f56b000 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -120,8 +120,8 @@ struct discovery {
struct btd_adapter {
uint16_t dev_id;
- gboolean up;
- gboolean already_up;
+ gboolean powered;
+ gboolean already_powered;
char *path; /* adapter object path */
bdaddr_t bdaddr; /* adapter Bluetooth Address */
uint32_t dev_class; /* Class of Device */
@@ -322,7 +322,7 @@ static int set_mode(struct btd_adapter *adapter, uint8_t new_mode)
if (adapter->pending_mode != NULL)
return -EALREADY;
- if (!adapter->up && new_mode != MODE_OFF) {
+ if (!adapter->powered && new_mode != MODE_OFF) {
err = mgmt_set_powered(adapter->dev_id, TRUE);
if (err < 0)
return err;
@@ -330,7 +330,7 @@ static int set_mode(struct btd_adapter *adapter, uint8_t new_mode)
goto done;
}
- if (adapter->up && new_mode == MODE_OFF) {
+ if (adapter->powered && new_mode == MODE_OFF) {
err = mgmt_set_powered(adapter->dev_id, FALSE);
if (err < 0)
return err;
@@ -597,7 +597,7 @@ static void stop_discovery(struct btd_adapter *adapter)
return;
}
- if (adapter->up)
+ if (adapter->powered)
mgmt_stop_discovery(adapter->dev_id);
else
discovery_cleanup(adapter);
@@ -1022,7 +1022,7 @@ static DBusMessage *adapter_start_discovery(DBusConnection *conn,
const char *sender = dbus_message_get_sender(msg);
int err;
- if (!adapter->up)
+ if (!adapter->powered)
return btd_error_not_ready(msg);
req = find_session(adapter->disc_sessions, sender);
@@ -1057,7 +1057,7 @@ static DBusMessage *adapter_stop_discovery(DBusConnection *conn,
struct session_req *req;
const char *sender = dbus_message_get_sender(msg);
- if (!adapter->up)
+ if (!adapter->powered)
return btd_error_not_ready(msg);
req = find_session(adapter->disc_sessions, sender);
@@ -1132,7 +1132,7 @@ static gboolean adapter_property_get_powered(
struct btd_adapter *adapter = data;
dbus_bool_t value;
- value = (adapter->up && !adapter->off_requested) ? TRUE : FALSE;
+ value = (adapter->powered && !adapter->off_requested) ? TRUE : FALSE;
dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &value);
return TRUE;
@@ -1740,7 +1740,7 @@ void adapter_connect_list_add(struct btd_adapter *adapter,
DBG("%s added to %s's connect_list", device_get_path(device),
adapter->name);
- if (!adapter->up)
+ if (!adapter->powered)
return;
if (adapter->off_requested)
@@ -1778,7 +1778,7 @@ void btd_adapter_start(struct btd_adapter *adapter)
struct session_req *req;
adapter->off_requested = FALSE;
- adapter->up = TRUE;
+ adapter->powered = TRUE;
if (adapter->scan_mode & SCAN_INQUIRY) {
adapter->mode = MODE_DISCOVERABLE;
@@ -1911,7 +1911,7 @@ int btd_adapter_stop(struct btd_adapter *adapter)
/* check pending requests */
reply_pending_requests(adapter);
- adapter->up = FALSE;
+ adapter->powered = FALSE;
if (adapter->discovery) {
emit_discovering = true;
@@ -2781,12 +2781,12 @@ static void load_config(struct btd_adapter *adapter)
g_key_file_free(key_file);
}
-gboolean adapter_init(struct btd_adapter *adapter, gboolean up)
+gboolean adapter_init(struct btd_adapter *adapter, gboolean powered)
{
struct agent *agent;
- adapter->up = up;
- adapter->already_up = up;
+ adapter->powered = powered;
+ adapter->already_powered = powered;
adapter->allow_name_changes = TRUE;
@@ -2877,7 +2877,7 @@ void adapter_remove(struct btd_adapter *adapter)
g_slist_free(adapter->pin_callbacks);
/* Return adapter to down state if it was not up on init */
- if (!adapter->already_up && adapter->up)
+ if (!adapter->already_powered && adapter->powered)
mgmt_set_powered(adapter->dev_id, FALSE);
}
@@ -3445,7 +3445,7 @@ int btd_cancel_authorization(guint id)
int btd_adapter_restore_powered(struct btd_adapter *adapter)
{
- if (adapter->up)
+ if (adapter->powered)
return 0;
if (adapter->mode == MODE_OFF)
@@ -3487,7 +3487,7 @@ ssize_t btd_adapter_get_pin(struct btd_adapter *adapter, struct btd_device *dev,
int btd_adapter_set_fast_connectable(struct btd_adapter *adapter,
gboolean enable)
{
- if (!adapter->up)
+ if (!adapter->powered)
return -EINVAL;
return mgmt_set_fast_connectable(adapter->dev_id, enable);
@@ -3497,7 +3497,7 @@ int btd_adapter_read_clock(struct btd_adapter *adapter, const bdaddr_t *bdaddr,
int which, int timeout, uint32_t *clock,
uint16_t *accuracy)
{
- if (!adapter->up)
+ if (!adapter->powered)
return -EINVAL;
return mgmt_read_clock(adapter->dev_id, bdaddr, which,
diff --git a/src/adapter.h b/src/adapter.h
index 5030cb0..3b2d14f 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -100,7 +100,7 @@ void adapter_remove_device(struct btd_adapter *adapter,
gboolean remove_storage);
struct btd_adapter *adapter_create(int id);
-gboolean adapter_init(struct btd_adapter *adapter, gboolean up);
+gboolean adapter_init(struct btd_adapter *adapter, gboolean powered);
void adapter_remove(struct btd_adapter *adapter);
void adapter_set_allow_name_changes(struct btd_adapter *adapter,
gboolean allow_name_changes);
--
1.8.0
^ permalink raw reply related
* [PATCH 02/11] manager: Rename btd_manager_register_adapter up parameter to powered
From: Szymon Janc @ 2012-12-17 14:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1355755498-2700-1-git-send-email-szymon.janc@tieto.com>
Match parameter name to adapter_init parameter name.
---
src/manager.c | 4 ++--
src/manager.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/manager.c b/src/manager.c
index 1f4b831..22e593d 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -156,7 +156,7 @@ GSList *manager_get_adapters(void)
return adapters;
}
-struct btd_adapter *btd_manager_register_adapter(int id, gboolean up)
+struct btd_adapter *btd_manager_register_adapter(int id, gboolean powered)
{
struct btd_adapter *adapter;
const char *path;
@@ -173,7 +173,7 @@ struct btd_adapter *btd_manager_register_adapter(int id, gboolean up)
adapters = g_slist_append(adapters, adapter);
- if (!adapter_init(adapter, up)) {
+ if (!adapter_init(adapter, powered)) {
adapters = g_slist_remove(adapters, adapter);
btd_adapter_unref(adapter);
return NULL;
diff --git a/src/manager.h b/src/manager.h
index fdaabfd..a2b8c31 100644
--- a/src/manager.h
+++ b/src/manager.h
@@ -35,5 +35,5 @@ struct btd_adapter *manager_find_adapter_by_id(int id);
struct btd_adapter *manager_get_default_adapter(void);
void manager_foreach_adapter(adapter_cb func, gpointer user_data);
GSList *manager_get_adapters(void);
-struct btd_adapter *btd_manager_register_adapter(int id, gboolean up);
+struct btd_adapter *btd_manager_register_adapter(int id, gboolean powered);
int btd_manager_unregister_adapter(int id);
--
1.8.0
^ permalink raw reply related
* [PATCH 03/11] adapter: Make adapter_mode_changed accept mode as bool params
From: Szymon Janc @ 2012-12-17 14:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1355755498-2700-1-git-send-email-szymon.janc@tieto.com>
Pass connectable and discoverable as bools.
---
src/adapter.c | 19 ++++++++++++++++++-
src/adapter.h | 3 ++-
src/mgmt.c | 19 ++++---------------
3 files changed, 24 insertions(+), 17 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index f56b000..e50e646 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3151,9 +3151,26 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
}
}
-void adapter_mode_changed(struct btd_adapter *adapter, uint8_t scan_mode)
+static uint8_t create_mode(bool connectable, bool discoverable)
+{
+ uint8_t mode = 0;
+
+ if (connectable)
+ mode |= SCAN_PAGE;
+
+ if (discoverable)
+ mode |= SCAN_INQUIRY;
+
+ return mode;
+}
+
+void adapter_mode_changed(struct btd_adapter *adapter, bool connectable,
+ bool discoverable)
{
bool emit_pairable = false;
+ uint8_t scan_mode;
+
+ scan_mode = create_mode(connectable, discoverable);
DBG("old 0x%02x new 0x%02x", adapter->scan_mode, scan_mode);
diff --git a/src/adapter.h b/src/adapter.h
index 3b2d14f..7c20e29 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -114,7 +114,8 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
uint8_t bdaddr_type, int8_t rssi,
bool confirm_name, bool legacy,
uint8_t *data, uint8_t data_len);
-void adapter_mode_changed(struct btd_adapter *adapter, uint8_t scan_mode);
+void adapter_mode_changed(struct btd_adapter *adapter, bool connectable,
+ bool discoverable);
int adapter_set_name(struct btd_adapter *adapter, const char *name);
void adapter_name_changed(struct btd_adapter *adapter, const char *name);
void adapter_service_insert(struct btd_adapter *adapter, void *rec);
diff --git a/src/mgmt.c b/src/mgmt.c
index dfcf558..cc54e8b 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -328,19 +328,6 @@ static inline int mgmt_low_energy(uint32_t settings)
return (settings & MGMT_SETTING_LE) != 0;
}
-static uint8_t create_mode(uint32_t settings)
-{
- uint8_t mode = 0;
-
- if (mgmt_connectable(settings))
- mode |= SCAN_PAGE;
-
- if (mgmt_discoverable(settings))
- mode |= SCAN_INQUIRY;
-
- return mode;
-}
-
static void update_settings(struct btd_adapter *adapter, uint32_t settings)
{
struct controller_info *info;
@@ -356,7 +343,8 @@ static void update_settings(struct btd_adapter *adapter, uint32_t settings)
info = &controllers[index];
if (mgmt_powered(settings))
- adapter_mode_changed(adapter, create_mode(settings));
+ adapter_mode_changed(adapter, mgmt_connectable(settings),
+ mgmt_discoverable(settings));
if (mgmt_pairable(settings) != pairable)
mgmt_set_pairable(index, pairable);
@@ -434,7 +422,8 @@ static void mgmt_new_settings(int sk, uint16_t index, void *buf, size_t len)
if (new_power != old_power)
mgmt_update_powered(adapter, info, settings);
else if (new_power && mode_changed(settings, info->current_settings))
- adapter_mode_changed(adapter, create_mode(settings));
+ adapter_mode_changed(adapter, mgmt_connectable(settings),
+ mgmt_discoverable(settings));
old_pairable = mgmt_pairable(info->current_settings);
new_pairable = mgmt_pairable(settings);
--
1.8.0
^ permalink raw reply related
* [PATCH 04/11] adapter: Add btd_adapter_get_pairable function
From: Szymon Janc @ 2012-12-17 14:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1355755498-2700-1-git-send-email-szymon.janc@tieto.com>
Add btd_adapter_get_pairable and remove pairable argument from
btd_adapter_get_mode. Use btd_adapter_get_pairable to get pairable
state where needed.
---
plugins/neard.c | 6 +-----
src/adapter.c | 9 +++++----
src/adapter.h | 5 +++--
src/mgmt.c | 6 ++++--
4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index a8c12fd..e1f3583 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -593,17 +593,13 @@ static int process_params(DBusMessage *msg, struct btd_adapter *adapter,
static int check_adapter(struct btd_adapter *adapter)
{
- gboolean pairable;
-
if (!adapter)
return -ENOENT;
if (btd_adapter_check_oob_handler(adapter))
return -EINPROGRESS;
- btd_adapter_get_mode(adapter, NULL, NULL, &pairable);
-
- if (!pairable || !adapter_get_agent(adapter))
+ if (!btd_adapter_get_pairable(adapter) || !adapter_get_agent(adapter))
return -ENONET;
if (!btd_adapter_ssp_enabled(adapter))
diff --git a/src/adapter.c b/src/adapter.c
index e50e646..8f1c229 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1694,17 +1694,18 @@ static void load_connections(struct btd_adapter *adapter)
}
void btd_adapter_get_mode(struct btd_adapter *adapter, uint8_t *mode,
- uint16_t *discoverable_timeout,
- gboolean *pairable)
+ uint16_t *discoverable_timeout)
{
if (mode)
*mode = adapter->mode;
if (discoverable_timeout)
*discoverable_timeout = adapter->discov_timeout;
+}
- if (pairable)
- *pairable = adapter->pairable;
+bool btd_adapter_get_pairable(struct btd_adapter *adapter)
+{
+ return adapter->pairable;
}
void btd_adapter_get_major_minor(struct btd_adapter *adapter, uint8_t *major,
diff --git a/src/adapter.h b/src/adapter.h
index 7c20e29..125657a 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -81,8 +81,9 @@ void btd_adapter_start(struct btd_adapter *adapter);
int btd_adapter_stop(struct btd_adapter *adapter);
void btd_adapter_get_mode(struct btd_adapter *adapter, uint8_t *mode,
- uint16_t *discoverable_timeout,
- gboolean *pairable);
+ uint16_t *discoverable_timeout);
+
+bool btd_adapter_get_pairable(struct btd_adapter *adapter);
void btd_adapter_get_major_minor(struct btd_adapter *adapter, uint8_t *major,
uint8_t *minor);
diff --git a/src/mgmt.c b/src/mgmt.c
index cc54e8b..feca194 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -336,7 +336,7 @@ static void update_settings(struct btd_adapter *adapter, uint32_t settings)
DBG("new settings %x", settings);
- btd_adapter_get_mode(adapter, NULL, &discoverable_timeout, &pairable);
+ btd_adapter_get_mode(adapter, NULL, &discoverable_timeout);
index = adapter_get_dev_id(adapter);
@@ -346,6 +346,8 @@ static void update_settings(struct btd_adapter *adapter, uint32_t settings)
adapter_mode_changed(adapter, mgmt_connectable(settings),
mgmt_discoverable(settings));
+ pairable = btd_adapter_get_pairable(adapter);
+
if (mgmt_pairable(settings) != pairable)
mgmt_set_pairable(index, pairable);
@@ -1213,7 +1215,7 @@ static void read_info_complete(int sk, uint16_t index, void *buf, size_t len)
btd_adapter_get_major_minor(adapter, &major, &minor);
mgmt_set_dev_class(index, major, minor);
- btd_adapter_get_mode(adapter, &mode, NULL, NULL);
+ btd_adapter_get_mode(adapter, &mode, NULL);
if (mode == MODE_OFF && mgmt_powered(info->current_settings)) {
mgmt_set_powered(index, FALSE);
return;
--
1.8.0
^ permalink raw reply related
* [PATCH 05/11] adapter: Remove not used parameter from btd_adapter_get_mode
From: Szymon Janc @ 2012-12-17 14:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1355755498-2700-1-git-send-email-szymon.janc@tieto.com>
discoverable_timeout is not used outside of adapter code.
---
src/adapter.c | 6 +-----
src/adapter.h | 3 +--
src/mgmt.c | 6 ++----
3 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 8f1c229..915d897 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1693,14 +1693,10 @@ static void load_connections(struct btd_adapter *adapter)
g_slist_free_full(conns, g_free);
}
-void btd_adapter_get_mode(struct btd_adapter *adapter, uint8_t *mode,
- uint16_t *discoverable_timeout)
+void btd_adapter_get_mode(struct btd_adapter *adapter, uint8_t *mode)
{
if (mode)
*mode = adapter->mode;
-
- if (discoverable_timeout)
- *discoverable_timeout = adapter->discov_timeout;
}
bool btd_adapter_get_pairable(struct btd_adapter *adapter)
diff --git a/src/adapter.h b/src/adapter.h
index 125657a..44ba56a 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -80,8 +80,7 @@ void btd_adapter_start(struct btd_adapter *adapter);
int btd_adapter_stop(struct btd_adapter *adapter);
-void btd_adapter_get_mode(struct btd_adapter *adapter, uint8_t *mode,
- uint16_t *discoverable_timeout);
+void btd_adapter_get_mode(struct btd_adapter *adapter, uint8_t *mode);
bool btd_adapter_get_pairable(struct btd_adapter *adapter);
diff --git a/src/mgmt.c b/src/mgmt.c
index feca194..3c7e014 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -332,12 +332,10 @@ static void update_settings(struct btd_adapter *adapter, uint32_t settings)
{
struct controller_info *info;
gboolean pairable;
- uint16_t index, discoverable_timeout;
+ uint16_t index;
DBG("new settings %x", settings);
- btd_adapter_get_mode(adapter, NULL, &discoverable_timeout);
-
index = adapter_get_dev_id(adapter);
info = &controllers[index];
@@ -1215,7 +1213,7 @@ static void read_info_complete(int sk, uint16_t index, void *buf, size_t len)
btd_adapter_get_major_minor(adapter, &major, &minor);
mgmt_set_dev_class(index, major, minor);
- btd_adapter_get_mode(adapter, &mode, NULL);
+ btd_adapter_get_mode(adapter, &mode);
if (mode == MODE_OFF && mgmt_powered(info->current_settings)) {
mgmt_set_powered(index, FALSE);
return;
--
1.8.0
^ permalink raw reply related
* [PATCH 06/11] adapter: Add connectable member to btd_adapter
From: Szymon Janc @ 2012-12-17 14:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1355755498-2700-1-git-send-email-szymon.janc@tieto.com>
This will be used to track if adapter is in connectable state.
---
src/adapter.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 915d897..473c9cf 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -153,6 +153,7 @@ struct btd_adapter {
guint auto_timeout_id; /* Automatic connections timeout */
sdp_list_t *services; /* Services associated to adapter */
+ bool connectable; /* connectable state */
gboolean discoverable; /* discoverable state */
gboolean pairable; /* pairable state */
gboolean initialized;
@@ -415,7 +416,7 @@ static void set_pairable(struct btd_adapter *adapter, gboolean pairable,
{
int err;
- if (adapter->scan_mode == SCAN_DISABLED)
+ if (!adapter->connectable)
return g_dbus_pending_property_error(id,
ERROR_INTERFACE ".NotReady",
"Resource Not Ready");
@@ -1785,6 +1786,8 @@ void btd_adapter_start(struct btd_adapter *adapter)
adapter->discoverable = FALSE;
}
+ adapter->connectable = true;
+
g_dbus_emit_property_changed(btd_get_dbus_connection(), adapter->path,
ADAPTER_INTERFACE, "Powered");
@@ -1928,10 +1931,12 @@ int btd_adapter_stop(struct btd_adapter *adapter)
if (adapter->scan_mode == (SCAN_PAGE | SCAN_INQUIRY))
emit_discoverable = true;
- if ((adapter->scan_mode & SCAN_PAGE) && adapter->pairable == TRUE)
+ if (adapter->connectable && adapter->pairable == TRUE)
emit_pairable = true;
adapter->scan_mode = SCAN_DISABLED;
+ adapter->connectable = false;
+
adapter->mode = MODE_OFF;
adapter->off_requested = FALSE;
@@ -3177,14 +3182,17 @@ void adapter_mode_changed(struct btd_adapter *adapter, bool connectable,
switch (scan_mode) {
case SCAN_DISABLED:
adapter->mode = MODE_OFF;
+ adapter->connectable = false;
break;
case SCAN_PAGE:
adapter->mode = MODE_CONNECTABLE;
adapter->discoverable = FALSE;
+ adapter->connectable = true;
break;
case (SCAN_PAGE | SCAN_INQUIRY):
adapter->mode = MODE_DISCOVERABLE;
adapter->discoverable = TRUE;
+ adapter->connectable = true;
break;
default:
/* ignore, reserved */
--
1.8.0
^ permalink raw reply related
* [PATCH 07/11] adapter: Use discoverable memeber instead of scan_mode
From: Szymon Janc @ 2012-12-17 14:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1355755498-2700-1-git-send-email-szymon.janc@tieto.com>
Where possible use discoverable memeber instead of checking scan_mode
against SCAN_INQUIRY flag.
---
src/adapter.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 473c9cf..2af0d4f 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -424,7 +424,7 @@ static void set_pairable(struct btd_adapter *adapter, gboolean pairable,
if (pairable == adapter->pairable)
goto done;
- if (!(adapter->scan_mode & SCAN_INQUIRY))
+ if (!adapter->discoverable)
goto store;
err = set_mode(adapter, MODE_DISCOVERABLE);
@@ -687,7 +687,7 @@ static void set_discoverable_timeout(struct btd_adapter *adapter,
if (adapter->discov_timeout == timeout && timeout == 0)
return g_dbus_pending_property_success(id);
- if (adapter->scan_mode & SCAN_INQUIRY)
+ if (adapter->discoverable)
mgmt_set_discoverable(adapter->dev_id, TRUE, timeout);
adapter->discov_timeout = timeout;
@@ -1163,7 +1163,7 @@ static gboolean adapter_property_get_discoverable(
struct btd_adapter *adapter = data;
dbus_bool_t value;
- value = adapter->scan_mode & SCAN_INQUIRY ? TRUE : FALSE;
+ value = adapter->discoverable ? TRUE : FALSE;
dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &value);
return TRUE;
@@ -1928,7 +1928,7 @@ int btd_adapter_stop(struct btd_adapter *adapter)
adapter_remove_connection(adapter, device);
}
- if (adapter->scan_mode == (SCAN_PAGE | SCAN_INQUIRY))
+ if (adapter->discoverable)
emit_discoverable = true;
if (adapter->connectable && adapter->pairable == TRUE)
@@ -3183,6 +3183,7 @@ void adapter_mode_changed(struct btd_adapter *adapter, bool connectable,
case SCAN_DISABLED:
adapter->mode = MODE_OFF;
adapter->connectable = false;
+ adapter->discoverable = FALSE;
break;
case SCAN_PAGE:
adapter->mode = MODE_CONNECTABLE;
--
1.8.0
^ permalink raw reply related
* [PATCH 08/11] adapter: Remove scan_mode member
From: Szymon Janc @ 2012-12-17 14:44 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1355755498-2700-1-git-send-email-szymon.janc@tieto.com>
This is not needed anymore as boolean flags can be used instead.
---
src/adapter.c | 68 +++++++++++++++--------------------------------------------
1 file changed, 17 insertions(+), 51 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 2af0d4f..e97e9bb 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -130,8 +130,6 @@ struct btd_adapter {
uint32_t discov_timeout; /* discoverable time(sec) */
guint pairable_timeout_id; /* pairable timeout id */
uint32_t pairable_timeout; /* pairable time(sec) */
- uint8_t scan_mode; /* scan mode: SCAN_DISABLED, SCAN_PAGE,
- * SCAN_INQUIRY */
uint8_t mode; /* off, connectable, discoverable,
* limited */
uint8_t global_mode; /* last valid global mode */
@@ -1778,16 +1776,6 @@ void btd_adapter_start(struct btd_adapter *adapter)
adapter->off_requested = FALSE;
adapter->powered = TRUE;
- if (adapter->scan_mode & SCAN_INQUIRY) {
- adapter->mode = MODE_DISCOVERABLE;
- adapter->discoverable = TRUE;
- } else {
- adapter->mode = MODE_CONNECTABLE;
- adapter->discoverable = FALSE;
- }
-
- adapter->connectable = true;
-
g_dbus_emit_property_changed(btd_get_dbus_connection(), adapter->path,
ADAPTER_INTERFACE, "Powered");
@@ -1934,7 +1922,7 @@ int btd_adapter_stop(struct btd_adapter *adapter)
if (adapter->connectable && adapter->pairable == TRUE)
emit_pairable = true;
- adapter->scan_mode = SCAN_DISABLED;
+ adapter->discoverable = FALSE;
adapter->connectable = false;
adapter->mode = MODE_OFF;
@@ -3155,56 +3143,34 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
static uint8_t create_mode(bool connectable, bool discoverable)
{
- uint8_t mode = 0;
-
- if (connectable)
- mode |= SCAN_PAGE;
+ if (connectable && discoverable)
+ return MODE_DISCOVERABLE;
- if (discoverable)
- mode |= SCAN_INQUIRY;
+ if (connectable && !discoverable)
+ return MODE_CONNECTABLE;
- return mode;
+ return MODE_OFF;
}
void adapter_mode_changed(struct btd_adapter *adapter, bool connectable,
bool discoverable)
{
- bool emit_pairable = false;
- uint8_t scan_mode;
-
- scan_mode = create_mode(connectable, discoverable);
+ bool emit_pairable;
- DBG("old 0x%02x new 0x%02x", adapter->scan_mode, scan_mode);
+ DBG("connectable %u (old %u) discoverable %u (old %u)",
+ connectable, adapter->connectable,
+ discoverable, adapter->discoverable);
- if (adapter->scan_mode == scan_mode)
+ if (connectable == adapter->connectable &&
+ discoverable == adapter->discoverable)
return;
- switch (scan_mode) {
- case SCAN_DISABLED:
- adapter->mode = MODE_OFF;
- adapter->connectable = false;
- adapter->discoverable = FALSE;
- break;
- case SCAN_PAGE:
- adapter->mode = MODE_CONNECTABLE;
- adapter->discoverable = FALSE;
- adapter->connectable = true;
- break;
- case (SCAN_PAGE | SCAN_INQUIRY):
- adapter->mode = MODE_DISCOVERABLE;
- adapter->discoverable = TRUE;
- adapter->connectable = true;
- break;
- default:
- /* ignore, reserved */
- return;
- }
-
- /* If page scanning gets toggled emit the Pairable property */
- if ((adapter->scan_mode & SCAN_PAGE) != (scan_mode & SCAN_PAGE))
- emit_pairable = true;
+ /* If connectable gets toggled emit the Pairable property */
+ emit_pairable = adapter->connectable != connectable;
- adapter->scan_mode = scan_mode;
+ adapter->connectable = connectable;
+ adapter->discoverable = discoverable;
+ adapter->mode = create_mode(connectable, discoverable);
if (emit_pairable)
g_dbus_emit_property_changed(btd_get_dbus_connection(),
--
1.8.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox