* [PATCH] src: fix typo
From: Gustavo F. Padovan @ 2011-02-14 21:34 UTC (permalink / raw)
To: linux-bluetooth
---
src/event.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/event.c b/src/event.c
index 0659fd1..a415468 100644
--- a/src/event.c
+++ b/src/event.c
@@ -731,7 +731,7 @@ void btd_event_le_set_scan_enable_complete(bdaddr_t *local, uint8_t status)
}
if (status) {
- error("Can't enabled/disable LE scan");
+ error("Can't enable/disable LE scan");
return;
}
--
1.7.4
^ permalink raw reply related
* Re: [HACK PATCH] N900 l2cap connect crash, NULL parent
From: Andrei Warkentin @ 2011-02-14 21:40 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: David Fries, linux-bluetooth
In-Reply-To: <20110214145649.GE2597@joana>
FWIW still need it in 2.6.36.
On Mon, Feb 14, 2011 at 8:56 AM, Gustavo F. Padovan
<padovan@profusion.mobi> wrote:
> Hi David,
>
> * David Fries <david@fries.net> [2011-02-10 21:53:09 -0600]:
>
>> Here's a patch to avoid a very repeatable crash in the N900. If I
>> take a Motorola S305 bluetooth headset that was previously paried with
>> the N900, turn it on, and press the play button before the headphones
>> automatically pair with the cell phone, the N900 will crash (and
>> reboot) in pairing. If I wait until after they have paired there
>> isn't any problem. The patch is against the kernel-power
>> 2.6.28-maemo46 by Thomas Tanner, the stock Nokia PR1.2 oops looked
>> the same, I just haven't gone back to that kernel.
>
> This is a very old kernel. You need to check this issue against
> bluetooth-next-2.6.
>
> --
> Gustavo F. Padovan
> http://profusion.mobi
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* Re: [PATCH 3/3] Add gatttool enhancements for UPF
From: Anderson Lizardo @ 2011-02-14 21:41 UTC (permalink / raw)
To: Brian Gix; +Cc: linux-bluetooth, johan.hedberg, padovan
In-Reply-To: <1297891081-27976-4-git-send-email-bgix@codeaurora.org>
Hi Brian,
On Wed, Feb 16, 2011 at 6:18 PM, Brian Gix <bgix@codeaurora.org> wrote:
> @@ -90,9 +91,9 @@ static GIOChannel *do_connect(gboolean le)
>
> /* This check is required because currently setsockopt() returns no
> * errors for MTU values smaller than the allowed minimum. */
> - if (opt_mtu != 0 && opt_mtu < ATT_MIN_MTU_L2CAP) {
> + if (opt_mtu != 0 && opt_mtu < 23) {
> g_printerr("MTU cannot be smaller than %d\n",
> - ATT_MIN_MTU_L2CAP);
> + 23);
> return NULL;
> }
The changes above seem unrelated to this patch.
>
> @@ -277,6 +278,14 @@ static gboolean characteristics(gpointer user_data)
> return FALSE;
> }
>
> +static void char_write_cb(guint8 status, const guint8 *pdu, guint16 plen,
> + gpointer user_data)
> +{
> + if (plen == 1)
> + g_print("Attrib Write Succeeded\n");
> + else
> + g_printerr("Attrib Write failed: %s\n", att_ecode2str(status));
Why not check by the status instead of plen ?
Also, I'd suggest "Characteristic write" instead of "Attrib Write".
> +}
> static void char_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
> gpointer user_data)
> {
> @@ -427,7 +436,40 @@ static gboolean characteristics_write(gpointer user_data)
> goto error;
> }
>
> + gatt_write_char(attrib, opt_handle, value, len, char_write_cb, value);
> + gatt_read_char(attrib, opt_handle, char_read_cb, attrib);
Why both read and write ?
> +
> + return FALSE;
> +
> +error:
> + g_main_loop_quit(event_loop);
> + return FALSE;
> +}
> +
> +static gboolean characteristics_cmd(gpointer user_data)
> +{
> + GAttrib *attrib = user_data;
> + uint8_t *value;
> + size_t len;
> +
> + if (opt_handle <= 0) {
> + g_printerr("A valid handle is required\n");
> + goto error;
> + }
> +
> + if (opt_value == NULL || opt_value[0] == '\0') {
> + g_printerr("A value is required\n");
> + goto error;
> + }
> +
> + len = attr_data_from_string(opt_value, &value);
> + if (len == 0) {
> + g_printerr("Invalid value\n");
> + goto error;
> + }
> +
> gatt_write_cmd(attrib, opt_handle, value, len, mainloop_quit, value);
> + gatt_read_char(attrib, opt_handle, char_read_cb, attrib);
Same question here.
>
> return FALSE;
>
> @@ -531,6 +573,8 @@ static GOptionEntry gatt_options[] = {
> "Characteristics Value/Descriptor Read", NULL },
> { "char-write", 0, 0, G_OPTION_ARG_NONE, &opt_char_write,
> "Characteristics Value Write", NULL },
> + { "char-cmd", 0, 0, G_OPTION_ARG_NONE, &opt_char_cmd,
> + "Characteristics Value Cmd", NULL },
Suggestion: "Characteristic Value write using Write Command" (or
something similar).
> { "char-desc", 0, 0, G_OPTION_ARG_NONE, &opt_char_desc,
> "Characteristics Descriptor Discovery", NULL },
> { "listen", 0, 0, G_OPTION_ARG_NONE, &opt_listen,
> @@ -561,7 +605,7 @@ int main(int argc, char *argv[])
> GError *gerr = NULL;
> GAttrib *attrib;
> GIOChannel *chan;
> - GSourceFunc callback;
> + GSourceFunc callback = NULL;
>
> context = g_option_context_new(NULL);
> g_option_context_add_main_entries(context, options, NULL);
> @@ -602,9 +646,11 @@ int main(int argc, char *argv[])
> callback = characteristics_read;
> else if (opt_char_write)
> callback = characteristics_write;
> + else if (opt_char_cmd)
> + callback = characteristics_cmd;
> else if (opt_char_desc)
> callback = characteristics_desc;
> - else {
> + else if (!opt_listen) {
> gchar *help = g_option_context_get_help(context, TRUE, NULL);
> g_print("%s\n", help);
> g_free(help);
> @@ -625,7 +671,8 @@ int main(int argc, char *argv[])
> if (opt_listen)
> g_idle_add(listen_start, attrib);
>
> - g_idle_add(callback, attrib);
> + if (callback)
> + g_idle_add(callback, attrib);
>
> g_main_loop_run(event_loop);
Regards,
--
Anderson Lizardo
OpenBossa Labs - INdT
Manaus - Brazil
^ permalink raw reply
* Re: [PATCH 2/3] Add SDP registration of Primary GATT services
From: Anderson Lizardo @ 2011-02-14 21:53 UTC (permalink / raw)
To: Brian Gix; +Cc: linux-bluetooth, johan.hedberg, padovan
In-Reply-To: <1297891081-27976-3-git-send-email-bgix@codeaurora.org>
On Wed, Feb 16, 2011 at 6:18 PM, Brian Gix <bgix@codeaurora.org> wrote:
> SDP registration can be supressed by passing Zero as the end
> handle argument to attrib_db_add().
> ---
> attrib/example.c | 119 +++++++++++++++++++++++++++++++------------
> src/attrib-server.c | 139 +++++++++++++++++++++++++++++++++++----------------
> src/attrib-server.h | 6 ++-
> 3 files changed, 184 insertions(+), 80 deletions(-)
>
> diff --git a/attrib/example.c b/attrib/example.c
> index 1911912..eab3c0f 100644
> --- a/attrib/example.c
> +++ b/attrib/example.c
> @@ -31,6 +31,7 @@
>
> #include <bluetooth/sdp.h>
> #include <bluetooth/sdp_lib.h>
> +#include <src/sdpd.h>
>
> #include <glib.h>
>
> @@ -59,6 +60,9 @@
> #define FMT_KILOGRAM_UUID 0xA010
> #define FMT_HANGING_UUID 0xA011
>
> +#define SDP_RECORD_COUNT 10
> +sdp_record_t *sdp_records[SDP_RECORD_COUNT];
> +
> static int register_attributes(void)
> {
> const char *desc_out_temp = "Outside Temperature";
> @@ -77,59 +81,73 @@ static int register_attributes(void)
> uint8_t atval[256];
> uuid_t uuid;
> int len;
> + int i = 0;
>
> /* Battery state service: primary service definition */
> sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
> att_put_u16(BATTERY_STATE_SVC_UUID, &atval[0]);
> - attrib_db_add(0x0100, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
> + sdp_records[i++] = attrib_db_add(0x0100, 0x0111, &uuid,
> + "Battery State Service",
> + ATT_NONE, ATT_NOT_PERMITTED,
> + atval, 2);
What if instead of changing attrib_db_add() signature to return a SDP
record, you create a "sdp_record_from_attrib()" for this purpose? This
function could get the struct attribute * pointers for start/end.
There are plans for attrib_db_add() to return the created struct
attribute *a (as shown in a patch I sent sometime ago which I still
need to resend), I can send an updated version of that patch if you
agree to this approach.
> @@ -609,7 +603,7 @@ static uint16_t write_value(struct gatt_channel *channel, uint16_t handle,
> static uint16_t mtu_exchange(struct gatt_channel *channel, uint16_t mtu,
> uint8_t *pdu, int len)
> {
> - channel->mtu = MIN(mtu, ATT_MAX_MTU);
> + channel->mtu = MIN(mtu, channel->mtu);
>
> return enc_mtu_resp(channel->mtu, pdu, len);
> }
This change looks unrelated to the patch.
Regards,
--
Anderson Lizardo
OpenBossa Labs - INdT
Manaus - Brazil
^ permalink raw reply
* [RFC 0/5] Advertising reports cache
From: anderson.briglia @ 2011-02-14 21:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Briglia
From: Anderson Briglia <anderson.briglia@openbossa.org>
The following patches implement a list for advertising report events from LE
devices in order to store the bdaddr and bdaddr type.
Next steps include remove all advertising reports cache from userspace and
implement a mechanism to sync kernel advertising cache and userspace adv cache.
Patches are rebased using Vinicius SMP patches, repo:
git://git.infradead.org/users/vcgomes/linux-2.6.git for-next
Anderson Briglia (1):
Bluetooth: Implement advertising report meta event
Andre Guedes (4):
Bluetooth: Implement advertising reports cache
Bluetooth: Add device addr type to hci_le_connect
Bluetooth: limit size of advertising reports cache
Bluetooth: hci_connect() should return status code
include/net/bluetooth/hci.h | 18 +++++++++
include/net/bluetooth/hci_core.h | 20 ++++++++++-
net/bluetooth/hci_conn.c | 40 ++++++++++++++-------
net/bluetooth/hci_core.c | 73 ++++++++++++++++++++++++++++++++++++++
net/bluetooth/hci_event.c | 24 ++++++++++++
net/bluetooth/l2cap_core.c | 9 ++---
net/bluetooth/sco.c | 8 ++--
7 files changed, 169 insertions(+), 23 deletions(-)
^ permalink raw reply
* [RFC 1/5] Bluetooth: Implement advertising report meta event
From: anderson.briglia @ 2011-02-14 21:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Briglia
From: Anderson Briglia <anderson.briglia@openbossa.org>
This patch implements new LE meta event in order to handle advertising
reports.
Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org>
---
include/net/bluetooth/hci.h | 18 ++++++++++++++++++
net/bluetooth/hci_event.c | 22 ++++++++++++++++++++++
2 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 46438f4..5180555 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -980,6 +980,24 @@ struct hci_ev_le_conn_complete {
__u8 clk_accurancy;
} __packed;
+#define ADV_IND 0x00
+#define ADV_DIRECT_IND 0x01
+#define ADV_SCAN_IND 0x02
+#define ADV_NONCONN_IND 0x03
+#define SCAN_RSP 0x04
+
+#define ADDR_DEV_PUBLIC 0x00
+#define ADDR_DEV_RANDOM 0x01
+
+#define HCI_EV_LE_ADVERTISING_REPORT 0x02
+struct hci_ev_le_advertising_info {
+ __u8 evt_type;
+ __u8 bdaddr_type;
+ bdaddr_t bdaddr;
+ __u8 length;
+ __u8 data[0];
+} __packed;
+
#define HCI_EV_LE_LTK_REQ 0x05
struct hci_ev_le_ltk_req {
__le16 handle;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 99c75f4..987f5de 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2498,6 +2498,25 @@ static inline void hci_le_ltk_request_evt(struct hci_dev *hdev,
hci_dev_unlock(hdev);
}
+static inline void hci_le_adv_report_evt(struct hci_dev *hdev,
+ struct sk_buff *skb)
+{
+ struct hci_ev_le_advertising_info *ev;
+ u8 num_reports, i;
+
+ num_reports = (u8) skb->data[0];
+
+ ev = (struct hci_ev_le_advertising_info *) (skb->data + 1);
+
+ BT_DBG("adv from: %s", batostr(&ev->bdaddr));
+
+ for (i = 1; i < num_reports; i++) {
+ ev = (struct hci_ev_le_advertising_info *)
+ (ev->data + ev->length + 1);
+ BT_DBG("adv from: %s", batostr(&ev->bdaddr));
+ }
+}
+
static inline void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb)
{
struct hci_ev_le_meta *le_ev = (void *) skb->data;
@@ -2513,6 +2532,9 @@ static inline void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb)
hci_le_ltk_request_evt(hdev, skb);
break;
+ case HCI_EV_LE_ADVERTISING_REPORT:
+ hci_le_adv_report_evt(hdev, skb);
+
default:
break;
}
--
1.7.1
^ permalink raw reply related
* [RFC 2/5] Bluetooth: Implement advertising reports cache
From: anderson.briglia @ 2011-02-14 21:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andre Guedes
From: Andre Guedes <andre.guedes@openbossa.org>
This patch implements a list to store the advertising reports and bdaddr
types from LE devices.
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
include/net/bluetooth/hci_core.h | 11 +++++++
net/bluetooth/hci_core.c | 58 ++++++++++++++++++++++++++++++++++++++
net/bluetooth/hci_event.c | 2 +
3 files changed, 71 insertions(+), 0 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 5114122..48059a2 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -82,6 +82,12 @@ struct link_key {
u8 pin_len;
};
+struct adv_entry {
+ struct list_head list;
+ bdaddr_t bdaddr;
+ u8 bdaddr_type;
+};
+
#define NUM_REASSEMBLY 4
struct hci_dev {
struct list_head list;
@@ -171,6 +177,8 @@ struct hci_dev {
struct list_head link_keys;
+ struct list_head adv_list;
+
struct hci_dev_stats stat;
struct sk_buff_head driver_init;
@@ -504,6 +512,9 @@ int hci_add_link_key(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr,
u8 *key, u8 type, u8 pin_len);
int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
+struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr);
+int hci_add_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type);
+
void hci_del_off_timer(struct hci_dev *hdev);
void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index c81dc17..b573832 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1067,6 +1067,61 @@ int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
return 0;
}
+static int hci_adv_list_clear(struct hci_dev *hdev)
+{
+ struct list_head *p, *n;
+
+ list_for_each_safe(p, n, &hdev->adv_list) {
+ struct adv_entry *entry;
+
+ entry = list_entry(p, struct adv_entry, list);
+
+ list_del(p);
+ kfree(entry);
+ }
+
+ return 0;
+
+}
+
+struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr)
+{
+ struct list_head *p;
+
+ list_for_each(p, &hdev->adv_list) {
+ struct adv_entry *k;
+
+ k = list_entry(p, struct adv_entry, list);
+
+ if (bacmp(bdaddr, &k->bdaddr) == 0)
+ return k;
+ }
+
+ return NULL;
+}
+
+int hci_add_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type)
+{
+ struct adv_entry *entry;
+
+ entry = hci_find_adv_entry(hdev, bdaddr);
+ /* Only new entries should be added to adv_list. So, if
+ * bdaddr was found, don't add it. */
+ if (entry)
+ return 0;
+
+ entry = kzalloc(sizeof(*entry), GFP_ATOMIC);
+ if (!entry)
+ return -ENOMEM;
+
+ bacpy(&entry->bdaddr, bdaddr);
+ entry->bdaddr_type = bdaddr_type;
+
+ list_add(&entry->list, &hdev->adv_list);
+
+ return 0;
+}
+
static struct crypto_blkcipher *alloc_cypher(void)
{
#ifndef CONFIG_BT_SMP
@@ -1137,6 +1192,8 @@ int hci_register_dev(struct hci_dev *hdev)
INIT_LIST_HEAD(&hdev->link_keys);
+ INIT_LIST_HEAD(&hdev->adv_list);
+
INIT_WORK(&hdev->power_on, hci_power_on);
INIT_WORK(&hdev->power_off, hci_power_off);
setup_timer(&hdev->off_timer, hci_auto_off, (unsigned long) hdev);
@@ -1222,6 +1279,7 @@ int hci_unregister_dev(struct hci_dev *hdev)
hci_blacklist_clear(hdev);
hci_uuids_clear(hdev);
hci_link_keys_clear(hdev);
+ hci_adv_list_clear(hdev);
hci_dev_unlock_bh(hdev);
__hci_dev_put(hdev);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 987f5de..0cbc1cf 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2507,12 +2507,14 @@ static inline void hci_le_adv_report_evt(struct hci_dev *hdev,
num_reports = (u8) skb->data[0];
ev = (struct hci_ev_le_advertising_info *) (skb->data + 1);
+ hci_add_adv_entry(hdev, &ev->bdaddr, ev->bdaddr_type);
BT_DBG("adv from: %s", batostr(&ev->bdaddr));
for (i = 1; i < num_reports; i++) {
ev = (struct hci_ev_le_advertising_info *)
(ev->data + ev->length + 1);
+ hci_add_adv_entry(hdev, &ev->bdaddr, ev->bdaddr_type);
BT_DBG("adv from: %s", batostr(&ev->bdaddr));
}
}
--
1.7.1
^ permalink raw reply related
* [RFC 3/5] Bluetooth: Add device addr type to hci_le_connect
From: anderson.briglia @ 2011-02-14 21:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andre Guedes
From: Andre Guedes <andre.guedes@openbossa.org>
This patch improves hci_connect and hci_le_connect in order to use the
remote address type stored in advertise reports list.
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
net/bluetooth/hci_conn.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index ee7dcdd..2c91f4e 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -45,7 +45,7 @@
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
-static void hci_le_connect(struct hci_conn *conn)
+static void hci_le_connect(struct hci_conn *conn, u8 bdaddr_type)
{
struct hci_dev *hdev = conn->hdev;
struct hci_cp_le_create_conn cp;
@@ -59,6 +59,7 @@ static void hci_le_connect(struct hci_conn *conn)
cp.scan_interval = cpu_to_le16(0x0004);
cp.scan_window = cpu_to_le16(0x0004);
bacpy(&cp.peer_addr, &conn->dst);
+ cp.peer_addr_type = bdaddr_type;
cp.conn_interval_min = cpu_to_le16(0x0008);
cp.conn_interval_max = cpu_to_le16(0x0100);
cp.supervision_timeout = cpu_to_le16(0x0064);
@@ -461,8 +462,13 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
le = hci_conn_add(hdev, LE_LINK, dst);
if (!le)
return NULL;
- if (le->state == BT_OPEN)
- hci_le_connect(le);
+ if (le->state == BT_OPEN) {
+ struct adv_entry *entry = hci_find_adv_entry(hdev, dst);
+ if (entry)
+ hci_le_connect(le, entry->bdaddr_type);
+ else
+ hci_le_connect(le, ADDR_DEV_PUBLIC);
+ }
hci_conn_hold(le);
--
1.7.1
^ permalink raw reply related
* [RFC 4/5] Bluetooth: limit size of advertising reports cache
From: anderson.briglia @ 2011-02-14 21:59 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andre Guedes
From: Andre Guedes <andre.guedes@openbossa.org>
This patch limits to 64 the size of the list used to store the
advertising reports.
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
---
include/net/bluetooth/hci_core.h | 8 +++++++-
net/bluetooth/hci_core.c | 29 ++++++++++++++++++++++-------
2 files changed, 29 insertions(+), 8 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 48059a2..5992148 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -88,6 +88,12 @@ struct adv_entry {
u8 bdaddr_type;
};
+#define ADV_LIST_MAX_SIZE 64
+struct adv_list {
+ struct list_head list;
+ size_t size;
+};
+
#define NUM_REASSEMBLY 4
struct hci_dev {
struct list_head list;
@@ -177,7 +183,7 @@ struct hci_dev {
struct list_head link_keys;
- struct list_head adv_list;
+ struct adv_list adv_entries;
struct hci_dev_stats stat;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index b573832..e749c90 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1067,11 +1067,17 @@ int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
return 0;
}
-static int hci_adv_list_clear(struct hci_dev *hdev)
+static inline void hci_adv_entries_init(struct hci_dev *hdev)
+{
+ hdev->adv_entries.size = 0;
+ INIT_LIST_HEAD(&hdev->adv_entries.list);
+}
+
+static int hci_adv_entries_clear(struct hci_dev *hdev)
{
struct list_head *p, *n;
- list_for_each_safe(p, n, &hdev->adv_list) {
+ list_for_each_safe(p, n, &hdev->adv_entries.list) {
struct adv_entry *entry;
entry = list_entry(p, struct adv_entry, list);
@@ -1080,6 +1086,7 @@ static int hci_adv_list_clear(struct hci_dev *hdev)
kfree(entry);
}
+ hdev->adv_entries.size = 0;
return 0;
}
@@ -1088,7 +1095,7 @@ struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr)
{
struct list_head *p;
- list_for_each(p, &hdev->adv_list) {
+ list_for_each(p, &hdev->adv_entries.list) {
struct adv_entry *k;
k = list_entry(p, struct adv_entry, list);
@@ -1105,7 +1112,7 @@ int hci_add_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type)
struct adv_entry *entry;
entry = hci_find_adv_entry(hdev, bdaddr);
- /* Only new entries should be added to adv_list. So, if
+ /* Only new entries should be added to adv_entries. So, if
* bdaddr was found, don't add it. */
if (entry)
return 0;
@@ -1117,7 +1124,15 @@ int hci_add_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 bdaddr_type)
bacpy(&entry->bdaddr, bdaddr);
entry->bdaddr_type = bdaddr_type;
- list_add(&entry->list, &hdev->adv_list);
+ if (hdev->adv_entries.size < ADV_LIST_MAX_SIZE) {
+ hdev->adv_entries.size += 1;
+ } else {
+ struct list_head *head = &hdev->adv_entries.list;
+ struct list_head *tail = head->prev;
+ list_del(tail);
+ }
+
+ list_add(&entry->list, &hdev->adv_entries.list);
return 0;
}
@@ -1192,7 +1207,7 @@ int hci_register_dev(struct hci_dev *hdev)
INIT_LIST_HEAD(&hdev->link_keys);
- INIT_LIST_HEAD(&hdev->adv_list);
+ hci_adv_entries_init(hdev);
INIT_WORK(&hdev->power_on, hci_power_on);
INIT_WORK(&hdev->power_off, hci_power_off);
@@ -1279,7 +1294,7 @@ int hci_unregister_dev(struct hci_dev *hdev)
hci_blacklist_clear(hdev);
hci_uuids_clear(hdev);
hci_link_keys_clear(hdev);
- hci_adv_list_clear(hdev);
+ hci_adv_entries_clear(hdev);
hci_dev_unlock_bh(hdev);
__hci_dev_put(hdev);
--
1.7.1
^ permalink raw reply related
* [RFC 5/5] Bluetooth: hci_connect() should return status code
From: anderson.briglia @ 2011-02-14 22:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andre Guedes, Anderson Briglia
From: Andre Guedes <andre.guedes@openbossa.org>
This patch changes the hci_connect() prototype and related code.
hci_connect() returns a status code instead of a struct hci_conn *.
A new parameter (struct hci_conn **conn) was added in order to
return the pointer to the struct hci_conn.
Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org>
---
include/net/bluetooth/hci_core.h | 3 ++-
net/bluetooth/hci_conn.c | 36 ++++++++++++++++++++++--------------
net/bluetooth/l2cap_core.c | 9 ++++-----
net/bluetooth/sco.c | 8 ++++----
4 files changed, 32 insertions(+), 24 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 5992148..1394aeb 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -419,7 +419,8 @@ int hci_conn_del(struct hci_conn *conn);
void hci_conn_hash_flush(struct hci_dev *hdev);
void hci_conn_check_pending(struct hci_dev *hdev);
-struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type);
+int hci_connect(struct hci_conn **conn, struct hci_dev *hdev, int type,
+ bdaddr_t *dst, __u8 sec_level, __u8 auth_type);
int hci_conn_check_link_mode(struct hci_conn *conn);
int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type);
int hci_conn_change_link_key(struct hci_conn *conn);
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 2c91f4e..27c430f 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -448,7 +448,8 @@ EXPORT_SYMBOL(hci_get_route);
/* Create SCO, ACL or LE connection.
* Device _must_ be locked */
-struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type)
+int hci_connect(struct hci_conn **conn, struct hci_dev *hdev, int type,
+ bdaddr_t *dst, __u8 sec_level, __u8 auth_type)
{
struct hci_conn *acl;
struct hci_conn *sco;
@@ -456,30 +457,33 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
BT_DBG("%s dst %s", hdev->name, batostr(dst));
+ if (!conn)
+ return -EINVAL;
+
if (type == LE_LINK) {
le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
if (!le)
le = hci_conn_add(hdev, LE_LINK, dst);
if (!le)
- return NULL;
+ return -ENOMEM;
if (le->state == BT_OPEN) {
struct adv_entry *entry = hci_find_adv_entry(hdev, dst);
- if (entry)
- hci_le_connect(le, entry->bdaddr_type);
- else
- hci_le_connect(le, ADDR_DEV_PUBLIC);
+ if (!entry)
+ return -EHOSTUNREACH;
+
+ hci_le_connect(le, entry->bdaddr_type);
}
hci_conn_hold(le);
-
- return le;
+ *conn = le;
+ return 0;
}
acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
if (!acl) {
acl = hci_conn_add(hdev, ACL_LINK, dst);
if (!acl)
- return NULL;
+ return -ENOMEM;
}
hci_conn_hold(acl);
@@ -491,15 +495,17 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
hci_acl_connect(acl);
}
- if (type == ACL_LINK)
- return acl;
+ if (type == ACL_LINK) {
+ *conn = acl;
+ return 0;
+ }
sco = hci_conn_hash_lookup_ba(hdev, type, dst);
if (!sco) {
sco = hci_conn_add(hdev, type, dst);
if (!sco) {
hci_conn_put(acl);
- return NULL;
+ return -ENOMEM;
}
}
@@ -516,13 +522,15 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
if (test_bit(HCI_CONN_MODE_CHANGE_PEND, &acl->pend)) {
/* defer SCO setup until mode change completed */
set_bit(HCI_CONN_SCO_SETUP_PEND, &acl->pend);
- return sco;
+ *conn = sco;
+ return 0;
}
hci_sco_setup(acl, 0x00);
}
- return sco;
+ *conn = sco;
+ return 0;
}
EXPORT_SYMBOL(hci_connect);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 0ca54d8..e87e625 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -882,20 +882,19 @@ int l2cap_do_connect(struct sock *sk)
hci_dev_lock_bh(hdev);
- err = -ENOMEM;
-
auth_type = l2cap_get_auth_type(sk);
if (l2cap_pi(sk)->dcid == L2CAP_CID_LE_DATA)
- hcon = hci_connect(hdev, LE_LINK, dst,
+ err = hci_connect(&hcon, hdev, LE_LINK, dst,
l2cap_pi(sk)->sec_level, auth_type);
else
- hcon = hci_connect(hdev, ACL_LINK, dst,
+ err = hci_connect(&hcon, hdev, ACL_LINK, dst,
l2cap_pi(sk)->sec_level, auth_type);
- if (!hcon)
+ if (err)
goto done;
+ err = -ENOMEM;
conn = l2cap_conn_add(hcon, 0);
if (!conn) {
hci_conn_put(hcon);
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 960c6d1..3725922 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -192,17 +192,17 @@ static int sco_connect(struct sock *sk)
hci_dev_lock_bh(hdev);
- err = -ENOMEM;
-
if (lmp_esco_capable(hdev) && !disable_esco)
type = ESCO_LINK;
else
type = SCO_LINK;
- hcon = hci_connect(hdev, type, dst, BT_SECURITY_LOW, HCI_AT_NO_BONDING);
- if (!hcon)
+ err = hci_connect(&hcon, hdev, type, dst, BT_SECURITY_LOW,
+ HCI_AT_NO_BONDING);
+ if (err)
goto done;
+ err = -ENOMEM;
conn = sco_conn_add(hcon, 0);
if (!conn) {
hci_conn_put(hcon);
--
1.7.1
^ permalink raw reply related
* Re: HCI core error recovery.
From: Andrei Warkentin @ 2011-02-14 22:23 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <AANLkTinsnjed16owx=JqCCPa3AMC3P_Z9qLNd8AZ4jyf@mail.gmail.com>
On Sat, Feb 12, 2011 at 12:47 AM, Andrei Warkentin <andreiw@motorola.com> wrote:
> On Fri, Feb 11, 2011 at 5:07 PM, Andrei Warkentin <andreiw@motorola.com> wrote:
>> Dear List,
>>
>> I've run into an interesting problem. Excuse me in advance if this was
>> already covered here, or for my explanations, since I'm not too
>> familiar with overall flow within BlueZ or Bluetooth specifics...
>> We've had some hardware config issues that resulted in garbage/malformed
>> messages arriving via H4 into the HCI layer. We've since resolved
>> these, but it got me thinking. The issues would result in certain HCI
>> messages being missed, including occasionally disconnect events being
>> missed, and a subsequent connect event would result in a double add.
>>
>> I was thinking about how to fix at the very least the crash. The sysfs
>> object is created as a last step after getting a "connection
>> completed" HCI message, I think. What I am unsure about is if it's
>> safe to just ignore the add if there is already a sysfs entry...
>>
>> So I would think the HCI core needs some resiliency against
>> bad/malignant bluetooth controllers, and perform error
>> recovery/resynchronization. Perhaps maybe there is room for a virtual
>> hci controller that just injects various message types to see how well
>> the core can cope?
>>
>> Thanks in advance,
>> A
>
> To further explain the issue, here is what was happening -
>
> 0) A BT device is paired.
> 1) Host goes into sleep mode.
> 2) BT device turns off.
> 3) Host wakes up due to BT waking the host. Due to UART resume issues,
> HCI message corrupted. hci_disconn_complete_evt never gets called.
> 4) BT device turns on.
> 5) devref gets incremented in hci_conn_complete_evt, and is now 2.
> 6) BT device turns off. hci_disconn_complete_evt is called, conn hash
> is deleted, but sysfs entry not cleaned up since
> atomic_dec_and_test(&conn->devref) != 0.
> 7) BT device turns on. sysfs add fails since it never was cleaned up.
>
> The attached patch takes care of that. I'm not too familiar with BlueZ
> (or bluetooth :-(), so I would like your feedback. In particular, I am
> unsure about sync connections.
> The primary issue overall is that HCI core doesn't handle HCI issues
> (whether caused by transport issues, or bad/malicious BT controller).
> I am curious if there are other ways to break the core.
>
> Thanks,
> A
>
Anyone?
^ permalink raw reply
* Re: [RFC 1/5] Bluetooth: Implement advertising report meta event
From: Anderson Lizardo @ 2011-02-14 22:23 UTC (permalink / raw)
To: anderson.briglia; +Cc: linux-bluetooth
In-Reply-To: <4d59a5ff.859ddc0a.46cb.5143@mx.google.com>
Hi Briglia,
On Mon, Feb 14, 2011 at 6:59 PM, <anderson.briglia@openbossa.org> wrote:
> From: Anderson Briglia <anderson.briglia@openbossa.org>
>
> This patch implements new LE meta event in order to handle advertising
> reports.
>
> Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org>
> ---
> include/net/bluetooth/hci.h | 18 ++++++++++++++++++
> net/bluetooth/hci_event.c | 22 ++++++++++++++++++++++
> 2 files changed, 40 insertions(+), 0 deletions(-)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 46438f4..5180555 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -980,6 +980,24 @@ struct hci_ev_le_conn_complete {
> __u8 clk_accurancy;
> } __packed;
>
> +#define ADV_IND 0x00
> +#define ADV_DIRECT_IND 0x01
> +#define ADV_SCAN_IND 0x02
> +#define ADV_NONCONN_IND 0x03
> +#define SCAN_RSP 0x04
> +
> +#define ADDR_DEV_PUBLIC 0x00
> +#define ADDR_DEV_RANDOM 0x01
> +
> +#define HCI_EV_LE_ADVERTISING_REPORT 0x02
> +struct hci_ev_le_advertising_info {
> + __u8 evt_type;
> + __u8 bdaddr_type;
> + bdaddr_t bdaddr;
> + __u8 length;
> + __u8 data[0];
> +} __packed;
> +
> #define HCI_EV_LE_LTK_REQ 0x05
> struct hci_ev_le_ltk_req {
> __le16 handle;
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 99c75f4..987f5de 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -2498,6 +2498,25 @@ static inline void hci_le_ltk_request_evt(struct hci_dev *hdev,
> hci_dev_unlock(hdev);
> }
>
> +static inline void hci_le_adv_report_evt(struct hci_dev *hdev,
> + struct sk_buff *skb)
> +{
> + struct hci_ev_le_advertising_info *ev;
> + u8 num_reports, i;
> +
> + num_reports = (u8) skb->data[0];
I think this cast is unnecessary.
> +
> + ev = (struct hci_ev_le_advertising_info *) (skb->data + 1);
What about a slightly shorter line (well I didn't count the chars):
ev = (struct hci_ev_le_advertising_info *) &skb->data[1];
> +
> + BT_DBG("adv from: %s", batostr(&ev->bdaddr));
> +
> + for (i = 1; i < num_reports; i++) {
> + ev = (struct hci_ev_le_advertising_info *)
> + (ev->data + ev->length + 1);
> + BT_DBG("adv from: %s", batostr(&ev->bdaddr));
> + }
What about (not sure if it is shorter, just a suggestion):
ev = (struct hci_ev_le_advertising_info *) &ev->data[ev->length + 1];
> +}
> +
> static inline void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb)
> {
> struct hci_ev_le_meta *le_ev = (void *) skb->data;
> @@ -2513,6 +2532,9 @@ static inline void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb)
> hci_le_ltk_request_evt(hdev, skb);
> break;
>
> + case HCI_EV_LE_ADVERTISING_REPORT:
> + hci_le_adv_report_evt(hdev, skb);
> +
missing a "break" here.
> default:
> break;
> }
> --
> 1.7.1
>
> --
> 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
>
--
Anderson Lizardo
OpenBossa Labs - INdT
Manaus - Brazil
^ permalink raw reply
* [PATCH] Add Atheros BT AR5BBU12 fw supported
From: Cho, Yu-Chen @ 2011-02-15 1:58 UTC (permalink / raw)
To: marcel, padovan, linux-bluetooth, linux-kernel; +Cc: acho, jlee
Add the btusb.c blacklist [0489:e02c] for Atheros AR5BBU12 BT
and add to ath3k.c supported this device.
Signed-off-by: Cho, Yu-Chen <acho@novell.com>
---
drivers/bluetooth/ath3k.c | 4 ++++
drivers/bluetooth/btusb.c | 3 +++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 333c212..d4065c0 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -41,6 +41,10 @@ static struct usb_device_id ath3k_table[] = {
/* Atheros AR9285 Malbec with sflash firmware */
{ USB_DEVICE(0x03F0, 0x311D) },
+
+ /* Atheros AR5BBU12 with sflash firmware */
+ { USB_DEVICE(0x0489, 0xE02C) },
+
{ } /* Terminating entry */
};
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 4cefa91..0ae22fd 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -105,6 +105,9 @@ static struct usb_device_id blacklist_table[] = {
/* Atheros AR9285 Malbec with sflash firmware */
{ USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
+ /* Atheros AR5BBU12 with sflash firmware */
+ { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
+
/* Broadcom BCM2035 */
{ USB_DEVICE(0x0a5c, 0x2035), .driver_info = BTUSB_WRONG_SCO_MTU },
{ USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU },
--
1.7.1
^ permalink raw reply related
* [PATCH] Add Atheros BT AR5BBU12 fw supported
From: Cho, Yu-Chen @ 2011-02-15 2:20 UTC (permalink / raw)
To: marcel, padovan, linux-bluetooth, linux-kernel; +Cc: acho, jlee
Add the btusb.c blacklist [0489:e02c] for Atheros AR5BBU12 BT
and add to ath3k.c supported this device.
Signed-off-by: Cho, Yu-Chen <acho@novell.com>
---
drivers/bluetooth/ath3k.c | 3 +++
drivers/bluetooth/btusb.c | 3 +++
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 333c212..6dcd55a 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -41,6 +41,9 @@ static struct usb_device_id ath3k_table[] = {
/* Atheros AR9285 Malbec with sflash firmware */
{ USB_DEVICE(0x03F0, 0x311D) },
+
+ /* Atheros AR5BBU12 with sflash firmware */
+ { USB_DEVICE(0x0489, 0xE02C) },
{ } /* Terminating entry */
};
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 664f1cc..b7f2f37 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -105,6 +105,9 @@ static struct usb_device_id blacklist_table[] = {
/* Atheros AR9285 Malbec with sflash firmware */
{ USB_DEVICE(0x03f0, 0x311d), .driver_info = BTUSB_IGNORE },
+ /* Atheros AR5BBU12 with sflash firmware */
+ { USB_DEVICE(0x0489, 0xe02c), .driver_info = BTUSB_IGNORE },
+
/* Broadcom BCM2035 */
{ USB_DEVICE(0x0a5c, 0x2035), .driver_info = BTUSB_WRONG_SCO_MTU },
{ USB_DEVICE(0x0a5c, 0x200a), .driver_info = BTUSB_WRONG_SCO_MTU },
--
1.7.1
^ permalink raw reply related
* Re: [PATCH] linux-firmware: Add patch and sysconfig files for AR3012.
From: Bala Shanmugam @ 2011-02-15 9:23 UTC (permalink / raw)
To: Shanmugamkamatchi Balashanmugam
Cc: dwmw2@infradead.org, Jothikumar Mothilal,
linux-bluetooth@vger.kernel.org
In-Reply-To: <1297248851-14996-1-git-send-email-sbalashanmugam@atheros.com>
Hi David,
On 2/9/2011 4:24 PM, Shanmugamkamatchi Balashanmugam wrote:
> Signed-off-by: Bala Shanmugam<sbalashanmugam@atheros.com>
> ---
> WHENCE | 9 +++++++++
> ar3k/AthrBT_0x01020001.dfu | Bin 0 -> 55244 bytes
> ar3k/ramps_0x01020001_26.dfu | Bin 0 -> 1224 bytes
> 3 files changed, 9 insertions(+), 0 deletions(-)
> create mode 100644 ar3k/AthrBT_0x01020001.dfu
> create mode 100644 ar3k/ramps_0x01020001_26.dfu
>
> diff --git a/WHENCE b/WHENCE
> index 1cbd0a6..2de0bea 100644
> --- a/WHENCE
> +++ b/WHENCE
> @@ -1534,3 +1534,12 @@ Driver: vt6656 - VIA VT6656 USB wireless driver
> File: vntwusb.fw
>
> Licence: Redistributable. See LICENCE.via_vt6656 for details.
> +
> +--------------------------------------------------------------------------
> +
> +Driver: DFU Driver for Atheros bluetooth chipset AR3012
> +
> +File: ar3k/AthrBT_0x01020001.dfu
> +File: ar3k/ramps_0x01020001_26.dfu
> +
Driver changes for AR3012 have been upstreamed.
Can you please upstream above patch?
Regards,
Bala.
^ permalink raw reply
* Re: [RFC 1/5] Bluetooth: Implement advertising report meta event
From: Anderson Briglia @ 2011-02-15 13:10 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <AANLkTikhs5uwFgeF0BT_5R_=8sM5Z+eQ_y2kxZ_oWj1V@mail.gmail.com>
Thanks for reviewing. I'll add that missing "break", but the other
tips are not so relevant since we should gain just 2 characters.
On Mon, Feb 14, 2011 at 7:23 PM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
>
> Hi Briglia,
>
> On Mon, Feb 14, 2011 at 6:59 PM, <anderson.briglia@openbossa.org> wrote:
> > From: Anderson Briglia <anderson.briglia@openbossa.org>
> >
> > This patch implements new LE meta event in order to handle advertising
> > reports.
> >
> > Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org>
> > ---
> > include/net/bluetooth/hci.h | 18 ++++++++++++++++++
> > net/bluetooth/hci_event.c | 22 ++++++++++++++++++++++
> > 2 files changed, 40 insertions(+), 0 deletions(-)
> >
> > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> > index 46438f4..5180555 100644
> > --- a/include/net/bluetooth/hci.h
> > +++ b/include/net/bluetooth/hci.h
> > @@ -980,6 +980,24 @@ struct hci_ev_le_conn_complete {
> > __u8 clk_accurancy;
> > } __packed;
> >
> > +#define ADV_IND 0x00
> > +#define ADV_DIRECT_IND 0x01
> > +#define ADV_SCAN_IND 0x02
> > +#define ADV_NONCONN_IND 0x03
> > +#define SCAN_RSP 0x04
> > +
> > +#define ADDR_DEV_PUBLIC 0x00
> > +#define ADDR_DEV_RANDOM 0x01
> > +
> > +#define HCI_EV_LE_ADVERTISING_REPORT 0x02
> > +struct hci_ev_le_advertising_info {
> > + __u8 evt_type;
> > + __u8 bdaddr_type;
> > + bdaddr_t bdaddr;
> > + __u8 length;
> > + __u8 data[0];
> > +} __packed;
> > +
> > #define HCI_EV_LE_LTK_REQ 0x05
> > struct hci_ev_le_ltk_req {
> > __le16 handle;
> > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> > index 99c75f4..987f5de 100644
> > --- a/net/bluetooth/hci_event.c
> > +++ b/net/bluetooth/hci_event.c
> > @@ -2498,6 +2498,25 @@ static inline void hci_le_ltk_request_evt(struct hci_dev *hdev,
> > hci_dev_unlock(hdev);
> > }
> >
> > +static inline void hci_le_adv_report_evt(struct hci_dev *hdev,
> > + struct sk_buff *skb)
> > +{
> > + struct hci_ev_le_advertising_info *ev;
> > + u8 num_reports, i;
> > +
> > + num_reports = (u8) skb->data[0];
>
> I think this cast is unnecessary.
>
> > +
> > + ev = (struct hci_ev_le_advertising_info *) (skb->data + 1);
>
> What about a slightly shorter line (well I didn't count the chars):
>
> ev = (struct hci_ev_le_advertising_info *) &skb->data[1];
>
> > +
> > + BT_DBG("adv from: %s", batostr(&ev->bdaddr));
> > +
> > + for (i = 1; i < num_reports; i++) {
> > + ev = (struct hci_ev_le_advertising_info *)
> > + (ev->data + ev->length + 1);
> > + BT_DBG("adv from: %s", batostr(&ev->bdaddr));
> > + }
>
> What about (not sure if it is shorter, just a suggestion):
>
> ev = (struct hci_ev_le_advertising_info *) &ev->data[ev->length + 1];
>
> > +}
> > +
> > static inline void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb)
> > {
> > struct hci_ev_le_meta *le_ev = (void *) skb->data;
> > @@ -2513,6 +2532,9 @@ static inline void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb)
> > hci_le_ltk_request_evt(hdev, skb);
> > break;
> >
> > + case HCI_EV_LE_ADVERTISING_REPORT:
> > + hci_le_adv_report_evt(hdev, skb);
> > +
>
> missing a "break" here.
>
> > default:
> > break;
> > }
> > --
> > 1.7.1
> >
> > --
> > 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
> >
>
>
>
> --
> Anderson Lizardo
> OpenBossa Labs - INdT
> Manaus - Brazil
--
INdT - Instituto Nokia de tecnologia
+55 2126 1122
http://techblog.briglia.net
^ permalink raw reply
* Re: [RFC 1/5] Bluetooth: Implement advertising report meta event
From: Gustavo F. Padovan @ 2011-02-15 13:44 UTC (permalink / raw)
To: Anderson Briglia; +Cc: Anderson Lizardo, linux-bluetooth
In-Reply-To: <AANLkTikEtO+jF-S9SDziueGh1rDUYhYeATT6_g84++0B@mail.gmail.com>
Hi Briglia,
Top posting is not allowed in this mailing list. Please stop it.
* Anderson Briglia <anderson.briglia@openbossa.org> [2011-02-15 10:10:12 -0300]:
> Thanks for reviewing. I'll add that missing "break", but the other
> tips are not so relevant since we should gain just 2 characters.
>
> On Mon, Feb 14, 2011 at 7:23 PM, Anderson Lizardo
> <anderson.lizardo@openbossa.org> wrote:
> >
> > Hi Briglia,
> >
> > On Mon, Feb 14, 2011 at 6:59 PM, <anderson.briglia@openbossa.org> wrote:
> > > From: Anderson Briglia <anderson.briglia@openbossa.org>
> > >
> > > This patch implements new LE meta event in order to handle advertising
> > > reports.
> > >
> > > Signed-off-by: Anderson Briglia <anderson.briglia@openbossa.org>
> > > ---
> > > include/net/bluetooth/hci.h | 18 ++++++++++++++++++
> > > net/bluetooth/hci_event.c | 22 ++++++++++++++++++++++
> > > 2 files changed, 40 insertions(+), 0 deletions(-)
> > >
> > > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> > > index 46438f4..5180555 100644
> > > --- a/include/net/bluetooth/hci.h
> > > +++ b/include/net/bluetooth/hci.h
> > > @@ -980,6 +980,24 @@ struct hci_ev_le_conn_complete {
> > > __u8 clk_accurancy;
> > > } __packed;
> > >
> > > +#define ADV_IND 0x00
> > > +#define ADV_DIRECT_IND 0x01
> > > +#define ADV_SCAN_IND 0x02
> > > +#define ADV_NONCONN_IND 0x03
> > > +#define SCAN_RSP 0x04
> > > +
> > > +#define ADDR_DEV_PUBLIC 0x00
> > > +#define ADDR_DEV_RANDOM 0x01
> > > +
> > > +#define HCI_EV_LE_ADVERTISING_REPORT 0x02
> > > +struct hci_ev_le_advertising_info {
> > > + __u8 evt_type;
> > > + __u8 bdaddr_type;
> > > + bdaddr_t bdaddr;
> > > + __u8 length;
> > > + __u8 data[0];
> > > +} __packed;
> > > +
> > > #define HCI_EV_LE_LTK_REQ 0x05
> > > struct hci_ev_le_ltk_req {
> > > __le16 handle;
> > > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> > > index 99c75f4..987f5de 100644
> > > --- a/net/bluetooth/hci_event.c
> > > +++ b/net/bluetooth/hci_event.c
> > > @@ -2498,6 +2498,25 @@ static inline void hci_le_ltk_request_evt(struct hci_dev *hdev,
> > > hci_dev_unlock(hdev);
> > > }
> > >
> > > +static inline void hci_le_adv_report_evt(struct hci_dev *hdev,
> > > + struct sk_buff *skb)
> > > +{
> > > + struct hci_ev_le_advertising_info *ev;
> > > + u8 num_reports, i;
> > > +
> > > + num_reports = (u8) skb->data[0];
> >
> > I think this cast is unnecessary.
> >
> > > +
> > > + ev = (struct hci_ev_le_advertising_info *) (skb->data + 1);
> >
> > What about a slightly shorter line (well I didn't count the chars):
> >
> > ev = (struct hci_ev_le_advertising_info *) &skb->data[1];
Use (void *) cast here.
> >
> > > +
> > > + BT_DBG("adv from: %s", batostr(&ev->bdaddr));
> > > +
> > > + for (i = 1; i < num_reports; i++) {
> > > + ev = (struct hci_ev_le_advertising_info *)
> > > + (ev->data + ev->length + 1);
> > > + BT_DBG("adv from: %s", batostr(&ev->bdaddr));
> > > + }
> >
> > What about (not sure if it is shorter, just a suggestion):
> >
> > ev = (struct hci_ev_le_advertising_info *) &ev->data[ev->length + 1];
Same here.
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* Re: bluetooth disabled with current 2.6.38-rc4
From: Johan Hedberg @ 2011-02-15 13:52 UTC (permalink / raw)
To: Justin Mattock; +Cc: linux-bluetooth
In-Reply-To: <1A8743E5-65EA-4625-82FD-658C9722629F@gmail.com>
Hi Justin,
On Sun, Feb 13, 2011, Justin Mattock wrote:
> maybe I missed something, but my bluetooth is just not functioning with
> 2.6.38-rc4(works with 2.6.37-rc4)
>
> I've done a bisect on this, but was pointed to:
> c0e45c1ca3162acb2e77b3d9e152ce6e7b6fa3f5
> but doesn't look correct to me
>
> here is what I am seeing with the bluetooth-applet etc..:
>
> working correctly:
> http://www.flickr.com/photos/44066293@N08/5443727238/
>
> not working:
> http://www.flickr.com/photos/44066293@N08/5443124859/
>
> my /var/log/daemon.log shows:
>
> Feb 13 17:12:22 Linux-2 acpid: 1 client rule loaded
> Feb 13 17:12:23 Linux-2 bluetoothd[1950]: HCI dev 0 registered
> Feb 13 17:12:23 Linux-2 bluetoothd[1950]: Listening for HCI events
> on hci0
> Feb 13 17:12:23 Linux-2 bluetoothd[1950]: HCI dev 0 up
> Feb 13 17:12:23 Linux-2 bluetoothd[1950]: Unable to find matching
> adapter
>
> I can try at another bisect, but might take some time.. let me know
> if there is something I can test
> or do.
Are you sure this is a kernel problem? There was a similar issue with
BlueZ 4.86 or 4.87 which was already fixed. Could you try with 4.88?
Johan
^ permalink raw reply
* [RFC] Bluetooth: add BT_CONNINFO socketopt
From: Gustavo F. Padovan @ 2011-02-15 14:01 UTC (permalink / raw)
To: linux-bluetooth
ATT needs to know to link key type before run some of it procedures.
Using the socket sec_level doesn't work because the socket may not reflect
the real sec_level of the link.
Reported-by: Anderson Lizardo <anderson.lizardo@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
include/net/bluetooth/bluetooth.h | 2 ++
net/bluetooth/l2cap_sock.c | 11 +++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 4375043..dea93df 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -66,6 +66,8 @@ struct bt_security {
#define BT_FLUSHABLE 8
+#define BT_CONNINFO 9
+
#define BT_FLUSHABLE_OFF 0
#define BT_FLUSHABLE_ON 1
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 484e717..c249617 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -468,6 +468,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
{
struct sock *sk = sock->sk;
struct bt_security sec;
+ struct hci_conn *hconn = (void *)l2cap_pi(sk)->conn;
int len, err = 0;
BT_DBG("sk %p", sk);
@@ -516,6 +517,16 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
break;
+ case BT_CONNINFO:
+ if (sk->sk_state != BT_CONNECTED) {
+ err = -EINVAL;
+ break;
+ }
+
+ if (put_user(hconn->sec_level, (u32 __user *) optval))
+ err = -EFAULT;
+ break;
+
default:
err = -ENOPROTOOPT;
break;
--
1.7.4
^ permalink raw reply related
* Re: [PATCH 1/3] Fix not stopping name resolving when discovery is suspended
From: Johan Hedberg @ 2011-02-15 14:14 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1297678882-26893-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Mon, Feb 14, 2011, Luiz Augusto von Dentz wrote:
> During device creation if discovery is active we suspend it to avoid
> interfering with pairing, but although it attempt to cancel name request
> there could be one already completed which would cause next name on the
> list to be requested.
> ---
> src/adapter.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
All three patches (v2 of 2/3) have been pushed upstream. Thanks.
Johan
^ permalink raw reply
* [PATCH 1/2] Add encode/decode for write response
From: Bruna Moreira @ 2011-02-15 14:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
The encode/decode functions for Write Response operations were created
to keep consistency with the rest of GATT API.
---
attrib/att.c | 21 +++++++++++++++++++++
attrib/att.h | 2 ++
src/attrib-server.c | 4 +---
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/attrib/att.c b/attrib/att.c
index dff8597..3259fca 100644
--- a/attrib/att.c
+++ b/attrib/att.c
@@ -526,6 +526,27 @@ uint16_t dec_write_req(const uint8_t *pdu, int len, uint16_t *handle,
return len;
}
+uint16_t enc_write_resp(uint8_t *pdu, int len)
+{
+ if (pdu == NULL)
+ return 0;
+
+ pdu[0] = ATT_OP_WRITE_RESP;
+
+ return sizeof(pdu[0]);
+}
+
+uint16_t dec_write_resp(const uint8_t *pdu, int len)
+{
+ if (pdu == NULL)
+ return 0;
+
+ if (pdu[0] != ATT_OP_WRITE_RESP)
+ return 0;
+
+ return len;
+}
+
uint16_t enc_read_req(uint16_t handle, uint8_t *pdu, int len)
{
const uint16_t min_len = sizeof(pdu[0]) + sizeof(handle);
diff --git a/attrib/att.h b/attrib/att.h
index 7e81dc4..7d9afeb 100644
--- a/attrib/att.h
+++ b/attrib/att.h
@@ -215,6 +215,8 @@ uint16_t enc_write_req(uint16_t handle, const uint8_t *value, int vlen,
uint8_t *pdu, int len);
uint16_t dec_write_req(const uint8_t *pdu, int len, uint16_t *handle,
uint8_t *value, int *vlen);
+uint16_t enc_write_resp(uint8_t *pdu, int len);
+uint16_t dec_write_resp(const uint8_t *pdu, int len);
uint16_t enc_read_req(uint16_t handle, uint8_t *pdu, int len);
uint16_t enc_read_blob_req(uint16_t handle, uint16_t offset, uint8_t *pdu,
int len);
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 72f5b17..85b39a8 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -601,9 +601,7 @@ static uint16_t write_value(struct gatt_channel *channel, uint16_t handle,
memcpy(&uuid, &a->uuid, sizeof(uuid_t));
attrib_db_update(handle, &uuid, value, vlen);
- pdu[0] = ATT_OP_WRITE_RESP;
-
- return sizeof(pdu[0]);
+ return enc_write_resp(pdu, len);
}
static uint16_t mtu_exchange(struct gatt_channel *channel, uint16_t mtu,
--
1.7.0.4
^ permalink raw reply related
* [PATCH 2/2] Add Write Request operation in gatttool
From: Bruna Moreira @ 2011-02-15 14:16 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
In-Reply-To: <1297779409-32597-1-git-send-email-bruna.moreira@openbossa.org>
Add option and callbacks for Write Request operation in gatttool.
---
attrib/gatttool.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 60 insertions(+), 1 deletions(-)
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 8e8ed8e..b9f0087 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -63,6 +63,7 @@ static gboolean opt_listen = FALSE;
static gboolean opt_char_desc = FALSE;
static gboolean opt_le = FALSE;
static gboolean opt_char_write = FALSE;
+static gboolean opt_char_write_req = FALSE;
static GMainLoop *event_loop;
static gboolean got_error = FALSE;
@@ -436,6 +437,59 @@ error:
return FALSE;
}
+static void char_write_req_cb(guint8 status, const guint8 *pdu, guint16 plen,
+ gpointer user_data)
+{
+ if (status != 0) {
+ g_printerr("Characteristic Write Request failed: "
+ "%s\n", att_ecode2str(status));
+ goto done;
+ }
+
+ if (!dec_write_resp(pdu, plen)) {
+ g_printerr("Protocol error\n");
+ goto done;
+ }
+
+ g_print("Characteristic value was written sucessfully\n");
+
+done:
+ if (opt_listen == FALSE)
+ g_main_loop_quit(event_loop);
+}
+
+static gboolean characteristics_write_req(gpointer user_data)
+{
+ GAttrib *attrib = user_data;
+ uint8_t *value;
+ size_t len;
+
+ if (opt_handle <= 0) {
+ g_printerr("A valid handle is required\n");
+ goto error;
+ }
+
+ if (opt_value == NULL || opt_value[0] == '\0') {
+ g_printerr("A value is required\n");
+ goto error;
+ }
+
+ len = attr_data_from_string(opt_value, &value);
+ if (len == 0) {
+ g_printerr("Invalid value\n");
+ goto error;
+ }
+
+ gatt_write_char(attrib, opt_handle, value, len, char_write_req_cb,
+ NULL);
+
+ return FALSE;
+
+error:
+ g_main_loop_quit(event_loop);
+ return FALSE;
+}
+
static void char_desc_cb(guint8 status, const guint8 *pdu, guint16 plen,
gpointer user_data)
{
@@ -530,7 +584,10 @@ static GOptionEntry gatt_options[] = {
{ "char-read", 0, 0, G_OPTION_ARG_NONE, &opt_char_read,
"Characteristics Value/Descriptor Read", NULL },
{ "char-write", 0, 0, G_OPTION_ARG_NONE, &opt_char_write,
- "Characteristics Value Write", NULL },
+ "Characteristics Value Write Without Response (Write Command)",
+ NULL },
+ { "char-write-req", 0, 0, G_OPTION_ARG_NONE, &opt_char_write_req,
+ "Characteristics Value Write (Write Request)", NULL },
{ "char-desc", 0, 0, G_OPTION_ARG_NONE, &opt_char_desc,
"Characteristics Descriptor Discovery", NULL },
{ "listen", 0, 0, G_OPTION_ARG_NONE, &opt_listen,
@@ -602,6 +659,8 @@ int main(int argc, char *argv[])
callback = characteristics_read;
else if (opt_char_write)
callback = characteristics_write;
+ else if (opt_char_write_req)
+ callback = characteristics_write_req;
else if (opt_char_desc)
callback = characteristics_desc;
else {
--
1.7.0.4
^ permalink raw reply related
* Re: [PATCH 1/7 v3] Add return value to query tracker
From: Johan Hedberg @ 2011-02-15 14:21 UTC (permalink / raw)
To: Radoslaw Jablonski; +Cc: linux-bluetooth
In-Reply-To: <1297675191-8046-1-git-send-email-ext-jablonski.radoslaw@nokia.com>
Hi Radek,
On Mon, Feb 14, 2011, Radoslaw Jablonski wrote:
> Previously errors were returned via parameter err - it was needed
> because some time ago query_tracker was returning newly allocated
> structure. Now returning error through return value has more
> sense.
> ---
> plugins/phonebook-tracker.c | 37 ++++++++++++++++++-------------------
> 1 files changed, 18 insertions(+), 19 deletions(-)
All seven patches have been pushed upstream. Thanks.
Johan
^ permalink raw reply
* [RFC -v2] Bluetooth: add BT_CONNINFO socketopt
From: Gustavo F. Padovan @ 2011-02-15 14:23 UTC (permalink / raw)
To: linux-bluetooth
ATT needs to know to link key type before run some of it procedures.
Using the socket sec_level doesn't work because the socket may not reflect
the real sec_level of the link.
Reported-by: Anderson Lizardo <anderson.lizardo@openbossa.org>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
include/net/bluetooth/bluetooth.h | 2 ++
net/bluetooth/l2cap_sock.c | 11 +++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 4375043..dea93df 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -66,6 +66,8 @@ struct bt_security {
#define BT_FLUSHABLE 8
+#define BT_CONNINFO 9
+
#define BT_FLUSHABLE_OFF 0
#define BT_FLUSHABLE_ON 1
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 484e717..c249617 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -468,6 +468,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
{
struct sock *sk = sock->sk;
struct bt_security sec;
+ struct hci_conn *hconn = (void *)l2cap_pi(sk)->conn;
int len, err = 0;
BT_DBG("sk %p", sk);
@@ -516,6 +517,16 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
break;
+ case BT_CONNINFO:
+ if (sk->sk_state != BT_CONNECTED) {
+ err = -EINVAL;
+ break;
+ }
+
+ if (put_user(hconn->sec_level, (u32 __user *) optval))
+ err = -EFAULT;
+ break;
+
default:
err = -ENOPROTOOPT;
break;
--
1.7.4
^ permalink raw reply related
* Re: [PATCH] Fix parsing of "Flags" AD type
From: Johan Hedberg @ 2011-02-15 14:25 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <1297705009-12848-1-git-send-email-anderson.lizardo@openbossa.org>
Hi Lizardo,
On Mon, Feb 14, 2011, Anderson Lizardo wrote:
> If an advertising report did not contain a "Flags" AD Type (e.g. a Scan
> response), the previous flags value was mistakenly set to 0x00. This fix
> makes sure dev->flags is only updated for valid values.
> ---
> src/adapter.c | 5 +++--
> src/adapter.h | 2 +-
> src/event.c | 4 +++-
> 3 files changed, 7 insertions(+), 4 deletions(-)
Pushed upstream. Thanks.
Johan
^ 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