* Re: setting BT connection over RFCOMM
From: Kevin Wilson @ 2012-12-22 17:22 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <CAGXs5wXEEnO084sg1Er-SgB3-TU+W5HtjsKnY7CdT9Hsw+jjew@mail.gmail.com>
Hi all,
Please ignore my question. It turns out that
CONFIG_BT_RFCOMM_TTY was not set.
As a result, there was an error on the server
which prevented connection establishment,
Now after setting CONFIG_BT_RFCOMM_TTY,
it works.
rgs
Kevin
On Sat, Dec 22, 2012 at 6:48 AM, Kevin Wilson <wkevils@gmail.com> wrote:
> connect rfcomm0
^ permalink raw reply
* Re: [PATCH BlueZ 4/4] hog: Remove pre-existing suspend FIFO
From: Johan Hedberg @ 2012-12-22 16:51 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: João Paulo Rechi Vita, linux-bluetooth
In-Reply-To: <1356194171.29264.14.camel@aeonflux>
Hi Marcel,
On Sat, Dec 22, 2012, Marcel Holtmann wrote:
> > + if (remove(HOG_SUSPEND_FIFO) < 0) {
>
> you are looking for unlink() to use here.
Since I already applied the patches I went ahead and fixed this myself.
Johan
^ permalink raw reply
* Re: [PATCH 1/2] Bluetooth: Fix to update EIR for uuid16 properly
From: Marcel Holtmann @ 2012-12-22 16:39 UTC (permalink / raw)
To: Johan Hedberg; +Cc: Syam Sidhardhan, linux-bluetooth
In-Reply-To: <20121221193112.GA31432@x220.ger.corp.intel.com>
Hi Johan,
> > If we register a uuid other than uuid16, especially custom 128 bit uuid
> > then nothing is updated in the EIR and it was broken.
> >
> > After registering a 16 bit uuid. ex: "sdptool add SP", we can see the
> > uuid in the EIR as below.
> > < 0000: 01 52 0c f1 00 08 09 52 65 64 77 6f 6f 64 15 03 .R.....Redwood..
> > 0010: 01 11 32 11 2f 11 06 11 05 11 0a 11 0e 11 0c 11 ..2./...........
> > 0020: 1f 11 12 11 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 00a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 00b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 00c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 00d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 00e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 00f0: 00 00 00 00 00 .....
> > > 0000: 04 0e 04 01 52 0c 00 ....R..
> >
> > But after register a user defined 128 bit uuid, nothing is
> > updated in the EIR.
> >
> > < 0000: 01 52 0c f1 00 08 09 52 65 64 77 6f 6f 64 00 00 .R.....Redwood..
> > 0010: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0030: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0040: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0050: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0060: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0070: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 0090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 00a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 00b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 00c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 00d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 00e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
> > 00f0: 00 00 00 00 00 .....
> > > 0000: 04 0e 04 01 52 0c 00 ....R..
> >
> > With this fix, we can see the EIR is updated properly.
> >
> > Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
> > ---
> > net/bluetooth/mgmt.c | 2 --
> > 1 file changed, 2 deletions(-)
> >
> > diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
> > index f559b96..512a3f5 100644
> > --- a/net/bluetooth/mgmt.c
> > +++ b/net/bluetooth/mgmt.c
> > @@ -514,8 +514,6 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
> > u16 uuid16;
> >
> > uuid16 = get_uuid16(uuid->uuid);
> > - if (uuid16 == 0)
> > - return;
> >
> > if (uuid16 < 0x1100)
> > continue;
>
> Nak. The bug is real and should be fixed but your fix is wrong. The
> right fix it to convert this return statement into a continue statement
> since we do still want to check for a 0 return value from get_uuid16.
>
> Along with this patch please prepare another one to increment the mgmt
> revision. These two should go together to upstream trees so that we can
> introduce a check in user space to know whether it's safe to pass
> non-16bit UUIDs to the kernel or not.
I want a fix that introduces also support for 32-bit and 128-bit UUIDs
now. No paper over the hole fixing here.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH BlueZ 4/4] hog: Remove pre-existing suspend FIFO
From: Marcel Holtmann @ 2012-12-22 16:36 UTC (permalink / raw)
To: João Paulo Rechi Vita; +Cc: linux-bluetooth
In-Reply-To: <1356189162-11584-4-git-send-email-jprvita@openbossa.org>
Hi Joao Paulo,
> If bluetoothd crashes the exit routine of the suspend plugin will not be
> executed, leaving the suspend FIFO behind and preventing the plugin load
> on subsequent executions. This commit checks for pre-existence of the
> suspend FIFO and tries to remove and re-create it.
> ---
> profiles/input/suspend-dummy.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/profiles/input/suspend-dummy.c b/profiles/input/suspend-dummy.c
> index 33b790a..43384c0 100644
> --- a/profiles/input/suspend-dummy.c
> +++ b/profiles/input/suspend-dummy.c
> @@ -119,6 +119,22 @@ int suspend_init(suspend_event suspend, resume_event resume)
>
> if (mkfifo(HOG_SUSPEND_FIFO, S_IRWXU) < 0) {
> int err = -errno;
> +
> + if (err == -EEXIST) {
> + DBG("FIFO (%s) already exists, trying to remove",
> + HOG_SUSPEND_FIFO);
> +
> + /* remove pre-existing FIFO and retry */
> + if (remove(HOG_SUSPEND_FIFO) < 0) {
you are looking for unlink() to use here.
> + err = -errno;
> + error("Failed to remove FIFO (%s): %s (%d)",
> + HOG_SUSPEND_FIFO, strerror(-err), -err);
> + return err;
> + }
> +
> + return suspend_init(suspend, resume);
> + }
> +
> error("Can't create FIFO (%s): %s (%d)", HOG_SUSPEND_FIFO,
> strerror(-err), -err);
> return err;
Regards
Marcel
^ permalink raw reply
* Re: [PATCH BlueZ 1/4] hog: Fix message text and level when failing to load suspend plugin
From: Johan Hedberg @ 2012-12-22 16:35 UTC (permalink / raw)
To: João Paulo Rechi Vita; +Cc: linux-bluetooth
In-Reply-To: <1356189162-11584-1-git-send-email-jprvita@openbossa.org>
Hi João Paulo,
On Sat, Dec 22, 2012, João Paulo Rechi Vita wrote:
> ---
> profiles/input/hog.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
All four patches have been applied. Thanks.
Johan
^ permalink raw reply
* [PATCH BlueZ 4/4] hog: Remove pre-existing suspend FIFO
From: João Paulo Rechi Vita @ 2012-12-22 15:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: João Paulo Rechi Vita
In-Reply-To: <1356189162-11584-1-git-send-email-jprvita@openbossa.org>
If bluetoothd crashes the exit routine of the suspend plugin will not be
executed, leaving the suspend FIFO behind and preventing the plugin load
on subsequent executions. This commit checks for pre-existence of the
suspend FIFO and tries to remove and re-create it.
---
profiles/input/suspend-dummy.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/profiles/input/suspend-dummy.c b/profiles/input/suspend-dummy.c
index 33b790a..43384c0 100644
--- a/profiles/input/suspend-dummy.c
+++ b/profiles/input/suspend-dummy.c
@@ -119,6 +119,22 @@ int suspend_init(suspend_event suspend, resume_event resume)
if (mkfifo(HOG_SUSPEND_FIFO, S_IRWXU) < 0) {
int err = -errno;
+
+ if (err == -EEXIST) {
+ DBG("FIFO (%s) already exists, trying to remove",
+ HOG_SUSPEND_FIFO);
+
+ /* remove pre-existing FIFO and retry */
+ if (remove(HOG_SUSPEND_FIFO) < 0) {
+ err = -errno;
+ error("Failed to remove FIFO (%s): %s (%d)",
+ HOG_SUSPEND_FIFO, strerror(-err), -err);
+ return err;
+ }
+
+ return suspend_init(suspend, resume);
+ }
+
error("Can't create FIFO (%s): %s (%d)", HOG_SUSPEND_FIFO,
strerror(-err), -err);
return err;
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 3/4] hog: Fix error message formating
From: João Paulo Rechi Vita @ 2012-12-22 15:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: João Paulo Rechi Vita
In-Reply-To: <1356189162-11584-1-git-send-email-jprvita@openbossa.org>
---
profiles/input/suspend-dummy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/profiles/input/suspend-dummy.c b/profiles/input/suspend-dummy.c
index 14aabd0..33b790a 100644
--- a/profiles/input/suspend-dummy.c
+++ b/profiles/input/suspend-dummy.c
@@ -119,7 +119,7 @@ int suspend_init(suspend_event suspend, resume_event resume)
if (mkfifo(HOG_SUSPEND_FIFO, S_IRWXU) < 0) {
int err = -errno;
- error("Can't create FIFO (%s) : %s(%d)", HOG_SUSPEND_FIFO,
+ error("Can't create FIFO (%s): %s (%d)", HOG_SUSPEND_FIFO,
strerror(-err), -err);
return err;
}
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 2/4] hog: Add debug info when initializing the suspend plugin
From: João Paulo Rechi Vita @ 2012-12-22 15:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: João Paulo Rechi Vita
In-Reply-To: <1356189162-11584-1-git-send-email-jprvita@openbossa.org>
---
profiles/input/suspend-dummy.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/profiles/input/suspend-dummy.c b/profiles/input/suspend-dummy.c
index b43946d..14aabd0 100644
--- a/profiles/input/suspend-dummy.c
+++ b/profiles/input/suspend-dummy.c
@@ -124,6 +124,8 @@ int suspend_init(suspend_event suspend, resume_event resume)
return err;
}
+ DBG("Created suspend-dummy FIFO on %s", HOG_SUSPEND_FIFO);
+
ret = fifo_open();
if (ret < 0)
remove(HOG_SUSPEND_FIFO);
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 1/4] hog: Fix message text and level when failing to load suspend plugin
From: João Paulo Rechi Vita @ 2012-12-22 15:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: João Paulo Rechi Vita
---
profiles/input/hog.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/profiles/input/hog.c b/profiles/input/hog.c
index b6ac61d..a9018f5 100644
--- a/profiles/input/hog.c
+++ b/profiles/input/hog.c
@@ -885,7 +885,8 @@ static int hog_init(void)
err = suspend_init(suspend_callback, resume_callback);
if (err < 0)
- DBG("Suspend: %s(%d)", strerror(-err), -err);
+ error("Loading suspend plugin failed: %s (%d)", strerror(-err),
+ -err);
else
suspend_supported = TRUE;
--
1.7.11.7
^ permalink raw reply related
* setting BT connection over RFCOMM
From: Kevin Wilson @ 2012-12-22 4:48 UTC (permalink / raw)
To: linux-bluetooth
Hi.
I am trying to establish BT connections between two PCs over RFCOMM serial port.
I ran on both:
sdptool add --channel=15 SP
then, on the server, I ran:
rfcomm listen rfcomm0 15
Waiting for connection on channel 15
and on the client, I ran:
hcitool scan
Scanning ...
00:23:4E:E5:70:3A n-0
rfcomm connect rfcomm0 00:23:4E:E5:70:3A
I got: (after a while)
Can't connect RFCOMM socket: Connection refused
shouldn't it work?
hcidump on the server gives this:
[root@n ~]\>hcidump
HCI sniffer - Bluetooth packet analyzer ver 2.2
device: hci0 snap_len: 1028 filter: 0xffffffffffffffff
> HCI Event: Connect Request (0x04) plen 10
bdaddr 00:02:72:AA:FB:94 class 0x500100 type ACL
< HCI Command: Accept Connection Request (0x01|0x0009) plen 7
bdaddr 00:02:72:AA:FB:94 role 0x00
Role: Master
> HCI Event: Command Status (0x0f) plen 4
Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1
> HCI Event: Role Change (0x12) plen 8
status 0x00 bdaddr 00:02:72:AA:FB:94 role 0x00
Role: Master
> HCI Event: Connect Complete (0x03) plen 11
status 0x00 handle 12 bdaddr 00:02:72:AA:FB:94 type ACL encrypt 0x00
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2
handle 12
> HCI Event: Command Status (0x0f) plen 4
Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
> HCI Event: Read Remote Supported Features (0x0b) plen 11
status 0x00 handle 12
Features: 0xff 0xff 0x8f 0xfe 0x9b 0xff 0x79 0x83
< HCI Command: Read Remote Extended Features (0x01|0x001c) plen 3
handle 12 page 1
> HCI Event: Command Status (0x0f) plen 4
Read Remote Extended Features (0x01|0x001c) status 0x00 ncmd 1
> HCI Event: Max Slots Change (0x1b) plen 3
handle 12 slots 5
> HCI Event: Read Remote Extended Features (0x23) plen 13
status 0x00 handle 12 page 1 max 1
Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
bdaddr 00:02:72:AA:FB:94 mode 2 clkoffset 0x0000
> HCI Event: Command Status (0x0f) plen 4
Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
> HCI Event: Remote Name Req Complete (0x07) plen 255
status 0x00 bdaddr 00:02:72:AA:FB:94 name 'h-0'
> HCI Event: IO Capability Response (0x32) plen 9
bdaddr 00:02:72:AA:FB:94 capability 0x01 oob 0x00 auth 0x00
Capability: DisplayYesNo (OOB data not present)
Authentication: No Bonding (No MITM Protection)
> HCI Event: IO Capability Request (0x31) plen 6
bdaddr 00:02:72:AA:FB:94
< HCI Command: IO Capability Request Reply (0x01|0x002b) plen 9
bdaddr 00:02:72:AA:FB:94 capability 0x03 oob 0x00 auth 0x00
Capability: NoInputNoOutput (OOB data not present)
Authentication: No Bonding (No MITM Protection)
> HCI Event: Command Complete (0x0e) plen 10
IO Capability Request Reply (0x01|0x002b) ncmd 1
status 0x00 bdaddr 00:02:72:AA:FB:94
> HCI Event: User Confirmation Request (0x33) plen 10
bdaddr 00:02:72:AA:FB:94 passkey 215699
< HCI Command: User Confirmation Request Reply (0x01|0x002c) plen 6
bdaddr 00:02:72:AA:FB:94
> HCI Event: Command Complete (0x0e) plen 10
User Confirmation Request Reply (0x01|0x002c) ncmd 1
status 0x00 bdaddr 00:02:72:AA:FB:94
> HCI Event: Simple Pairing Complete (0x36) plen 7
status 0x00 bdaddr 00:02:72:AA:FB:94
> HCI Event: Link Key Notification (0x18) plen 23
bdaddr 00:02:72:AA:FB:94 key 774160EF3B5C52E709937AF2D82885F4 type 4
Type: Unauthenticated Combination Key
> HCI Event: Encrypt Change (0x08) plen 4
status 0x00 handle 12 encrypt 0x01
> ACL data: handle 12 flags 0x02 dlen 10
L2CAP(s): Info req: type 2
< ACL data: handle 12 flags 0x00 dlen 16
L2CAP(s): Info rsp: type 2 result 0
Extended feature mask 0x00b8
Enhanced Retransmission mode
Streaming mode
FCS Option
Fixed Channels
> ACL data: handle 12 flags 0x02 dlen 10
L2CAP(s): Info req: type 3
< ACL data: handle 12 flags 0x00 dlen 20
L2CAP(s): Info rsp: type 3 result 0
Fixed channel list 0x00000002
L2CAP Signalling Channel
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 2
> ACL data: handle 12 flags 0x02 dlen 12
L2CAP(s): Connect req: psm 3 scid 0x0040
< ACL data: handle 12 flags 0x00 dlen 16
L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 1 status 0
Connection pending - No futher information available
< ACL data: handle 12 flags 0x00 dlen 10
L2CAP(s): Info req: type 2
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 2
> ACL data: handle 12 flags 0x02 dlen 16
L2CAP(s): Info rsp: type 2 result 0
Extended feature mask 0x00b8
Enhanced Retransmission mode
Streaming mode
FCS Option
Fixed Channels
< ACL data: handle 12 flags 0x00 dlen 10
L2CAP(s): Info req: type 3
> ACL data: handle 12 flags 0x02 dlen 20
L2CAP(s): Info rsp: type 3 result 0
Fixed channel list 0x00000002
L2CAP Signalling Channel
< ACL data: handle 12 flags 0x00 dlen 16
L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0040 result 0 status 0
Connection successful
< ACL data: handle 12 flags 0x00 dlen 27
L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 15
MTU 1013
RFC 0x00 (Basic)
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 2
> ACL data: handle 12 flags 0x02 dlen 27
L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 15
MTU 1013
RFC 0x00 (Basic)
< ACL data: handle 12 flags 0x00 dlen 18
L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 4
MTU 1013
> ACL data: handle 12 flags 0x02 dlen 18
L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 4
MTU 1013
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 2
> ACL data: handle 12 flags 0x02 dlen 8
L2CAP(d): cid 0x0040 len 4 [psm 3]
RFCOMM(s): SABM: cr 1 dlci 0 pf 1 ilen 0 fcs 0x1c
< ACL data: handle 12 flags 0x00 dlen 8
L2CAP(d): cid 0x0040 len 4 [psm 3]
RFCOMM(s): UA: cr 1 dlci 0 pf 1 ilen 0 fcs 0xd7
> ACL data: handle 12 flags 0x02 dlen 18
L2CAP(d): cid 0x0040 len 14 [psm 3]
RFCOMM(s): PN CMD: cr 1 dlci 0 pf 0 ilen 10 fcs 0x70 mcc_len 8
dlci 2 frame_type 0 credit_flow 15 pri 7 ack_timer 0
frame_size 1008 max_retrans 0 credits 7
< ACL data: handle 12 flags 0x00 dlen 8
L2CAP(d): cid 0x0040 len 4 [psm 3]
RFCOMM(s): DM: cr 1 dlci 2 pf 1 ilen 0 fcs 0x73
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 2
< ACL data: handle 12 flags 0x00 dlen 12
L2CAP(s): Connect req: psm 1 scid 0x0041
> ACL data: handle 12 flags 0x02 dlen 16
L2CAP(s): Connect rsp: dcid 0x0041 scid 0x0041 result 0 status 0
Connection successful
< ACL data: handle 12 flags 0x00 dlen 23
L2CAP(s): Config req: dcid 0x0041 flags 0x00 clen 11
RFC 0x00 (Basic)
> ACL data: handle 12 flags 0x02 dlen 23
L2CAP(s): Config req: dcid 0x0041 flags 0x00 clen 11
RFC 0x00 (Basic)
< ACL data: handle 12 flags 0x00 dlen 18
L2CAP(s): Config rsp: scid 0x0041 flags 0x00 result 0 clen 4
MTU 672
> ACL data: handle 12 flags 0x02 dlen 12
L2CAP(s): Connect req: psm 1 scid 0x0042
< ACL data: handle 12 flags 0x00 dlen 16
L2CAP(s): Connect rsp: dcid 0x0042 scid 0x0042 result 0 status 0
Connection successful
< ACL data: handle 12 flags 0x00 dlen 23
L2CAP(s): Config req: dcid 0x0042 flags 0x00 clen 11
RFC 0x00 (Basic)
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 2
> ACL data: handle 12 flags 0x02 dlen 18
L2CAP(s): Config rsp: scid 0x0041 flags 0x00 result 0 clen 4
MTU 672
< ACL data: handle 12 flags 0x00 dlen 24
L2CAP(d): cid 0x0041 len 20 [psm 1]
SDP SSA Req: tid 0x0 len 0xf
pat uuid-16 0x0100 (L2CAP)
max 65535
aid(s) 0x0000 - 0xffff
cont 00
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 2
> ACL data: handle 12 flags 0x02 dlen 23
L2CAP(s): Config req: dcid 0x0042 flags 0x00 clen 11
RFC 0x00 (Basic)
< ACL data: handle 12 flags 0x00 dlen 18
L2CAP(s): Config rsp: scid 0x0042 flags 0x00 result 0 clen 4
MTU 672
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 2
> ACL data: handle 12 flags 0x02 dlen 18
L2CAP(s): Config rsp: scid 0x0042 flags 0x00 result 0 clen 4
MTU 672
> ACL data: handle 12 flags 0x02 dlen 676
L2CAP(d): cid 0x0041 len 672 [psm 1]
SDP SSA Rsp: tid 0x0 len 0x29b
count 656
cont 08 E7 35 D5 50 90 02 00 00
< ACL data: handle 12 flags 0x00 dlen 32
L2CAP(d): cid 0x0041 len 28 [psm 1]
SDP SSA Req: tid 0x1 len 0x17
pat uuid-16 0x0100 (L2CAP)
max 65535
aid(s) 0x0000 - 0xffff
cont 08 E7 35 D5 50 90 02 00 00
> ACL data: handle 12 flags 0x02 dlen 24
L2CAP(d): cid 0x0042 len 20 [psm 1]
SDP SSA Req: tid 0x0 len 0xf
pat uuid-16 0x0100 (L2CAP)
max 65535
aid(s) 0x0000 - 0xffff
cont 00
< ACL data: handle 12 flags 0x00 dlen 676
L2CAP(d): cid 0x0042 len 672 [psm 1]
SDP SSA Rsp: tid 0x0 len 0x29b
count 656
cont 08 5A 28 D5 50 90 02 00 00
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 2
> ACL data: handle 12 flags 0x02 dlen 100
L2CAP(d): cid 0x0041 len 96 [psm 1]
SDP SSA Rsp: tid 0x1 len 0x5b
count 88
record #0
aid 0x0000 (SrvRecHndl)
uint 0x10000
aid 0x0001 (SrvClassIDList)
< uuid-16 0x1112 (Headset AG) uuid-16 0x1203 (Audio) >
aid 0x0004 (ProtocolDescList)
< < uuid-16 0x0100 (L2CAP) > <
uuid-16 0x0003 (RFCOMM) uint 0xc > >
aid 0x0005 (BrwGrpList)
< uuid-16 0x1002 (PubBrwsGrp) >
aid 0x0009 (BTProfileDescList)
< < uuid-16 0x1108 (Headset) uint 0x102 > >
aid 0x0100 (SrvName)
str "Headset Audio Gateway"
record #1
aid 0x0000 (SrvRecHndl)
uint 0x10001
aid 0x0001 (SrvClassIDList)
< uuid-16 0x111f (Handsfree AG) uuid-16 0x1203 (Audio) >
aid 0x0004 (ProtocolDescList)
< < uuid-16 0x0100 (L2CAP) > <
uuid-16 0x0003 (RFCOMM) uint 0xd > >
aid 0x0005 (BrwGrpList)
< uuid-16 0x1002 (PubBrwsGrp) >
aid 0x0009 (BTProfileDescList)
< < uuid-16 0x111e (Handsfree) uint 0x105 > >
aid 0x0100 (SrvName)
str "Hands-Free Audio Gateway"
aid 0x0301 (SuppDataStoresList)
uint 0x1
aid 0x0311 (SuppFeatures)
uint 0x0
record #2
aid 0x0000 (SrvRecHndl)
uint 0x10002
aid 0x0001 (SrvClassIDList)
< uuid-16 0x110c (AVRemTarget) >
aid 0x0004 (ProtocolDescList)
< < uuid-16 0x0100 (L2CAP) uint 0x17 > <
uuid-16 0x0017 (AVCTP) uint 0x103 > >
aid 0x0005 (BrwGrpList)
< uuid-16 0x1002 (PubBrwsGrp) >
aid 0x0009 (BTProfileDescList)
< < uuid-16 0x110e (AVRemote) uint 0x103 > >
aid 0x0100 (SrvName)
str "AVRCP TG"
aid 0x0311 (SuppFeatures)
uint 0xf
record #3
aid 0x0000 (SrvRecHndl)
uint 0x10003
aid 0x0001 (SrvClassIDList)
< uuid-16 0x110e (AVRemote) >
aid 0x0004 (ProtocolDescList)
< < uuid-16 0x0100 (L2CAP) uint 0x17 > <
uuid-16 0x0017 (AVCTP) uint 0x103 > >
aid 0x0005 (BrwGrpList)
< uuid-16 0x1002 (PubBrwsGrp) >
aid 0x0009 (BTProfileDescList)
< < uuid-16 0x110e (AVRemote) uint 0x100 > >
aid 0x0100 (SrvName)
str "AVRCP CT"
aid 0x0311 (SuppFeatures)
uint 0xf
record #4
aid 0x0000 (SrvRecHndl)
uint 0x10004
aid 0x0001 (SrvClassIDList)
< uuid-16 0x1101 (SP) >
aid 0x0002 (SrvRecState)
uint 0x1234
aid 0x0003 (SrvID)
uuid-16 0x1101 (SP)
aid 0x0004 (ProtocolDescList)
< < uuid-16 0x0100 (L2CAP) > <
uuid-16 0x0003 (RFCOMM) uint 0xf > >
aid 0x0005 (BrwGrpList)
< uuid-16 0x1002 (PubBrwsGrp) >
aid 0x0006 (LangBaseAttrIDList)
< uint 0x656e uint 0x6a uint 0x100 >
aid 0x0007 (SrvInfoTimeToLive)
uint 0xffff
aid 0x0008 (SrvAvail)
uint 0xff
aid 0x0009 (BTProfileDescList)
< < uuid-16 0x1101 (SP) uint 0x100 > >
aid 0x000a (DocURL)
url "http://www.bluez.org/"
aid 0x000b (ClientExeURL)
url "http://www.bluez.org/"
aid 0x000c (IconURL)
url "http://www.bluez.org/"
aid 0x0100 (SrvName)
str "Serial Port"
aid 0x0101 (SrvDesc)
str "COM Port"
aid 0x0102 (ProviderName)
str "BlueZ"
record #5
aid 0x0000 (SrvRecHndl)
uint 0x10005
aid 0x0001 (SrvClassIDList)
< uuid-16 0x1105 (OBEXObjPush) >
aid 0x0004 (ProtocolDescList)
< < uuid-16 0x0100 (L2CAP) > <
uuid-16 0x0003 (RFCOMM) uint 0x9 > <
uuid-16 0x0008 (OBEX) > >
aid 0x0005 (BrwGrpList)
< uuid-16 0x1002 (PubBrwsGrp) >
aid 0x0009 (BTProfileDescList)
< < uuid-16 0x1105 (OBEXObjPush) uint 0x100 > >
aid 0x0100 (SrvName)
str "OBEX Object Push"
aid 0x0303 (SuppFormatsList)
< uint 0x1 uint 0x2 uint 0x3 uint 0x4 uint 0x5 uint
0x6 uint 0xff >
record #6
aid 0x0000 (SrvRecHndl)
uint 0x10006
aid 0x0001 (SrvClassIDList)
< uuid-16 0x1106 (OBEXObjTrnsf) >
aid 0x0004 (ProtocolDescList)
< < uuid-16 0x0100 (L2CAP) > <
uuid-16 0x0003 (RFCOMM) uint 0xa > <
uuid-16 0x0008 (OBEX) > >
aid 0x0005 (BrwGrpList)
< uuid-16 0x1002 (PubBrwsGrp) >
aid 0x0009 (BTProfileDescList)
< < uuid-16 0x1106 (OBEXObjTrnsf) uint 0x100 > >
aid 0x0100 (SrvName)
str "OBEX File Transfer"
cont 00
> ACL data: handle 12 flags 0x02 dlen 32
L2CAP(d): cid 0x0042 len 28 [psm 1]
SDP SSA Req: tid 0x1 len 0x17
pat uuid-16 0x0100 (L2CAP)
max 65535
aid(s) 0x0000 - 0xffff
cont 08 5A 28 D5 50 90 02 00 00
> ACL data: handle 12 flags 0x02 dlen 8
L2CAP(d): cid 0x0040 len 4 [psm 3]
RFCOMM(s): DISC: cr 1 dlci 0 pf 1 ilen 0 fcs 0xfd
< ACL data: handle 12 flags 0x00 dlen 8
L2CAP(d): cid 0x0040 len 4 [psm 3]
RFCOMM(s): UA: cr 1 dlci 0 pf 1 ilen 0 fcs 0xd7
> ACL data: handle 12 flags 0x02 dlen 12
L2CAP(s): Disconn req: dcid 0x0040 scid 0x0040
< ACL data: handle 12 flags 0x00 dlen 12
L2CAP(s): Disconn rsp: dcid 0x0040 scid 0x0040
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 2
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 1
< ACL data: handle 12 flags 0x00 dlen 129
L2CAP(d): cid 0x0042 len 125 [psm 1]
SDP SSA Rsp: tid 0x1 len 0x78
count 117
record #0
aid 0x0000 (SrvRecHndl)
uint 0x10000
aid 0x0001 (SrvClassIDList)
< uuid-16 0x1112 (Headset AG) uuid-16 0x1203 (Audio) >
aid 0x0004 (ProtocolDescList)
< < uuid-16 0x0100 (L2CAP) > <
uuid-16 0x0003 (RFCOMM) uint 0xc > >
aid 0x0005 (BrwGrpList)
< uuid-16 0x1002 (PubBrwsGrp) >
aid 0x0009 (BTProfileDescList)
< < uuid-16 0x1108 (Headset) uint 0x102 > >
aid 0x0100 (SrvName)
str "Headset Audio Gateway"
record #1
aid 0x0000 (SrvRecHndl)
uint 0x10001
aid 0x0001 (SrvClassIDList)
< uuid-16 0x111f (Handsfree AG) uuid-16 0x1203 (Audio) >
aid 0x0004 (ProtocolDescList)
< < uuid-16 0x0100 (L2CAP) > <
uuid-16 0x0003 (RFCOMM) uint 0xd > >
aid 0x0005 (BrwGrpList)
< uuid-16 0x1002 (PubBrwsGrp) >
aid 0x0009 (BTProfileDescList)
< < uuid-16 0x111e (Handsfree) uint 0x105 > >
aid 0x0100 (SrvName)
str "Hands-Free Audio Gateway"
aid 0x0301 (SuppDataStoresList)
uint 0x1
aid 0x0311 (SuppFeatures)
uint 0x0
record #2
aid 0x0000 (SrvRecHndl)
uint 0x10002
aid 0x0001 (SrvClassIDList)
< uuid-16 0x110c (AVRemTarget) >
aid 0x0004 (ProtocolDescList)
< < uuid-16 0x0100 (L2CAP) uint 0x17 > <
uuid-16 0x0017 (AVCTP) uint 0x103 > >
aid 0x0005 (BrwGrpList)
< uuid-16 0x1002 (PubBrwsGrp) >
aid 0x0009 (BTProfileDescList)
< < uuid-16 0x110e (AVRemote) uint 0x103 > >
aid 0x0100 (SrvName)
str "AVRCP TG"
aid 0x0311 (SuppFeatures)
uint 0xf
record #3
aid 0x0000 (SrvRecHndl)
uint 0x10003
aid 0x0001 (SrvClassIDList)
< uuid-16 0x110e (AVRemote) >
aid 0x0004 (ProtocolDescList)
< < uuid-16 0x0100 (L2CAP) uint 0x17 > <
uuid-16 0x0017 (AVCTP) uint 0x103 > >
aid 0x0005 (BrwGrpList)
< uuid-16 0x1002 (PubBrwsGrp) >
aid 0x0009 (BTProfileDescList)
< < uuid-16 0x110e (AVRemote) uint 0x100 > >
aid 0x0100 (SrvName)
str "AVRCP CT"
aid 0x0311 (SuppFeatures)
uint 0xf
record #4
aid 0x0000 (SrvRecHndl)
uint 0x10004
aid 0x0001 (SrvClassIDList)
< uuid-16 0x1101 (SP) >
aid 0x0002 (SrvRecState)
uint 0x1234
aid 0x0003 (SrvID)
uuid-16 0x1101 (SP)
aid 0x0004 (ProtocolDescList)
< < uuid-16 0x0100 (L2CAP) > <
uuid-16 0x0003 (RFCOMM) uint 0xf > >
aid 0x0005 (BrwGrpList)
< uuid-16 0x1002 (PubBrwsGrp) >
aid 0x0006 (LangBaseAttrIDList)
< uint 0x656e uint 0x6a uint 0x100 >
aid 0x0007 (SrvInfoTimeToLive)
uint 0xffff
aid 0x0008 (SrvAvail)
uint 0xff
aid 0x0009 (BTProfileDescList)
< < uuid-16 0x1101 (SP) uint 0x100 > >
aid 0x000a (DocURL)
url "http://www.bluez.org/"
aid 0x000b (ClientExeURL)
url "http://www.bluez.org/"
aid 0x000c (IconURL)
url "http://www.bluez.org/"
aid 0x0100 (SrvName)
str "Serial Port"
aid 0x0101 (SrvDesc)
str "COM Port"
aid 0x0102 (ProviderName)
str "BlueZ"
record #5
aid 0x0000 (SrvRecHndl)
uint 0x10005
aid 0x0001 (SrvClassIDList)
< uuid-16 0x1101 (SP) >
aid 0x0002 (SrvRecState)
uint 0x1234
aid 0x0003 (SrvID)
uuid-16 0x1101 (SP)
aid 0x0004 (ProtocolDescList)
< < uuid-16 0x0100 (L2CAP) > <
uuid-16 0x0003 (RFCOMM) uint 0xf > >
aid 0x0005 (BrwGrpList)
< uuid-16 0x1002 (PubBrwsGrp) >
aid 0x0006 (LangBaseAttrIDList)
< uint 0x656e uint 0x6a uint 0x100 >
aid 0x0007 (SrvInfoTimeToLive)
uint 0xffff
aid 0x0008 (SrvAvail)
uint 0xff
aid 0x0009 (BTProfileDescList)
< < uuid-16 0x1101 (SP) uint 0x100 > >
aid 0x000a (DocURL)
url "http://www.bluez.org/"
aid 0x000b (ClientExeURL)
url "http://www.bluez.org/"
aid 0x000c (IconURL)
url "http://www.bluez.org/"
aid 0x0100 (SrvName)
str "Serial Port"
aid 0x0101 (SrvDesc)
str "COM Port"
aid 0x0102 (ProviderName)
str "BlueZ"
cont 00
< ACL data: handle 12 flags 0x00 dlen 24
L2CAP(d): cid 0x0041 len 20 [psm 1]
SDP SSA Req: tid 0x2 len 0xf
pat uuid-16 0x1200 (PNPInfo)
max 65535
aid(s) 0x0000 - 0xffff
cont 00
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 2
> ACL data: handle 12 flags 0x02 dlen 14
L2CAP(d): cid 0x0041 len 10 [psm 1]
SDP SSA Rsp: tid 0x2 len 0x5
count 2
cont 00
> ACL data: handle 12 flags 0x02 dlen 24
L2CAP(d): cid 0x0042 len 20 [psm 1]
SDP SSA Req: tid 0x2 len 0xf
pat uuid-16 0x1200 (PNPInfo)
max 65535
aid(s) 0x0000 - 0xffff
cont 00
< ACL data: handle 12 flags 0x00 dlen 14
L2CAP(d): cid 0x0042 len 10 [psm 1]
SDP SSA Rsp: tid 0x2 len 0x5
count 2
cont 00
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 1
< ACL data: handle 12 flags 0x00 dlen 12
L2CAP(s): Disconn req: dcid 0x0041 scid 0x0041
> ACL data: handle 12 flags 0x02 dlen 12
L2CAP(s): Disconn rsp: dcid 0x0041 scid 0x0041
> ACL data: handle 12 flags 0x02 dlen 12
L2CAP(s): Disconn req: dcid 0x0042 scid 0x0042
< ACL data: handle 12 flags 0x00 dlen 12
L2CAP(s): Disconn rsp: dcid 0x0042 scid 0x0042
> HCI Event: Number of Completed Packets (0x13) plen 5
handle 12 packets 2
> HCI Event: Disconn Complete (0x05) plen 4
status 0x00 handle 12 reason 0x13
Reason: Remote User Terminated Connection
< HCI Command: Delete Stored Link Key (0x03|0x0012) plen 7
bdaddr 00:02:72:AA:FB:94 all 0
> HCI Event: Command Complete (0x0e) plen 6
Delete Stored Link Key (0x03|0x0012) ncmd 1
status 0x00 deleted 0
rgs,
Kevin
^ permalink raw reply
* [PATCH] Bluetooth: Fix skb allocation check for A2MP
From: Gustavo Padovan @ 2012-12-22 3:22 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
vtable's method alloc_skb() needs to return a ERR_PTR in case of err and
not a NULL.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/a2mp.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
index 0a2ec84..cd9410c 100644
--- a/net/bluetooth/a2mp.c
+++ b/net/bluetooth/a2mp.c
@@ -693,7 +693,13 @@ static void a2mp_chan_state_change_cb(struct l2cap_chan *chan, int state, int er
static struct sk_buff *a2mp_chan_alloc_skb_cb(struct l2cap_chan *chan,
unsigned long len, int nb)
{
- return bt_skb_alloc(len, GFP_KERNEL);
+ struct sk_buff *skb;
+
+ skb = bt_skb_alloc(len, GFP_KERNEL);
+ if (!skb)
+ return ERR_PTR(-ENOMEM);
+
+ return skb;
}
static struct l2cap_ops a2mp_chan_ops = {
--
1.8.0.2
^ permalink raw reply related
* [PATCH 12/25] bluetooth/l2cap: don't use [delayed_]work_pending()
From: Tejun Heo @ 2012-12-22 1:57 UTC (permalink / raw)
To: linux-kernel
Cc: Tejun Heo, Marcel Holtmann, Gustavo Padovan, Johan Hedberg,
linux-bluetooth
In-Reply-To: <1356141435-17340-1-git-send-email-tj@kernel.org>
There's no need to test whether a (delayed) work item in pending
before queueing, flushing or cancelling it. Most uses are unnecessary
and quite a few of them are buggy.
Reimplement l2cap_set_timer() such that it uses mod_delayed_work() or
schedule_delayed_work() depending on a new param @override and let the
users specify whether to override or not instead of using
delayed_work_pending().
Only compile tested.
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Marcel Holtmann <marcel@holtmann.org>
Cc: Gustavo Padovan <gustavo@padovan.org>
Cc: Johan Hedberg <johan.hedberg@gmail.com>
Cc: linux-bluetooth@vger.kernel.org
---
Please let me know how this patch should be routed. I can take it
through the workqueue tree if necessary.
Thanks.
include/net/bluetooth/l2cap.h | 24 ++++++++++++++++--------
net/bluetooth/l2cap_core.c | 7 +++----
2 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 7588ef4..f12cbeb 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -718,17 +718,25 @@ static inline void l2cap_chan_unlock(struct l2cap_chan *chan)
}
static inline void l2cap_set_timer(struct l2cap_chan *chan,
- struct delayed_work *work, long timeout)
+ struct delayed_work *work, long timeout,
+ bool override)
{
+ bool was_pending;
+
BT_DBG("chan %p state %s timeout %ld", chan,
state_to_string(chan->state), timeout);
- /* If delayed work cancelled do not hold(chan)
- since it is already done with previous set_timer */
- if (!cancel_delayed_work(work))
- l2cap_chan_hold(chan);
+ /* @work should hold a reference to @chan */
+ l2cap_chan_hold(chan);
+
+ if (override)
+ was_pending = mod_delayed_work(system_wq, work, timeout);
+ else
+ was_pending = !schedule_delayed_work(work, timeout);
- schedule_delayed_work(work, timeout);
+ /* if @work was already pending, lose the extra ref */
+ if (was_pending)
+ l2cap_chan_put(chan);
}
static inline bool l2cap_clear_timer(struct l2cap_chan *chan,
@@ -745,12 +753,12 @@ static inline bool l2cap_clear_timer(struct l2cap_chan *chan,
return ret;
}
-#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t))
+#define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t), true)
#define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer)
#define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer)
#define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer)
#define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \
- msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO));
+ msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO), true);
#define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer)
static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 2c78208..91db91c 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -246,10 +246,9 @@ static inline void l2cap_chan_set_err(struct l2cap_chan *chan, int err)
static void __set_retrans_timer(struct l2cap_chan *chan)
{
- if (!delayed_work_pending(&chan->monitor_timer) &&
- chan->retrans_timeout) {
+ if (chan->retrans_timeout) {
l2cap_set_timer(chan, &chan->retrans_timer,
- msecs_to_jiffies(chan->retrans_timeout));
+ msecs_to_jiffies(chan->retrans_timeout), false);
}
}
@@ -258,7 +257,7 @@ static void __set_monitor_timer(struct l2cap_chan *chan)
__clear_retrans_timer(chan);
if (chan->monitor_timeout) {
l2cap_set_timer(chan, &chan->monitor_timer,
- msecs_to_jiffies(chan->monitor_timeout));
+ msecs_to_jiffies(chan->monitor_timeout), true);
}
}
--
1.8.0.2
^ permalink raw reply related
* [PATCH] Bluetooth: Fix uuid output in debugfs
From: Gustavo Padovan @ 2012-12-21 22:58 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
The uuid should be printed in the CPU endianness and not in little-endian.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/hci_sysfs.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 55cceee..05b78c7 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -461,19 +461,18 @@ static const struct file_operations blacklist_fops = {
static void print_bt_uuid(struct seq_file *f, u8 *uuid)
{
- __be32 data0, data4;
- __be16 data1, data2, data3, data5;
-
- memcpy(&data0, &uuid[0], 4);
- memcpy(&data1, &uuid[4], 2);
- memcpy(&data2, &uuid[6], 2);
- memcpy(&data3, &uuid[8], 2);
- memcpy(&data4, &uuid[10], 4);
- memcpy(&data5, &uuid[14], 2);
-
- seq_printf(f, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x\n",
- ntohl(data0), ntohs(data1), ntohs(data2), ntohs(data3),
- ntohl(data4), ntohs(data5));
+ u32 data0, data5;
+ u16 data1, data2, data3, data4;
+
+ data5 = le32_to_cpu(*(__le32 *)uuid);
+ data4 = le16_to_cpu(*(__le16 *)(uuid + 4));
+ data3 = le16_to_cpu(*(__le16 *)(uuid + 6));
+ data2 = le16_to_cpu(*(__le16 *)(uuid + 8));
+ data1 = le16_to_cpu(*(__le16 *)(uuid + 10));
+ data0 = le32_to_cpu(*(__le32 *)(uuid + 12));
+
+ seq_printf(f, "%.8x-%.4x-%.4x-%.4x-%.4x%.8x\n",
+ data0, data1, data2, data3, data4, data5);
}
static int uuids_show(struct seq_file *f, void *p)
--
1.8.0.2
^ permalink raw reply related
* [PATCH] Bluetooth: Fix uuid output in debugfs
From: Gustavo Padovan @ 2012-12-21 22:57 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
The uuid should be printed in the CPU endianness and not in little-endian.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/hci_sysfs.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 55cceee..05b78c7 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -461,19 +461,18 @@ static const struct file_operations blacklist_fops = {
static void print_bt_uuid(struct seq_file *f, u8 *uuid)
{
- __be32 data0, data4;
- __be16 data1, data2, data3, data5;
-
- memcpy(&data0, &uuid[0], 4);
- memcpy(&data1, &uuid[4], 2);
- memcpy(&data2, &uuid[6], 2);
- memcpy(&data3, &uuid[8], 2);
- memcpy(&data4, &uuid[10], 4);
- memcpy(&data5, &uuid[14], 2);
-
- seq_printf(f, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x\n",
- ntohl(data0), ntohs(data1), ntohs(data2), ntohs(data3),
- ntohl(data4), ntohs(data5));
+ u32 data0, data5;
+ u16 data1, data2, data3, data4;
+
+ data5 = le32_to_cpu(*(__le32 *)uuid);
+ data4 = le16_to_cpu(*(__le16 *)(uuid + 4));
+ data3 = le16_to_cpu(*(__le16 *)(uuid + 6));
+ data2 = le16_to_cpu(*(__le16 *)(uuid + 8));
+ data1 = le16_to_cpu(*(__le16 *)(uuid + 10));
+ data0 = le32_to_cpu(*(__le32 *)(uuid + 12));
+
+ seq_printf(f, "%.8x-%.4x-%.4x-%.4x-%.4x%.8x\n",
+ data0, data1, data2, data3, data4, data5);
}
static int uuids_show(struct seq_file *f, void *p)
--
1.8.0.2
^ permalink raw reply related
* [PATCH] Bluetooth: Fix uuid output in debugfs
From: Gustavo Padovan @ 2012-12-21 22:57 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
The uuid should be printed in the CPU endianness and not in little-endian.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/hci_sysfs.c | 25 ++++++++++++-------------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 55cceee..05b78c7 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -461,19 +461,18 @@ static const struct file_operations blacklist_fops = {
static void print_bt_uuid(struct seq_file *f, u8 *uuid)
{
- __be32 data0, data4;
- __be16 data1, data2, data3, data5;
-
- memcpy(&data0, &uuid[0], 4);
- memcpy(&data1, &uuid[4], 2);
- memcpy(&data2, &uuid[6], 2);
- memcpy(&data3, &uuid[8], 2);
- memcpy(&data4, &uuid[10], 4);
- memcpy(&data5, &uuid[14], 2);
-
- seq_printf(f, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x\n",
- ntohl(data0), ntohs(data1), ntohs(data2), ntohs(data3),
- ntohl(data4), ntohs(data5));
+ u32 data0, data5;
+ u16 data1, data2, data3, data4;
+
+ data5 = le32_to_cpu(*(__le32 *)uuid);
+ data4 = le16_to_cpu(*(__le16 *)(uuid + 4));
+ data3 = le16_to_cpu(*(__le16 *)(uuid + 6));
+ data2 = le16_to_cpu(*(__le16 *)(uuid + 8));
+ data1 = le16_to_cpu(*(__le16 *)(uuid + 10));
+ data0 = le32_to_cpu(*(__le32 *)(uuid + 12));
+
+ seq_printf(f, "%.8x-%.4x-%.4x-%.4x-%.4x%.8x\n",
+ data0, data1, data2, data3, data4, data5);
}
static int uuids_show(struct seq_file *f, void *p)
--
1.8.0.2
^ permalink raw reply related
* Re: [PATCH BlueZ 1/4] core: Use ERROR_INTERFACE instead of org.bluez.Error
From: Johan Hedberg @ 2012-12-21 22:17 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <1356107103-18039-1-git-send-email-anderson.lizardo@openbossa.org>
Hi Lizardo,
On Fri, Dec 21, 2012, Anderson Lizardo wrote:
> This will simplify changing interface name later (e.g. adding
> versioning).
> ---
> src/adapter.c | 4 ++--
> src/agent.c | 5 +++--
> src/device.c | 2 +-
> 3 files changed, 6 insertions(+), 5 deletions(-)
All four patches have been applied, though I removed the comment about
versioning in this one as I don't think anything like that will be done
for the errors.
Johan
^ permalink raw reply
* [PATCH BlueZ 25/25] broadcaster: Add python test script
From: Bruna Moreira @ 2012-12-21 20:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1356121612-15172-1-git-send-email-bruna.moreira@openbossa.org>
---
test/test-broadcaster | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 61 insertions(+)
create mode 100755 test/test-broadcaster
diff --git a/test/test-broadcaster b/test/test-broadcaster
new file mode 100755
index 0000000..237887d
--- /dev/null
+++ b/test/test-broadcaster
@@ -0,0 +1,61 @@
+#!/usr/bin/python
+
+'''Broadcaster test script
+'''
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+from gi.repository import GObject
+
+import sys
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+from optparse import OptionParser, make_option
+import time
+import bluezutils
+
+if __name__ == "__main__":
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+ bus = dbus.SystemBus()
+
+ option_list = [
+ make_option("-i", "--adapter", action="store",
+ type="string", dest="adapter"),
+ make_option("-s", "--service", action="store",
+ type="int", dest="service",
+ help="Format: Service UUID (0xNNNN) followed by" +
+ " Service Data (e.g. aa bb cc)"),
+ make_option("-m", "--manufacturer", action="store",
+ type="int", dest="manufacturer",
+ help="Format: Company Identifier Code (0xNNNN)" +
+ " followed by Manufacturer Specific Data (e.g. 11 22 aa)"),
+ ]
+
+ parser = OptionParser(option_list=option_list,
+ usage="Usage: %prog <-s uuid | -m cid> <data bytes in hex>")
+
+ (options, args) = parser.parse_args()
+ if not args:
+ parser.error("Hex encoded data is required.")
+
+ if options.service and options.manufacturer:
+ parser.error("options -m and -s are mutually exclusive")
+
+ try:
+ data = dbus.Array(map(lambda i: dbus.Byte(int(i, 16)), args))
+ except ValueError:
+ parser.error("Invalid data. Should be hex encoded bytes" +
+ " separated by whitespace.")
+
+ adapter = bluezutils.find_adapter(options.adapter)
+
+ if options.service:
+ adapter.SetServiceData(dbus.UInt16(options.service), data)
+
+ if options.manufacturer:
+ adapter.SetManufacturerData(dbus.UInt16(options.manufacturer), data)
+
+ mainloop = GObject.MainLoop()
+ mainloop.run()
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 24/25] broadcaster: Update some data of already broadcast value
From: Bruna Moreira @ 2012-12-21 20:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1356121612-15172-1-git-send-email-bruna.moreira@openbossa.org>
To update previously set data, it is necessary to use same Service UUID
or Company Identifier Code in SetServiceData() and
SetManufacturerData().
---
src/adapter.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/adapter.c b/src/adapter.c
index 9c99070..96badfd 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1570,6 +1570,10 @@ static void bcast_session_exit(DBusConnection *conn, void *user_data)
static void update_adv_data(struct btd_adapter *adapter,
struct bcast_session *session, uint8_t *data, int size)
{
+ session->data_len = size;
+ memcpy(session->data, data, size);
+
+ restore_bcast_type(adapter, session->data_type);
}
void adapter_set_controller_data_failed(struct btd_adapter *adapter)
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 23/25] broadcaster: Add ClearBroadcastData() D-Bus method
From: Bruna Moreira @ 2012-12-21 20:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1356121612-15172-1-git-send-email-bruna.moreira@openbossa.org>
The ClearBroadcastData() function will clean all data (Service Data or
Manufacturer Specific Data) set by the current application. All data set
by any other application will be kept.
---
src/adapter.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
diff --git a/src/adapter.c b/src/adapter.c
index 45471dc..9c99070 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1699,9 +1699,84 @@ done:
return NULL;
}
+static void restore_bcast_data(gpointer data, gpointer user_data)
+{
+ struct bcast_session *session = data, *cleared = user_data;
+
+ if (session == cleared)
+ return;
+
+ if (session->data_type != cleared->data_type)
+ return;
+
+ send_advdata_blob(session->adapter, session);
+}
+
+static gint cmp_bcast_session_owner(gconstpointer a, gconstpointer b)
+{
+ const struct bcast_session *session = a;
+ const char *owner = b;
+
+ return g_strcmp0(session->owner, owner);
+}
+
+static gboolean find_bcast_session_by_owner(struct btd_adapter *adapter,
+ const char *sender,
+ struct bcast_session **session)
+{
+ GSList *l;
+
+ l = g_slist_find_custom(adapter->bcast_sessions, sender,
+ cmp_bcast_session_owner);
+ if (!l)
+ return FALSE;
+
+ if (session)
+ *session = l->data;
+
+ return TRUE;
+}
+
static DBusMessage *clear_broadcast_data(DBusConnection *conn,
DBusMessage *msg, void *data)
{
+ struct btd_adapter *adapter = data;
+ struct bcast_session *session;
+ const char *sender;
+ int err;
+
+ sender = dbus_message_get_sender(msg);
+
+ DBG("Clear all data in broadcaster registered for hci%d at %s",
+ adapter->dev_id, sender);
+
+ while (find_bcast_session_by_owner(adapter, sender, &session)) {
+ uint8_t type = session->data_type;
+
+ err = mgmt_unset_controller_data(adapter->dev_id, type);
+ if (err < 0)
+ error("Failed to set Broadcaster: %s (%d)",
+ strerror(-err), -err);
+
+ /* mgmt_unset_controller_data() also clears broadcast data from
+ * other clients with the same data type, so they need to be
+ * restored. */
+ g_slist_foreach(adapter->bcast_sessions, restore_bcast_data,
+ session);
+
+ adapter->bcast_sessions =
+ g_slist_remove(adapter->bcast_sessions, session);
+
+ free_bcast_session(session);
+ }
+
+ if (!adapter->bcast_sessions) {
+ err = mgmt_set_broadcaster(adapter->dev_id, FALSE);
+ if (err < 0)
+ error("Failed to set Broadcaster: %s (%d)",
+ strerror(-err), -err);
+ }
+
return dbus_message_new_method_return(msg);
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 22/25] broadcaster: Build and send ADV/EIR data blob to kernel
From: Bruna Moreira @ 2012-12-21 20:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1356121612-15172-1-git-send-email-bruna.moreira@openbossa.org>
SetServiceData() and SetManufacturerData() operations will save all data
and send the ADV/EIR data to kernel. The new ADV/EIR data will be added
to the current one.
Note: For now, the maximum ADV/EIR data length is limited to 27
(HCI_LE_MAX_ADV_DATA_LENGTH - 4) octets. This is needed to reserve 2
octets for length and data type and more 2 octets for UUID/CompanyID. If
the ADV/EIR data from new broadcaster session tries to insert more
octets than 27 bytes the operation will fail.
---
src/adapter.c | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 119 insertions(+), 11 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index 7e0f2b5..45471dc 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -92,6 +92,9 @@ static const char *base_path = "/org/bluez";
#define FILTER_SERVICE_UUID 0x01
#define FILTER_COMPANY_IC 0x02
+/* Flags for Broadcaster */
+#define BCAST_DATA_NORMAL_PRIORITY 0x00
+
static GSList *adapter_drivers = NULL;
enum session_req_type {
@@ -601,6 +604,31 @@ void adapter_name_changed(struct btd_adapter *adapter, const char *name)
void adapter_set_controller_data_complete(struct btd_adapter *adapter)
{
+ struct bcast_session *session = adapter->bcast_sessions->data;
+ DBusMessage *msg = session->msg;
+ DBusMessage *reply;
+ int err;
+
+ if (!adapter->bcast_sessions)
+ error("No Broadcaster session running");
+
+ err = mgmt_set_broadcaster(adapter->dev_id, TRUE);
+ if (err < 0) {
+ error("Failed to set Broadcaster: %s (%d)", strerror(-err),
+ -err);
+ reply = btd_error_failed(msg, strerror(-err));
+ } else
+ reply = dbus_message_new_method_return(msg);
+
+
+ if (session->data_type == EIR_SVC_DATA)
+ DBG("Service Data Broadcaster registered for hci%d at %s",
+ adapter->dev_id, session->owner);
+ else
+ DBG("Manufacturer Data Broadcaster registered for hci%d at %s",
+ adapter->dev_id, session->owner);
+
+ g_dbus_send_message(btd_get_dbus_connection(), reply);
}
int adapter_set_name(struct btd_adapter *adapter, const char *name)
@@ -1471,6 +1499,53 @@ static struct bcast_session *find_bcast_session(GSList *list,
return l ? l->data : NULL;
}
+static void send_advdata_blob(struct btd_adapter *adapter,
+ struct bcast_session *session)
+{
+ uint8_t data[EIR_DATA_MAX_LEN];
+ uint16_t *u16 = (void *) data;
+ int err;
+
+ bt_put_unaligned(htobs(session->data_id), u16);
+ memcpy(data + sizeof(session->data_id), session->data,
+ session->data_len);
+
+ err = mgmt_set_controller_data(adapter->dev_id,
+ BCAST_DATA_NORMAL_PRIORITY,
+ session->data_type, data,
+ session->data_len + sizeof(session->data_id));
+ if (err < 0)
+ error("Failed to set controller data in Broadcaster: %s (%d)",
+ strerror(-err), -err);
+}
+
+static void restore_bcast_type(struct btd_adapter *adapter, uint8_t type)
+{
+ GSList *l;
+ int err;
+
+ err = mgmt_unset_controller_data(adapter->dev_id, type);
+ if (err < 0) {
+ error("Failed to unset controller data: %s (%d)",
+ strerror(-err), -err);
+ return;
+ }
+
+ for (l = adapter->bcast_sessions; l; l = g_slist_next(l)) {
+ struct bcast_session *session = l->data;
+
+ if (session->data_type == type)
+ send_advdata_blob(adapter, session);
+ }
+
+ if (!adapter->bcast_sessions) {
+ err = mgmt_set_broadcaster(adapter->dev_id, FALSE);
+ if (err < 0)
+ error("Failed to set Broadcaster: %s (%d)",
+ strerror(-err), -err);
+ }
+}
+
static void bcast_session_exit(DBusConnection *conn, void *user_data)
{
struct bcast_session *session = user_data;
@@ -1486,10 +1561,10 @@ static void bcast_session_exit(DBusConnection *conn, void *user_data)
adapter->bcast_sessions = g_slist_remove(adapter->bcast_sessions,
session);
- free_bcast_session(session);
- /* FIXME: Stop advertising, send data blob from others apps to kernel
- * with same type and restart advertising*/
+ restore_bcast_type(adapter, type);
+
+ free_bcast_session(session);
}
static void update_adv_data(struct btd_adapter *adapter,
@@ -1499,6 +1574,21 @@ static void update_adv_data(struct btd_adapter *adapter,
void adapter_set_controller_data_failed(struct btd_adapter *adapter)
{
+ struct bcast_session *session = adapter->bcast_sessions->data;
+ DBusMessage *msg = session->msg;
+ DBusMessage *reply;
+
+ DBG("Manufacturer Specific Data Broadcaster failed for hci%d at %s",
+ adapter->dev_id, session->owner);
+
+ reply = btd_error_failed(msg,
+ "Broadcaster: No resources, data too long");
+ g_dbus_send_message(btd_get_dbus_connection(), reply);
+
+ adapter->bcast_sessions = g_slist_remove(adapter->bcast_sessions,
+ session);
+
+ free_bcast_session(session);
}
static DBusMessage *set_service_data(DBusConnection *conn,
@@ -1517,6 +1607,12 @@ static DBusMessage *set_service_data(DBusConnection *conn,
DBUS_TYPE_INVALID))
return btd_error_invalid_args(msg);
+ /* It will accept new ADV/EIR data only if there is space for complete
+ * data. Reserve 2 octets for Service UUID */
+ if (ssize + sizeof(uint16_t) > EIR_DATA_MAX_LEN)
+ return btd_error_failed(msg,
+ "ADV/EIR data is bigger than permitted");
+
sender = dbus_message_get_sender(msg);
session = find_bcast_session(adapter->bcast_sessions, sender,
@@ -1528,22 +1624,25 @@ static DBusMessage *set_service_data(DBusConnection *conn,
session = g_new(struct bcast_session, 1);
session->data_id = uuid;
+ session->data_len = ssize;
session->owner = g_strdup(sender);
session->adapter = btd_adapter_ref(adapter);
session->data_type = EIR_SVC_DATA;
session->msg = dbus_message_ref(msg);
+
+ memcpy(session->data, sdata, ssize);
+
session->id = g_dbus_add_disconnect_watch(conn, sender,
bcast_session_exit, session,
NULL);
+ send_advdata_blob(adapter, session);
+
adapter->bcast_sessions = g_slist_prepend(adapter->bcast_sessions,
session);
- DBG("Service Data Broadcaster registered for hci%d at %s",
- adapter->dev_id, sender);
-
done:
- return dbus_message_new_method_return(msg);
+ return NULL;
}
static DBusMessage *set_manufacturer_data(DBusConnection *conn,
@@ -1562,6 +1661,12 @@ static DBusMessage *set_manufacturer_data(DBusConnection *conn,
DBUS_TYPE_INVALID))
return btd_error_invalid_args(msg);
+ /* It will accept new ADV/EIR data only if there is space for complete
+ * data. Reserve 2 octets for Company Identifier Code */
+ if (msize + sizeof(uint16_t) > EIR_DATA_MAX_LEN)
+ return btd_error_failed(msg,
+ "ADV/EIR data is bigger than permitted");
+
sender = dbus_message_get_sender(msg);
session = find_bcast_session(adapter->bcast_sessions, sender,
@@ -1573,22 +1678,25 @@ static DBusMessage *set_manufacturer_data(DBusConnection *conn,
session = g_new(struct bcast_session, 1);
session->data_id = company_id;
+ session->data_len = msize;
session->owner = g_strdup(sender);
session->adapter = btd_adapter_ref(adapter);
session->data_type = EIR_MANUF_DATA;
session->msg = dbus_message_ref(msg);
+
+ memcpy(session->data, mdata, msize);
+
session->id = g_dbus_add_disconnect_watch(conn, sender,
bcast_session_exit, session,
NULL);
+ send_advdata_blob(adapter, session);
+
adapter->bcast_sessions = g_slist_prepend(adapter->bcast_sessions,
session);
- DBG("Manufacturer Specific Data Broadcaster registered for hci%d at %s",
- adapter->dev_id, sender);
-
done:
- return dbus_message_new_method_return(msg);
+ return NULL;
}
static DBusMessage *clear_broadcast_data(DBusConnection *conn,
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 21/25] broadcaster: Add list of broadcaster sessions
From: Bruna Moreira @ 2012-12-21 20:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jefferson Delfes
In-Reply-To: <1356121612-15172-1-git-send-email-bruna.moreira@openbossa.org>
From: Jefferson Delfes <jefferson.delfes@openbossa.org>
The adapter will keep a list of broadcasters which set new advertising
data values. The new broadcaster is added to the list when the function
SetServiceData() or SetManufacturerData() is called.
---
src/adapter.c | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/eir.h | 3 ++
2 files changed, 162 insertions(+)
diff --git a/src/adapter.c b/src/adapter.c
index 60c0697..7e0f2b5 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -133,6 +133,18 @@ struct observer_watcher {
char *path; /* DBus path */
};
+struct bcast_session {
+ struct btd_adapter *adapter;
+ DBusMessage *msg;
+ guint id;
+ char *owner;
+ uint8_t data_type;
+ uint16_t data_id;
+ uint8_t data_len;
+ /* Reserve 2 octets for ServiceUUID/CompanyId */
+ uint8_t data[EIR_DATA_MAX_LEN - sizeof(uint16_t)];
+};
+
struct btd_adapter {
uint16_t dev_id;
gboolean powered;
@@ -154,6 +166,7 @@ struct btd_adapter {
struct session_req *scanning_session;
GSList *connect_list; /* Devices to connect when found */
GSList *observers; /* Observer watchers */
+ GSList *bcast_sessions; /* Broadcast sessions */
guint discov_id; /* Discovery timer */
struct discovery *discovery; /* Discovery active */
gboolean connecting; /* Connect active */
@@ -1409,6 +1422,81 @@ static DBusMessage *unregister_manuf_observer(DBusConnection *conn,
return dbus_message_new_method_return(msg);
}
+static void free_bcast_session(gpointer user_data)
+{
+ struct bcast_session *session = user_data;
+
+ btd_adapter_unref(session->adapter);
+ if (session->msg)
+ dbus_message_unref(session->msg);
+
+ g_dbus_remove_watch(btd_get_dbus_connection(), session->id);
+
+ g_free(session->owner);
+ g_free(session);
+}
+
+static gint cmp_bcast_session(gconstpointer a, gconstpointer b)
+{
+ const struct bcast_session *session = a;
+ const struct bcast_session *match = b;
+ int ret;
+
+ ret = g_strcmp0(session->owner, match->owner);
+ if (ret)
+ return ret;
+
+ ret = session->data_type - match->data_type;
+ if (ret)
+ return ret;
+
+ return session->data_id - match->data_id;
+}
+
+static struct bcast_session *find_bcast_session(GSList *list,
+ const char *sender, uint8_t type, uint16_t data_id)
+{
+ struct bcast_session *match;
+ GSList *l;
+
+ match = g_new0(struct bcast_session, 1);
+ match->owner = g_strdup(sender);
+ match->data_type = type;
+ match->data_id = data_id;
+
+ l = g_slist_find_custom(list, match, cmp_bcast_session);
+ g_free(match->owner);
+ g_free(match);
+
+ return l ? l->data : NULL;
+}
+
+static void bcast_session_exit(DBusConnection *conn, void *user_data)
+{
+ struct bcast_session *session = user_data;
+ struct btd_adapter *adapter = session->adapter;
+ uint8_t type = session->data_type;
+
+ if (type == EIR_SVC_DATA)
+ DBG("Service Data Broadcaster watcher %s disconnected",
+ session->owner);
+ else
+ DBG("Manufacturer Data Broadcasterer watcher %s disconnected",
+ session->owner);
+
+ adapter->bcast_sessions = g_slist_remove(adapter->bcast_sessions,
+ session);
+ free_bcast_session(session);
+
+ /* FIXME: Stop advertising, send data blob from others apps to kernel
+ * with same type and restart advertising*/
+}
+
+static void update_adv_data(struct btd_adapter *adapter,
+ struct bcast_session *session, uint8_t *data, int size)
+{
+}
+
void adapter_set_controller_data_failed(struct btd_adapter *adapter)
{
}
@@ -1417,6 +1505,7 @@ static DBusMessage *set_service_data(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct btd_adapter *adapter = data;
+ struct bcast_session *session;
const char *sender;
uint16_t uuid;
uint8_t *sdata;
@@ -1430,9 +1519,30 @@ static DBusMessage *set_service_data(DBusConnection *conn,
sender = dbus_message_get_sender(msg);
+ session = find_bcast_session(adapter->bcast_sessions, sender,
+ EIR_SVC_DATA, uuid);
+ if (session) {
+ update_adv_data(adapter, session, sdata, ssize);
+ goto done;
+ }
+
+ session = g_new(struct bcast_session, 1);
+ session->data_id = uuid;
+ session->owner = g_strdup(sender);
+ session->adapter = btd_adapter_ref(adapter);
+ session->data_type = EIR_SVC_DATA;
+ session->msg = dbus_message_ref(msg);
+ session->id = g_dbus_add_disconnect_watch(conn, sender,
+ bcast_session_exit, session,
+ NULL);
+
+ adapter->bcast_sessions = g_slist_prepend(adapter->bcast_sessions,
+ session);
+
DBG("Service Data Broadcaster registered for hci%d at %s",
adapter->dev_id, sender);
+done:
return dbus_message_new_method_return(msg);
}
@@ -1440,6 +1550,7 @@ static DBusMessage *set_manufacturer_data(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct btd_adapter *adapter = data;
+ struct bcast_session *session;
const char *sender;
uint16_t company_id;
uint8_t *mdata;
@@ -1453,9 +1564,30 @@ static DBusMessage *set_manufacturer_data(DBusConnection *conn,
sender = dbus_message_get_sender(msg);
+ session = find_bcast_session(adapter->bcast_sessions, sender,
+ EIR_MANUF_DATA, company_id);
+ if (session != NULL) {
+ update_adv_data(adapter, session, mdata, msize);
+ goto done;
+ }
+
+ session = g_new(struct bcast_session, 1);
+ session->data_id = company_id;
+ session->owner = g_strdup(sender);
+ session->adapter = btd_adapter_ref(adapter);
+ session->data_type = EIR_MANUF_DATA;
+ session->msg = dbus_message_ref(msg);
+ session->id = g_dbus_add_disconnect_watch(conn, sender,
+ bcast_session_exit, session,
+ NULL);
+
+ adapter->bcast_sessions = g_slist_prepend(adapter->bcast_sessions,
+ session);
+
DBG("Manufacturer Specific Data Broadcaster registered for hci%d at %s",
adapter->dev_id, sender);
+done:
return dbus_message_new_method_return(msg);
}
@@ -3067,6 +3199,31 @@ static void release_all_obs(struct btd_adapter *adapter)
g_slist_free_full(adapter->observers, destroy_observer);
}
+static void release_all_bcast(struct btd_adapter *adapter)
+{
+ int err;
+
+ if (!adapter->bcast_sessions)
+ return;
+
+ err = mgmt_set_broadcaster(adapter->dev_id, FALSE);
+ if (err < 0)
+ error("Failed to set Broadcaster: %s (%d)", strerror(-err),
+ -err);
+
+ err = mgmt_unset_controller_data(adapter->dev_id, EIR_SVC_DATA);
+ if (err < 0)
+ error("Failed to unset service data: %s (%d)", strerror(-err),
+ -err);
+
+ err = mgmt_unset_controller_data(adapter->dev_id, EIR_MANUF_DATA);
+ if (err < 0)
+ error("Failed to unset manufacturer spcific data: %s (%d)",
+ strerror(-err), -err);
+
+ g_slist_free_full(adapter->bcast_sessions, free_bcast_session);
+}
+
void adapter_remove(struct btd_adapter *adapter)
{
GSList *l;
@@ -3091,6 +3248,8 @@ void adapter_remove(struct btd_adapter *adapter)
release_all_obs(adapter);
+ release_all_bcast(adapter);
+
if (adapter->powered)
mgmt_set_powered(adapter->dev_id, FALSE);
}
diff --git a/src/eir.h b/src/eir.h
index e410753..9fb0ba1 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -40,6 +40,9 @@
#define EIR_GAP_APPEARANCE 0x19 /* GAP appearance */
#define EIR_MANUF_DATA 0xFF /* manufacturer specific data */
+/* Reserve 2 octets for length and data type */
+#define EIR_DATA_MAX_LEN (HCI_LE_MAX_ADV_DATA_LENGTH - 2)
+
struct svc_data {
uint16_t uuid;
uint8_t data_len;
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 20/25] broadcaster: Add SetService/ManufacturerData() D-Bus method
From: Bruna Moreira @ 2012-12-21 20:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jefferson Delfes
In-Reply-To: <1356121612-15172-1-git-send-email-bruna.moreira@openbossa.org>
From: Jefferson Delfes <jefferson.delfes@openbossa.org>
For SetServiceData(), receive the service UUID with advertising data
that will be set in device.
For SetManufacturerData(), receive the Company Identifier Code with
advertising data that will be set in device.
---
src/adapter.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/src/adapter.c b/src/adapter.c
index 90aab94..60c0697 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1416,12 +1416,46 @@ void adapter_set_controller_data_failed(struct btd_adapter *adapter)
static DBusMessage *set_service_data(DBusConnection *conn,
DBusMessage *msg, void *data)
{
+ struct btd_adapter *adapter = data;
+ const char *sender;
+ uint16_t uuid;
+ uint8_t *sdata;
+ int ssize;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT16, &uuid,
+ DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
+ &sdata, &ssize,
+ DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+
+ sender = dbus_message_get_sender(msg);
+
+ DBG("Service Data Broadcaster registered for hci%d at %s",
+ adapter->dev_id, sender);
+
return dbus_message_new_method_return(msg);
}
static DBusMessage *set_manufacturer_data(DBusConnection *conn,
DBusMessage *msg, void *data)
{
+ struct btd_adapter *adapter = data;
+ const char *sender;
+ uint16_t company_id;
+ uint8_t *mdata;
+ int msize;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_UINT16, &company_id,
+ DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
+ &mdata, &msize,
+ DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+
+ sender = dbus_message_get_sender(msg);
+
+ DBG("Manufacturer Specific Data Broadcaster registered for hci%d at %s",
+ adapter->dev_id, sender);
+
return dbus_message_new_method_return(msg);
}
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 19/25] lib: Maximum value to advertising and scan response
From: Bruna Moreira @ 2012-12-21 20:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1356121612-15172-1-git-send-email-bruna.moreira@openbossa.org>
Create a constant to define the maximum lenght for advertising and scan
response data format.
---
lib/hci.h | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/hci.h b/lib/hci.h
index 56c9316..bce6b41 100644
--- a/lib/hci.h
+++ b/lib/hci.h
@@ -1505,17 +1505,19 @@ typedef struct {
} __attribute__ ((packed)) le_read_advertising_channel_tx_power_rp;
#define LE_READ_ADVERTISING_CHANNEL_TX_POWER_RP_SIZE 2
+#define HCI_LE_MAX_ADV_DATA_LENGTH 31
+
#define OCF_LE_SET_ADVERTISING_DATA 0x0008
typedef struct {
uint8_t length;
- uint8_t data[31];
+ uint8_t data[HCI_LE_MAX_ADV_DATA_LENGTH];
} __attribute__ ((packed)) le_set_advertising_data_cp;
#define LE_SET_ADVERTISING_DATA_CP_SIZE 32
#define OCF_LE_SET_SCAN_RESPONSE_DATA 0x0009
typedef struct {
uint8_t length;
- uint8_t data[31];
+ uint8_t data[HCI_LE_MAX_ADV_DATA_LENGTH];
} __attribute__ ((packed)) le_set_scan_response_data_cp;
#define LE_SET_SCAN_RESPONSE_DATA_CP_SIZE 32
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 18/25] adapter: Add D-Bus API for Broadcaster GAP Role
From: Bruna Moreira @ 2012-12-21 20:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jefferson Delfes
In-Reply-To: <1356121612-15172-1-git-send-email-bruna.moreira@openbossa.org>
From: Jefferson Delfes <jefferson.delfes@openbossa.org>
Implement dummy calls for register or unregister Broadcaster.
---
src/adapter.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/adapter.c b/src/adapter.c
index 4fc4fa9..90aab94 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1413,6 +1413,24 @@ void adapter_set_controller_data_failed(struct btd_adapter *adapter)
{
}
+static DBusMessage *set_service_data(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ return dbus_message_new_method_return(msg);
+}
+
+static DBusMessage *set_manufacturer_data(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ return dbus_message_new_method_return(msg);
+}
+
+static DBusMessage *clear_broadcast_data(DBusConnection *conn,
+ DBusMessage *msg, void *data)
+{
+ return dbus_message_new_method_return(msg);
+}
+
static const GDBusMethodTable adapter_methods[] = {
{ GDBUS_METHOD("StartDiscovery", NULL, NULL,
adapter_start_discovery) },
@@ -1435,6 +1453,15 @@ static const GDBusMethodTable adapter_methods[] = {
{ GDBUS_METHOD("UnregisterManufacturerObserver",
GDBUS_ARGS({ "observer", "o" }), NULL,
unregister_manuf_observer) },
+ { GDBUS_ASYNC_METHOD("SetServiceData", GDBUS_ARGS({ "uuid", "q" },
+ { "data", "ay" }), NULL,
+ set_service_data) },
+ { GDBUS_ASYNC_METHOD("SetManufacturerData",
+ GDBUS_ARGS({ "company_id", "q" },
+ { "data", "ay" }), NULL,
+ set_manufacturer_data) },
+ { GDBUS_METHOD("ClearBroadcastData", NULL, NULL,
+ clear_broadcast_data) },
{ }
};
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 17/25] observer: Add python test script
From: Bruna Moreira @ 2012-12-21 20:26 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1356121612-15172-1-git-send-email-bruna.moreira@openbossa.org>
---
test/test-observer | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 75 insertions(+)
create mode 100755 test/test-observer
diff --git a/test/test-observer b/test/test-observer
new file mode 100755
index 0000000..04d3f05
--- /dev/null
+++ b/test/test-observer
@@ -0,0 +1,75 @@
+#!/usr/bin/python
+
+'''Observer test script
+'''
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+from gi.repository import GObject
+
+import sys
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+from optparse import OptionParser, make_option
+import bluezutils
+
+def dbus_data(data):
+ return "".join(["%02x" % c for c in data])
+
+class Observer(dbus.service.Object):
+ @dbus.service.method("org.bluez.Observer1",
+ in_signature="sqay", out_signature="")
+ def ServiceReceived(self, address, uuid, value):
+ print("[ " + address + " ]")
+ print(" Service UUID = 0x%04x" % int(uuid))
+ print(" Data = %s" % dbus_data(value))
+ print()
+
+ @dbus.service.method("org.bluez.Observer1",
+ in_signature="sqay", out_signature="")
+ def ManufacturerReceived(self, address, cid, value):
+ print("[ " + address + " ]")
+ print(" Company ID = 0x%04x" % int(cid))
+ print(" Data = %s" % dbus_data(value))
+ print()
+
+if __name__ == "__main__":
+ dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+
+ bus = dbus.SystemBus()
+
+ manager = dbus.Interface(bus.get_object("org.bluez", "/"),
+ "org.bluez.Manager")
+
+ option_list = [
+ make_option("-i", "--adapter", action="store",
+ type="string", dest="adapter"),
+ make_option("-s", "--service", action="store",
+ type="int", dest="service_uuid",
+ help="Service UUID (e.g. \"0x0001\")"),
+ make_option("-c", "--company", action="store",
+ type="int", dest="company_id",
+ help="Company Identifier Code (e.g. \"0x0002\")"),
+ ]
+
+ parser = OptionParser(option_list=option_list)
+
+ (options, args) = parser.parse_args()
+
+ if not options.service_uuid and not options.company_id:
+ parser.error("At least one option is required: -c or -s")
+
+ adapter = bluezutils.find_adapter(options.adapter)
+
+ path = "/test/observer"
+ observer = Observer(bus, path)
+
+ if options.service_uuid:
+ adapter.RegisterServiceObserver(path, dbus.UInt16(options.service_uuid))
+
+ if options.company_id:
+ adapter.RegisterManufacturerObserver(path, dbus.UInt16(options.company_id))
+
+ mainloop = GObject.MainLoop()
+ mainloop.run()
--
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