* Re: [RFC 0/1] Implement Compound (Multi-step) GATT Procedure Support
From: Brian Gix @ 2010-12-21 19:50 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: vinicius.gomes, linux-bluetooth
In-Reply-To: <AANLkTin8BHWOhpnv36ncteMNRfXwU81r17owAAaixiD-@mail.gmail.com>
Hi Caudio,
On Tue, 2010-12-21 at 16:25 -0300, Claudio Takahasi wrote:
> Hi Brian,
>
> On Tue, Dec 21, 2010 at 2:25 PM, Brian Gix <bgix@codeaurora.org> wrote:
> > Hi Claudio & Vinicius,
> >
> >
> > On Fri, 2010-12-17 at 14:48 -0800, Brian Gix wrote:
> >> The following two proposed patches implement a method for correctly
> >> staging GATT procedures that require multiple ATT req/resp exchanges.
> >
> > If you guys get a chance, could you consider this proposed change
> > to gattrib.[ch] and the subsequent change to gatt.c? It differs from my
> > initial proposed patch which subverted the gattrib queuing mechanism. It
> > now lets each ATT command run to completion. It also fixes the memory
> > leak potential that Vinicius spotted. I think it is important that you
> > give it at least a cursory look, because you guys know more about bluez
> > GATT than anyone else here at this point. Otherwise, I will resubmit
> > this version as a patch request. -- thx
> >
>
> ok. We can review your patches.
> Could you please send patches to change gatttool to support this new feature?
> How are you testing it? Do you have a modified BlueZ attribute server
> or another GATT server?
There are no changes required to gatttool. The implemented high level
function is still to read an attribute, and the function works the same
if the remote attribute is shorter than 22 octets, and will be "long"
only if the first response indicates a remote attribute of 22 octets or
longer. (accounting for the one octet for the response hdr)
I am testing this against against the internal Qualcomm GATT server,
which has been tested at the past two UPFs. This is also the same stack
which I hope to use to pre-vet the SM changes you are leading, prior to
the UPF in Las Vegas.
As my next task, I could implement the capability to support long reads
in the BlueZ GATT server. (likely followed by long writes in both the
GATT client and server of BlueZ)
>
> Claudio
Thanks,
--
Brian Gix
bgix@codeaurora.org
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
^ permalink raw reply
* Re: [RFC 0/1] Implement Compound (Multi-step) GATT Procedure Support
From: Claudio Takahasi @ 2010-12-21 19:25 UTC (permalink / raw)
To: Brian Gix; +Cc: vinicius.gomes, linux-bluetooth
In-Reply-To: <1292952355.14993.9.camel@sealablnx02.qualcomm.com>
Hi Brian,
On Tue, Dec 21, 2010 at 2:25 PM, Brian Gix <bgix@codeaurora.org> wrote:
> Hi Claudio & Vinicius,
>
>
> On Fri, 2010-12-17 at 14:48 -0800, Brian Gix wrote:
>> The following two proposed patches implement a method for correctly
>> staging GATT procedures that require multiple ATT req/resp exchanges.
>
> If you guys get a chance, could you consider this proposed change
> to gattrib.[ch] and the subsequent change to gatt.c? It differs from my
> initial proposed patch which subverted the gattrib queuing mechanism. It
> now lets each ATT command run to completion. It also fixes the memory
> leak potential that Vinicius spotted. I think it is important that you
> give it at least a cursory look, because you guys know more about bluez
> GATT than anyone else here at this point. Otherwise, I will resubmit
> this version as a patch request. -- thx
>
ok. We can review your patches.
Could you please send patches to change gatttool to support this new feature?
How are you testing it? Do you have a modified BlueZ attribute server
or another GATT server?
Claudio
^ permalink raw reply
* Re: [PATCH] sbc: detect when bitpool has changed
From: Brian Gix @ 2010-12-21 18:02 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1292950724-4918-1-git-send-email-luiz.dentz@gmail.com>
Hello Luiz,
On Tue, 2010-12-21 at 18:58 +0200, Luiz Augusto von Dentz wrote:
> From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
>
> ---
> sbc/sbc.c | 8 +++++---
> 1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/sbc/sbc.c b/sbc/sbc.c
> index a6391ae..b3a7a09 100644
> --- a/sbc/sbc.c
> +++ b/sbc/sbc.c
> @@ -965,7 +965,8 @@ ssize_t sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
>
> framelen = sbc_unpack_frame(input, &priv->frame, input_len);
>
> - if (!priv->init) {
> + /* init if no previous frame was encode or bitpool has changed */
> + if (!priv->init || priv->frame.bitpool != sbc->bitpool) {
> sbc_decoder_init(&priv->dec_state, &priv->frame);
> priv->init = 1;
I don't think it is a good idea to reinitialize the SBC decoder if a
change in bitpool size is detected.
The A2DP and AVDTP specifications do not allow most of the parameters to
change from one frame to the next (mode, channels, subbands, blocks,
allocation, frequency) but explicitly DO allow changes in bitpool size
midstream. This allows for Variable Bit Rate (VBR) streaming, and adds
efficiency to the over-the-air link with no quality loss. Also, the
space required for decoding does not change just because the bitpool has
changed, so re-initialization should not be required.
The only things that should be different from one SBC frame to the next
is the bitpool of course, and the framelen. That said, if a bitpool
change is detected the only thing within that "IF" block that should be
updated is:
sbc->bitpool
If any of the other afore mentioned parameters change, the stream should
be terminated.
>
> @@ -1035,7 +1036,8 @@ ssize_t sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
> if (written)
> *written = 0;
>
> - if (!priv->init) {
> + /* init if no previous frame was encode or bitpool has changed */
> + if (!priv->init || priv->frame.bitpool != sbc->bitpool) {
> priv->frame.frequency = sbc->frequency;
> priv->frame.mode = sbc->mode;
> priv->frame.channels = sbc->mode == SBC_MODE_MONO ? 1 : 2;
Same basic comment here, although it is perfectly allowable for the
Encoder to not support VBR. However if the Encoder does change the
bitpool, then the list of fields that need to be updated are:
priv->frame.bitpool
priv->frame.length
But again, the sbc_encoder_init should *not* be re-run. I would pull
those two variables out of that IF block, and set them in their own IF
block either directly before or directly after the !priv->init IF block.
> @@ -1120,7 +1122,7 @@ size_t sbc_get_frame_length(sbc_t *sbc)
> struct sbc_priv *priv;
>
> priv = sbc->priv;
> - if (priv->init)
> + if (priv->init && priv->frame.bitpool == sbc->bitpool)
> return priv->frame.length;
>
> subbands = sbc->subbands ? 8 : 4;
This is a valid change, because bitpool changes do indeed change the
frame.length.
--
Brian Gix
bgix@codeaurora.org
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
^ permalink raw reply
* AVRCP connect failing with Interop headset-Buffalo
From: roystonr @ 2010-12-21 17:35 UTC (permalink / raw)
To: linux-bluetooth
Cc: Luiz Augusto von Dentz, Johan Hedberg, roystonr, rshaffer,
skrovvid
Hi,
During Interop testing with Buffalo headset (supporting A2DP+AVRCP), its
observed that the A2DP connection is failing.
>From the sniffer logs, its observed that the DUT (Device under test)
issues avrcp_connect even before the l2cap connections for avdtp transport
and signaling are completed. Its also observed from the sniffer logs that
the remote side hasnt responded to one of the DUTs l2cap connection
request, before the DUT initiates the avrcp_connect.
As an experiment, by modifying the CONTROL_CONNECT_TIMEOUT (in device.c)
value from 2 to 5 seconds this issue with the mentioned headset is
avoided.
To my understanding, CONTROL_CONNECT_TIMEOUT controls the interval at
which the avrcp_connect is initiated from the DUT i.e. if the stream setup
is active then the timer is kicked in to delay the DUT side avrcp_connect.
Though by increasing the CONTROL_CONNECT_TIMEOUT value, this issue with
the headset under test is avoided. The ideal way would be to trigger the
DUT initiated avrcp_connect only after the l2cap connections are
completed. Correct me if my understanding is wrong.
Kindly provide reference as to how to control the DUT initiated
avrcp_connect only after ensuring that the l2cap connections are
completed. Or is it safe to the modify CONTROL_CONNECT_TIMEOUT value as
mentioned above.
Regards,
Royston Rodrigues.
"Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum."
^ permalink raw reply
* Re: [RFC 0/1] Implement Compound (Multi-step) GATT Procedure Support
From: Brian Gix @ 2010-12-21 17:25 UTC (permalink / raw)
To: claudio.takahasi, vinicius.gomes; +Cc: linux-bluetooth
In-Reply-To: <1292626132-30029-1-git-send-email-bgix@codeaurora.org>
Hi Claudio & Vinicius,
On Fri, 2010-12-17 at 14:48 -0800, Brian Gix wrote:
> The following two proposed patches implement a method for correctly
> staging GATT procedures that require multiple ATT req/resp exchanges.
If you guys get a chance, could you consider this proposed change
to gattrib.[ch] and the subsequent change to gatt.c? It differs from my
initial proposed patch which subverted the gattrib queuing mechanism. It
now lets each ATT command run to completion. It also fixes the memory
leak potential that Vinicius spotted. I think it is important that you
give it at least a cursory look, because you guys know more about bluez
GATT than anyone else here at this point. Otherwise, I will resubmit
this version as a patch request. -- thx
>
> The first RFC / PATCH is gattrib.[ch], which allows the caller to specify
> a gboolean indicating that the command being queued is Compound
> (even if the procedure ends up being single/atomic) and a queue ID
> number, which allows the caller to cancel the GATT procedure at any
> stage of the transaction.
>
> IF -
> The ATT opcode being queued is specified as compound, the resulting response
> will not cause the next item in the queue to be sent until *after* the
> response has been forwarded to the caller via the response callback.
>
> IF -
> The ATT opcode being queued is *not* compound, the resulting response
> will service the pkt queue immediately (legacy functionality).
>
> IF -
> The ID passed to g_attrib_send_seq is ZERO, the command pkt will
> be added to the TAIL of the queue, and a new ID assigned to it.
> (Legacy functionality)
>
> IF -
> The ID passed to g_attrib_send_seq is NON-ZERO, the command pkt
> will be added to the HEAD of the queue, causing it to be the next
> pkt sent to the remote device. The NON-ZERO ID is also then able
> to cancel the command.
>
>
> The second RFC / PATCH is to gatt.c. It modifies the existing gatt_read_char()
> function to recognize the need for a compound Read procedure, and implements
> it as a READ_REQ + READ_BLOB_REQ + READ_BLOB_REQ ...<etc> as needed, using
> the g_attrib_send_seq() logic from the first RFC / PATCH.
>
^ permalink raw reply
* [PATCH] sbc: detect when bitpool has changed
From: Luiz Augusto von Dentz @ 2010-12-21 16:58 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
---
sbc/sbc.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/sbc/sbc.c b/sbc/sbc.c
index a6391ae..b3a7a09 100644
--- a/sbc/sbc.c
+++ b/sbc/sbc.c
@@ -965,7 +965,8 @@ ssize_t sbc_decode(sbc_t *sbc, const void *input, size_t input_len,
framelen = sbc_unpack_frame(input, &priv->frame, input_len);
- if (!priv->init) {
+ /* init if no previous frame was encode or bitpool has changed */
+ if (!priv->init || priv->frame.bitpool != sbc->bitpool) {
sbc_decoder_init(&priv->dec_state, &priv->frame);
priv->init = 1;
@@ -1035,7 +1036,8 @@ ssize_t sbc_encode(sbc_t *sbc, const void *input, size_t input_len,
if (written)
*written = 0;
- if (!priv->init) {
+ /* init if no previous frame was encode or bitpool has changed */
+ if (!priv->init || priv->frame.bitpool != sbc->bitpool) {
priv->frame.frequency = sbc->frequency;
priv->frame.mode = sbc->mode;
priv->frame.channels = sbc->mode == SBC_MODE_MONO ? 1 : 2;
@@ -1120,7 +1122,7 @@ size_t sbc_get_frame_length(sbc_t *sbc)
struct sbc_priv *priv;
priv = sbc->priv;
- if (priv->init)
+ if (priv->init && priv->frame.bitpool == sbc->bitpool)
return priv->frame.length;
subbands = sbc->subbands ? 8 : 4;
--
1.7.1
^ permalink raw reply related
* RE: problem to disconnect with bluez-test
From: Goubert, TonyX @ 2010-12-21 15:57 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <20101221092421.GA17157@jh-x301>
Hi Johan,
Thank you for your answer.
Yes, in fact, I want to use the test scripts in bluez to disconnect a device.
Well, I download the latest version of bluez (Bluez-4.82) and I have not find the command 'disconnect' in the script 'test-device'.
There are : list, create, remove, ... no disconnect.
> I just went ahead and pushed a patch for it upstream.
Can you give me your patch?
BR
--
Tony Goubert
tonyx.goubert@intel.com
-----Original Message-----
From: linux-bluetooth-owner@vger.kernel.org [mailto:linux-bluetooth-owner@vger.kernel.org] On Behalf Of Johan Hedberg
Sent: Tuesday, December 21, 2010 10:24 AM
To: Goubert, TonyX
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: problem to disconnect with bluez-test
Hi Tony,
On Tue, Dec 21, 2010, Goubert, TonyX wrote:
> I have paired a handset with a laptop by using 'simple-agent'
> bluez-test script BUT I can't disconnect it when I use the bluez
> stack.
I suppose you mean you can't disconnect it using the test scripts that
come with BlueZ (since I'm sure you *can* disconnect it with BlueZ as
long as you use the D-Bus interface directly).
> I can remove it (./test-device remove xx:xx:xx:xx:xx:xx) but I
> want to be able to connect/disconnect/connect...
The Device.Disconnect method is indeed something that should be added to
the test-device script. I just went ahead and pushed a patch for it
upstream.
> [root@localhost test]# ./test-device disconnect xx:xx:xx:xx:xx:xx
> Unknown command
This command should work with latest git now.
Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply
* [PATCH] Configure HFP/HSP endpoints if headset interface is already connected
From: Luiz Augusto von Dentz @ 2010-12-21 15:43 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.dentz-von@nokia.com>
HFP/HSP can be connected when registering an endpoint which is different
than on a2dp where the sep cannot be configured already since it wasn't
available before.
---
audio/media.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/audio/media.c b/audio/media.c
index b28bb33..97a60a1 100644
--- a/audio/media.c
+++ b/audio/media.c
@@ -42,6 +42,7 @@
#include "transport.h"
#include "a2dp.h"
#include "headset.h"
+#include "manager.h"
#ifndef DBUS_TYPE_UNIX_FD
#define DBUS_TYPE_UNIX_FD -1
@@ -200,10 +201,18 @@ static struct media_endpoint *media_endpoint_create(struct media_adapter *adapte
if (endpoint->sep == NULL)
goto failed;
} else if (strcasecmp(uuid, HFP_AG_UUID) == 0 ||
- g_strcmp0(uuid, HSP_AG_UUID) == 0)
+ g_strcmp0(uuid, HSP_AG_UUID) == 0) {
+ struct audio_device *dev;
+
endpoint->hs_watch = headset_add_state_cb(headset_state_changed,
endpoint);
- else
+ dev = manager_find_device(NULL, &adapter->src, BDADDR_ANY,
+ AUDIO_HEADSET_INTERFACE, TRUE);
+ if (dev)
+ media_endpoint_set_configuration(endpoint, dev, NULL,
+ 0, headset_setconf_cb,
+ dev);
+ } else
goto failed;
endpoint->watch = g_dbus_add_disconnect_watch(adapter->conn, sender,
--
1.7.1
^ permalink raw reply related
* Re: [PATCH v4] Bluetooth: Fix __hci_request synchronization for hci_open_dev
From: Marcel Holtmann @ 2010-12-21 15:06 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20101221150258.GA25824@jh-x301>
Hi Johan,
> > And actually hci_init_req is not the only function where you would need
> > to add hdev->req_last_cmd entries. There are hci_reset_req and some
> > others. Without that, the rest of your patch makes hci_req_complete a
> > non functional operation.
>
> Actually no, if req_last_cmd is 0 (which it is in all cases except
> hci_init_req) then the comparison is not done:
>
> > + if (hdev->req_last_cmd && cmd != hdev->req_last_cmd)
> > + return;
>
> I did this to keep the patch simple and to not have to change all the
> single HCI command cases. I.e. only multi-HCI command requests need to
> set this variable.
not a huge fan of this, but if you put a comment on top then I could be
convinced ;)
Regards
Marcel
^ permalink raw reply
* Re: [PATCH v4] Bluetooth: Fix __hci_request synchronization for hci_open_dev
From: Johan Hedberg @ 2010-12-21 15:02 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1292942802.2658.49.camel@aeonflux>
Hi Marcel,
On Tue, Dec 21, 2010, Marcel Holtmann wrote:
> just for style consistency add an empty line before this command.
Sure.
> And actually hci_init_req is not the only function where you would need
> to add hdev->req_last_cmd entries. There are hci_reset_req and some
> others. Without that, the rest of your patch makes hci_req_complete a
> non functional operation.
Actually no, if req_last_cmd is 0 (which it is in all cases except
hci_init_req) then the comparison is not done:
> + if (hdev->req_last_cmd && cmd != hdev->req_last_cmd)
> + return;
I did this to keep the patch simple and to not have to change all the
single HCI command cases. I.e. only multi-HCI command requests need to
set this variable.
Johan
^ permalink raw reply
* Re: [PATCH v4] Bluetooth: Fix __hci_request synchronization for hci_open_dev
From: Marcel Holtmann @ 2010-12-21 14:46 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1292590111-6564-1-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> The initialization function used by hci_open_dev (hci_init_req) sends
> many different HCI commands. The __hci_request function should only
> return when all of these commands have completed (or a timeout occurs).
> Several of these commands cause hci_req_complete to be called which
> causes __hci_request to return prematurely.
>
> This patch fixes the issue by adding a new hdev->req_last_cmd variable
> which is set during the initialization procedure. The hci_req_complete
> function will no longer mark the request as complete until the command
> matching hdev->req_last_cmd completes.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
> ---
> v4: Use __u16 instead of int for req_last_cmd
>
> include/net/bluetooth/hci_core.h | 3 ++-
> net/bluetooth/hci_core.c | 10 +++++++---
> net/bluetooth/hci_event.c | 33 +++++++++++++++++++++++----------
> 3 files changed, 32 insertions(+), 14 deletions(-)
>
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 3786ee8..a29feb0 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -129,6 +129,7 @@ struct hci_dev {
> wait_queue_head_t req_wait_q;
> __u32 req_status;
> __u32 req_result;
> + __u16 req_last_cmd;
>
> struct inquiry_cache inq_cache;
> struct hci_conn_hash conn_hash;
> @@ -693,6 +694,6 @@ struct hci_sec_filter {
> #define hci_req_lock(d) mutex_lock(&d->req_lock)
> #define hci_req_unlock(d) mutex_unlock(&d->req_lock)
>
> -void hci_req_complete(struct hci_dev *hdev, int result);
> +void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result);
>
> #endif /* __HCI_CORE_H */
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 1a4ec97..787c8df 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -91,9 +91,12 @@ static void hci_notify(struct hci_dev *hdev, int event)
>
> /* ---- HCI requests ---- */
>
> -void hci_req_complete(struct hci_dev *hdev, int result)
> +void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result)
> {
> - BT_DBG("%s result 0x%2.2x", hdev->name, result);
> + BT_DBG("%s command 0x%04x result 0x%2.2x", hdev->name, cmd, result);
> +
> + if (hdev->req_last_cmd && cmd != hdev->req_last_cmd)
> + return;
>
> if (hdev->req_status == HCI_REQ_PEND) {
> hdev->req_result = result;
> @@ -149,7 +152,7 @@ static int __hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *hdev,
> break;
> }
>
> - hdev->req_status = hdev->req_result = 0;
> + hdev->req_last_cmd = hdev->req_status = hdev->req_result = 0;
>
> BT_DBG("%s end: err %d", hdev->name, err);
>
> @@ -252,6 +255,7 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
> /* Connection accept timeout ~20 secs */
> param = cpu_to_le16(0x7d00);
> hci_send_cmd(hdev, HCI_OP_WRITE_CA_TIMEOUT, 2, ¶m);
> + hdev->req_last_cmd = HCI_OP_WRITE_CA_TIMEOUT;
just for style consistency add an empty line before this command.
And actually hci_init_req is not the only function where you would need
to add hdev->req_last_cmd entries. There are hci_reset_req and some
others. Without that, the rest of your patch makes hci_req_complete a
non functional operation.
Regards
Marcel
^ permalink raw reply
* [PATCH v4 2/5] Change CreatePairedDevice to support LE devices
From: Sheldon Demario @ 2010-12-21 14:34 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
In-Reply-To: <20101221084243.GA14108@jh-x301>
CreatePairedDevice implements now the same behaviour of CreateDevice,
triggering Discover All Primary Services when needed. SMP negotiation
starts when the link is established. LE capable kernel is required to
test this method properly.
Limitation: For dual mode devices, Discover All Primary Services is not
being executed after SDP search if GATT record is found.
---
src/adapter.c | 102 +++++++++++++++++++++++++++++++++++++----------------
src/device.c | 89 ++++++++++++++++++++++++----------------------
src/device.h | 5 ++-
src/glib-helper.c | 12 +++++-
src/glib-helper.h | 1 +
5 files changed, 132 insertions(+), 77 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index cf3566d..82f55ef 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -1510,15 +1510,48 @@ static gboolean event_is_connectable(uint8_t type)
}
}
+static struct btd_device *create_device_internal(DBusConnection *conn,
+ struct btd_adapter *adapter,
+ const gchar *address,
+ gboolean force, int *err)
+{
+ struct remote_dev_info *dev, match;
+ struct btd_device *device;
+ device_type_t type;
+
+ memset(&match, 0, sizeof(struct remote_dev_info));
+ str2ba(address, &match.bdaddr);
+ match.name_status = NAME_ANY;
+
+ dev = adapter_search_found_devices(adapter, &match);
+ if (dev && dev->flags)
+ type = flags2type(dev->flags);
+ else
+ type = DEVICE_TYPE_BREDR;
+
+ if (!force && type == DEVICE_TYPE_LE &&
+ !event_is_connectable(dev->evt_type)) {
+ if (err)
+ *err = -ENOTCONN;
+
+ return NULL;
+ }
+
+ device = adapter_create_device(conn, adapter, address, type);
+ if (!device && err)
+ *err = -ENOMEM;
+
+ return device;
+}
+
static DBusMessage *create_device(DBusConnection *conn,
DBusMessage *msg, void *data)
{
struct btd_adapter *adapter = data;
struct btd_device *device;
- struct remote_dev_info *dev, match;
const gchar *address;
+ DBusMessage *reply;
int err;
- device_type_t type;
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
DBUS_TYPE_INVALID) == FALSE)
@@ -1535,41 +1568,36 @@ static DBusMessage *create_device(DBusConnection *conn,
DBG("%s", address);
- memset(&match, 0, sizeof(struct remote_dev_info));
- str2ba(address, &match.bdaddr);
- match.name_status = NAME_ANY;
+ device = create_device_internal(conn, adapter, address, TRUE, &err);
+ if (!device)
+ goto failed;
- dev = adapter_search_found_devices(adapter, &match);
- if (dev && dev->flags)
- type = flags2type(dev->flags);
+ if (device_get_type(device) != DEVICE_TYPE_LE)
+ err = device_browse_sdp(device, conn, msg, NULL, FALSE);
else
- type = DEVICE_TYPE_BREDR;
+ err = device_browse_primary(device, conn, msg, FALSE);
- device = adapter_create_device(conn, adapter, address, type);
- if (!device)
- return NULL;
+ if (err < 0) {
+ adapter_remove_device(conn, adapter, device, TRUE);
+ return btd_error_failed(msg, strerror(-err));
+ }
- if (type == DEVICE_TYPE_LE && !event_is_connectable(dev->evt_type)) {
+ return NULL;
+
+failed:
+ if (err == -ENOTCONN) {
/* Device is not connectable */
const char *path = device_get_path(device);
- DBusMessage *reply;
reply = dbus_message_new_method_return(msg);
dbus_message_append_args(reply,
- DBUS_TYPE_OBJECT_PATH, &path,
- DBUS_TYPE_INVALID);
-
- return reply;
- }
-
- err = device_browse(device, conn, msg, NULL, FALSE);
- if (err < 0) {
- adapter_remove_device(conn, adapter, device, TRUE);
- return btd_error_failed(msg, strerror(-err));
- }
+ DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_INVALID);
+ } else
+ reply = btd_error_failed(msg, strerror(-err));
- return NULL;
+ return reply;
}
static uint8_t parse_io_capability(const char *capability)
@@ -1594,6 +1622,7 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
struct btd_device *device;
const gchar *address, *agent_path, *capability, *sender;
uint8_t cap;
+ int err;
if (dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
DBUS_TYPE_OBJECT_PATH, &agent_path,
@@ -1618,12 +1647,23 @@ static DBusMessage *create_paired_device(DBusConnection *conn,
if (cap == IO_CAPABILITY_INVALID)
return btd_error_invalid_args(msg);
- device = adapter_get_device(conn, adapter, address);
- if (!device)
- return btd_error_failed(msg,
- "Unable to create a new device object");
+ device = adapter_find_device(adapter, address);
+ if (!device) {
+ device = create_device_internal(conn, adapter, address,
+ FALSE, &err);
+ if (!device)
+ return btd_error_failed(msg, strerror(-err));
+ }
+
+ if (device_get_type(device) != DEVICE_TYPE_LE)
+ return device_create_bonding(device, conn, msg,
+ agent_path, cap);
- return device_create_bonding(device, conn, msg, agent_path, cap);
+ err = device_browse_primary(device, conn, msg, TRUE);
+ if (err < 0)
+ return btd_error_failed(msg, strerror(-err));
+
+ return NULL;
}
static gint device_path_cmp(struct btd_device *device, const gchar *path)
diff --git a/src/device.c b/src/device.c
index bef8e71..87a6647 100644
--- a/src/device.c
+++ b/src/device.c
@@ -583,7 +583,7 @@ static DBusMessage *discover_services(DBusConnection *conn,
return btd_error_invalid_args(msg);
if (strlen(pattern) == 0) {
- err = device_browse(device, conn, msg, NULL, FALSE);
+ err = device_browse_sdp(device, conn, msg, NULL, FALSE);
if (err < 0)
goto fail;
} else {
@@ -594,7 +594,7 @@ static DBusMessage *discover_services(DBusConnection *conn,
sdp_uuid128_to_uuid(&uuid);
- err = device_browse(device, conn, msg, &uuid, FALSE);
+ err = device_browse_sdp(device, conn, msg, &uuid, FALSE);
if (err < 0)
goto fail;
}
@@ -985,6 +985,11 @@ void device_get_name(struct btd_device *device, char *name, size_t len)
strncpy(name, device->name, len);
}
+device_type_t device_get_type(struct btd_device *device)
+{
+ return device->type;
+}
+
void device_remove_bonding(struct btd_device *device)
{
char filename[PATH_MAX + 1];
@@ -1537,41 +1542,62 @@ done:
browse_request_free(req);
}
-static struct browse_req *browse_primary(struct btd_device *device, int *err)
+int device_browse_primary(struct btd_device *device, DBusConnection *conn,
+ DBusMessage *msg, gboolean secure)
{
struct btd_adapter *adapter = device->adapter;
struct browse_req *req;
bdaddr_t src;
- int ret;
+ int err;
+
+ if (device->browse)
+ return -EBUSY;
req = g_new0(struct browse_req, 1);
req->device = btd_device_ref(device);
adapter_get_address(adapter, &src);
- ret = bt_discover_primary(&src, &device->bdaddr, -1, primary_cb, req,
- NULL);
-
- if (ret < 0) {
+ err = bt_discover_primary(&src, &device->bdaddr, -1, primary_cb, req,
+ secure, NULL);
+ if (err < 0) {
browse_request_free(req);
- if (err)
- *err = ret;
+ return err;
+ }
- return NULL;
+ if (conn == NULL)
+ conn = get_dbus_connection();
+
+ req->conn = dbus_connection_ref(conn);
+ device->browse = req;
+
+ if (msg) {
+ const char *sender = dbus_message_get_sender(msg);
+
+ req->msg = dbus_message_ref(msg);
+ /* Track the request owner to cancel it
+ * automatically if the owner exits */
+ req->listener_id = g_dbus_add_disconnect_watch(conn,
+ sender,
+ discover_services_req_exit,
+ req, NULL);
}
- return req;
+ return err;
}
-static struct browse_req *browse_sdp(struct btd_device *device, uuid_t *search,
- gboolean reverse, int *err)
+int device_browse_sdp(struct btd_device *device, DBusConnection *conn,
+ DBusMessage *msg, uuid_t *search, gboolean reverse)
{
struct btd_adapter *adapter = device->adapter;
struct browse_req *req;
bt_callback_t cb;
bdaddr_t src;
uuid_t uuid;
- int ret;
+ int err;
+
+ if (device->browse)
+ return -EBUSY;
adapter_get_address(adapter, &src);
@@ -1586,34 +1612,11 @@ static struct browse_req *browse_sdp(struct btd_device *device, uuid_t *search,
cb = browse_cb;
}
- ret = bt_search_service(&src, &device->bdaddr, &uuid, cb, req, NULL);
- if (ret < 0) {
+ err = bt_search_service(&src, &device->bdaddr, &uuid, cb, req, NULL);
+ if (err < 0) {
browse_request_free(req);
- if (err)
- *err = ret;
-
- return NULL;
- }
-
- return req;
-}
-
-int device_browse(struct btd_device *device, DBusConnection *conn,
- DBusMessage *msg, uuid_t *search, gboolean reverse)
-{
- struct browse_req *req;
- int err = 0;
-
- if (device->browse)
- return -EBUSY;
-
- if (device->type == DEVICE_TYPE_LE)
- req = browse_primary(device, &err);
- else
- req = browse_sdp(device, search, reverse, &err);
-
- if (req == NULL)
return err;
+ }
if (conn == NULL)
conn = get_dbus_connection();
@@ -1716,7 +1719,7 @@ static gboolean start_discovery(gpointer user_data)
{
struct btd_device *device = user_data;
- device_browse(device, NULL, NULL, NULL, TRUE);
+ device_browse_sdp(device, NULL, NULL, NULL, TRUE);
device->discov_timer = 0;
@@ -2053,7 +2056,7 @@ void device_bonding_complete(struct btd_device *device, uint8_t status)
device->discov_timer = 0;
}
- device_browse(device, bonding->conn, bonding->msg,
+ device_browse_sdp(device, bonding->conn, bonding->msg,
NULL, FALSE);
bonding_request_free(bonding);
diff --git a/src/device.h b/src/device.h
index 74b968c..9c645df 100644
--- a/src/device.h
+++ b/src/device.h
@@ -46,9 +46,12 @@ struct btd_device *device_create(DBusConnection *conn,
const gchar *address, device_type_t type);
void device_set_name(struct btd_device *device, const char *name);
void device_get_name(struct btd_device *device, char *name, size_t len);
+device_type_t device_get_type(struct btd_device *device);
void device_remove(struct btd_device *device, gboolean remove_stored);
gint device_address_cmp(struct btd_device *device, const gchar *address);
-int device_browse(struct btd_device *device, DBusConnection *conn,
+int device_browse_primary(struct btd_device *device, DBusConnection *conn,
+ DBusMessage *msg, gboolean secure);
+int device_browse_sdp(struct btd_device *device, DBusConnection *conn,
DBusMessage *msg, uuid_t *search, gboolean reverse);
void device_probe_drivers(struct btd_device *device, GSList *profiles);
const sdp_record_t *btd_device_get_record(struct btd_device *device,
diff --git a/src/glib-helper.c b/src/glib-helper.c
index c440e60..459a21c 100644
--- a/src/glib-helper.c
+++ b/src/glib-helper.c
@@ -520,9 +520,11 @@ static void connect_cb(GIOChannel *io, GError *gerr, gpointer user_data)
int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
bt_primary_t cb, void *user_data,
+ gboolean secure,
bt_destroy_t destroy)
{
struct gattrib_context *ctxt;
+ BtIOSecLevel sec_level;
GIOChannel *io;
GError *gerr = NULL;
@@ -536,19 +538,25 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
ctxt->cb = cb;
ctxt->destroy = destroy;
+ if (secure == TRUE)
+ sec_level = BT_IO_SEC_HIGH;
+ else
+ sec_level = BT_IO_SEC_LOW;
+
+
if (psm < 0)
io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
BT_IO_OPT_SOURCE_BDADDR, src,
BT_IO_OPT_DEST_BDADDR, dst,
BT_IO_OPT_CID, GATT_CID,
- BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
+ BT_IO_OPT_SEC_LEVEL, sec_level,
BT_IO_OPT_INVALID);
else
io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
BT_IO_OPT_SOURCE_BDADDR, src,
BT_IO_OPT_DEST_BDADDR, dst,
BT_IO_OPT_PSM, psm,
- BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
+ BT_IO_OPT_SEC_LEVEL, sec_level,
BT_IO_OPT_INVALID);
if (io == NULL) {
diff --git a/src/glib-helper.h b/src/glib-helper.h
index 10718bb..17739cf 100644
--- a/src/glib-helper.h
+++ b/src/glib-helper.h
@@ -35,6 +35,7 @@ int bt_cancel_discovery(const bdaddr_t *src, const bdaddr_t *dst);
int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
bt_primary_t cb, void *user_data,
+ gboolean secure,
bt_destroy_t destroy);
gchar *bt_uuid2string(uuid_t *uuid);
--
1.7.3.2
^ permalink raw reply related
* [PATCH] Fix build in directory separate from source.
From: Michal Labedzki @ 2010-12-21 14:22 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michal Labedzki
After bootstrapping can build bluez outside of sources. Patch add required
"include" paths, put all udev's rules to preprocess stage and change
behaviour on "./configure --prefix=PATH". When --prefix is set, all files
will be put in prefix-path. Otherwise, use path from PKG_CONFIG. This change
allow install all files in place which user chosen.
---
Makefile.am | 10 ++++++----
acinclude.m4 | 2 +-
configure.ac | 5 +++--
scripts/bluetooth-hid2hci.rules | 36 ------------------------------------
scripts/bluetooth-hid2hci.rules.in | 36 ++++++++++++++++++++++++++++++++++++
scripts/bluetooth-serial.rules | 35 -----------------------------------
scripts/bluetooth-serial.rules.in | 35 +++++++++++++++++++++++++++++++++++
7 files changed, 81 insertions(+), 78 deletions(-)
delete mode 100644 scripts/bluetooth-hid2hci.rules
create mode 100644 scripts/bluetooth-hid2hci.rules.in
delete mode 100644 scripts/bluetooth-serial.rules
create mode 100644 scripts/bluetooth-serial.rules.in
diff --git a/Makefile.am b/Makefile.am
index 5f96975..ab4b460 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -361,12 +361,14 @@ AM_YFLAGS = -d
AM_CFLAGS = @DBUS_CFLAGS@ @GLIB_CFLAGS@ @CAPNG_CFLAGS@ \
-DBLUETOOTH_PLUGIN_BUILTIN -DPLUGINDIR=\""$(plugindir)"\"
-INCLUDES = -I$(builddir)/lib -I$(builddir)/src -I$(srcdir)/src \
- -I$(srcdir)/audio -I$(srcdir)/sbc -I$(srcdir)/gdbus \
- -I$(srcdir)/attrib -I$(srcdir)/btio
+INCLUDES = -I$(builddir)/lib -I$(srcdir)/lib \
+ -I$(builddir)/tools -I$(srcdir)/tools \
+ -I$(builddir)/src -I$(srcdir)/src \
+ -I$(srcdir)/audio -I$(srcdir)/sbc -I$(srcdir)/gdbus \
+ -I$(srcdir)/attrib -I$(srcdir)/btio
if MCAP
-INCLUDES += -I$(builddir)/health
+INCLUDES += -I$(builddir)/health -I$(srcdir)/health
endif
pkgconfigdir = $(libdir)/pkgconfig
diff --git a/acinclude.m4 b/acinclude.m4
index 287f07d..4f1aae4 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -84,7 +84,7 @@ AC_DEFUN([AC_INIT_BLUEZ], [
AC_SUBST(STORAGEDIR, "${storagedir}")
UDEV_DATADIR="`$PKG_CONFIG --variable=udevdir udev`"
- if (test -z "${UDEV_DATADIR}"); then
+ if ((test "${prefix}" != "NONE") || (test -z "${UDEV_DATADIR}")); then
UDEV_DATADIR="${sysconfdir}/udev/rules.d"
else
UDEV_DATADIR="${UDEV_DATADIR}/rules.d"
diff --git a/configure.ac b/configure.ac
index 5f09cb6..da567e6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -55,5 +55,6 @@ if (test "${enable_capng}" = "yes"); then
AC_DEFINE(HAVE_CAPNG, 1, [Define to 1 if you have capabilities library.])
fi
-AC_OUTPUT(Makefile scripts/bluetooth.rules doc/version.xml
- src/bluetoothd.8 bluez.pc)
+AC_OUTPUT(Makefile scripts/bluetooth.rules scripts/bluetooth-hid2hci.rules
+ scripts/bluetooth-serial.rules doc/version.xml src/bluetoothd.8
+ bluez.pc)
diff --git a/scripts/bluetooth-hid2hci.rules b/scripts/bluetooth-hid2hci.rules
deleted file mode 100644
index 1b231d1..0000000
--- a/scripts/bluetooth-hid2hci.rules
+++ /dev/null
@@ -1,36 +0,0 @@
-# Variety of Dell Bluetooth devices
-#
-# it looks like a bit of an odd rule, because it is matching
-# on a mouse device that is self powered, but that is where
-# a HID report needs to be sent to switch modes.
-#
-# Known supported devices:
-# 413c:8154
-# 413c:8158
-# 413c:8162
-ACTION=="add", ENV{ID_VENDOR}=="413c", ENV{ID_CLASS}=="mouse", ATTRS{bmAttributes}=="e0", KERNEL=="mouse*", RUN+="/usr/sbin/hid2hci --method dell -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-
-# Logitech devices
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c703" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c704" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c705" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70a" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70b" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70c" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70e" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c713" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c714" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c71b" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c71c" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-
-# CSR devices (in HID mode)
-ACTION=="add", ENV{ID_VENDOR}=="0a12", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="0458", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
-
-# CSR devices (in HCI mode)
-#ACTION=="add", ENV{ID_VENDOR}=="0a12", ENV{ID_MODEL}=="0001" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
-#ACTION=="add", ENV{ID_VENDOR}=="0458", ENV{ID_MODEL}=="003f" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
-#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8203" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
-#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8204" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
-#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8207" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
diff --git a/scripts/bluetooth-hid2hci.rules.in b/scripts/bluetooth-hid2hci.rules.in
new file mode 100644
index 0000000..1b231d1
--- /dev/null
+++ b/scripts/bluetooth-hid2hci.rules.in
@@ -0,0 +1,36 @@
+# Variety of Dell Bluetooth devices
+#
+# it looks like a bit of an odd rule, because it is matching
+# on a mouse device that is self powered, but that is where
+# a HID report needs to be sent to switch modes.
+#
+# Known supported devices:
+# 413c:8154
+# 413c:8158
+# 413c:8162
+ACTION=="add", ENV{ID_VENDOR}=="413c", ENV{ID_CLASS}=="mouse", ATTRS{bmAttributes}=="e0", KERNEL=="mouse*", RUN+="/usr/sbin/hid2hci --method dell -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+
+# Logitech devices
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c703" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c704" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c705" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70a" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70b" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70c" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c70e" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c713" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c714" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c71b" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="046d", ENV{ID_MODEL}=="c71c" RUN+="/usr/sbin/hid2hci --method logitech -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+
+# CSR devices (in HID mode)
+ACTION=="add", ENV{ID_VENDOR}=="0a12", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="0458", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="1000" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hci"
+
+# CSR devices (in HCI mode)
+#ACTION=="add", ENV{ID_VENDOR}=="0a12", ENV{ID_MODEL}=="0001" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
+#ACTION=="add", ENV{ID_VENDOR}=="0458", ENV{ID_MODEL}=="003f" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
+#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8203" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
+#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8204" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
+#ACTION=="add", ENV{ID_VENDOR}=="05ac", ENV{ID_MODEL}=="8207" RUN+="/usr/sbin/hid2hci --method csr -v $env{ID_VENDOR} -p $env{ID_MODEL} --mode hid"
diff --git a/scripts/bluetooth-serial.rules b/scripts/bluetooth-serial.rules
deleted file mode 100644
index 072335f..0000000
--- a/scripts/bluetooth-serial.rules
+++ /dev/null
@@ -1,35 +0,0 @@
-# Brain Boxes BL-620 Bluetooth Adapter
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Brain Boxes", ATTRS{prod_id2}=="Bluetooth PC Card", ENV{HCIOPTS}="bboxes", RUN+="bluetooth_serial"
-
-# Xircom CreditCard Bluetooth Adapter
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Xircom", ATTRS{prod_id3}=="CBT", ENV{HCIOPTS}="xircom", RUN+="bluetooth_serial"
-
-# Xircom RealPort2 Bluetooth Adapter
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Xircom", ATTRS{prod_id3}=="CBT", ENV{HCIOPTS}="xircom", RUN+="bluetooth_serial"
-
-# IBM Bluetooth PC Card II
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="IBM", ATTRS{prod_id2}=="Bluetooth PC Card II", ENV{HCIOPTS}="tdk", RUN+="bluetooth_serial"
-
-# TDK Bluetooth PC Card
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="TDK", ATTRS{prod_id2}=="Bluetooth PC Card II", ENV{HCIOPTS}="tdk", RUN+="bluetooth_serial"
-
-# AmbiCom BT2000C Bluetooth PC/CF Card
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="AmbiCom BT2000C", ATTRS{prod_id2}=="Bluetooth PC/CF Card", ENV{HCIOPTS}="bt2000c", RUN+="bluetooth_serial"
-
-# COM One Platinium Bluetooth PC Card
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="COM1 SA", ATTRS{prod_id2}=="MC310 CARD", ENV{HCIOPTS}="comone", RUN+="bluetooth_serial"
-
-# Sphinx PICO Card
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="SPHINX", ATTRS{prod_id2}=="BT-CARD", ENV{HCIOPTS}="picocard", RUN+="bluetooth_serial"
-
-# H-Soft blue+Card
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="H-Soft", ATTRS{prod_id2}=="Blue+CARD", ENV{HCIOPTS}="$sysfs{manf_id},$sysfs{card_id}", RUN+="bluetooth_serial"
-
-# Compaq iPAQ Bluetooth Sleeve, Belkin F8T020, any other muppet who used an OXCF950 and didn't bother to program it appropriately.
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="CF CARD", ATTRS{prod_id2}=="GENERIC", ENV{HCIOPTS}="$sysfs{manf_id},$sysfs{card_id}", RUN+="bluetooth_serial"
-
-# Zoom Bluetooth Card and Sitecom CN-504 Card
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="PCMCIA", ATTRS{prod_id2}=="Bluetooth Card", ENV{HCIOPTS}="zoom", RUN+="bluetooth_serial"
-
-# CC&C BT0100M
-SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Bluetooth BT0100M", ENV{HCIOPTS}="bcsp 115200", RUN+="bluetooth_serial"
diff --git a/scripts/bluetooth-serial.rules.in b/scripts/bluetooth-serial.rules.in
new file mode 100644
index 0000000..072335f
--- /dev/null
+++ b/scripts/bluetooth-serial.rules.in
@@ -0,0 +1,35 @@
+# Brain Boxes BL-620 Bluetooth Adapter
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Brain Boxes", ATTRS{prod_id2}=="Bluetooth PC Card", ENV{HCIOPTS}="bboxes", RUN+="bluetooth_serial"
+
+# Xircom CreditCard Bluetooth Adapter
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Xircom", ATTRS{prod_id3}=="CBT", ENV{HCIOPTS}="xircom", RUN+="bluetooth_serial"
+
+# Xircom RealPort2 Bluetooth Adapter
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Xircom", ATTRS{prod_id3}=="CBT", ENV{HCIOPTS}="xircom", RUN+="bluetooth_serial"
+
+# IBM Bluetooth PC Card II
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="IBM", ATTRS{prod_id2}=="Bluetooth PC Card II", ENV{HCIOPTS}="tdk", RUN+="bluetooth_serial"
+
+# TDK Bluetooth PC Card
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="TDK", ATTRS{prod_id2}=="Bluetooth PC Card II", ENV{HCIOPTS}="tdk", RUN+="bluetooth_serial"
+
+# AmbiCom BT2000C Bluetooth PC/CF Card
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="AmbiCom BT2000C", ATTRS{prod_id2}=="Bluetooth PC/CF Card", ENV{HCIOPTS}="bt2000c", RUN+="bluetooth_serial"
+
+# COM One Platinium Bluetooth PC Card
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="COM1 SA", ATTRS{prod_id2}=="MC310 CARD", ENV{HCIOPTS}="comone", RUN+="bluetooth_serial"
+
+# Sphinx PICO Card
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="SPHINX", ATTRS{prod_id2}=="BT-CARD", ENV{HCIOPTS}="picocard", RUN+="bluetooth_serial"
+
+# H-Soft blue+Card
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="H-Soft", ATTRS{prod_id2}=="Blue+CARD", ENV{HCIOPTS}="$sysfs{manf_id},$sysfs{card_id}", RUN+="bluetooth_serial"
+
+# Compaq iPAQ Bluetooth Sleeve, Belkin F8T020, any other muppet who used an OXCF950 and didn't bother to program it appropriately.
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="CF CARD", ATTRS{prod_id2}=="GENERIC", ENV{HCIOPTS}="$sysfs{manf_id},$sysfs{card_id}", RUN+="bluetooth_serial"
+
+# Zoom Bluetooth Card and Sitecom CN-504 Card
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="PCMCIA", ATTRS{prod_id2}=="Bluetooth Card", ENV{HCIOPTS}="zoom", RUN+="bluetooth_serial"
+
+# CC&C BT0100M
+SUBSYSTEM=="tty", SUBSYSTEMS=="pcmcia", ATTRS{prod_id1}=="Bluetooth BT0100M", ENV{HCIOPTS}="bcsp 115200", RUN+="bluetooth_serial"
--
1.7.0.4
^ permalink raw reply related
* [PATCHv2] Bluetooth: Use non-flushable by default L2CAP data packets
From: Emeltchenko Andrei @ 2010-12-21 14:21 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
Modification of Nick Pelly <npelly@google.com> patch.
With Bluetooth 2.1 ACL packets can be flushable or non-flushable. This commit
makes ACL data packets non-flushable by default on compatible chipsets, and
adds the BT_FLUSHABLE socket option to explicitly request flushable ACL
data packets for a given L2CAP socket. This is useful for A2DP data which can
be safely discarded if it can not be delivered within a short time (while
other ACL data should not be discarded).
Note that making ACL data flushable has no effect unless the automatic flush
timeout for that ACL link is changed from its default of 0 (infinite).
Default packet types (for compatible chipsets):
Frame 34: 13 bytes on wire (104 bits), 13 bytes captured (104 bits)
Bluetooth HCI H4
Bluetooth HCI ACL Packet
.... 0000 0000 0010 = Connection Handle: 0x0002
..00 .... .... .... = PB Flag: First Non-automatically Flushable Packet (0)
00.. .... .... .... = BC Flag: Point-To-Point (0)
Data Total Length: 8
Bluetooth L2CAP Packet
After setting BT_FLUSHABLE
(sock.setsockopt(274 /*SOL_BLUETOOTH*/, 8 /* BT_FLUSHABLE */, 1 /* flush */))
Frame 34: 13 bytes on wire (104 bits), 13 bytes captured (104 bits)
Bluetooth HCI H4
Bluetooth HCI ACL Packet
.... 0000 0000 0010 = Connection Handle: 0x0002
..10 .... .... .... = PB Flag: First Automatically Flushable Packet (2)
00.. .... .... .... = BC Flag: Point-To-Point (0)
Data Total Length: 8
Bluetooth L2CAP Packet
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
---
include/net/bluetooth/bluetooth.h | 5 ++++
include/net/bluetooth/hci.h | 2 +
include/net/bluetooth/hci_core.h | 1 +
include/net/bluetooth/l2cap.h | 2 +
net/bluetooth/hci_core.c | 6 +++-
net/bluetooth/l2cap.c | 48 ++++++++++++++++++++++++++++++++++--
6 files changed, 59 insertions(+), 5 deletions(-)
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 0c5e725..ed7d775 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -64,6 +64,11 @@ struct bt_security {
#define BT_DEFER_SETUP 7
+#define BT_FLUSHABLE 8
+
+#define BT_FLUSHABLE_OFF 0
+#define BT_FLUSHABLE_ON 1
+
#define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg)
#define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg)
#define BT_DBG(fmt, arg...) pr_debug("%s: " fmt "\n" , __func__ , ## arg)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 29a7a8c..333d5cb 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -150,6 +150,7 @@ enum {
#define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5)
/* ACL flags */
+#define ACL_START_NO_FLUSH 0x00
#define ACL_CONT 0x01
#define ACL_START 0x02
#define ACL_ACTIVE_BCAST 0x04
@@ -193,6 +194,7 @@ enum {
#define LMP_EDR_ESCO_3M 0x40
#define LMP_EDR_3S_ESCO 0x80
+#define LMP_NO_FLUSH 0x01
#define LMP_SIMPLE_PAIR 0x08
/* Connection modes */
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 1992fac..9778bc8 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -456,6 +456,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
#define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR)
#define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO)
#define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR)
+#define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH)
/* ----- HCI protocols ----- */
struct hci_proto {
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 7ad25ca..af35711 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -75,6 +75,7 @@ struct l2cap_conninfo {
#define L2CAP_LM_TRUSTED 0x0008
#define L2CAP_LM_RELIABLE 0x0010
#define L2CAP_LM_SECURE 0x0020
+#define L2CAP_LM_FLUSHABLE 0x0040
/* L2CAP command codes */
#define L2CAP_COMMAND_REJ 0x01
@@ -327,6 +328,7 @@ struct l2cap_pinfo {
__u8 sec_level;
__u8 role_switch;
__u8 force_reliable;
+ __u8 flushable;
__u8 conf_req[64];
__u8 conf_len;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 51c61f7..c0d776b 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1380,7 +1380,7 @@ void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
skb->dev = (void *) hdev;
bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
- hci_add_acl_hdr(skb, conn->handle, flags | ACL_START);
+ hci_add_acl_hdr(skb, conn->handle, flags);
list = skb_shinfo(skb)->frag_list;
if (!list) {
@@ -1398,12 +1398,14 @@ void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
spin_lock_bh(&conn->data_q.lock);
__skb_queue_tail(&conn->data_q, skb);
+ flags &= ~ACL_START;
+ flags |= ACL_CONT;
do {
skb = list; list = list->next;
skb->dev = (void *) hdev;
bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
- hci_add_acl_hdr(skb, conn->handle, flags | ACL_CONT);
+ hci_add_acl_hdr(skb, conn->handle, flags);
BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len);
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index c791fcd..efa60eb 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -362,13 +362,19 @@ static inline u8 l2cap_get_ident(struct l2cap_conn *conn)
static inline void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data)
{
struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
+ u8 flags;
BT_DBG("code 0x%2.2x", code);
if (!skb)
return;
- hci_send_acl(conn->hcon, skb, 0);
+ if (lmp_no_flush_capable(conn->hcon->hdev))
+ flags = ACL_START_NO_FLUSH;
+ else
+ flags = ACL_START;
+
+ hci_send_acl(conn->hcon, skb, flags);
}
static inline void l2cap_send_sframe(struct l2cap_pinfo *pi, u16 control)
@@ -900,6 +906,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
pi->sec_level = l2cap_pi(parent)->sec_level;
pi->role_switch = l2cap_pi(parent)->role_switch;
pi->force_reliable = l2cap_pi(parent)->force_reliable;
+ pi->flushable = l2cap_pi(parent)->flushable;
} else {
pi->imtu = L2CAP_DEFAULT_MTU;
pi->omtu = 0;
@@ -915,6 +922,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
pi->sec_level = BT_SECURITY_LOW;
pi->role_switch = 0;
pi->force_reliable = 0;
+ pi->flushable = BT_FLUSHABLE_OFF;
}
/* Default config options */
@@ -1450,10 +1458,17 @@ static void l2cap_drop_acked_frames(struct sock *sk)
static inline void l2cap_do_send(struct sock *sk, struct sk_buff *skb)
{
struct l2cap_pinfo *pi = l2cap_pi(sk);
+ struct hci_conn *hcon = pi->conn->hcon;
+ u16 flags;
BT_DBG("sk %p, skb %p len %d", sk, skb, skb->len);
- hci_send_acl(pi->conn->hcon, skb, 0);
+ if (lmp_no_flush_capable(hcon->hdev) && !l2cap_pi(sk)->flushable)
+ flags = ACL_START_NO_FLUSH;
+ else
+ flags = ACL_START;
+
+ hci_send_acl(hcon, skb, flags);
}
static void l2cap_streaming_send(struct sock *sk)
@@ -2045,6 +2060,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
{
struct sock *sk = sock->sk;
+ struct hci_conn *hcon = l2cap_pi(sk)->conn->hcon;
struct bt_security sec;
int len, err = 0;
u32 opt;
@@ -2098,6 +2114,26 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
bt_sk(sk)->defer_setup = opt;
break;
+ case BT_FLUSHABLE:
+ if (get_user(opt, (u32 __user *) optval)) {
+ err = -EFAULT;
+ break;
+ }
+
+ if (opt > BT_FLUSHABLE_ON) {
+ err = -EINVAL;
+ break;
+ }
+
+ if (opt == BT_FLUSHABLE_OFF &&
+ !lmp_no_flush_capable(hcon->hdev)) {
+ err = -EINVAL;
+ break;
+ }
+
+ l2cap_pi(sk)->flushable = opt;
+ break;
+
default:
err = -ENOPROTOOPT;
break;
@@ -2237,6 +2273,12 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
break;
+ case BT_FLUSHABLE:
+ if (put_user(l2cap_pi(sk)->flushable, (u32 __user *) optval))
+ err = -EFAULT;
+
+ break;
+
default:
err = -ENOPROTOOPT;
break;
@@ -4697,7 +4739,7 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
BT_DBG("conn %p len %d flags 0x%x", conn, skb->len, flags);
- if (flags & ACL_START) {
+ if (!(flags & ACL_CONT)) {
struct l2cap_hdr *hdr;
struct sock *sk;
u16 cid;
--
1.7.1
^ permalink raw reply related
* Re: [PATCH v3] Remove unneeded variable
From: Johan Hedberg @ 2010-12-21 12:47 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth, Claudio Takahasi
In-Reply-To: <1292932968-3951-1-git-send-email-anderson.lizardo@openbossa.org>
Hi,
On Tue, Dec 21, 2010, Anderson Lizardo wrote:
> From: Claudio Takahasi <claudio.takahasi@openbossa.org>
>
> ---
> src/glib-helper.c | 5 ++---
> 1 files changed, 2 insertions(+), 3 deletions(-)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH v2 5/5] Remove unneeded variable
From: Anderson Lizardo @ 2010-12-21 12:03 UTC (permalink / raw)
To: Claudio Takahasi, linux-bluetooth
In-Reply-To: <20101220230227.GC6365@jh-x301>
On Mon, Dec 20, 2010 at 7:02 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Claudio,
>
> On Mon, Dec 20, 2010, Claudio Takahasi wrote:
>> ---
>> src/glib-helper.c | 5 ++---
>> 1 files changed, 2 insertions(+), 3 deletions(-)
>
> This patch seems fine but it doesn't apply (probably due to me not
> applying v2 2/5).
Just sent a rebased one that should apply to master branch.
Regards,
--
Anderson Lizardo
OpenBossa Labs - INdT
Manaus - Brazil
^ permalink raw reply
* [PATCH v3] Remove unneeded variable
From: Anderson Lizardo @ 2010-12-21 12:02 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1292885388-21703-1-git-send-email-claudio.takahasi@openbossa.org>
From: Claudio Takahasi <claudio.takahasi@openbossa.org>
---
src/glib-helper.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/glib-helper.c b/src/glib-helper.c
index 0233eb7..bf39a83 100644
--- a/src/glib-helper.c
+++ b/src/glib-helper.c
@@ -514,7 +514,6 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
{
struct gattrib_context *ctxt;
GIOChannel *io;
- GError *gerr = NULL;
ctxt = g_try_new0(struct gattrib_context, 1);
if (ctxt == NULL)
@@ -527,14 +526,14 @@ int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
ctxt->destroy = destroy;
if (psm < 0)
- io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
+ io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, NULL,
BT_IO_OPT_SOURCE_BDADDR, src,
BT_IO_OPT_DEST_BDADDR, dst,
BT_IO_OPT_CID, GATT_CID,
BT_IO_OPT_SEC_LEVEL, BT_IO_SEC_LOW,
BT_IO_OPT_INVALID);
else
- io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, &gerr,
+ io = bt_io_connect(BT_IO_L2CAP, connect_cb, ctxt, NULL, NULL,
BT_IO_OPT_SOURCE_BDADDR, src,
BT_IO_OPT_DEST_BDADDR, dst,
BT_IO_OPT_PSM, psm,
--
1.7.0.4
^ permalink raw reply related
* Re: problem to disconnect with bluez-test
From: Johan Hedberg @ 2010-12-21 9:24 UTC (permalink / raw)
To: Goubert, TonyX; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <6E42A1B4DD2F7B4D80A1F26BB498BF9F8C9BD2CAB2@irsmsx501.ger.corp.intel.com>
Hi Tony,
On Tue, Dec 21, 2010, Goubert, TonyX wrote:
> I have paired a handset with a laptop by using 'simple-agent'
> bluez-test script BUT I can't disconnect it when I use the bluez
> stack.
I suppose you mean you can't disconnect it using the test scripts that
come with BlueZ (since I'm sure you *can* disconnect it with BlueZ as
long as you use the D-Bus interface directly).
> I can remove it (./test-device remove xx:xx:xx:xx:xx:xx) but I
> want to be able to connect/disconnect/connect...
The Device.Disconnect method is indeed something that should be added to
the test-device script. I just went ahead and pushed a patch for it
upstream.
> [root@localhost test]# ./test-device disconnect xx:xx:xx:xx:xx:xx
> Unknown command
This command should work with latest git now.
Johan
^ permalink raw reply
* problem to disconnect with bluez-test
From: Goubert, TonyX @ 2010-12-21 8:53 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
Hi all,
I use bluez-4.76.2.6 i586.rpm and bluez-test-4.76.2.6.i586.rpm in order to discover, connect, ...
Link : repo.meego.com/MeeGo/builds/trunk/1.1.80.10.20101214.1/core/repos/ia32/packages/i586/
I have paired a handset with a laptop by using 'simple-agent' bluez-test script
BUT I can't disconnect it when I use the bluez stack.
I can remove it (./test-device remove xx:xx:xx:xx:xx:xx) but I want to be able to connect/disconnect/connect...
Is there a command?
Some handset traces:
[root@localhost test]# ./list-devices
[ /org/bluez/369/hci0/dev_xx_xx_xx_xx_xx_xx ]
Name = tllab54
Paired = 1
Adapter = /org/bluez/369/hci0
Alias = tllab54
Connected = 1
UUIDs = 0x110a 0x110c 0x110e 0x1112 0x1115 0x1116 0x1117 0x111f
Address = xx:xx:xx:xx:xx:xx
Services = dbus.Array([], signature=dbus.Signature('o'), variant_level=1)
Class = 0x000000
Trusted = 0
Blocked = 0
[root@localhost test]# ./test-device disconnect xx:xx:xx:xx:xx:xx
Unknown command
[root@localhost test]# ./test-input disconnect xx:xx:xx:xx:xx:xx
Traceback (most recent call last):
File "./test-input", line 42, in <module>
input.Disconnect()
File "/usr/lib/python2.6/site-packages/dbus/proxies.py", line 68, in __call__
return self._proxy_method(*args, **keywords)
File "/usr/lib/python2.6/site-packages/dbus/proxies.py", line 140, in __call__
**keywords)
File "/usr/lib/python2.6/site-packages/dbus/connection.py", line 630, in call_blocking
message, timeout)
dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "Disconnect" wt
BR
--
Tony Goubert
tonyx.goubert@intel.com
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris,
92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros
This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
^ permalink raw reply
* Re: [PATCH v2 3/3] More CodingStyle in lib and tools
From: Johan Hedberg @ 2010-12-21 8:52 UTC (permalink / raw)
To: Michal Labedzki; +Cc: linux-bluetooth
In-Reply-To: <1292920489-29040-1-git-send-email-michal.labedzki@tieto.com>
Hi Michal,
On Tue, Dec 21, 2010, Michal Labedzki wrote:
> ---
> lib/hci.c | 65 ++++++++++++++++++++++++++------------
> tools/hciconfig.c | 89 ++++++++++++++++++++++++++++++++++-------------------
> tools/hcitool.c | 20 ++++++------
> 3 files changed, 111 insertions(+), 63 deletions(-)
Thanks. This patch has been pushed upstream.
Johan
^ permalink raw reply
* Re: [PATCH v2 1/3] Filter device name in hciconfig.
From: Johan Hedberg @ 2010-12-21 8:49 UTC (permalink / raw)
To: Michal Labedzki; +Cc: linux-bluetooth
In-Reply-To: <1292920258-28989-1-git-send-email-michal.labedzki@tieto.com>
Hi Michal,
On Tue, Dec 21, 2010, Michal Labedzki wrote:
> No anymore work someting like "hciconfig tty1", "hciconfig qfg1" or
> "hciconfig hci1hg" as "hci1".
> ---
> lib/hci.c | 12 +++++++++++-
> tools/hciconfig.c | 30 +++++++++++++++++++++++++++++-
> 2 files changed, 40 insertions(+), 2 deletions(-)
This doesn't compile for me:
lib/hci.c: In function 'is_number':
lib/hci.c:60: error: implicit declaration of function 'isdigit'
Did you actually compile using ./boostrap-configure? Always do that
before submitting patches. It'll enable some extra checks and convert
all warnings to errors so you don't miss them by mistake.
"man isdigit" tells me that <ctype.h> should be included to use the
funciton.
Also, your commit message doesn't match the patch content. The patch
also changes hci_devid which is in no way specific to hciconfig whereas
your commit message implies that the patch is specific to hciconfig.
Feel free to split this into two separate patches with appropriate
commit messages.
Johan
^ permalink raw reply
* Re: [PATCH v3 2/5] Change CreatePairedDevice to support LE devices
From: Johan Hedberg @ 2010-12-21 8:42 UTC (permalink / raw)
To: Sheldon Demario; +Cc: linux-bluetooth
In-Reply-To: <1292889434-3773-1-git-send-email-sheldon.demario@openbossa.org>
Hi Sheldon,
On Mon, Dec 20, 2010, Sheldon Demario wrote:
> +static struct btd_device *create_device_internal(DBusConnection *conn,
> + struct btd_adapter *adapter,
> + const gchar *address,
> + gboolean secure, int *err)
> +{
> + struct remote_dev_info *dev, match;
> + struct btd_device *device;
> + device_type_t type;
> +
> + memset(&match, 0, sizeof(struct remote_dev_info));
> + str2ba(address, &match.bdaddr);
> + match.name_status = NAME_ANY;
> +
> + dev = adapter_search_found_devices(adapter, &match);
> + if (dev && dev->flags)
> + type = flags2type(dev->flags);
> + else
> + type = DEVICE_TYPE_BREDR;
> +
> + if (!secure && type == DEVICE_TYPE_LE &&
> + !event_is_connectable(dev->evt_type)) {
I think you got something mixed up here. I asked you to change the
sec_level_high variable occurences to secure. Here you've gone and
changed the force variable to secure (something that I didn't request).
I.e. please use "force" like before (since that describes its purpose
within the create_device_internal function more intuitively) and change
the following:
> +int device_browse_primary(struct btd_device *device, DBusConnection *conn,
> + DBusMessage *msg, gboolean sec_level_high)
> +int device_browse_primary(struct btd_device *device, DBusConnection *conn,
> + DBusMessage *msg, gboolean sec_level_high);
> int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
> bt_primary_t cb, void *user_data,
> + gboolean sec_level_high,
> bt_destroy_t destroy)
> int bt_discover_primary(const bdaddr_t *src, const bdaddr_t *dst, int psm,
> bt_primary_t cb, void *user_data,
> + gboolean sec_level_high,
> bt_destroy_t destroy);
Johan
^ permalink raw reply
* [PATCH v2 3/3] More CodingStyle in lib and tools
From: Michal Labedzki @ 2010-12-21 8:34 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michal Labedzki
In-Reply-To: <20101220153817.GB14575@jh-x301>
---
lib/hci.c | 65 ++++++++++++++++++++++++++------------
tools/hciconfig.c | 89 ++++++++++++++++++++++++++++++++++-------------------
tools/hcitool.c | 20 ++++++------
3 files changed, 111 insertions(+), 63 deletions(-)
diff --git a/lib/hci.c b/lib/hci.c
index 1d33e0e..29b053e 100644
--- a/lib/hci.c
+++ b/lib/hci.c
@@ -138,7 +138,8 @@ static int hci_str2uint(hci_map *map, char *str, unsigned int *val)
while ((t = strsep(&ptr, ","))) {
for (m = map; m->str; m++) {
if (!strcasecmp(m->str,t)) {
- *val = (unsigned int) m->val; set = 1;
+ *val = (unsigned int) m->val;
+ set = 1;
break;
}
}
@@ -781,7 +782,8 @@ char *lmp_featurestostr(uint8_t *features, char *pref, int width)
while (m->str) {
if (m->val & features[i])
- size += strlen(m->str) + (pref ? strlen(pref) : 0) + 1;
+ size += strlen(m->str) +
+ (pref ? strlen(pref) : 0) + 1;
m++;
}
}
@@ -803,7 +805,8 @@ char *lmp_featurestostr(uint8_t *features, char *pref, int width)
while (m->str) {
if (m->val & features[i]) {
if (strlen(off) + strlen(m->str) > maxwidth) {
- ptr += sprintf(ptr, "\n%s", pref ? pref : "");
+ ptr += sprintf(ptr, "\n%s",
+ pref ? pref : "");
off = ptr;
}
ptr += sprintf(ptr, "%s ", m->str);
@@ -816,8 +819,8 @@ char *lmp_featurestostr(uint8_t *features, char *pref, int width)
}
/* HCI functions that do not require open device */
-
-int hci_for_each_dev(int flag, int (*func)(int dd, int dev_id, long arg), long arg)
+int hci_for_each_dev(int flag, int (*func)(int dd, int dev_id, long arg),
+ long arg)
{
struct hci_dev_list_req *dl;
struct hci_dev_req *dr;
@@ -951,7 +954,8 @@ int hci_devba(int dev_id, bdaddr_t *bdaddr)
return 0;
}
-int hci_inquiry(int dev_id, int len, int nrsp, const uint8_t *lap, inquiry_info **ii, long flags)
+int hci_inquiry(int dev_id, int len, int nrsp, const uint8_t *lap,
+ inquiry_info **ii, long flags)
{
struct hci_inquiry_req *ir;
uint8_t num_rsp = nrsp;
@@ -1138,7 +1142,8 @@ int hci_send_req(int dd, struct hci_request *r, int to)
}
to -= 10;
- if (to < 0) to = 0;
+ if (to < 0)
+ to = 0;
}
@@ -1231,7 +1236,9 @@ done:
return 0;
}
-int hci_create_connection(int dd, const bdaddr_t *bdaddr, uint16_t ptype, uint16_t clkoffset, uint8_t rswitch, uint16_t *handle, int to)
+int hci_create_connection(int dd, const bdaddr_t *bdaddr, uint16_t ptype,
+ uint16_t clkoffset, uint8_t rswitch,
+ uint16_t *handle, int to)
{
evt_conn_complete rp;
create_conn_cp cp;
@@ -1338,7 +1345,10 @@ int hci_write_local_name(int dd, const char *name, int to)
return 0;
}
-int hci_read_remote_name_with_clock_offset(int dd, const bdaddr_t *bdaddr, uint8_t pscan_rep_mode, uint16_t clkoffset, int len, char *name, int to)
+int hci_read_remote_name_with_clock_offset(int dd, const bdaddr_t *bdaddr,
+ uint8_t pscan_rep_mode,
+ uint16_t clkoffset,
+ int len, char *name, int to)
{
evt_remote_name_req_complete rn;
remote_name_req_cp cp;
@@ -1371,9 +1381,11 @@ int hci_read_remote_name_with_clock_offset(int dd, const bdaddr_t *bdaddr, uint8
return 0;
}
-int hci_read_remote_name(int dd, const bdaddr_t *bdaddr, int len, char *name, int to)
+int hci_read_remote_name(int dd, const bdaddr_t *bdaddr, int len, char *name,
+ int to)
{
- return hci_read_remote_name_with_clock_offset(dd, bdaddr, 0x02, 0x0000, len, name, to);
+ return hci_read_remote_name_with_clock_offset(dd, bdaddr, 0x02, 0x0000,
+ len, name, to);
}
int hci_read_remote_name_cancel(int dd, const bdaddr_t *bdaddr, int to)
@@ -1396,7 +1408,8 @@ int hci_read_remote_name_cancel(int dd, const bdaddr_t *bdaddr, int to)
return 0;
}
-int hci_read_remote_version(int dd, uint16_t handle, struct hci_version *ver, int to)
+int hci_read_remote_version(int dd, uint16_t handle, struct hci_version *ver,
+ int to)
{
evt_read_remote_version_complete rp;
read_remote_version_cp cp;
@@ -1460,7 +1473,9 @@ int hci_read_remote_features(int dd, uint16_t handle, uint8_t *features, int to)
return 0;
}
-int hci_read_remote_ext_features(int dd, uint16_t handle, uint8_t page, uint8_t *max_page, uint8_t *features, int to)
+int hci_read_remote_ext_features(int dd, uint16_t handle, uint8_t page,
+ uint8_t *max_page, uint8_t *features,
+ int to)
{
evt_read_remote_ext_features_complete rp;
read_remote_ext_features_cp cp;
@@ -1603,7 +1618,8 @@ int hci_read_local_features(int dd, uint8_t *features, int to)
return 0;
}
-int hci_read_local_ext_features(int dd, uint8_t page, uint8_t *max_page, uint8_t *features, int to)
+int hci_read_local_ext_features(int dd, uint8_t page, uint8_t *max_page,
+ uint8_t *features, int to)
{
read_local_ext_features_cp cp;
read_local_ext_features_rp rp;
@@ -1944,7 +1960,8 @@ int hci_switch_role(int dd, bdaddr_t *bdaddr, uint8_t role, int to)
return 0;
}
-int hci_park_mode(int dd, uint16_t handle, uint16_t max_interval, uint16_t min_interval, int to)
+int hci_park_mode(int dd, uint16_t handle, uint16_t max_interval,
+ uint16_t min_interval, int to)
{
park_mode_cp cp;
evt_mode_change rp;
@@ -2342,7 +2359,8 @@ int hci_write_inquiry_transmit_power_level(int dd, int8_t level, int to)
return 0;
}
-int hci_read_transmit_power_level(int dd, uint16_t handle, uint8_t type, int8_t *level, int to)
+int hci_read_transmit_power_level(int dd, uint16_t handle, uint8_t type,
+ int8_t *level, int to)
{
read_transmit_power_level_cp cp;
read_transmit_power_level_rp rp;
@@ -2426,7 +2444,8 @@ int hci_write_link_policy(int dd, uint16_t handle, uint16_t policy, int to)
return 0;
}
-int hci_read_link_supervision_timeout(int dd, uint16_t handle, uint16_t *timeout, int to)
+int hci_read_link_supervision_timeout(int dd, uint16_t handle,
+ uint16_t *timeout, int to)
{
read_link_supervision_timeout_rp rp;
struct hci_request rq;
@@ -2451,7 +2470,8 @@ int hci_read_link_supervision_timeout(int dd, uint16_t handle, uint16_t *timeout
return 0;
}
-int hci_write_link_supervision_timeout(int dd, uint16_t handle, uint16_t timeout, int to)
+int hci_write_link_supervision_timeout(int dd, uint16_t handle,
+ uint16_t timeout, int to)
{
write_link_supervision_timeout_cp cp;
write_link_supervision_timeout_rp rp;
@@ -2508,7 +2528,8 @@ int hci_set_afh_classification(int dd, uint8_t *map, int to)
return 0;
}
-int hci_read_link_quality(int dd, uint16_t handle, uint8_t *link_quality, int to)
+int hci_read_link_quality(int dd, uint16_t handle, uint8_t *link_quality,
+ int to)
{
read_link_quality_rp rp;
struct hci_request rq;
@@ -2558,7 +2579,8 @@ int hci_read_rssi(int dd, uint16_t handle, int8_t *rssi, int to)
return 0;
}
-int hci_read_afh_map(int dd, uint16_t handle, uint8_t *mode, uint8_t *map, int to)
+int hci_read_afh_map(int dd, uint16_t handle, uint8_t *mode, uint8_t *map,
+ int to)
{
read_afh_map_rp rp;
struct hci_request rq;
@@ -2584,7 +2606,8 @@ int hci_read_afh_map(int dd, uint16_t handle, uint8_t *mode, uint8_t *map, int t
return 0;
}
-int hci_read_clock(int dd, uint16_t handle, uint8_t which, uint32_t *clock, uint16_t *accuracy, int to)
+int hci_read_clock(int dd, uint16_t handle, uint8_t which, uint32_t *clock,
+ uint16_t *accuracy, int to)
{
read_clock_cp cp;
read_clock_rp rp;
diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index 6d2d1a5..0148ab5 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -57,7 +57,8 @@ static void print_dev_list(int ctl, int flags)
struct hci_dev_req *dr;
int i;
- if (!(dl = malloc(HCI_MAX_DEV * sizeof(struct hci_dev_req) + sizeof(uint16_t)))) {
+ if (!(dl = malloc(HCI_MAX_DEV * sizeof(struct hci_dev_req) +
+ sizeof(uint16_t)))) {
perror("Can't allocate memory");
exit(1);
}
@@ -501,7 +502,7 @@ static char *get_minor_device_name(int major, int minor)
case 0: /* misc */
return "";
case 1: /* computer */
- switch(minor) {
+ switch (minor) {
case 0:
return "Uncategorized";
case 1:
@@ -519,7 +520,7 @@ static char *get_minor_device_name(int major, int minor)
}
break;
case 2: /* phone */
- switch(minor) {
+ switch (minor) {
case 0:
return "Uncategorized";
case 1:
@@ -539,7 +540,7 @@ static char *get_minor_device_name(int major, int minor)
case 3: /* lan access */
if (minor == 0)
return "Uncategorized";
- switch(minor / 8) {
+ switch (minor / 8) {
case 0:
return "Fully available";
case 1:
@@ -559,7 +560,7 @@ static char *get_minor_device_name(int major, int minor)
}
break;
case 4: /* audio/video */
- switch(minor) {
+ switch (minor) {
case 0:
return "Uncategorized";
case 1:
@@ -603,7 +604,7 @@ static char *get_minor_device_name(int major, int minor)
cls_str[0] = '\0';
- switch(minor & 48) {
+ switch (minor & 48) {
case 16:
strncpy(cls_str, "Keyboard", sizeof(cls_str));
break;
@@ -614,10 +615,10 @@ static char *get_minor_device_name(int major, int minor)
strncpy(cls_str, "Combo keyboard/pointing device", sizeof(cls_str));
break;
}
- if((minor & 15) && (strlen(cls_str) > 0))
+ if ((minor & 15) && (strlen(cls_str) > 0))
strcat(cls_str, "/");
- switch(minor & 15) {
+ switch (minor & 15) {
case 0:
break;
case 1:
@@ -642,7 +643,7 @@ static char *get_minor_device_name(int major, int minor)
strncat(cls_str, "(reserved)", sizeof(cls_str) - strlen(cls_str));
break;
}
- if(strlen(cls_str) > 0)
+ if (strlen(cls_str) > 0)
return cls_str;
}
case 6: /* imaging */
@@ -656,7 +657,7 @@ static char *get_minor_device_name(int major, int minor)
return "Printer";
break;
case 7: /* wearable */
- switch(minor) {
+ switch (minor) {
case 1:
return "Wrist Watch";
case 2:
@@ -670,7 +671,7 @@ static char *get_minor_device_name(int major, int minor)
}
break;
case 8: /* toy */
- switch(minor) {
+ switch (minor) {
case 1:
return "Robot";
case 2:
@@ -754,10 +755,24 @@ static void cmd_class(int ctl, int hdev, char *opt)
static void cmd_voice(int ctl, int hdev, char *opt)
{
- static char *icf[] = { "Linear", "u-Law", "A-Law", "Reserved" };
- static char *idf[] = { "1's complement", "2's complement", "Sign-Magnitude", "Reserved" };
- static char *iss[] = { "8 bit", "16 bit" };
- static char *acf[] = { "CVSD", "u-Law", "A-Law", "Reserved" };
+ static char *icf[] = { "Linear",
+ "u-Law",
+ "A-Law",
+ "Reserved" };
+
+ static char *idf[] = { "1's complement",
+ "2's complement",
+ "Sign-Magnitude",
+ "Reserved" };
+
+ static char *iss[] = { "8 bit",
+ "16 bit" };
+
+ static char *acf[] = { "CVSD",
+ "u-Law",
+ "A-Law",
+ "Reserved" };
+
int s = hci_open_dev(hdev);
if (s < 0) {
@@ -787,15 +802,19 @@ static void cmd_voice(int ctl, int hdev, char *opt)
((vs & 0x03fc) == 0x0060) ? " (Default Condition)" : "");
printf("\tInput Coding: %s\n", icf[ic]);
printf("\tInput Data Format: %s\n", idf[(vs & 0xc0) >> 6]);
+
if (!ic) {
- printf("\tInput Sample Size: %s\n", iss[(vs & 0x20) >> 5]);
- printf("\t# of bits padding at MSB: %d\n", (vs & 0x1c) >> 2);
+ printf("\tInput Sample Size: %s\n",
+ iss[(vs & 0x20) >> 5]);
+ printf("\t# of bits padding at MSB: %d\n",
+ (vs & 0x1c) >> 2);
}
printf("\tAir Coding Format: %s\n", acf[vs & 0x03]);
}
}
-static int get_link_key(const bdaddr_t *local, const bdaddr_t *peer, uint8_t *key)
+static int get_link_key(const bdaddr_t *local, const bdaddr_t *peer,
+ uint8_t *key)
{
char filename[PATH_MAX + 1], addr[18], tmp[3], *str;
int i;
@@ -1356,8 +1375,10 @@ static void cmd_page_parms(int ctl, int hdev, char *opt)
window = btohs(rp.window);
interval = btohs(rp.interval);
- printf("\tPage interval: %u slots (%.2f ms), window: %u slots (%.2f ms)\n",
- interval, (float)interval * 0.625, window, (float)window * 0.625);
+ printf("\tPage interval: %u slots (%.2f ms), "
+ "window: %u slots (%.2f ms)\n",
+ interval, (float)interval * 0.625,
+ window, (float)window * 0.625);
}
}
@@ -1441,7 +1462,7 @@ static void cmd_afh_mode(int ctl, int hdev, char *opt)
if (hci_write_afh_mode(dd, mode, 2000) < 0) {
fprintf(stderr, "Can't set AFH mode on hci%d: %s (%d)\n",
- hdev, strerror(errno), errno);
+ hdev, strerror(errno), errno);
exit(1);
}
} else {
@@ -1449,7 +1470,7 @@ static void cmd_afh_mode(int ctl, int hdev, char *opt)
if (hci_read_afh_mode(dd, &mode, 1000) < 0) {
fprintf(stderr, "Can't read AFH mode on hci%d: %s (%d)\n",
- hdev, strerror(errno), errno);
+ hdev, strerror(errno), errno);
exit(1);
}
@@ -1474,7 +1495,7 @@ static void cmd_ssp_mode(int ctl, int hdev, char *opt)
if (hci_write_simple_pairing_mode(dd, mode, 2000) < 0) {
fprintf(stderr, "Can't set Simple Pairing mode on hci%d: %s (%d)\n",
- hdev, strerror(errno), errno);
+ hdev, strerror(errno), errno);
exit(1);
}
} else {
@@ -1482,12 +1503,13 @@ static void cmd_ssp_mode(int ctl, int hdev, char *opt)
if (hci_read_simple_pairing_mode(dd, &mode, 1000) < 0) {
fprintf(stderr, "Can't read Simple Pairing mode on hci%d: %s (%d)\n",
- hdev, strerror(errno), errno);
+ hdev, strerror(errno), errno);
exit(1);
}
print_dev_hdr(&di);
- printf("\tSimple Pairing mode: %s\n", mode == 1 ? "Enabled" : "Disabled");
+ printf("\tSimple Pairing mode: %s\n",
+ mode == 1 ? "Enabled" : "Disabled");
}
}
@@ -1505,7 +1527,8 @@ static void print_rev_ericsson(int dd)
rq.rlen = sizeof(buf);
if (hci_send_req(dd, &rq, 1000) < 0) {
- printf("\nCan't read revision info: %s (%d)\n", strerror(errno), errno);
+ printf("\nCan't read revision info: %s (%d)\n",
+ strerror(errno), errno);
return;
}
@@ -1551,7 +1574,8 @@ static void print_rev_digianswer(int dd)
rq.rlen = sizeof(buf);
if (hci_send_req(dd, &rq, 1000) < 0) {
- printf("\nCan't read revision info: %s (%d)\n", strerror(errno), errno);
+ printf("\nCan't read revision info: %s (%d)\n",
+ strerror(errno), errno);
return;
}
@@ -1560,7 +1584,8 @@ static void print_rev_digianswer(int dd)
static void print_rev_broadcom(uint16_t hci_rev, uint16_t lmp_subver)
{
- printf("\tFirmware %d.%d / %d\n", hci_rev & 0xff, lmp_subver >> 8, lmp_subver & 0xff);
+ printf("\tFirmware %d.%d / %d\n",
+ hci_rev & 0xff, lmp_subver >> 8, lmp_subver & 0xff);
}
static void print_rev_avm(uint16_t hci_rev, uint16_t lmp_subver)
@@ -1807,7 +1832,7 @@ static void usage(void)
"\thciconfig\n"
"\thciconfig [-a] hciX [command ...]\n");
printf("Commands:\n");
- for (i=0; command[i].cmd; i++)
+ for (i = 0; command[i].cmd; i++)
printf("\t%-10s %-8s\t%s\n", command[i].cmd,
command[i].opt ? command[i].opt : " ",
command[i].doc);
@@ -1821,10 +1846,10 @@ static struct option main_options[] = {
int main(int argc, char *argv[])
{
- int opt, ctl, i, cmd=0;
+ int opt, ctl, i, cmd = 0;
- while ((opt=getopt_long(argc, argv, "ah", main_options, NULL)) != -1) {
- switch(opt) {
+ while ((opt = getopt_long(argc, argv, "ah", main_options, NULL)) != -1) {
+ switch (opt) {
case 'a':
all = 1;
break;
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 847bf1b..d50adaf 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -197,7 +197,7 @@ static char *get_minor_device_name(int major, int minor)
case 0: /* misc */
return "";
case 1: /* computer */
- switch(minor) {
+ switch (minor) {
case 0:
return "Uncategorized";
case 1:
@@ -215,7 +215,7 @@ static char *get_minor_device_name(int major, int minor)
}
break;
case 2: /* phone */
- switch(minor) {
+ switch (minor) {
case 0:
return "Uncategorized";
case 1:
@@ -235,7 +235,7 @@ static char *get_minor_device_name(int major, int minor)
case 3: /* lan access */
if (minor == 0)
return "Uncategorized";
- switch(minor / 8) {
+ switch (minor / 8) {
case 0:
return "Fully available";
case 1:
@@ -255,7 +255,7 @@ static char *get_minor_device_name(int major, int minor)
}
break;
case 4: /* audio/video */
- switch(minor) {
+ switch (minor) {
case 0:
return "Uncategorized";
case 1:
@@ -297,7 +297,7 @@ static char *get_minor_device_name(int major, int minor)
case 5: /* peripheral */ {
static char cls_str[48]; cls_str[0] = 0;
- switch(minor & 48) {
+ switch (minor & 48) {
case 16:
strncpy(cls_str, "Keyboard", sizeof(cls_str));
break;
@@ -308,10 +308,10 @@ static char *get_minor_device_name(int major, int minor)
strncpy(cls_str, "Combo keyboard/pointing device", sizeof(cls_str));
break;
}
- if((minor & 15) && (strlen(cls_str) > 0))
+ if ((minor & 15) && (strlen(cls_str) > 0))
strcat(cls_str, "/");
- switch(minor & 15) {
+ switch (minor & 15) {
case 0:
break;
case 1:
@@ -336,7 +336,7 @@ static char *get_minor_device_name(int major, int minor)
strncat(cls_str, "(reserved)", sizeof(cls_str) - strlen(cls_str));
break;
}
- if(strlen(cls_str) > 0)
+ if (strlen(cls_str) > 0)
return cls_str;
}
case 6: /* imaging */
@@ -350,7 +350,7 @@ static char *get_minor_device_name(int major, int minor)
return "Printer";
break;
case 7: /* wearable */
- switch(minor) {
+ switch (minor) {
case 1:
return "Wrist Watch";
case 2:
@@ -364,7 +364,7 @@ static char *get_minor_device_name(int major, int minor)
}
break;
case 8: /* toy */
- switch(minor) {
+ switch (minor) {
case 1:
return "Robot";
case 2:
--
1.7.0.4
^ permalink raw reply related
* [PATCH v2 1/3] Filter device name in hciconfig.
From: Michal Labedzki @ 2010-12-21 8:30 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Michal Labedzki
In-Reply-To: <1292840029-27770-2-git-send-email-michal.labedzki@tieto.com>
No anymore work someting like "hciconfig tty1", "hciconfig qfg1" or
"hciconfig hci1hg" as "hci1".
---
lib/hci.c | 12 +++++++++++-
tools/hciconfig.c | 30 +++++++++++++++++++++++++++++-
2 files changed, 40 insertions(+), 2 deletions(-)
diff --git a/lib/hci.c b/lib/hci.c
index 3304daa..1d33e0e 100644
--- a/lib/hci.c
+++ b/lib/hci.c
@@ -54,6 +54,16 @@ typedef struct {
unsigned int val;
} hci_map;
+static int is_number(const char *c)
+{
+ while (*c) {
+ if (!isdigit(*c))
+ return 0;
+ ++c;
+ }
+ return 1;
+}
+
static char *hci_bit2str(hci_map *m, unsigned int val)
{
char *str = malloc(120);
@@ -889,7 +899,7 @@ int hci_devid(const char *str)
bdaddr_t ba;
int id = -1;
- if (!strncmp(str, "hci", 3) && strlen(str) >= 4) {
+ if (!strncmp(str, "hci", 3) && strlen(str) >= 4 && is_number(str + 3)) {
id = atoi(str + 3);
if (hci_devba(id, &ba) < 0)
return -1;
diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index 995aca1..6d2d1a5 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -1721,6 +1721,33 @@ static void print_dev_info(int ctl, struct hci_dev_info *di)
printf("\n");
}
+static int is_number(const char *c)
+{
+ while (*c) {
+ if (!isdigit(*c))
+ return 0;
+ ++c;
+ }
+ return 1;
+}
+
+static int dev_name_filter(char *dev_name)
+{
+ int ret;
+
+ if ((strlen(dev_name) >= 4) && (!strncmp(dev_name, "hci", 3)) &&
+ (is_number(dev_name + 3)))
+ ret = atoi(dev_name + 3);
+ else if (is_number(dev_name))
+ ret = atoi(dev_name);
+ else {
+ fprintf(stderr, "No valid device name\n");
+ exit(1);
+ }
+
+ return ret;
+}
+
static struct {
char *cmd;
void (*func)(int ctl, int hdev, char *opt);
@@ -1824,7 +1851,8 @@ int main(int argc, char *argv[])
exit(0);
}
- di.dev_id = atoi(argv[0] + 3);
+ di.dev_id = dev_name_filter(argv[0]);
+
argc--; argv++;
if (ioctl(ctl, HCIGETDEVINFO, (void *) &di)) {
--
1.7.0.4
^ permalink raw reply related
* bluetooth for vendor special command and event
From: Challen Zhou @ 2010-12-21 8:09 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
In-Reply-To: <1292886362-19755-1-git-send-email-sheldon.demario@openbossa.org>
Hi,all,
I want to add a control interface for BT control other device(bt and the device on single chip),
Thus , I need to add some special HCI command and Event, but when I view the code
in kernel, but find that it do not provide this interface or function. Anybody have any idea on this?
BRS
Challen zhou
^ permalink raw reply
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