* Re: gatt-example plugin
From: John Tobias @ 2012-08-23 21:04 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <CAJdJm_OC4dcjY-yY4=LsNebeuAFnst4QxCO6oLCLATm9zTHVLA@mail.gmail.com>
Hi Anderson,
Thanks for the info. I got it working.. :)
I have a follow question, I've tried different Linux kernel release
for Pandaboard ES and I'm getting same kernel error( please see
below). I am just wondering if (you) or someone have a patch to fix
it?.
[ 265.400543]
[ 265.402130] =============================================
[ 265.407836] [ INFO: possible recursive locking detected ]
[ 265.413543] 3.6.0-rc3 #2 Not tainted
[ 265.417297] ---------------------------------------------
[ 265.422973] kworker/u:0H/7 is trying to acquire lock:
[ 265.428283] (sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP){+.+...}, at:
[<bf3bc350>] l2cap_sock_ready_cb+0x14/0x50 [bluetooth]
[ 265.439575]
[ 265.439575] but task is already holding lock:
[ 265.445709] (sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP){+.+...}, at:
[<bf3bb8fc>] l2cap_connect_cfm+0x1a4/0x2f4 [bluetooth]
[ 265.456939]
[ 265.456939] other info that might help us debug this:
[ 265.463775] Possible unsafe locking scenario:
[ 265.463775]
[ 265.470001] CPU0
[ 265.472564] ----
[ 265.475128] lock(sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP);
[ 265.480651] lock(sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP);
[ 265.486145]
[ 265.486145] *** DEADLOCK ***
[ 265.486145]
[ 265.492340] May be due to missing lock nesting notation
[ 265.492340]
[ 265.499481] 4 locks held by kworker/u:0H/7:
[ 265.503875] #0: (hdev->name){.+.+.+}, at: [<c005c56c>]
process_one_work+0x138/0x584
[ 265.512176] #1: ((&hdev->rx_work)){+.+.+.}, at: [<c005c56c>]
process_one_work+0x138/0x584
[ 265.520996] #2: (&hdev->lock){+.+.+.}, at: [<bf3a8074>]
hci_le_meta_evt+0x58/0x6fc [bluetooth]
[ 265.530303] #3: (sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP){+.+...}, at:
[<bf3bb8fc>] l2cap_connect_cfm+0x1a4/0x2f4 [bluetooth]
[ 265.542022]
[ 265.542022] stack backtrace:
[ 265.546630] [<c001b784>] (unwind_backtrace+0x0/0xf0) from
[<c0093024>] (__lock_acquire+0x1d00/0x1e24)
[ 265.556335] [<c0093024>] (__lock_acquire+0x1d00/0x1e24) from
[<c0093790>] (lock_acquire+0x98/0x100)
[ 265.565826] [<c0093790>] (lock_acquire+0x98/0x100) from
[<c0433f70>] (lock_sock_nested+0x6c/0x78)
[ 265.575225] [<c0433f70>] (lock_sock_nested+0x6c/0x78) from
[<bf3bc350>] (l2cap_sock_ready_cb+0x14/0x50 [bluetooth])
[ 265.586303] [<bf3bc350>] (l2cap_sock_ready_cb+0x14/0x50
[bluetooth]) from [<bf3b4950>] (l2cap_chan_ready+0x38/0x80
[bluetooth])
[ 265.598480] [<bf3b4950>] (l2cap_chan_ready+0x38/0x80 [bluetooth])
from [<bf3bb9ac>] (l2cap_connect_cfm+0x254/0x2f4 [bluetooth])
[ 265.610656] [<bf3bb9ac>] (l2cap_connect_cfm+0x254/0x2f4
[bluetooth]) from [<bf3a8604>] (hci_le_meta_evt+0x5e8/0x6fc
[bluetooth])
[ 265.622894] [<bf3a8604>] (hci_le_meta_evt+0x5e8/0x6fc [bluetooth])
from [<bf3a8cb0>] (hci_event_packet+0x598/0x27c4 [bluetooth])
[ 265.635101] [<bf3a8cb0>] (hci_event_packet+0x598/0x27c4
[bluetooth]) from [<bf39ec54>] (hci_rx_work+0x1c0/0x358 [bluetooth])
[ 265.646942] [<bf39ec54>] (hci_rx_work+0x1c0/0x358 [bluetooth]) from
[<c005c5ec>] (process_one_work+0x1b8/0x584)
[ 265.657562] [<c005c5ec>] (process_one_work+0x1b8/0x584) from
[<c005f2a8>] (worker_thread+0x170/0x4a4)
[ 265.667266] [<c005f2a8>] (worker_thread+0x170/0x4a4) from
[<c0064250>] (kthread+0x90/0x9c)
[ 265.675964] [<c0064250>] (kthread+0x90/0x9c) from [<c0014e94>]
(kernel_thread_exit+0x0/0x8)
Regards,
John
On Tue, Aug 21, 2012 at 3:41 AM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> Hi John,
>
> On Mon, Aug 20, 2012 at 9:19 PM, John Tobias <john.tobias.ph@gmail.com> wrote:
>> Hello Guys,
>>
>> I was playing with bluez-4.99 for LE. After setting the "EnableGatt to
>> true" and re-start the bluetoothd, I was able to connect to the
>> advertised services of the bluez. But, I could not figured out how to
>> access/load the gatt_example plugin and access the services. Any
>> information how to do it?
>
> First, make sure that gatt_example plugin was compiled into
> bluetoothd. You can check this by looking at the first lines of the
> debug log for this string:
>
> src/plugin.c:add_plugin() Loading gatt_example plugin
>
> As long as you don't pass any "-P" option to bluetoothd, all compiled
> plugins will load by default.
>
> Next, you can test GATT operations from a remote device, e.g. some
> GATT client you already have or the "gatttool" in BlueZ (running on
> another adapter).
>
> Best Regards,
> --
> Anderson Lizardo
> Instituto Nokia de Tecnologia - INdT
> Manaus - Brazil
^ permalink raw reply
* [PATCH 1/2] Bluetooth: Change signature of smp_conn_security()
From: Vinicius Costa Gomes @ 2012-08-24 0:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Vinicius Costa Gomes
To make it clear that it may be called from contexts that may not have
any knowledge of L2CAP, we change the connection parameter, to receive
a hci_conn.
This also makes it clear that it is checking the security of the link.
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
---
include/net/bluetooth/smp.h | 2 +-
net/bluetooth/l2cap_core.c | 11 ++++++-----
net/bluetooth/l2cap_sock.c | 2 +-
net/bluetooth/smp.c | 4 ++--
4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/include/net/bluetooth/smp.h b/include/net/bluetooth/smp.h
index 50993a5..f8ba07f 100644
--- a/include/net/bluetooth/smp.h
+++ b/include/net/bluetooth/smp.h
@@ -136,7 +136,7 @@ struct smp_chan {
};
/* SMP Commands */
-int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level);
+int smp_conn_security(struct hci_conn *hcon, __u8 sec_level);
int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb);
int smp_distribute_keys(struct l2cap_conn *conn, __u8 force);
int smp_user_confirm_reply(struct hci_conn *conn, u16 mgmt_op, __le32 passkey);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 9732f03..7479825 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1216,14 +1216,15 @@ clean:
static void l2cap_conn_ready(struct l2cap_conn *conn)
{
struct l2cap_chan *chan;
+ struct hci_conn *hcon = conn->hcon;
BT_DBG("conn %p", conn);
- if (!conn->hcon->out && conn->hcon->type == LE_LINK)
+ if (!hcon->out && hcon->type == LE_LINK)
l2cap_le_conn_ready(conn);
- if (conn->hcon->out && conn->hcon->type == LE_LINK)
- smp_conn_security(conn, conn->hcon->pending_sec_level);
+ if (hcon->out && hcon->type == LE_LINK)
+ smp_conn_security(hcon, hcon->pending_sec_level);
mutex_lock(&conn->chan_lock);
@@ -1236,8 +1237,8 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)
continue;
}
- if (conn->hcon->type == LE_LINK) {
- if (smp_conn_security(conn, chan->sec_level))
+ if (hcon->type == LE_LINK) {
+ if (smp_conn_security(hcon, chan->sec_level))
l2cap_chan_ready(chan);
} else if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) {
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 13f6a98..a75be577 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -619,7 +619,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
break;
}
- if (smp_conn_security(conn, sec.level))
+ if (smp_conn_security(conn->hcon, sec.level))
break;
sk->sk_state = BT_CONFIG;
chan->state = BT_CONFIG;
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index 16ef0dc..03e284e 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -757,9 +757,9 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)
return 0;
}
-int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level)
+int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
{
- struct hci_conn *hcon = conn->hcon;
+ struct l2cap_conn *conn = hcon->l2cap_data;
struct smp_chan *smp = conn->smp_chan;
__u8 authreq;
--
1.7.12
^ permalink raw reply related
* [PATCH 2/2] Bluetooth: Fix sending a HCI Authorization Request over LE links
From: Vinicius Costa Gomes @ 2012-08-24 0:32 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Vinicius Costa Gomes
In-Reply-To: <1345768364-9546-1-git-send-email-vinicius.gomes@openbossa.org>
In the case that the link is already in the connected state and a
Pairing request arrives from the mgmt interface, hci_conn_security()
would be called but it was not considering LE links.
Reported-by: João Paulo Rechi Vita <jprvita@openbossa.org>
Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
---
net/bluetooth/hci_conn.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 3e65c02..2f8013d 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -29,6 +29,7 @@
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/a2mp.h>
+#include <net/bluetooth/smp.h>
static void hci_le_create_connection(struct hci_conn *conn)
{
@@ -645,6 +646,9 @@ int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
{
BT_DBG("hcon %p", conn);
+ if (conn->type == LE_LINK)
+ return smp_conn_security(conn, sec_level);
+
/* For sdp we don't need the link key. */
if (sec_level == BT_SECURITY_SDP)
return 1;
--
1.7.12
^ permalink raw reply related
* Re: [PATCH 0/5] PAN server fixes
From: Luiz Augusto von Dentz @ 2012-08-24 7:54 UTC (permalink / raw)
To: Tomasz Bursztyka; +Cc: linux-bluetooth
In-Reply-To: <1345545955-13144-1-git-send-email-tomasz.bursztyka@linux.intel.com>
Hi Tomasz,
On Tue, Aug 21, 2012 at 1:45 PM, Tomasz Bursztyka
<tomasz.bursztyka@linux.intel.com> wrote:
> Hi,
>
> After looking at connman's bug https://bugs.meego.com/show_bug.cgi?id=25125 I figured out that PAN server code was missbehaving.
> Basically, when DBus Unregister call is made: all bnep ifs and there corresponding connections are not touched at all, so on the
> client side: it still thinks it's connected (it is, but it lost the tethering stuff and so on).
>
> So here is a patch set that fixes the issue.
>
> 1 - it tracks the bnep interface per session, it will be necessary afterwards
> 2 - An helper to remove properly an interface from a bridge, it will be necessary afterwards also
> 3 - Here we are: it deletes the interface from the bridge, and puts it down when the server is freed. It's on its own function since it will be
> necessary aft
> erwards.
> 4 - It kills the underlying connection properly so the client is notified as it should
> 5 - Finally, when Unregister method call is made: it cleans up all sessions so clients are disconnected accordingly etc...
>
> Note: I tested this patch against 4.101 and it worken properly.
>
> Please review,
>
>
> Tomasz Bursztyka (5):
> network: Keep track of session's interface name in server
> network: Add helper function to remove an interface from a bridge
> network: Release session's interface from bridge when unregistering
> network: Kill underlying session's connection before freeing it
> network: Remove sessions from server on DBus call Unregister
>
> profiles/network/common.c | 29 +++++++++++++++++++++++++++++
> profiles/network/common.h | 1 +
> profiles/network/server.c | 31 ++++++++++++++++++++++++++++---
> 3 files changed, 58 insertions(+), 3 deletions(-)
>
> --
> 1.7.8.6
All 5 patches are now upstream, thanks.
--
Luiz Augusto von Dentz
^ permalink raw reply
* duplicate devices found when using StartDiscovery API
From: Geay Franck @ 2012-08-24 8:12 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
Hi
I have a problem with bluez scanning API
When I call StartDiscovery dbus API, I get some duplicate devices found signal whereas using hcitool scan doesn't list duplicate devices
Is it normal, do I have to filter duplicate devices based on the BD address ? Is there a fix for this problem ?
I am using bluez version 4.87
root@localhost ~]# /usr/lib/bluez/test/test-discovery | grep -e Name -e Addres
Name = MyLapTop
Address = 00:16:41:DB:FF:F2
Name = C1-01
Address = 78:2E:EF:10:F4:7B
Name = Dell Wireless 370 Bluetooth Mini-card
Address = 00:25:56:E4:0E:0C
Name = Nokia 2730
Address = C8:DF:7C:CF:CE:E7
Name = MyLapTop
Address = 00:16:41:DB:FF:F2
Name = Nokia 2730
Address = C8:DF:7C:CF:CE:E7
Name = Dell Wireless 370 Bluetooth Mini-card
[root@localhost ~]# hcitool scan
Scanning ...
78:2E:EF:10:F4:7B C1-01
00:25:56:E4:0E:0C Dell Wireless 370 Bluetooth Mini-card
C8:DF:7C:CF:CE:E7 Nokia 2730
00:16:41:DB:FF:F2 MyLapTop
34:4B:50:BC:EB:84 My Tara
Thanks
Franck
^ permalink raw reply
* Re: [PATCH obexd v1 2/4] build: Require GLib 2.32 or later
From: Luiz Augusto von Dentz @ 2012-08-24 9:45 UTC (permalink / raw)
To: Syam Sidhardhan; +Cc: linux-bluetooth
In-Reply-To: <CABBYNZJ37+GoQx66+xD+K9_Lbi4yQZq_TWt_qDMiObdmwUg0AA@mail.gmail.com>
Hi Syam,
On Thu, Aug 23, 2012 at 1:36 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Syam,
>
> On Thu, Aug 23, 2012 at 1:27 AM, Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
>> Hi Syam,
>>
>> On Wed, Aug 22, 2012 at 7:35 PM, Syam Sidhardhan <s.syam@samsung.com> wrote:
>>> If we use GLib version less than 2.32 (more precisely < 2.31.2) then
>>> the following build error may occure in a 32 bit.
>>
>> We had the issue with BlueZ but we did not bump the glib version,
>> which makes me wonder if you are able to compile bluetoothd?
>
> It looks like we fix it with use of a variable:
>
> commit e34836262ba6a46491b6a760520158d70e8b51b5
> Author: Johan Hedberg <johan.hedberg@intel.com>
> Date: Wed Oct 12 00:48:59 2011 +0300
>
> Fix compilation error on 32-bit systems
>
> This fixes the following compilation error with GLib on 32-bit sytems:
>
> audio/media.c: In function 'get_setting':
> audio/media.c:1109:44: error: cast to pointer from integer of
> different size [-Werror=int-to-pointer-cast]
> audio/media.c: In function 'set_setting':
> audio/media.c:1132:41: error: cast to pointer from integer of
> different size [-Werror=int-to-pointer-cast]
How about the following patch:
diff --git a/gobex/gobex-apparam.c b/gobex/gobex-apparam.c
index 8f72aa7..d29dfc1 100644
--- a/gobex/gobex-apparam.c
+++ b/gobex/gobex-apparam.c
@@ -112,12 +112,14 @@ GObexApparam *g_obex_apparam_decode(const void
*data, gsize size)
while (count < size) {
struct apparam_tag *tag;
gsize parsed;
+ guint id;
tag = apparam_tag_decode(data + count, size - count, &parsed);
if (tag == NULL)
break;
- g_hash_table_insert(tags, GUINT_TO_POINTER(tag->id), tag);
+ id = tag->id;
+ g_hash_table_insert(tags, GUINT_TO_POINTER(id), tag);
count += parsed;
}
@@ -167,12 +169,14 @@ GObexApparam
*g_obex_apparam_set_bytes(GObexApparam *apparam, guint8 id,
const void *value, gsize len)
{
struct apparam_tag *tag;
+ guint uid;
if (apparam == NULL)
apparam = g_obex_apparam_new();
tag = tag_new(id, len, value);
- g_hash_table_replace(apparam->tags, GUINT_TO_POINTER(id), tag);
+ uid = id;
+ g_hash_table_replace(apparam->tags, GUINT_TO_POINTER(uid), tag);
return apparam;
}
@@ -232,6 +236,12 @@ GObexApparam
*g_obex_apparam_set_string(GObexApparam *apparam, guint8 id,
return g_obex_apparam_set_bytes(apparam, id, value, len);
}
+static struct apparam_tag *g_obex_apparam_find_tag(GObexApparam *apparam,
+ guint id)
+{
+ return g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
+}
+
gboolean g_obex_apparam_get_uint8(GObexApparam *apparam, guint8 id,
guint8 *dest)
{
@@ -239,7 +249,7 @@ gboolean g_obex_apparam_get_uint8(GObexApparam
*apparam, guint8 id,
g_obex_debug(G_OBEX_DEBUG_APPARAM, "tag 0x%02x", id);
- tag = g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
+ tag = g_obex_apparam_find_tag(apparam, id);
if (tag == NULL)
return FALSE;
@@ -257,7 +267,7 @@ gboolean g_obex_apparam_get_uint16(GObexApparam
*apparam, guint8 id,
g_obex_debug(G_OBEX_DEBUG_APPARAM, "tag 0x%02x", id);
- tag = g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
+ tag = g_obex_apparam_find_tag(apparam, id);
if (tag == NULL)
return FALSE;
@@ -278,7 +288,7 @@ gboolean g_obex_apparam_get_uint32(GObexApparam
*apparam, guint8 id,
g_obex_debug(G_OBEX_DEBUG_APPARAM, "tag 0x%02x", id);
- tag = g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
+ tag = g_obex_apparam_find_tag(apparam, id);
if (tag == NULL)
return FALSE;
@@ -299,7 +309,7 @@ gboolean g_obex_apparam_get_uint64(GObexApparam
*apparam, guint8 id,
g_obex_debug(G_OBEX_DEBUG_APPARAM, "tag 0x%02x", id);
- tag = g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
+ tag = g_obex_apparam_find_tag(apparam, id);
if (tag == NULL)
return FALSE;
@@ -320,7 +330,7 @@ char *g_obex_apparam_get_string(GObexApparam
*apparam, guint8 id)
g_obex_debug(G_OBEX_DEBUG_APPARAM, "tag 0x%02x", id);
- tag = g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
+ tag = g_obex_apparam_find_tag(apparam, id);
if (tag == NULL)
return NULL;
@@ -338,7 +348,7 @@ gboolean g_obex_apparam_get_bytes(GObexApparam
*apparam, guint8 id,
g_obex_debug(G_OBEX_DEBUG_APPARAM, "tag 0x%02x", id);
- tag = g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
+ tag = g_obex_apparam_find_tag(apparam, id);
if (tag == NULL)
return FALSE;
--
1.7.11.4
--
Luiz Augusto von Dentz
^ permalink raw reply related
* [PATCH BlueZ] gdbus: Fix crash error when calling g_dbus_remove_all_watches
From: Tomasz Bursztyka @ 2012-08-24 10:09 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Tomasz Bursztyka
---
Hi,
While using gdbus on some other code, I found out that bug around g_dbus_remove_all_watches() usage.
Tomasz
gdbus/watch.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/gdbus/watch.c b/gdbus/watch.c
index d749176..968a38a 100644
--- a/gdbus/watch.c
+++ b/gdbus/watch.c
@@ -298,6 +298,9 @@ static void filter_data_call_and_free(struct filter_data *data)
g_free(cb);
}
+ g_slist_free(data->callbacks);
+ data->callbacks = NULL;
+
filter_data_free(data);
}
--
1.7.8.6
^ permalink raw reply related
* Re: duplicate devices found when using StartDiscovery API
From: Luiz Augusto von Dentz @ 2012-08-24 10:19 UTC (permalink / raw)
To: Geay Franck; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <453EEB4CD4162742B6EF3D3F84E88A6E01ADB2AAC3@MOPESMBX01.eu.thmulti.com>
Hi Geay,
On Fri, Aug 24, 2012 at 11:12 AM, Geay Franck
<franck.geay@technicolor.com> wrote:
> Hi
>
> I have a problem with bluez scanning API
> When I call StartDiscovery dbus API, I get some duplicate devices found signal whereas using hcitool scan doesn't list duplicate devices
> Is it normal, do I have to filter duplicate devices based on the BD address ? Is there a fix for this problem ?
> I am using bluez version 4.87
>
> root@localhost ~]# /usr/lib/bluez/test/test-discovery | grep -e Name -e Addres
> Name = MyLapTop
> Address = 00:16:41:DB:FF:F2
> Name = C1-01
> Address = 78:2E:EF:10:F4:7B
> Name = Dell Wireless 370 Bluetooth Mini-card
> Address = 00:25:56:E4:0E:0C
> Name = Nokia 2730
> Address = C8:DF:7C:CF:CE:E7
> Name = MyLapTop
> Address = 00:16:41:DB:FF:F2
> Name = Nokia 2730
> Address = C8:DF:7C:CF:CE:E7
> Name = Dell Wireless 370 Bluetooth Mini-card
It works as intended as they could be found in different scan rounds
or due to rssi signal has been changed, hcitool in the other hand is a
single shot and is not rssi aware so it just need to return one entry
of each device found but if you use hcidump you will see that the
inquiry result may contain more than one entry for each device.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [PATCH obexd v1 2/4] build: Require GLib 2.32 or later
From: Syam Sidhardhan @ 2012-08-24 11:33 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <CABBYNZLyT80dZHzuZA=F=KvqrQsK9sZqgyq211Uoysk0Gap7UA@mail.gmail.com>
Hi Luiz,
----- Original Message -----
From: "Luiz Augusto von Dentz" <luiz.dentz@gmail.com>
To: "Syam Sidhardhan" <s.syam@samsung.com>
Cc: <linux-bluetooth@vger.kernel.org>
Sent: Friday, August 24, 2012 3:15 PM
Subject: Re: [PATCH obexd v1 2/4] build: Require GLib 2.32 or later
> Hi Syam,
>
> On Thu, Aug 23, 2012 at 1:36 AM, Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
>> Hi Syam,
>>
>> On Thu, Aug 23, 2012 at 1:27 AM, Luiz Augusto von Dentz
>> <luiz.dentz@gmail.com> wrote:
>>> Hi Syam,
>>>
>>> On Wed, Aug 22, 2012 at 7:35 PM, Syam Sidhardhan <s.syam@samsung.com>
>>> wrote:
>>>> If we use GLib version less than 2.32 (more precisely < 2.31.2) then
>>>> the following build error may occure in a 32 bit.
>>>
>>> We had the issue with BlueZ but we did not bump the glib version,
>>> which makes me wonder if you are able to compile bluetoothd?
>>
>> It looks like we fix it with use of a variable:
>>
>> commit e34836262ba6a46491b6a760520158d70e8b51b5
>> Author: Johan Hedberg <johan.hedberg@intel.com>
>> Date: Wed Oct 12 00:48:59 2011 +0300
>>
>> Fix compilation error on 32-bit systems
>>
>> This fixes the following compilation error with GLib on 32-bit
>> sytems:
>>
>> audio/media.c: In function 'get_setting':
>> audio/media.c:1109:44: error: cast to pointer from integer of
>> different size [-Werror=int-to-pointer-cast]
>> audio/media.c: In function 'set_setting':
>> audio/media.c:1132:41: error: cast to pointer from integer of
>> different size [-Werror=int-to-pointer-cast]
>
> How about the following patch:
>
> diff --git a/gobex/gobex-apparam.c b/gobex/gobex-apparam.c
> index 8f72aa7..d29dfc1 100644
> --- a/gobex/gobex-apparam.c
> +++ b/gobex/gobex-apparam.c
> @@ -112,12 +112,14 @@ GObexApparam *g_obex_apparam_decode(const void
> *data, gsize size)
> while (count < size) {
> struct apparam_tag *tag;
> gsize parsed;
> + guint id;
>
> tag = apparam_tag_decode(data + count, size - count, &parsed);
> if (tag == NULL)
> break;
>
> - g_hash_table_insert(tags, GUINT_TO_POINTER(tag->id), tag);
> + id = tag->id;
> + g_hash_table_insert(tags, GUINT_TO_POINTER(id), tag);
>
> count += parsed;
> }
> @@ -167,12 +169,14 @@ GObexApparam
> *g_obex_apparam_set_bytes(GObexApparam *apparam, guint8 id,
> const void *value, gsize len)
> {
> struct apparam_tag *tag;
> + guint uid;
>
> if (apparam == NULL)
> apparam = g_obex_apparam_new();
>
> tag = tag_new(id, len, value);
> - g_hash_table_replace(apparam->tags, GUINT_TO_POINTER(id), tag);
> + uid = id;
Its ok, but in this case assigning id during variable declaration looks good
for me.
ie, guint uid = id;
> + g_hash_table_replace(apparam->tags, GUINT_TO_POINTER(uid), tag);
>
> return apparam;
> }
> @@ -232,6 +236,12 @@ GObexApparam
> *g_obex_apparam_set_string(GObexApparam *apparam, guint8 id,
> return g_obex_apparam_set_bytes(apparam, id, value, len);
> }
>
> +static struct apparam_tag *g_obex_apparam_find_tag(GObexApparam *apparam,
> + guint id)
> +{
> + return g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
> +}
> +
> gboolean g_obex_apparam_get_uint8(GObexApparam *apparam, guint8 id,
> guint8 *dest)
> {
> @@ -239,7 +249,7 @@ gboolean g_obex_apparam_get_uint8(GObexApparam
> *apparam, guint8 id,
>
> g_obex_debug(G_OBEX_DEBUG_APPARAM, "tag 0x%02x", id);
>
> - tag = g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
> + tag = g_obex_apparam_find_tag(apparam, id);
> if (tag == NULL)
> return FALSE;
>
> @@ -257,7 +267,7 @@ gboolean g_obex_apparam_get_uint16(GObexApparam
> *apparam, guint8 id,
>
> g_obex_debug(G_OBEX_DEBUG_APPARAM, "tag 0x%02x", id);
>
> - tag = g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
> + tag = g_obex_apparam_find_tag(apparam, id);
> if (tag == NULL)
> return FALSE;
>
> @@ -278,7 +288,7 @@ gboolean g_obex_apparam_get_uint32(GObexApparam
> *apparam, guint8 id,
>
> g_obex_debug(G_OBEX_DEBUG_APPARAM, "tag 0x%02x", id);
>
> - tag = g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
> + tag = g_obex_apparam_find_tag(apparam, id);
> if (tag == NULL)
> return FALSE;
>
> @@ -299,7 +309,7 @@ gboolean g_obex_apparam_get_uint64(GObexApparam
> *apparam, guint8 id,
>
> g_obex_debug(G_OBEX_DEBUG_APPARAM, "tag 0x%02x", id);
>
> - tag = g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
> + tag = g_obex_apparam_find_tag(apparam, id);
> if (tag == NULL)
> return FALSE;
>
> @@ -320,7 +330,7 @@ char *g_obex_apparam_get_string(GObexApparam
> *apparam, guint8 id)
>
> g_obex_debug(G_OBEX_DEBUG_APPARAM, "tag 0x%02x", id);
>
> - tag = g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
> + tag = g_obex_apparam_find_tag(apparam, id);
> if (tag == NULL)
> return NULL;
>
> @@ -338,7 +348,7 @@ gboolean g_obex_apparam_get_bytes(GObexApparam
> *apparam, guint8 id,
>
> g_obex_debug(G_OBEX_DEBUG_APPARAM, "tag 0x%02x", id);
>
> - tag = g_hash_table_lookup(apparam->tags, GUINT_TO_POINTER(id));
> + tag = g_obex_apparam_find_tag(apparam, id);
> if (tag == NULL)
> return FALSE;
>
Apart form the above mention nitpick, this patch is ok for me. Its a better
fix.
Thanks,
Syam
^ permalink raw reply
* Re: [PATCH 2/2] Bluetooth: Power the device up after a rfkill unblock
From: Johan Hedberg @ 2012-08-24 12:28 UTC (permalink / raw)
To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <1345664010-30471-2-git-send-email-vinicius.gomes@openbossa.org>
Hi Vinicius,
On Wed, Aug 22, 2012, Vinicius Costa Gomes wrote:
> With the HCI_SETUP patches, this is all that is needed to make the
> case when a adapter is added with Bluetooth blocked in rfkill to work.
>
> When rfkill is unblocked, the device will be powered on, and if not
> needed it will be automatically powered off.
>
> Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
> ---
> net/bluetooth/hci_core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index fa974a1..395dcc6 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -1061,8 +1061,10 @@ static int hci_rfkill_set_block(void *data, bool blocked)
>
> BT_DBG("%p name %s blocked %d", hdev, hdev->name, blocked);
>
> - if (!blocked)
> + if (!blocked) {
> + schedule_work(&hdev->power_on);
Don't you need to check for HCI_SETUP before calling schedule_work here?
It should be possible to have an adapter powered off and toggling rfkill
back and forth shouldn't cause it to be powered on.
Johan
^ permalink raw reply
* Re: [PATCH 2/2] Bluetooth: Power the device up after a rfkill unblock
From: Vinicius Costa Gomes @ 2012-08-24 13:32 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <20120824122800.GA27292@x220.ger.corp.intel.com>
Hi Johan,
On 15:28 Fri 24 Aug, Johan Hedberg wrote:
> Hi Vinicius,
>
> On Wed, Aug 22, 2012, Vinicius Costa Gomes wrote:
> > With the HCI_SETUP patches, this is all that is needed to make the
> > case when a adapter is added with Bluetooth blocked in rfkill to work.
> >
> > When rfkill is unblocked, the device will be powered on, and if not
> > needed it will be automatically powered off.
> >
> > Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org>
> > ---
> > net/bluetooth/hci_core.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> > index fa974a1..395dcc6 100644
> > --- a/net/bluetooth/hci_core.c
> > +++ b/net/bluetooth/hci_core.c
> > @@ -1061,8 +1061,10 @@ static int hci_rfkill_set_block(void *data, bool blocked)
> >
> > BT_DBG("%p name %s blocked %d", hdev, hdev->name, blocked);
> >
> > - if (!blocked)
> > + if (!blocked) {
> > + schedule_work(&hdev->power_on);
>
> Don't you need to check for HCI_SETUP before calling schedule_work here?
> It should be possible to have an adapter powered off and toggling rfkill
> back and forth shouldn't cause it to be powered on.
Most probably. Nice catch. Thanks.
I am going to try it and see if it doesn't have any unexpected side effects.
Cheers,
--
Vinicius
^ permalink raw reply
* Re: [PATCH obexd v1 2/4] build: Require GLib 2.32 or later
From: Lucas De Marchi @ 2012-08-24 13:46 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: Syam Sidhardhan, linux-bluetooth
In-Reply-To: <CABBYNZLyT80dZHzuZA=F=KvqrQsK9sZqgyq211Uoysk0Gap7UA@mail.gmail.com>
On Fri, Aug 24, 2012 at 6:45 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Syam,
>
> On Thu, Aug 23, 2012 at 1:36 AM, Luiz Augusto von Dentz
> <luiz.dentz@gmail.com> wrote:
>> Hi Syam,
>>
>> On Thu, Aug 23, 2012 at 1:27 AM, Luiz Augusto von Dentz
>> <luiz.dentz@gmail.com> wrote:
>>> Hi Syam,
>>>
>>> On Wed, Aug 22, 2012 at 7:35 PM, Syam Sidhardhan <s.syam@samsung.com> wrote:
>>>> If we use GLib version less than 2.32 (more precisely < 2.31.2) then
>>>> the following build error may occure in a 32 bit.
>>>
>>> We had the issue with BlueZ but we did not bump the glib version,
>>> which makes me wonder if you are able to compile bluetoothd?
>>
>> It looks like we fix it with use of a variable:
>>
>> commit e34836262ba6a46491b6a760520158d70e8b51b5
>> Author: Johan Hedberg <johan.hedberg@intel.com>
>> Date: Wed Oct 12 00:48:59 2011 +0300
>>
>> Fix compilation error on 32-bit systems
>>
>> This fixes the following compilation error with GLib on 32-bit sytems:
>>
>> audio/media.c: In function 'get_setting':
>> audio/media.c:1109:44: error: cast to pointer from integer of
>> different size [-Werror=int-to-pointer-cast]
>> audio/media.c: In function 'set_setting':
>> audio/media.c:1132:41: error: cast to pointer from integer of
>> different size [-Werror=int-to-pointer-cast]
>
> How about the following patch:
I will say the same thing when the other similar fix was committed to
BlueZ: creating an extra variable all over the repository because the
macro was not defined correctly is not good. Mainly because over the
time we would create the same problem in other places as well because
in general devs are using more recent versions of glib (as shown in
the places this patch is fixing now) .
So, I'd propose the following: if we don't want to increase the
minimum required version of glib, lets define this macro ourselves. Or
make it a build-time conditional in glib-helper.h
Lucas De Marchi
^ permalink raw reply
* [PATCH obexd 1/7] client: Add filters to Phonebook.PullAll
From: Luiz Augusto von Dentz @ 2012-08-24 13:59 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This avoid D-Bus round trips and is more aligned with what has been
proposed for MessageAccess interface.
---
client/pbap.c | 254 +++++++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 208 insertions(+), 46 deletions(-)
diff --git a/client/pbap.c b/client/pbap.c
index ebd6320..0c1336c 100644
--- a/client/pbap.c
+++ b/client/pbap.c
@@ -351,18 +351,189 @@ send:
pending_request_free(request);
}
+static GObexApparam *parse_format(GObexApparam *apparam, DBusMessageIter *iter)
+{
+ const char *string;
+ guint8 format;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+ return NULL;
+
+ dbus_message_iter_get_basic(iter, &string);
+
+ if (!string || g_str_equal(string, ""))
+ format = FORMAT_VCARD21;
+ else if (!g_ascii_strcasecmp(string, "vcard21"))
+ format = FORMAT_VCARD21;
+ else if (!g_ascii_strcasecmp(string, "vcard30"))
+ format = FORMAT_VCARD30;
+ else
+ return NULL;
+
+ return g_obex_apparam_set_uint8(apparam, FORMAT_TAG, format);
+}
+
+static GObexApparam *parse_order(GObexApparam *apparam, DBusMessageIter *iter)
+{
+ const char *string;
+ guint8 order;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+ return NULL;
+
+ dbus_message_iter_get_basic(iter, &string);
+
+ if (!string || g_str_equal(string, ""))
+ order = ORDER_INDEXED;
+ else if (!g_ascii_strcasecmp(string, "indexed"))
+ order = ORDER_INDEXED;
+ else if (!g_ascii_strcasecmp(string, "alphanumeric"))
+ order = ORDER_ALPHANUMERIC;
+ else if (!g_ascii_strcasecmp(string, "phonetic"))
+ order = ORDER_PHONETIC;
+ else
+ return NULL;
+
+ return g_obex_apparam_set_uint8(apparam, ORDER_TAG, order);
+}
+
+static GObexApparam *parse_offset(GObexApparam *apparam, DBusMessageIter *iter)
+{
+ guint16 num;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16)
+ return NULL;
+
+ dbus_message_iter_get_basic(iter, &num);
+
+ return g_obex_apparam_set_uint16(apparam, LISTSTARTOFFSET_TAG, num);
+}
+
+static GObexApparam *parse_items(GObexApparam *apparam, DBusMessageIter *iter)
+{
+ guint16 num;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16)
+ return NULL;
+
+ dbus_message_iter_get_basic(iter, &num);
+
+ return g_obex_apparam_set_uint16(apparam, MAXLISTCOUNT_TAG, num);
+}
+
+static uint64_t get_filter_mask(const char *filterstr)
+{
+ int i, bit = -1;
+
+ if (!filterstr)
+ return 0;
+
+ if (!g_ascii_strcasecmp(filterstr, "ALL"))
+ return FILTER_ALL;
+
+ for (i = 0; filter_list[i] != NULL; i++)
+ if (!g_ascii_strcasecmp(filterstr, filter_list[i]))
+ return 1ULL << i;
+
+ if (strlen(filterstr) < 4 || strlen(filterstr) > 5
+ || g_ascii_strncasecmp(filterstr, "bit", 3) != 0)
+ return 0;
+
+ sscanf(&filterstr[3], "%d", &bit);
+ if (bit >= 0 && bit <= FILTER_BIT_MAX)
+ return 1ULL << bit;
+ else
+ return 0;
+}
+
+static int set_field(guint64 *filter, const char *filterstr)
+{
+ guint64 mask;
+
+ mask = get_filter_mask(filterstr);
+
+ if (mask == 0)
+ return -EINVAL;
+
+ *filter |= mask;
+ return 0;
+}
+
+static GObexApparam *parse_fields(GObexApparam *apparam, DBusMessageIter *iter)
+{
+ DBusMessageIter array;
+ guint64 filter = 0;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
+ return NULL;
+
+ dbus_message_iter_recurse(iter, &array);
+
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_STRING) {
+ const char *string;
+
+ dbus_message_iter_get_basic(&array, &string);
+
+ if (set_field(&filter, string) < 0)
+ return NULL;
+
+ dbus_message_iter_next(&array);
+ }
+
+ return g_obex_apparam_set_uint64(apparam, FILTER_TAG, filter);
+}
+static GObexApparam *parse_filters(GObexApparam *apparam,
+ DBusMessageIter *iter)
+{
+ DBusMessageIter array;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
+ return NULL;
+
+ dbus_message_iter_recurse(iter, &array);
+
+ while (dbus_message_iter_get_arg_type(&array) == DBUS_TYPE_DICT_ENTRY) {
+ const char *key;
+ DBusMessageIter value, entry;
+
+ dbus_message_iter_recurse(&array, &entry);
+ dbus_message_iter_get_basic(&entry, &key);
+
+ dbus_message_iter_next(&entry);
+ dbus_message_iter_recurse(&entry, &value);
+
+ if (strcasecmp(key, "Format") == 0) {
+ if (parse_format(apparam, &value) == NULL)
+ return NULL;
+ } else if (strcasecmp(key, "Order") == 0) {
+ if (parse_order(apparam, &value) == NULL)
+ return NULL;
+ } else if (strcasecmp(key, "Offset") == 0) {
+ if (parse_offset(apparam, &value) == NULL)
+ return NULL;
+ } else if (strcasecmp(key, "Items") == 0) {
+ if (parse_items(apparam, &value) == NULL)
+ return NULL;
+ } else if (strcasecmp(key, "Fields") == 0) {
+ if (parse_fields(apparam, &value) == NULL)
+ return NULL;
+ }
+
+ dbus_message_iter_next(&array);
+ }
+
+ return apparam;
+}
+
static struct obc_transfer *pull_phonebook(struct pbap_data *pbap,
DBusMessage *message,
guint8 type, const char *name,
const char *targetfile,
- uint64_t filter, guint8 format,
- guint16 maxlistcount,
- guint16 liststartoffset,
+ GObexApparam *apparam,
GError **err)
{
struct pending_request *request;
struct obc_transfer *transfer;
- GObexApparam *apparam;
guint8 buf[32];
gsize len;
session_callback_t func;
@@ -371,13 +542,6 @@ static struct obc_transfer *pull_phonebook(struct pbap_data *pbap,
if (transfer == NULL)
return NULL;
- apparam = g_obex_apparam_set_uint64(NULL, FILTER_TAG, filter);
- apparam = g_obex_apparam_set_uint8(apparam, FORMAT_TAG, format);
- apparam = g_obex_apparam_set_uint16(apparam, MAXLISTCOUNT_TAG,
- maxlistcount);
- apparam = g_obex_apparam_set_uint16(apparam, LISTSTARTOFFSET_TAG,
- liststartoffset);
-
switch (type) {
case PULLPHONEBOOK:
func = NULL;
@@ -396,8 +560,6 @@ static struct obc_transfer *pull_phonebook(struct pbap_data *pbap,
obc_transfer_set_params(transfer, buf, len);
- g_obex_apparam_free(apparam);
-
if (!obc_session_queue(pbap->session, transfer, func, request, err)) {
if (request != NULL)
pending_request_free(request);
@@ -490,31 +652,6 @@ static int set_order(struct pbap_data *pbap, const char *orderstr)
return 0;
}
-static uint64_t get_filter_mask(const char *filterstr)
-{
- int i, bit = -1;
-
- if (!filterstr)
- return 0;
-
- if (!g_ascii_strcasecmp(filterstr, "ALL"))
- return FILTER_ALL;
-
- for (i = 0; filter_list[i] != NULL; i++)
- if (!g_ascii_strcasecmp(filterstr, filter_list[i]))
- return 1ULL << i;
-
- if (strlen(filterstr) < 4 || strlen(filterstr) > 5
- || g_ascii_strncasecmp(filterstr, "bit", 3) != 0)
- return 0;
-
- sscanf(&filterstr[3], "%d", &bit);
- if (bit >= 0 && bit <= FILTER_BIT_MAX)
- return 1ULL << bit;
- else
- return 0;
-}
-
static int add_filter(struct pbap_data *pbap, const char *filterstr)
{
uint64_t mask;
@@ -618,25 +755,41 @@ static DBusMessage *pbap_pull_all(DBusConnection *connection,
struct obc_transfer *transfer;
const char *targetfile;
char *name;
+ GObexApparam *apparam;
GError *err = NULL;
+ DBusMessageIter args;
if (!pbap->path)
return g_dbus_create_error(message,
ERROR_INTERFACE ".Forbidden",
"Call Select first of all");
- if (dbus_message_get_args(message, NULL,
- DBUS_TYPE_STRING, &targetfile,
- DBUS_TYPE_INVALID) == FALSE)
+ dbus_message_iter_init(message, &args);
+
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
return g_dbus_create_error(message,
ERROR_INTERFACE ".InvalidArguments", NULL);
+ dbus_message_iter_get_basic(&args, &targetfile);
+ dbus_message_iter_next(&args);
+
+ apparam = g_obex_apparam_set_uint16(NULL, MAXLISTCOUNT_TAG,
+ DEFAULT_COUNT);
+ apparam = g_obex_apparam_set_uint16(apparam, LISTSTARTOFFSET_TAG,
+ DEFAULT_OFFSET);
+
+ if (parse_filters(apparam, &args) == NULL) {
+ g_obex_apparam_free(apparam);
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".InvalidArguments", NULL);
+ }
+
name = g_strconcat(pbap->path, ".vcf", NULL);
transfer = pull_phonebook(pbap, message, PULLPHONEBOOK, name,
- targetfile, pbap->filter, pbap->format,
- DEFAULT_COUNT, DEFAULT_OFFSET, &err);
+ targetfile, apparam, &err);
g_free(name);
+ g_obex_apparam_free(apparam);
if (transfer == NULL) {
DBusMessage *reply = g_dbus_create_error(message,
@@ -754,20 +907,28 @@ static DBusMessage *pbap_get_size(DBusConnection *connection,
DBusMessage *reply;
struct obc_transfer *transfer;
char *name;
+ GObexApparam *apparam;
GError *err = NULL;
+ DBusMessageIter args;
if (!pbap->path)
return g_dbus_create_error(message,
ERROR_INTERFACE ".Forbidden",
"Call Select first of all");
+ dbus_message_iter_init(message, &args);
+
name = g_strconcat(pbap->path, ".vcf", NULL);
+ apparam = g_obex_apparam_set_uint16(NULL, MAXLISTCOUNT_TAG, 0);
+ apparam = g_obex_apparam_set_uint16(apparam, LISTSTARTOFFSET_TAG,
+ DEFAULT_OFFSET);
+
transfer = pull_phonebook(pbap, message, GETPHONEBOOKSIZE, name, NULL,
- pbap->filter, pbap->format, 0,
- DEFAULT_OFFSET, &err);
+ apparam, &err);
g_free(name);
+ g_obex_apparam_free(apparam);
if (transfer != NULL)
return NULL;
@@ -891,7 +1052,8 @@ static const GDBusMethodTable pbap_methods[] = {
GDBUS_ARGS({ "location", "s" }, { "phonebook", "s" }),
NULL, pbap_select) },
{ GDBUS_METHOD("PullAll",
- GDBUS_ARGS({ "targetfile", "s" }),
+ GDBUS_ARGS({ "targetfile", "s" },
+ { "filters", "a{sv}" }),
GDBUS_ARGS({ "transfer", "o" },
{ "properties", "a{sv}" }),
pbap_pull_all) },
--
1.7.11.4
^ permalink raw reply related
* [PATCH obexd 2/7] client: Add filters to PhonebookAccess.Pull
From: Luiz Augusto von Dentz @ 2012-08-24 13:59 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1345816795-14092-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This avoid D-Bus round trips and is more aligned with what has been
proposed for MessageAccess interface.
---
client/pbap.c | 79 +++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 53 insertions(+), 26 deletions(-)
diff --git a/client/pbap.c b/client/pbap.c
index 0c1336c..0c7c08a 100644
--- a/client/pbap.c
+++ b/client/pbap.c
@@ -610,6 +610,7 @@ static DBusMessage *pull_vcard_listing(struct pbap_data *pbap,
pending_request_free(request);
fail:
+ g_obex_apparam_free(apparam);
reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s",
err->message);
g_error_free(err);
@@ -802,43 +803,25 @@ static DBusMessage *pbap_pull_all(DBusConnection *connection,
return obc_transfer_create_dbus_reply(transfer, message);
}
-static DBusMessage *pbap_pull_vcard(DBusConnection *connection,
- DBusMessage *message, void *user_data)
+static DBusMessage *pull_vcard(struct pbap_data *pbap, DBusMessage *message,
+ const char *name, const char *targetfile,
+ GObexApparam *apparam)
{
- struct pbap_data *pbap = user_data;
struct obc_transfer *transfer;
- GObexApparam *apparam;
- guint8 buf[32];
- gsize len;
- const char *name, *targetfile;
DBusMessage *reply;
GError *err = NULL;
+ guint8 buf[32];
+ gsize len;
- if (!pbap->path)
- return g_dbus_create_error(message,
- ERROR_INTERFACE ".Forbidden",
- "Call Select first of all");
-
- if (dbus_message_get_args(message, NULL,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_STRING, &targetfile,
- DBUS_TYPE_INVALID) == FALSE)
- return g_dbus_create_error(message,
- ERROR_INTERFACE ".InvalidArguments", NULL);
+ len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
+ g_obex_apparam_free(apparam);
transfer = obc_transfer_get("x-bt/vcard", name, targetfile, &err);
if (transfer == NULL)
goto fail;
- apparam = g_obex_apparam_set_uint64(NULL, FILTER_TAG, pbap->filter);
- apparam = g_obex_apparam_set_uint8(apparam, FORMAT_TAG, pbap->format);
-
- len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
-
obc_transfer_set_params(transfer, buf, len);
- g_obex_apparam_free(apparam);
-
if (!obc_session_queue(pbap->session, transfer, NULL, NULL, &err))
goto fail;
@@ -851,6 +834,49 @@ fail:
return reply;
}
+static DBusMessage *pbap_pull_vcard(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ struct pbap_data *pbap = user_data;
+ GObexApparam *apparam;
+ const char *name, *targetfile;
+ DBusMessageIter args;
+
+ if (!pbap->path)
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".Forbidden",
+ "Call Select first of all");
+
+ dbus_message_iter_init(message, &args);
+
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".InvalidArguments", NULL);
+
+ dbus_message_iter_get_basic(&args, &name);
+ dbus_message_iter_next(&args);
+
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".InvalidArguments", NULL);
+
+ dbus_message_iter_get_basic(&args, &targetfile);
+ dbus_message_iter_next(&args);
+
+ apparam = g_obex_apparam_set_uint16(NULL, MAXLISTCOUNT_TAG,
+ DEFAULT_COUNT);
+ apparam = g_obex_apparam_set_uint16(apparam, LISTSTARTOFFSET_TAG,
+ DEFAULT_OFFSET);
+
+ if (parse_filters(apparam, &args) == NULL) {
+ g_obex_apparam_free(apparam);
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".InvalidArguments", NULL);
+ }
+
+ return pull_vcard(pbap, message, name, targetfile, apparam);
+}
+
static DBusMessage *pbap_list(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
@@ -1058,7 +1084,8 @@ static const GDBusMethodTable pbap_methods[] = {
{ "properties", "a{sv}" }),
pbap_pull_all) },
{ GDBUS_METHOD("Pull",
- GDBUS_ARGS({ "vcard", "s" }, { "targetfile", "s" }),
+ GDBUS_ARGS({ "vcard", "s" }, { "targetfile", "s" },
+ { "filters", "a{sv}" }),
GDBUS_ARGS({ "transfer", "o" },
{ "properties", "a{sv}" }),
pbap_pull_vcard) },
--
1.7.11.4
^ permalink raw reply related
* [PATCH obexd 3/7] client: Add filters to PhonebookAccess.List and PhonebookAccess.Search
From: Luiz Augusto von Dentz @ 2012-08-24 13:59 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1345816795-14092-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This avoid D-Bus round trips and is more aligned with what has been
proposed for MessageAccess interface.
---
client/pbap.c | 115 ++++++++++++++++++++++++++++++++++++++--------------------
1 file changed, 76 insertions(+), 39 deletions(-)
diff --git a/client/pbap.c b/client/pbap.c
index 0c7c08a..fcc339b 100644
--- a/client/pbap.c
+++ b/client/pbap.c
@@ -573,35 +573,24 @@ static struct obc_transfer *pull_phonebook(struct pbap_data *pbap,
static DBusMessage *pull_vcard_listing(struct pbap_data *pbap,
DBusMessage *message, const char *name,
- guint8 order, char *searchval, guint8 attrib,
- guint16 count, guint16 offset)
+ GObexApparam *apparam)
{
struct pending_request *request;
struct obc_transfer *transfer;
guint8 buf[272];
gsize len;
GError *err = NULL;
- GObexApparam *apparam;
DBusMessage *reply;
+ len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
+ g_obex_apparam_free(apparam);
+
transfer = obc_transfer_get("x-bt/vcard-listing", name, NULL, &err);
if (transfer == NULL)
goto fail;
- apparam = g_obex_apparam_set_uint8(NULL, ORDER_TAG, order);
- apparam = g_obex_apparam_set_uint8(apparam, SEARCHATTRIB_TAG, attrib);
- apparam = g_obex_apparam_set_string(apparam, SEARCHVALUE_TAG,
- searchval);
- apparam = g_obex_apparam_set_uint16(apparam, MAXLISTCOUNT_TAG, count);
- apparam = g_obex_apparam_set_uint16(apparam, LISTSTARTOFFSET_TAG,
- offset);
-
- len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
-
obc_transfer_set_params(transfer, buf, len);
- g_obex_apparam_free(apparam);
-
request = pending_request_new(pbap, message);
if (obc_session_queue(pbap->session, transfer,
pull_vcard_listing_callback, request, &err))
@@ -881,34 +870,33 @@ static DBusMessage *pbap_list(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
struct pbap_data *pbap = user_data;
+ GObexApparam *apparam;
+ DBusMessageIter args;
if (!pbap->path)
return g_dbus_create_error(message,
ERROR_INTERFACE ".Forbidden",
"Call Select first of all");
- return pull_vcard_listing(pbap, message, "", pbap->order, "",
- ATTRIB_NAME, DEFAULT_COUNT, DEFAULT_OFFSET);
-}
+ dbus_message_iter_init(message, &args);
-static DBusMessage *pbap_search(DBusConnection *connection,
- DBusMessage *message, void *user_data)
-{
- struct pbap_data *pbap = user_data;
- char *field, *value;
- guint8 attrib;
+ apparam = g_obex_apparam_set_uint16(NULL, MAXLISTCOUNT_TAG,
+ DEFAULT_COUNT);
+ apparam = g_obex_apparam_set_uint16(apparam, LISTSTARTOFFSET_TAG,
+ DEFAULT_OFFSET);
- if (dbus_message_get_args(message, NULL,
- DBUS_TYPE_STRING, &field,
- DBUS_TYPE_STRING, &value,
- DBUS_TYPE_INVALID) == FALSE)
+ if (parse_filters(apparam, &args) == NULL) {
+ g_obex_apparam_free(apparam);
return g_dbus_create_error(message,
ERROR_INTERFACE ".InvalidArguments", NULL);
+ }
- if (!pbap->path)
- return g_dbus_create_error(message,
- ERROR_INTERFACE ".Forbidden",
- "Call Select first of all");
+ return pull_vcard_listing(pbap, message, "", apparam);
+}
+
+static GObexApparam *parse_attribute(GObexApparam *apparam, const char *field)
+{
+ guint8 attrib;
if (!field || g_str_equal(field, ""))
attrib = ATTRIB_NAME;
@@ -919,11 +907,58 @@ static DBusMessage *pbap_search(DBusConnection *connection,
else if (!g_ascii_strcasecmp(field, "sound"))
attrib = ATTRIB_SOUND;
else
+ return NULL;
+
+ return g_obex_apparam_set_uint8(apparam, SEARCHATTRIB_TAG, attrib);
+}
+
+static DBusMessage *pbap_search(DBusConnection *connection,
+ DBusMessage *message, void *user_data)
+{
+ struct pbap_data *pbap = user_data;
+ char *field, *value;
+ GObexApparam *apparam;
+ DBusMessageIter args;
+
+ if (!pbap->path)
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".Forbidden",
+ "Call Select first of all");
+
+ dbus_message_iter_init(message, &args);
+
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".InvalidArguments", NULL);
+
+ dbus_message_iter_get_basic(&args, &field);
+ dbus_message_iter_next(&args);
+
+ apparam = parse_attribute(NULL, field);
+ if (apparam == NULL)
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".InvalidArguments", NULL);
+
+ if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING)
+ return g_dbus_create_error(message,
+ ERROR_INTERFACE ".InvalidArguments", NULL);
+
+ dbus_message_iter_get_basic(&args, &value);
+ dbus_message_iter_next(&args);
+
+ apparam = g_obex_apparam_set_uint16(apparam, MAXLISTCOUNT_TAG,
+ DEFAULT_COUNT);
+ apparam = g_obex_apparam_set_uint16(apparam, LISTSTARTOFFSET_TAG,
+ DEFAULT_OFFSET);
+ apparam = g_obex_apparam_set_string(apparam, SEARCHVALUE_TAG, value);
+
+ if (parse_filters(apparam, &args) == NULL) {
+ g_obex_apparam_free(apparam);
return g_dbus_create_error(message,
ERROR_INTERFACE ".InvalidArguments", NULL);
+ }
- return pull_vcard_listing(pbap, message, "", pbap->order, value,
- attrib, DEFAULT_COUNT, DEFAULT_OFFSET);
+ return pull_vcard_listing(pbap, message, "", apparam);
}
static DBusMessage *pbap_get_size(DBusConnection *connection,
@@ -1090,12 +1125,14 @@ static const GDBusMethodTable pbap_methods[] = {
{ "properties", "a{sv}" }),
pbap_pull_vcard) },
{ GDBUS_ASYNC_METHOD("List",
- NULL, GDBUS_ARGS({ "vcard_listing", "a(ss)" }),
- pbap_list) },
+ GDBUS_ARGS({ "filters", "a{sv}" }),
+ GDBUS_ARGS({ "vcard_listing", "a(ss)" }),
+ pbap_list) },
{ GDBUS_ASYNC_METHOD("Search",
- GDBUS_ARGS({ "field", "s" }, { "value", "s" }),
- GDBUS_ARGS({ "vcard_listing", "a(ss)" }),
- pbap_search) },
+ GDBUS_ARGS({ "field", "s" }, { "value", "s" },
+ { "filters", "a{sv}" }),
+ GDBUS_ARGS({ "vcard_listing", "a(ss)" }),
+ pbap_search) },
{ GDBUS_ASYNC_METHOD("GetSize",
NULL, GDBUS_ARGS({ "size", "q" }),
pbap_get_size) },
--
1.7.11.4
^ permalink raw reply related
* [PATCH obexd 4/7] client: Remove SetOrder, SetFormat and SetFilter from PhonebookAccess
From: Luiz Augusto von Dentz @ 2012-08-24 13:59 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1345816795-14092-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Those methods are no longer necessary as other methods now take them
as parameters to avoid round trips.
---
client/pbap.c | 211 ----------------------------------------------------------
1 file changed, 211 deletions(-)
diff --git a/client/pbap.c b/client/pbap.c
index fcc339b..3e9301a 100644
--- a/client/pbap.c
+++ b/client/pbap.c
@@ -116,9 +116,6 @@ static const char *filter_list[] = {
struct pbap_data {
struct obc_session *session;
char *path;
- guint8 format;
- guint8 order;
- uint64_t filter;
};
struct pending_request {
@@ -606,91 +603,6 @@ fail:
return reply;
}
-static int set_format(struct pbap_data *pbap, const char *formatstr)
-{
- if (!formatstr || g_str_equal(formatstr, "")) {
- pbap->format = FORMAT_VCARD21;
- return 0;
- }
-
- if (!g_ascii_strcasecmp(formatstr, "vcard21"))
- pbap->format = FORMAT_VCARD21;
- else if (!g_ascii_strcasecmp(formatstr, "vcard30"))
- pbap->format = FORMAT_VCARD30;
- else
- return -EINVAL;
-
- return 0;
-}
-
-static int set_order(struct pbap_data *pbap, const char *orderstr)
-{
- if (!orderstr || g_str_equal(orderstr, "")) {
- pbap->order = ORDER_INDEXED;
- return 0;
- }
-
- if (!g_ascii_strcasecmp(orderstr, "indexed"))
- pbap->order = ORDER_INDEXED;
- else if (!g_ascii_strcasecmp(orderstr, "alphanumeric"))
- pbap->order = ORDER_ALPHANUMERIC;
- else if (!g_ascii_strcasecmp(orderstr, "phonetic"))
- pbap->order = ORDER_PHONETIC;
- else
- return -EINVAL;
-
- return 0;
-}
-
-static int add_filter(struct pbap_data *pbap, const char *filterstr)
-{
- uint64_t mask;
-
- mask = get_filter_mask(filterstr);
-
- if (mask == 0)
- return -EINVAL;
-
- pbap->filter |= mask;
- return 0;
-}
-
-static int remove_filter(struct pbap_data *pbap, const char *filterstr)
-{
- uint64_t mask;
-
- mask = get_filter_mask(filterstr);
-
- if (mask == 0)
- return -EINVAL;
-
- pbap->filter &= ~mask;
- return 0;
-}
-
-static gchar **get_filter_strs(uint64_t filter, gint *size)
-{
- gchar **list, **item;
- gint i;
- gint filter_list_size = sizeof(filter_list) / sizeof(filter_list[0]) - 1;
-
- list = g_malloc0(sizeof(gchar **) * (FILTER_BIT_MAX + 2));
-
- item = list;
-
- for (i = 0; i < filter_list_size; i++)
- if (filter & (1ULL << i))
- *(item++) = g_strdup(filter_list[i]);
-
- for (i = filter_list_size; i <= FILTER_BIT_MAX; i++)
- if (filter & (1ULL << i))
- *(item++) = g_strdup_printf("%s%d", "BIT", i);
-
- *item = NULL;
- *size = item - list;
- return list;
-}
-
static DBusMessage *pbap_select(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
@@ -1000,114 +912,6 @@ static DBusMessage *pbap_get_size(DBusConnection *connection,
return reply;
}
-static DBusMessage *pbap_set_format(DBusConnection *connection,
- DBusMessage *message, void *user_data)
-{
- struct pbap_data *pbap = user_data;
- const char *format;
-
- if (dbus_message_get_args(message, NULL,
- DBUS_TYPE_STRING, &format,
- DBUS_TYPE_INVALID) == FALSE)
- return g_dbus_create_error(message,
- ERROR_INTERFACE ".InvalidArguments", NULL);
-
- if (set_format(pbap, format) < 0)
- return g_dbus_create_error(message,
- ERROR_INTERFACE ".InvalidArguments",
- "InvalidFormat");
-
- return dbus_message_new_method_return(message);
-}
-
-static DBusMessage *pbap_set_order(DBusConnection *connection,
- DBusMessage *message, void *user_data)
-{
- struct pbap_data *pbap = user_data;
- const char *order;
-
- if (dbus_message_get_args(message, NULL,
- DBUS_TYPE_STRING, &order,
- DBUS_TYPE_INVALID) == FALSE)
- return g_dbus_create_error(message,
- ERROR_INTERFACE ".InvalidArguments", NULL);
-
- if (set_order(pbap, order) < 0)
- return g_dbus_create_error(message,
- ERROR_INTERFACE ".InvalidArguments",
- "InvalidFilter");
-
- return dbus_message_new_method_return(message);
-}
-
-static DBusMessage *pbap_set_filter(DBusConnection *connection,
- DBusMessage *message, void *user_data)
-{
- struct pbap_data *pbap = user_data;
- char **filters, **item;
- gint size;
- uint64_t oldfilter = pbap->filter;
-
- if (dbus_message_get_args(message, NULL, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING, &filters, &size,
- DBUS_TYPE_INVALID) == FALSE)
- return g_dbus_create_error(message,
- ERROR_INTERFACE ".InvalidArguments", NULL);
-
- remove_filter(pbap, "ALL");
- if (size == 0)
- goto done;
-
- for (item = filters; *item; item++) {
- if (add_filter(pbap, *item) < 0) {
- pbap->filter = oldfilter;
- g_strfreev(filters);
- return g_dbus_create_error(message,
- ERROR_INTERFACE ".InvalidArguments",
- "InvalidFilters");
- }
- }
-
-done:
- g_strfreev(filters);
- return dbus_message_new_method_return(message);
-}
-
-static DBusMessage *pbap_get_filter(DBusConnection *connection,
- DBusMessage *message, void *user_data)
-{
- struct pbap_data *pbap = user_data;
- gchar **filters = NULL;
- gint size;
- DBusMessage *reply;
-
- filters = get_filter_strs(pbap->filter, &size);
- reply = dbus_message_new_method_return(message);
- dbus_message_append_args(reply, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING, &filters, size,
- DBUS_TYPE_INVALID);
-
- g_strfreev(filters);
- return reply;
-}
-
-static DBusMessage *pbap_list_filter_fields(DBusConnection *connection,
- DBusMessage *message, void *user_data)
-{
- gchar **filters = NULL;
- gint size;
- DBusMessage *reply;
-
- filters = get_filter_strs(FILTER_ALL, &size);
- reply = dbus_message_new_method_return(message);
- dbus_message_append_args(reply, DBUS_TYPE_ARRAY,
- DBUS_TYPE_STRING, &filters, size,
- DBUS_TYPE_INVALID);
-
- g_strfreev(filters);
- return reply;
-}
-
static const GDBusMethodTable pbap_methods[] = {
{ GDBUS_ASYNC_METHOD("Select",
GDBUS_ARGS({ "location", "s" }, { "phonebook", "s" }),
@@ -1136,21 +940,6 @@ static const GDBusMethodTable pbap_methods[] = {
{ GDBUS_ASYNC_METHOD("GetSize",
NULL, GDBUS_ARGS({ "size", "q" }),
pbap_get_size) },
- { GDBUS_METHOD("SetFormat",
- GDBUS_ARGS({ "format", "s" }), NULL,
- pbap_set_format) },
- { GDBUS_METHOD("SetOrder",
- GDBUS_ARGS({ "order", "s" }), NULL,
- pbap_set_order) },
- { GDBUS_METHOD("SetFilter",
- GDBUS_ARGS({ "fields", "as" }), NULL,
- pbap_set_filter) },
- { GDBUS_METHOD("GetFilter",
- NULL, GDBUS_ARGS({ "fields", "as" }),
- pbap_get_filter) },
- { GDBUS_METHOD("ListFilterFields",
- NULL, GDBUS_ARGS({ "fields", "as" }),
- pbap_list_filter_fields) },
{ }
};
--
1.7.11.4
^ permalink raw reply related
* [PATCH obexd 5/7] test: Update pbap-client to work with changes in PhonebookAcess
From: Luiz Augusto von Dentz @ 2012-08-24 13:59 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1345816795-14092-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
test/pbap-client | 21 +++++++++------------
1 file changed, 9 insertions(+), 12 deletions(-)
diff --git a/test/pbap-client b/test/pbap-client
index 498f8a3..7dd54ef 100755
--- a/test/pbap-client
+++ b/test/pbap-client
@@ -70,16 +70,16 @@ class PbapClient:
print "Transfer finished with error %s: %s" % (code, message)
mainloop.quit()
- def pull(self, vcard, func):
+ def pull(self, vcard, params, func):
req = Transfer(func)
- self.pbap.Pull(vcard, "",
+ self.pbap.Pull(vcard, "", params,
reply_handler=lambda r: self.register(r, req),
error_handler=self.error)
self.transfers += 1
- def pull_all(self, func):
+ def pull_all(self, params, func):
req = Transfer(func)
- self.pbap.PullAll("",
+ self.pbap.PullAll("", params,
reply_handler=lambda r: self.register(r, req),
error_handler=self.error)
self.transfers += 1
@@ -135,18 +135,15 @@ if __name__ == '__main__':
print "Size = %d\n" % (ret)
print "\n--- List vCard ---\n"
- ret = pbap_client.interface().List()
+ ret = pbap_client.interface().List(dbus.Dictionary())
+ params = dbus.Dictionary({ "Format" : "vcard30",
+ "Fields" : [ "VERSION", "FN", "TEL"] })
for item in ret:
print "%s : %s" % (item[0], item[1])
- pbap_client.interface().SetFormat("vcard30")
- pbap_client.interface().SetFilter(["VERSION", "FN",
- "TEL"]);
- pbap_client.pull(item[0],
+ pbap_client.pull(item[0], params,
lambda x: process_result(x, None))
- pbap_client.interface().SetFormat("vcard30")
- pbap_client.interface().SetFilter(["VERSION", "FN", "TEL"]);
- pbap_client.pull_all(lambda x: process_result(x,
+ pbap_client.pull_all(params, lambda x: process_result(x,
"\n--- PullAll ---\n"))
pbap_client.flush_transfers(lambda: test_paths(paths[1:]))
--
1.7.11.4
^ permalink raw reply related
* [PATCH obexd 6/7] client: Move common code to pull_phonebook
From: Luiz Augusto von Dentz @ 2012-08-24 13:59 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1345816795-14092-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
client/pbap.c | 79 +++++++++++++++++++++++------------------------------------
1 file changed, 30 insertions(+), 49 deletions(-)
diff --git a/client/pbap.c b/client/pbap.c
index 3e9301a..b460987 100644
--- a/client/pbap.c
+++ b/client/pbap.c
@@ -522,22 +522,29 @@ static GObexApparam *parse_filters(GObexApparam *apparam,
return apparam;
}
-static struct obc_transfer *pull_phonebook(struct pbap_data *pbap,
+static DBusMessage *pull_phonebook(struct pbap_data *pbap,
DBusMessage *message,
- guint8 type, const char *name,
+ guint8 type,
const char *targetfile,
- GObexApparam *apparam,
- GError **err)
+ GObexApparam *apparam)
{
struct pending_request *request;
struct obc_transfer *transfer;
+ char *name;
guint8 buf[32];
gsize len;
session_callback_t func;
+ DBusMessage *reply;
+ GError *err = NULL;
+
+ name = g_strconcat(pbap->path, ".vcf", NULL);
+
+ len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
+ g_obex_apparam_free(apparam);
- transfer = obc_transfer_get("x-bt/phonebook", name, targetfile, err);
+ transfer = obc_transfer_get("x-bt/phonebook", name, targetfile, &err);
if (transfer == NULL)
- return NULL;
+ goto fail;
switch (type) {
case PULLPHONEBOOK:
@@ -553,19 +560,28 @@ static struct obc_transfer *pull_phonebook(struct pbap_data *pbap,
return NULL;
}
- len = g_obex_apparam_encode(apparam, buf, sizeof(buf));
-
obc_transfer_set_params(transfer, buf, len);
- if (!obc_session_queue(pbap->session, transfer, func, request, err)) {
+ if (!obc_session_queue(pbap->session, transfer, func, request, &err)) {
if (request != NULL)
pending_request_free(request);
- return NULL;
+ goto fail;
}
+ g_free(name);
+
+ if (targetfile == NULL)
+ return NULL;
- return transfer;
+ return obc_transfer_create_dbus_reply(transfer, message);
+
+fail:
+ g_free(name);
+ reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s",
+ err->message);
+ g_error_free(err);
+ return reply;
}
static DBusMessage *pull_vcard_listing(struct pbap_data *pbap,
@@ -654,11 +670,8 @@ static DBusMessage *pbap_pull_all(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
struct pbap_data *pbap = user_data;
- struct obc_transfer *transfer;
const char *targetfile;
- char *name;
GObexApparam *apparam;
- GError *err = NULL;
DBusMessageIter args;
if (!pbap->path)
@@ -686,22 +699,8 @@ static DBusMessage *pbap_pull_all(DBusConnection *connection,
ERROR_INTERFACE ".InvalidArguments", NULL);
}
- name = g_strconcat(pbap->path, ".vcf", NULL);
-
- transfer = pull_phonebook(pbap, message, PULLPHONEBOOK, name,
- targetfile, apparam, &err);
- g_free(name);
- g_obex_apparam_free(apparam);
-
- if (transfer == NULL) {
- DBusMessage *reply = g_dbus_create_error(message,
- ERROR_INTERFACE ".Failed", "%s",
- err->message);
- g_error_free(err);
- return reply;
- }
-
- return obc_transfer_create_dbus_reply(transfer, message);
+ return pull_phonebook(pbap, message, PULLPHONEBOOK, targetfile,
+ apparam);
}
static DBusMessage *pull_vcard(struct pbap_data *pbap, DBusMessage *message,
@@ -877,11 +876,7 @@ static DBusMessage *pbap_get_size(DBusConnection *connection,
DBusMessage *message, void *user_data)
{
struct pbap_data *pbap = user_data;
- DBusMessage *reply;
- struct obc_transfer *transfer;
- char *name;
GObexApparam *apparam;
- GError *err = NULL;
DBusMessageIter args;
if (!pbap->path)
@@ -891,25 +886,11 @@ static DBusMessage *pbap_get_size(DBusConnection *connection,
dbus_message_iter_init(message, &args);
- name = g_strconcat(pbap->path, ".vcf", NULL);
-
apparam = g_obex_apparam_set_uint16(NULL, MAXLISTCOUNT_TAG, 0);
apparam = g_obex_apparam_set_uint16(apparam, LISTSTARTOFFSET_TAG,
DEFAULT_OFFSET);
- transfer = pull_phonebook(pbap, message, GETPHONEBOOKSIZE, name, NULL,
- apparam, &err);
-
- g_free(name);
- g_obex_apparam_free(apparam);
-
- if (transfer != NULL)
- return NULL;
-
- reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s",
- err->message);
- g_error_free(err);
- return reply;
+ return pull_phonebook(pbap, message, GETPHONEBOOKSIZE, NULL, apparam);
}
static const GDBusMethodTable pbap_methods[] = {
--
1.7.11.4
^ permalink raw reply related
* [PATCH obexd 7/7] client-doc: Update documentation of PhonebookAccess interface
From: Luiz Augusto von Dentz @ 2012-08-24 13:59 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1345816795-14092-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
doc/client-api.txt | 180 ++++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 145 insertions(+), 35 deletions(-)
diff --git a/doc/client-api.txt b/doc/client-api.txt
index 839a78c..adbb12d 100644
--- a/doc/client-api.txt
+++ b/doc/client-api.txt
@@ -206,7 +206,7 @@ Methods void Select(string location, string phonebook)
"mch": missing call history
"cch": combination of ich och mch
- object, dict PullAll(string targetfile)
+ object, dict PullAll(string targetfile, dict filters)
Return the entire phonebook object from the PSE server
in plain string with vcard format, and store it in
@@ -222,14 +222,95 @@ Methods void Select(string location, string phonebook)
The properties of this transfer are also returned along
with the object path, to avoid a call to GetProperties.
- array{string vcard, string name} List()
+ filters:
+
+ string Format:
+
+ Items vcard format
+
+ Possible values: "vcard21" (default) or
+ "vcard30"
+
+ string Order:
+
+ Items order
+
+ Possible values: "indexed" (default),
+ "alphanumeric" or "phonetic"
+
+ uint16 Offset:
+
+ Offset of the first item, default is 0
+
+ uint16 Items:
+
+ Maximum number of items, default is
+ unlimited (65535)
+
+ array{string} Fields:
+
+ Item vcard fields, default is all
+ values.
+
+ Possible values:
+
+ "VERSION",
+ "FN",
+ "N",
+ "PHOTO",
+ "BDAY",
+ "ADR",
+ "LABEL",
+ "TEL",
+ "EMAIL",
+ "MAILER",
+ "TZ",
+ "GEO",
+ "TITLE",
+ "ROLE",
+ "LOGO",
+ "AGENT",
+ "ORG",
+ "NOTE",
+ "REV",
+ "SOUND",
+ "URL",
+ "UID",
+ "KEY",
+ "NICKNAME",
+ "CATEGORIES",
+ "PROID",
+ "CLASS",
+ "SORT-STRING",
+ "X-IRMC-CALL-DATETIME"
+
+ array{string vcard, string name} List(dict filters)
Return an array of vcard-listing data where every entry
consists of a pair of strings containing the vcard
handle and the contact name. For example:
"1.vcf" : "John"
- object, dict Pull(string vcard, string targetfile)
+ filters:
+
+ string Order:
+
+ Items order
+
+ Possible values: "indexed" (default),
+ "alphanumeric" or "phonetic"
+
+ uint16 Offset:
+
+ Offset of the first item, default is 0
+
+ uint16 Items:
+
+ Maximum number of items, default is
+ unlimited (65535)
+
+ object, dict
+ Pull(string vcard, string targetfile, dict filters)
Given a vcard handle, retrieve the vcard in the current
phonebook object and store it in a local file.
@@ -244,8 +325,54 @@ Methods void Select(string location, string phonebook)
The properties of this transfer are also returned along
with the object path, to avoid a call to GetProperties.
+ filters:
+
+ string Format:
+
+ Items vcard format
+
+ Possible values: "vcard21" (default) or
+ "vcard30"
+
+ array{string} Fields:
+
+ Item vcard fields, default is all
+ values.
+
+ Possible values:
+
+ "VERSION",
+ "FN",
+ "N",
+ "PHOTO",
+ "BDAY",
+ "ADR",
+ "LABEL",
+ "TEL",
+ "EMAIL",
+ "MAILER",
+ "TZ",
+ "GEO",
+ "TITLE",
+ "ROLE",
+ "LOGO",
+ "AGENT",
+ "ORG",
+ "NOTE",
+ "REV",
+ "SOUND",
+ "URL",
+ "UID",
+ "KEY",
+ "NICKNAME",
+ "CATEGORIES",
+ "PROID",
+ "CLASS",
+ "SORT-STRING",
+ "X-IRMC-CALL-DATETIME"
+
array{string vcard, string name}
- Search(string field, string value)
+ Search(string field, string value, dict filters)
Search for entries matching the given condition and
return an array of vcard-listing data where every entry
@@ -258,47 +385,30 @@ Methods void Select(string location, string phonebook)
{ "name" (default) | "number" | "sound" }
value : the string value to search for
- uint16 GetSize()
-
- Return the number of entries in the selected phonebook
- object that are actually used (i.e. indexes that
- correspond to non-NULL entries).
-
- void SetFormat(string format)
-
- Indicate the format of the vcard that should be return
- by related methods.
-
- format : { "vcard21" (default) | "vcard30" }
-
- void SetOrder(string order)
+ filters:
- Indicate the sorting method of the vcard-listing data
- returned by List and Search methods.
+ string Order:
- order : { "indexed" (default) | "alphanumeric" |
- "phonetic" }
+ Items order
- void SetFilter(array{string})
+ Possible values: "indexed" (default),
+ "alphanumeric" or "phonetic"
- Indicate fields that should be contained in vcards
- return by related methods.
+ uint16 Offset:
- Give an empty array will clear the filter and return
- all fields available in vcards. And this is the default
- behavior.
+ Offset of the first item, default is 0
- Possible filter fields : "VERSION", "FN", ..., "ALL",
- "bit[0-63]"
+ uint16 Items:
- array{string} ListFilterFields()
+ Maximum number of items, default is
+ unlimited (65535)
- Return All Available fields that can be used in
- SetFilter method.
+ uint16 GetSize()
- array{string} GetFilter()
+ Return the number of entries in the selected phonebook
+ object that are actually used (i.e. indexes that
+ correspond to non-NULL entries).
- Return the current filter setting
Synchronization hierarchy
=======================
--
1.7.11.4
^ permalink raw reply related
* [PATCHv2 00/22] Bluetooth: Create AMP physical link
From: Andrei Emeltchenko @ 2012-08-24 13:59 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1340981212-21709-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This set of patches enhances A2MP protocol and creates physical
link between AMP controllers. This is further iteration towards
Bluetooth High Speed.
Changes:
* p2: Remove HCI callbacks and use amp_mgr global list, refactor code.
* p1: Fixed locking issues, added basic logical link preparation.
* v3: Remove workqueue from callback processing; change callback functions
names according to reviewers recommendations; create global amp_mgr_list to
have lookup to amp manager, physical and logical links so for those HCI events
which might be identified by __handler__ we have lookup; remove extensive
hexdump from gen_amp_key.
* v2: Fix typos and bugs, add functionality: now physical connection
might be established.
* v1: Fix typos, change debug prints, refactor code for better
splitting functionality.
Andrei Emeltchenko (21):
Bluetooth: debug: Print refcnt for hci_dev
Bluetooth: trivial: Remove empty line
Bluetooth: Add HCI logical link cmds definitions
Bluetooth: A2MP: Create amp_mgr global list
Bluetooth: AMP: Use HCI cmd to Read AMP Info
Bluetooth: AMP: Use HCI cmd to Read Loc AMP Assoc
Bluetooth: A2MP: Process Discover Response
Bluetooth: AMP: Physical link struct definitions
Bluetooth: Add phylink lookup helper function
Bluetooth: AMP: Remote AMP ctrl definitions
Bluetooth: AMP: Use phylink in create/disc phylink req
Bluetooth: A2MP: Process A2MP Getinfo Rsp
Bluetooth: A2MP: Process A2MP Get AMP Assoc Rsp
Bluetooth: Choose connection based on capabilities
Bluetooth: Close A2MP chan when deleting corr L2CAP chan
Bluetooth: AMP: Add AMP key calculation
Bluetooth: AMP: Create Physical Link
Bluetooth: AMP: Write remote AMP Assoc
Bluetooth: A2MP: Add fallback to normal l2cap init sequence
Bluetooth: AMP: Process Chan Selected event
Bluetooth: AMP: Process physical link complete event
Dmitry Kasatkin (1):
Bluetooth: Add function to derive AMP key using hmac
include/net/bluetooth/a2mp.h | 23 +++
include/net/bluetooth/amp.h | 29 +++
include/net/bluetooth/hci.h | 39 +++-
include/net/bluetooth/hci_core.h | 17 ++
include/net/bluetooth/l2cap.h | 2 +
include/net/bluetooth/pal.h | 58 ++++++
net/bluetooth/Kconfig | 1 +
net/bluetooth/Makefile | 2 +-
net/bluetooth/a2mp.c | 421 +++++++++++++++++++++++++++++++++++---
net/bluetooth/amp.c | 156 ++++++++++++++
net/bluetooth/hci_core.c | 1 -
net/bluetooth/hci_event.c | 156 +++++++++++++-
net/bluetooth/l2cap_core.c | 44 +++-
net/bluetooth/pal.c | 330 ++++++++++++++++++++++++++++++
14 files changed, 1241 insertions(+), 38 deletions(-)
create mode 100644 include/net/bluetooth/amp.h
create mode 100644 include/net/bluetooth/pal.h
create mode 100644 net/bluetooth/amp.c
create mode 100644 net/bluetooth/pal.c
--
1.7.9.5
^ permalink raw reply
* [PATCHv2 01/22] Bluetooth: debug: Print refcnt for hci_dev
From: Andrei Emeltchenko @ 2012-08-24 14:00 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1345816821-32331-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/hci_core.h | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 1bbc109..5354e7b 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -612,11 +612,17 @@ static inline void hci_conn_put(struct hci_conn *conn)
/* ----- HCI Devices ----- */
static inline void hci_dev_put(struct hci_dev *d)
{
+ BT_DBG("%s orig refcnt %d", d->name,
+ atomic_read(&d->dev.kobj.kref.refcount));
+
put_device(&d->dev);
}
static inline struct hci_dev *hci_dev_hold(struct hci_dev *d)
{
+ BT_DBG("%s orig refcnt %d", d->name,
+ atomic_read(&d->dev.kobj.kref.refcount));
+
get_device(&d->dev);
return d;
}
--
1.7.9.5
^ permalink raw reply related
* [PATCHv2 02/22] Bluetooth: trivial: Remove empty line
From: Andrei Emeltchenko @ 2012-08-24 14:00 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1345816821-32331-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
net/bluetooth/hci_core.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 28bab9d..42c00d18 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -268,7 +268,6 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
BT_ERR("Unknown device type %d", hdev->dev_type);
break;
}
-
}
static void hci_le_init_req(struct hci_dev *hdev, unsigned long opt)
--
1.7.9.5
^ permalink raw reply related
* [PATCHv2 03/22] Bluetooth: Add HCI logical link cmds definitions
From: Andrei Emeltchenko @ 2012-08-24 14:00 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1345816821-32331-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/hci.h | 36 +++++++++++++++++++++++++++++++++++-
1 file changed, 35 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 0f28f70..42aae18 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -556,12 +556,46 @@ struct hci_cp_accept_phy_link {
__u8 key[HCI_AMP_LINK_KEY_SIZE];
} __packed;
-#define HCI_OP_DISCONN_PHY_LINK 0x0437
+#define HCI_OP_DISCONN_PHY_LINK 0x0437
struct hci_cp_disconn_phy_link {
__u8 phy_handle;
__u8 reason;
} __packed;
+struct ext_flow_spec {
+ __u8 id;
+ __u8 stype;
+ __le16 msdu;
+ __le32 sdu_itime;
+ __le32 acc_lat;
+ __le32 flush_to;
+} __packed;
+
+#define HCI_OP_CREATE_LOGICAL_LINK 0x0438
+#define HCI_OP_ACCEPT_LOGICAL_LINK 0x0439
+struct hci_cp_create_accept_logical_link {
+ __u8 phy_handle;
+ struct ext_flow_spec tx_flow_spec;
+ struct ext_flow_spec rx_flow_spec;
+} __packed;
+
+#define HCI_OP_DISCONN_LOGICAL_LINK 0x043a
+struct hci_cp_disconn_logical_link {
+ __le16 log_handle;
+} __packed;
+
+#define HCI_OP_LOGICAL_LINK_CANCEL 0x043b
+struct hci_cp_logical_link_cancel {
+ __u8 phy_handle;
+ __u8 flow_spec_id;
+} __packed;
+
+struct hci_rp_logical_link_cancel {
+ __u8 status;
+ __u8 phy_handle;
+ __u8 flow_spec_id;
+} __packed;
+
#define HCI_OP_SNIFF_MODE 0x0803
struct hci_cp_sniff_mode {
__le16 handle;
--
1.7.9.5
^ permalink raw reply related
* [PATCHv2 04/22] Bluetooth: A2MP: Create amp_mgr global list
From: Andrei Emeltchenko @ 2012-08-24 14:00 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1345816821-32331-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Create amp_mgr_list global list which will be used by different
hci devices to find amp_mgr.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/a2mp.h | 8 ++++++++
net/bluetooth/a2mp.c | 29 +++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/include/net/bluetooth/a2mp.h b/include/net/bluetooth/a2mp.h
index 6a76e0a..e56d656 100644
--- a/include/net/bluetooth/a2mp.h
+++ b/include/net/bluetooth/a2mp.h
@@ -20,11 +20,15 @@
#define A2MP_FEAT_EXT 0x8000
struct amp_mgr {
+ struct list_head list;
struct l2cap_conn *l2cap_conn;
struct l2cap_chan *a2mp_chan;
struct kref kref;
__u8 ident;
__u8 handle;
+ enum {
+ READ_LOC_AMP_INFO,
+ } state;
unsigned long flags;
};
@@ -118,9 +122,13 @@ struct a2mp_physlink_rsp {
#define A2MP_STATUS_PHYS_LINK_EXISTS 0x05
#define A2MP_STATUS_SECURITY_VIOLATION 0x06
+extern struct list_head amp_mgr_list;
+extern struct mutex amp_mgr_list_lock;
+
void amp_mgr_get(struct amp_mgr *mgr);
int amp_mgr_put(struct amp_mgr *mgr);
struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
struct sk_buff *skb);
+struct amp_mgr *amp_mgr_lookup_by_state(u8 state);
#endif /* __A2MP_H */
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
index 44ef201..81d72be 100644
--- a/net/bluetooth/a2mp.c
+++ b/net/bluetooth/a2mp.c
@@ -17,6 +17,10 @@
#include <net/bluetooth/l2cap.h>
#include <net/bluetooth/a2mp.h>
+/* Global AMP Manager list */
+LIST_HEAD(amp_mgr_list);
+DEFINE_MUTEX(amp_mgr_list_lock);
+
/* A2MP build & send command helper functions */
static struct a2mp_cmd *__a2mp_build(u8 code, u8 ident, u16 len, void *data)
{
@@ -518,6 +522,10 @@ static void amp_mgr_destroy(struct kref *kref)
BT_DBG("mgr %p", mgr);
+ mutex_lock(&_mgr_list_lock);
+ list_del(&mgr->list);
+ mutex_unlock(&_mgr_list_lock);
+
kfree(mgr);
}
@@ -552,6 +560,10 @@ static struct amp_mgr *amp_mgr_create(struct l2cap_conn *conn)
conn->hcon->amp_mgr = mgr;
+ mutex_lock(&_mgr_list_lock);
+ list_add(&mgr->list, &_mgr_list);
+ mutex_unlock(&_mgr_list_lock);
+
kref_init(&mgr->kref);
return mgr;
@@ -572,3 +584,20 @@ struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
return mgr->a2mp_chan;
}
+
+struct amp_mgr *amp_mgr_lookup_by_state(u8 state)
+{
+ struct amp_mgr *mgr;
+
+ mutex_lock(&_mgr_list_lock);
+ list_for_each_entry(mgr, &_mgr_list, list) {
+ if (mgr->state == state) {
+ amp_mgr_get(mgr);
+ mutex_unlock(&_mgr_list_lock);
+ return mgr;
+ }
+ }
+ mutex_unlock(&_mgr_list_lock);
+
+ return NULL;
+}
--
1.7.9.5
^ permalink raw reply related
* [PATCHv2 05/22] Bluetooth: AMP: Use HCI cmd to Read AMP Info
From: Andrei Emeltchenko @ 2012-08-24 14:00 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1345816821-32331-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
When receiving A2MP Get Info Request execute Read Local AMP Info HCI
command to AMP controller with function to be executed upon receiving
command complete event. Function will handle A2MP Get Info Response.
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
include/net/bluetooth/a2mp.h | 2 ++
net/bluetooth/a2mp.c | 57 ++++++++++++++++++++++++++++++------------
net/bluetooth/hci_event.c | 6 ++++-
3 files changed, 48 insertions(+), 17 deletions(-)
diff --git a/include/net/bluetooth/a2mp.h b/include/net/bluetooth/a2mp.h
index e56d656..c21268a 100644
--- a/include/net/bluetooth/a2mp.h
+++ b/include/net/bluetooth/a2mp.h
@@ -130,5 +130,7 @@ int amp_mgr_put(struct amp_mgr *mgr);
struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn,
struct sk_buff *skb);
struct amp_mgr *amp_mgr_lookup_by_state(u8 state);
+void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data);
+void a2mp_send_getinfo_rsp(struct hci_dev *hdev);
#endif /* __A2MP_H */
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
index 81d72be..0a46bd6 100644
--- a/net/bluetooth/a2mp.c
+++ b/net/bluetooth/a2mp.c
@@ -41,8 +41,7 @@ static struct a2mp_cmd *__a2mp_build(u8 code, u8 ident, u16 len, void *data)
return cmd;
}
-static void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len,
- void *data)
+void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data)
{
struct l2cap_chan *chan = mgr->a2mp_chan;
struct a2mp_cmd *cmd;
@@ -185,7 +184,6 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
struct a2mp_cmd *hdr)
{
struct a2mp_info_req *req = (void *) skb->data;
- struct a2mp_info_rsp rsp;
struct hci_dev *hdev;
if (le16_to_cpu(hdr->len) < sizeof(*req))
@@ -193,23 +191,23 @@ static int a2mp_getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb,
BT_DBG("id %d", req->id);
- rsp.id = req->id;
- rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
-
hdev = hci_dev_get(req->id);
- if (hdev && hdev->amp_type != HCI_BREDR) {
- rsp.status = 0;
- rsp.total_bw = cpu_to_le32(hdev->amp_total_bw);
- rsp.max_bw = cpu_to_le32(hdev->amp_max_bw);
- rsp.min_latency = cpu_to_le32(hdev->amp_min_latency);
- rsp.pal_cap = cpu_to_le16(hdev->amp_pal_cap);
- rsp.assoc_size = cpu_to_le16(hdev->amp_assoc_size);
+ if (!hdev) {
+ struct a2mp_info_rsp rsp;
+
+ rsp.id = req->id;
+ rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
+
+ a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp),
+ &rsp);
}
- if (hdev)
- hci_dev_put(hdev);
+ if (hdev->dev_type != HCI_BREDR) {
+ mgr->state = READ_LOC_AMP_INFO;
+ hci_send_cmd(hdev, HCI_OP_READ_LOCAL_AMP_INFO, 0, NULL);
+ }
- a2mp_send(mgr, A2MP_GETINFO_RSP, hdr->ident, sizeof(rsp), &rsp);
+ hci_dev_put(hdev);
skb_pull(skb, sizeof(*req));
return 0;
@@ -601,3 +599,30 @@ struct amp_mgr *amp_mgr_lookup_by_state(u8 state)
return NULL;
}
+
+void a2mp_send_getinfo_rsp(struct hci_dev *hdev)
+{
+ struct amp_mgr *mgr;
+ struct a2mp_info_rsp rsp;
+
+ mgr = amp_mgr_lookup_by_state(READ_LOC_AMP_INFO);
+ if (!mgr)
+ return;
+
+ BT_DBG("%s mgr %p", hdev->name, mgr);
+
+ rsp.id = hdev->id;
+ rsp.status = A2MP_STATUS_INVALID_CTRL_ID;
+
+ if (hdev->amp_type != HCI_BREDR) {
+ rsp.status = 0;
+ rsp.total_bw = cpu_to_le32(hdev->amp_total_bw);
+ rsp.max_bw = cpu_to_le32(hdev->amp_max_bw);
+ rsp.min_latency = cpu_to_le32(hdev->amp_min_latency);
+ rsp.pal_cap = cpu_to_le16(hdev->amp_pal_cap);
+ rsp.assoc_size = cpu_to_le16(hdev->amp_assoc_size);
+ }
+
+ a2mp_send(mgr, A2MP_GETINFO_RSP, mgr->ident, sizeof(rsp), &rsp);
+ amp_mgr_put(mgr);
+}
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 1f49957..e95e1e5 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -30,6 +30,7 @@
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/mgmt.h>
+#include <net/bluetooth/a2mp.h>
/* Handle HCI Event packets */
@@ -846,7 +847,7 @@ static void hci_cc_read_local_amp_info(struct hci_dev *hdev,
BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
if (rp->status)
- return;
+ goto a2mp_rsp;
hdev->amp_status = rp->amp_status;
hdev->amp_total_bw = __le32_to_cpu(rp->total_bw);
@@ -860,6 +861,9 @@ static void hci_cc_read_local_amp_info(struct hci_dev *hdev,
hdev->amp_max_flush_to = __le32_to_cpu(rp->max_flush_to);
hci_req_complete(hdev, HCI_OP_READ_LOCAL_AMP_INFO, rp->status);
+
+a2mp_rsp:
+ a2mp_send_getinfo_rsp(hdev);
}
static void hci_cc_delete_stored_link_key(struct hci_dev *hdev,
--
1.7.9.5
^ 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