* HFP can't work well and sound can't be heard
From: Zheng, Wu @ 2012-11-08 9:41 UTC (permalink / raw)
To: Von Dentz, Luiz; +Cc: linux-bluetooth@vger.kernel.org
Hi Luiz,
The GetProperties methods of "org.bluez.manager", "org.bluez.Adapter" and so on have been converted to some methods of "org.freedesktop.DBus.Properties".
It results in pulseaudio can't communicate with bluez well and sound can't be heard when using HFP.
What do upstream plan for it? Thanks.
Best Regards
Zheng Wu
^ permalink raw reply
* [PATCH] Bluetooth: Fix memory leak when removing a UUID
From: Johan Hedberg @ 2012-11-08 9:25 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
When removing a UUID from the list in the remove_uuid() function we must
also kfree the entry in addition to removing it from the list.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
net/bluetooth/mgmt.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index ad1054f..142764a 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -1379,6 +1379,7 @@ static int remove_uuid(struct sock *sk, struct hci_dev *hdev, void *data,
continue;
list_del(&match->list);
+ kfree(match);
found++;
}
--
1.7.10.4
^ permalink raw reply related
* [PATCH 3/3 v2] Bluetooth: Fix updating advertising state flags and data
From: Johan Hedberg @ 2012-11-08 0:23 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1352334181-19198-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch adds a callback for the HCI_LE_Set_Advertise_Enable command.
The callback is responsible for updating the HCI_LE_PERIPHERAL flag
updating as well as updating the advertising data flags field to
indicate undirected connectable advertising.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 2 ++
net/bluetooth/hci_event.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 7306078..4bbabd8 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -957,6 +957,8 @@ struct hci_cp_le_set_adv_data {
__u8 data[HCI_MAX_AD_LENGTH];
} __packed;
+#define HCI_OP_LE_SET_ADV_ENABLE 0x200a
+
#define HCI_OP_LE_SET_SCAN_PARAM 0x200b
struct hci_cp_le_set_scan_param {
__u8 type;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 7caea1a..9f5c5f2 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1190,6 +1190,33 @@ static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev,
hci_dev_unlock(hdev);
}
+static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ __u8 *sent, status = *((__u8 *) skb->data);
+
+ BT_DBG("%s status 0x%2.2x", hdev->name, status);
+
+ sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_ENABLE);
+ if (!sent)
+ return;
+
+ hci_dev_lock(hdev);
+
+ if (!status) {
+ if (*sent)
+ set_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags);
+ else
+ clear_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags);
+ }
+
+ hci_dev_unlock(hdev);
+
+ if (!test_bit(HCI_INIT, &hdev->flags))
+ hci_update_ad(hdev);
+
+ hci_req_complete(hdev, HCI_OP_LE_SET_ADV_ENABLE, status);
+}
+
static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb)
{
__u8 status = *((__u8 *) skb->data);
@@ -2585,6 +2612,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
hci_cc_le_set_scan_param(hdev, skb);
break;
+ case HCI_OP_LE_SET_ADV_ENABLE:
+ hci_cc_le_set_adv_enable(hdev, skb);
+ break;
+
case HCI_OP_LE_SET_SCAN_ENABLE:
hci_cc_le_set_scan_enable(hdev, skb);
break;
--
1.7.10.4
^ permalink raw reply related
* [PATCH 2/3 v2] Bluetooth: Add support for setting LE advertising data
From: Johan Hedberg @ 2012-11-08 0:23 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1352334181-19198-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch adds support for setting basing LE advertising data. The
three elements supported for now are the advertising flags, the TX power
and the friendly name.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 15 ++++++
include/net/bluetooth/hci_core.h | 4 ++
net/bluetooth/hci_core.c | 97 ++++++++++++++++++++++++++++++++++++++
net/bluetooth/hci_event.c | 11 ++++-
4 files changed, 126 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 344fea0..7306078 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -338,6 +338,13 @@ enum {
#define EIR_SSP_RAND_R 0x0F /* Simple Pairing Randomizer R */
#define EIR_DEVICE_ID 0x10 /* device ID */
+/* Low Energy Advertising Flags */
+#define LE_AD_LIMITED 0x01 /* Limited Discoverable */
+#define LE_AD_GENERAL 0x02 /* General Discoverable */
+#define LE_AD_NO_BREDR 0x04 /* BR/EDR not supported */
+#define LE_AD_SIM_LE_BREDR_CTRL 0x08 /* Simultaneous LE & BR/EDR Controller */
+#define LE_AD_SIM_LE_BREDR_HOST 0x10 /* Simultaneous LE & BR/EDR Host */
+
/* ----- HCI Commands ---- */
#define HCI_OP_NOP 0x0000
@@ -942,6 +949,14 @@ struct hci_rp_le_read_adv_tx_power {
__s8 tx_power;
} __packed;
+#define HCI_MAX_AD_LENGTH 31
+
+#define HCI_OP_LE_SET_ADV_DATA 0x2008
+struct hci_cp_le_set_adv_data {
+ __u8 length;
+ __u8 data[HCI_MAX_AD_LENGTH];
+} __packed;
+
#define HCI_OP_LE_SET_SCAN_PARAM 0x200b
struct hci_cp_le_set_scan_param {
__u8 type;
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index ce6dbeb..ef5b85d 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -279,6 +279,8 @@ struct hci_dev {
struct le_scan_params le_scan_params;
__s8 adv_tx_power;
+ __u8 adv_data[HCI_MAX_AD_LENGTH];
+ __u8 adv_data_len;
int (*open)(struct hci_dev *hdev);
int (*close)(struct hci_dev *hdev);
@@ -734,6 +736,8 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
u8 *randomizer);
int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
+int hci_update_ad(struct hci_dev *hdev);
+
void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
int hci_recv_frame(struct sk_buff *skb);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 0af08f3..0af3ea8 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -594,6 +594,102 @@ done:
return err;
}
+static u16 create_ad(struct hci_dev *hdev, u8 *data)
+{
+ u8 *ptr = data;
+ u16 ad_len = 0;
+ size_t name_len;
+ u8 flags = 0;
+
+ if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags))
+ flags |= LE_AD_GENERAL;
+
+ if (!lmp_bredr_capable(hdev))
+ flags |= LE_AD_NO_BREDR;
+
+ if (lmp_le_br_capable(hdev))
+ flags |= LE_AD_SIM_LE_BREDR_CTRL;
+
+ if (lmp_host_le_br_capable(hdev))
+ flags |= LE_AD_SIM_LE_BREDR_HOST;
+
+ if (flags) {
+ BT_DBG("adv flags 0x%02x", flags);
+
+ ptr[0] = 2;
+ ptr[1] = EIR_FLAGS;
+ ptr[2] = flags;
+
+ ad_len += 3;
+ ptr += 3;
+ }
+
+ if (hdev->adv_tx_power != HCI_TX_POWER_INVALID) {
+ ptr[0] = 2;
+ ptr[1] = EIR_TX_POWER;
+ ptr[2] = (u8) hdev->adv_tx_power;
+
+ ad_len += 3;
+ ptr += 3;
+ }
+
+ name_len = strlen(hdev->dev_name);
+ if (name_len > 0) {
+ size_t max_len = HCI_MAX_AD_LENGTH - ad_len - 2;
+
+ if (name_len > max_len) {
+ name_len = max_len;
+ ptr[1] = EIR_NAME_SHORT;
+ } else
+ ptr[1] = EIR_NAME_COMPLETE;
+
+ ptr[0] = name_len + 1;
+
+ memcpy(ptr + 2, hdev->dev_name, name_len);
+
+ ad_len += (name_len + 2);
+ ptr += (name_len + 2);
+ }
+
+ return ad_len;
+}
+
+int hci_update_ad(struct hci_dev *hdev)
+{
+ struct hci_cp_le_set_adv_data cp;
+ u16 len;
+ int err;
+
+ hci_dev_lock(hdev);
+
+ if (!lmp_le_capable(hdev)) {
+ err = -EINVAL;
+ goto unlock;
+ }
+
+ memset(&cp, 0, sizeof(cp));
+
+ len = create_ad(hdev, cp.data);
+
+ if (hdev->adv_data_len == len &&
+ memcmp(cp.data, hdev->adv_data, len) == 0) {
+ err = 0;
+ goto unlock;
+ }
+
+ memcpy(hdev->adv_data, cp.data, sizeof(cp.data));
+ hdev->adv_data_len = len;
+
+ cp.length = cpu_to_le16(len);
+
+ err = hci_send_cmd(hdev, HCI_OP_LE_SET_ADV_DATA, sizeof(cp), &cp);
+
+unlock:
+ hci_dev_unlock(hdev);
+
+ return err;
+}
+
/* ---- HCI ioctl helpers ---- */
int hci_dev_open(__u16 dev)
@@ -651,6 +747,7 @@ int hci_dev_open(__u16 dev)
hci_dev_hold(hdev);
set_bit(HCI_UP, &hdev->flags);
hci_notify(hdev, HCI_DEV_UP);
+ hci_update_ad(hdev);
if (!test_bit(HCI_SETUP, &hdev->dev_flags) &&
mgmt_valid_hdev(hdev)) {
hci_dev_lock(hdev);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 09c6571..7caea1a 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -204,6 +204,9 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
hdev->discovery.state = DISCOVERY_STOPPED;
hdev->inq_tx_power = HCI_TX_POWER_INVALID;
hdev->adv_tx_power = HCI_TX_POWER_INVALID;
+
+ memset(hdev->adv_data, 0, sizeof(hdev->adv_data));
+ hdev->adv_data_len = 0;
}
static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
@@ -226,6 +229,9 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
hci_dev_unlock(hdev);
+ if (!status && !test_bit(HCI_INIT, &hdev->flags))
+ hci_update_ad(hdev);
+
hci_req_complete(hdev, HCI_OP_WRITE_LOCAL_NAME, status);
}
@@ -1091,8 +1097,11 @@ static void hci_cc_le_read_adv_tx_power(struct hci_dev *hdev,
BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
- if (!rp->status)
+ if (!rp->status) {
hdev->adv_tx_power = rp->tx_power;
+ if (!test_bit(HCI_INIT, &hdev->flags))
+ hci_update_ad(hdev);
+ }
hci_req_complete(hdev, HCI_OP_LE_READ_ADV_TX_POWER, rp->status);
}
--
1.7.10.4
^ permalink raw reply related
* [PATCH 1/3 v2] Bluetooth: Use proper invalid value for tx_power
From: Johan Hedberg @ 2012-11-08 0:22 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
The core specification defines 127 as the "not available" value (well,
"reserved" for BR/EDR and "not available" for LE - but essentially the
same). Therefore, instead of testing for 0 (which is in fact a valid
value) we should be using this invalid value to test if the tx_power is
available.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 3 +++
net/bluetooth/hci_core.c | 2 ++
net/bluetooth/hci_event.c | 2 ++
net/bluetooth/mgmt.c | 2 +-
4 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 6c414f4..344fea0 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -319,6 +319,9 @@ enum {
#define HCI_FLOW_CTL_MODE_PACKET_BASED 0x00
#define HCI_FLOW_CTL_MODE_BLOCK_BASED 0x01
+/* The core spec defines 127 as the "not available" value */
+#define HCI_TX_POWER_INVALID 127
+
/* Extended Inquiry Response field types */
#define EIR_FLAGS 0x01 /* flags */
#define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index c68c409..0af08f3 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1606,6 +1606,8 @@ struct hci_dev *hci_alloc_dev(void)
hdev->esco_type = (ESCO_HV1);
hdev->link_mode = (HCI_LM_ACCEPT);
hdev->io_capability = 0x03; /* No Input No Output */
+ hdev->inq_tx_power = HCI_TX_POWER_INVALID;
+ hdev->adv_tx_power = HCI_TX_POWER_INVALID;
hdev->sniff_max_interval = 800;
hdev->sniff_min_interval = 80;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index c08ac7c..09c6571 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -202,6 +202,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
BIT(HCI_PERIODIC_INQ));
hdev->discovery.state = DISCOVERY_STOPPED;
+ hdev->inq_tx_power = HCI_TX_POWER_INVALID;
+ hdev->adv_tx_power = HCI_TX_POWER_INVALID;
}
static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 26a0984..ad1054f 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -485,7 +485,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
ptr += (name_len + 2);
}
- if (hdev->inq_tx_power) {
+ if (hdev->inq_tx_power != HCI_TX_POWER_INVALID) {
ptr[0] = 2;
ptr[1] = EIR_TX_POWER;
ptr[2] = (u8) hdev->inq_tx_power;
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH 1/3] Bluetooth: Use proper invalid value for tx_power
From: Johan Hedberg @ 2012-11-08 0:22 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1352333942-18964-1-git-send-email-johan.hedberg@gmail.com>
Hi,
On Thu, Nov 08, 2012, Johan Hedberg wrote:
> The core specification defines 127 as the "not available" value (well,
> "reserved" for BR/EDR and "not available" for LE - but essentially the
> same). Therefore, instead of testing for 0 (which is in fact a valid
> value) we should be using this invalid value to test if the tx_power is
> available.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> Acked-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> include/net/bluetooth/hci.h | 3 +++
> net/bluetooth/hci_core.c | 2 ++
> net/bluetooth/hci_event.c | 2 ++
> net/bluetooth/mgmt.c | 2 +-
> 4 files changed, 8 insertions(+), 1 deletion(-)
Please ignore these two patches. They slipped off before I had the
chance to slap the v2 label on them. Proper set coming in a minute.
Johan
^ permalink raw reply
* [PATCH 1/3] Bluetooth: Use proper invalid value for tx_power
From: Johan Hedberg @ 2012-11-08 0:19 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
The core specification defines 127 as the "not available" value (well,
"reserved" for BR/EDR and "not available" for LE - but essentially the
same). Therefore, instead of testing for 0 (which is in fact a valid
value) we should be using this invalid value to test if the tx_power is
available.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
include/net/bluetooth/hci.h | 3 +++
net/bluetooth/hci_core.c | 2 ++
net/bluetooth/hci_event.c | 2 ++
net/bluetooth/mgmt.c | 2 +-
4 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 6c414f4..344fea0 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -319,6 +319,9 @@ enum {
#define HCI_FLOW_CTL_MODE_PACKET_BASED 0x00
#define HCI_FLOW_CTL_MODE_BLOCK_BASED 0x01
+/* The core spec defines 127 as the "not available" value */
+#define HCI_TX_POWER_INVALID 127
+
/* Extended Inquiry Response field types */
#define EIR_FLAGS 0x01 /* flags */
#define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index c68c409..0af08f3 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1606,6 +1606,8 @@ struct hci_dev *hci_alloc_dev(void)
hdev->esco_type = (ESCO_HV1);
hdev->link_mode = (HCI_LM_ACCEPT);
hdev->io_capability = 0x03; /* No Input No Output */
+ hdev->inq_tx_power = HCI_TX_POWER_INVALID;
+ hdev->adv_tx_power = HCI_TX_POWER_INVALID;
hdev->sniff_max_interval = 800;
hdev->sniff_min_interval = 80;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index c08ac7c..09c6571 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -202,6 +202,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
BIT(HCI_PERIODIC_INQ));
hdev->discovery.state = DISCOVERY_STOPPED;
+ hdev->inq_tx_power = HCI_TX_POWER_INVALID;
+ hdev->adv_tx_power = HCI_TX_POWER_INVALID;
}
static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 26a0984..ad1054f 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -485,7 +485,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
ptr += (name_len + 2);
}
- if (hdev->inq_tx_power) {
+ if (hdev->inq_tx_power != HCI_TX_POWER_INVALID) {
ptr[0] = 2;
ptr[1] = EIR_TX_POWER;
ptr[2] = (u8) hdev->inq_tx_power;
--
1.7.10.4
^ permalink raw reply related
* Re: [PATCH 2/3] Bluetooth: Add support for setting LE advertising data
From: Johan Hedberg @ 2012-11-08 0:17 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1352303722.16204.2.camel@aeonflux>
Hi Marcel,
On Wed, Nov 07, 2012, Marcel Holtmann wrote:
> > diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> > index 344fea0..705e2f0 100644
> > --- a/include/net/bluetooth/hci.h
> > +++ b/include/net/bluetooth/hci.h
> > @@ -338,6 +338,13 @@ enum {
> > #define EIR_SSP_RAND_R 0x0F /* Simple Pairing Randomizer R */
> > #define EIR_DEVICE_ID 0x10 /* device ID */
> >
> > +/* Low Energy Advertising Flags */
> > +#define LE_AD_LIMITED 0x01 /* Limited Discoverable */
> > +#define LE_AD_GENERAL 0x02 /* General Discoverable */
> > +#define LE_AD_NO_BREDR 0x04 /* BR/EDR not supported */
> > +#define LE_AD_SIM_LE_BREDR_CTRL 0x08 /* Simultaneous LE & BR/EDR Controller */
> > +#define LE_AD_SIM_LE_BREDR_HOST 0x10 /* Simultaneous LE & BR/EDR Host */
> > +
>
> is this bad formatting in the email client and they are actually
> aligned.
They're properly aligned (I double checked looking at the resulting code
itself)
> > @@ -942,6 +949,14 @@ struct hci_rp_le_read_adv_tx_power {
> > __s8 tx_power;
> > } __packed;
> >
> > +#define HCI_MAX_AD_LENGTH 31
> > +
> > +#define HCI_OP_LE_SET_ADV_DATA 0x2008
> > +struct hci_cp_le_set_adv_data {
> > + __u8 length;
> > + __u8 data[HCI_MAX_AD_LENGTH];
> > +} __packed;
> > +
>
> This indentation looks weird.
Agreed. Fixed in v2 (where I added your ack since I understood you were
otherwise fine with this patch.
Johan
^ permalink raw reply
* Re: DBus.Properties: help for remaining convertions
From: Luiz Augusto von Dentz @ 2012-11-07 22:34 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: BlueZ development
In-Reply-To: <CAMOw1v5q7eP2O4h6KtKNv0himHKA4pmg9STrxUczL_frYgECZA@mail.gmail.com>
Hi Lucas,
On Wed, Nov 7, 2012 at 9:20 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> Luiz, do you plan to convert to DBus.Properties after you finish the
> pending features you are doing? I think audio/transport.c is the only
> one still requiring a feature in gdbus: security check for the sender
> as discussed previously. I can add this when we are converting audio.
I can take care of converting the audio after we move it to profiles,
and yes we need the sender check for in gdbus, but that can come
latter.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: DBus.Properties: help for remaining convertions
From: Andrzej Kaczmarek @ 2012-11-07 19:51 UTC (permalink / raw)
To: Lucas De Marchi; +Cc: BlueZ development, Luiz Augusto von Dentz
In-Reply-To: <CAMOw1v5q7eP2O4h6KtKNv0himHKA4pmg9STrxUczL_frYgECZA@mail.gmail.com>
Hi Lucas,
On Wed, Nov 7, 2012 at 8:20 PM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> Hey!
>
> I stopped converting profiles to DBus.Properties due to some reasons
> like 1) lack of time; 2) I don't use or can't test the conversion or
> 3) I'm seeing a lots of patches to that profile and my changes would
> conflict.
>
>
> Here is a list of missing profiles (except audio):
> └ bluez ➤ git grep -l GetProperties | grep -e " | grep -v -e "^audio"
> attrib/client.c
> profiles/cups/main.c
> profiles/network/connection.c
> profiles/proximity/monitor.c
> profiles/proximity/reporter.c
> profiles/thermometer/thermometer.c
<snip>
> Anyone to step up and help to finish the conversions? The sooner these
> are finished, the sooner other projects can adapt themselves to the
> upcoming API.
I have patches for thermometer (together with some other changes
there) - just need to test them and will send soon.
BR,
Andrzej
^ permalink raw reply
* DBus.Properties: help for remaining convertions
From: Lucas De Marchi @ 2012-11-07 19:20 UTC (permalink / raw)
To: BlueZ development; +Cc: Luiz Augusto von Dentz
Hey!
I stopped converting profiles to DBus.Properties due to some reasons
like 1) lack of time; 2) I don't use or can't test the conversion or
3) I'm seeing a lots of patches to that profile and my changes would
conflict.
Here is a list of missing profiles (except audio):
└ bluez ➤ git grep -l GetProperties | grep -e " | grep -v -e "^audio"
attrib/client.c
profiles/cups/main.c
profiles/network/connection.c
profiles/proximity/monitor.c
profiles/proximity/reporter.c
profiles/thermometer/thermometer.c
Most of them are trivial and mostly a manual conversion job. These
fall in categories (1) and (2) above. If no one interested in that
profiles does the conversion, I'll try my best to convert them, but
I'd like they to at least check/ack the changes.
And the audio ones, in category (1) and (3) above:
└ bluez ➤ git grep -l GetProperties | grep -e " | grep -v -e "^audio"
audio/device.c
audio/gateway.c
audio/gstavdtpsink.c
audio/headset.c
audio/player.c
audio/sink.c
audio/source.c
audio/telephony-ofono.c
audio/transport.c
Luiz, do you plan to convert to DBus.Properties after you finish the
pending features you are doing? I think audio/transport.c is the only
one still requiring a feature in gdbus: security check for the sender
as discussed previously. I can add this when we are converting audio.
Anyone to step up and help to finish the conversions? The sooner these
are finished, the sooner other projects can adapt themselves to the
upcoming API.
Lucas De Marchi
^ permalink raw reply
* BLE issue - Reusing Existing LE physical link
From: Ajay @ 2012-11-07 16:44 UTC (permalink / raw)
To: linux-bluetooth
Hi ,
I came across an issue as part of my "BLE test tool project" . After
the first successful connection of BLE l2cap connection (client server)
, we just retains the physical link without calling le_connection
cancel() (logical link is closed) (patch has been added). But second
time i wanted to use the existing connection , without calling
hci_le_connect() . but here l2cap connect fails . I noticed in normal
acl link , the same scenario is working on existing link. so can we
do the same working on BLE link . (ubuntu 11.10 and kernel 3.2.5)
--
Thanks & regards
AJAY KV
GlobalEdge software Ltd
8892753703
^ permalink raw reply
* Re: [PATCH 3/3] Bluetooth: Fix updating advertising state flags and data
From: Marcel Holtmann @ 2012-11-07 15:56 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1352239600-5840-3-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> This patch adds a callback for the HCI_LE_Set_Advertise_Enable command.
> The callback is responsible for updating the HCI_LE_PERIPHERAL flag
> updating as well as updating the advertising data flags field to
> indicate undirected connectable advertising.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci.h | 2 ++
> net/bluetooth/hci_event.c | 31 +++++++++++++++++++++++++++++++
> 2 files changed, 33 insertions(+)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 2/3] Bluetooth: Add support for setting LE advertising data
From: Marcel Holtmann @ 2012-11-07 15:55 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1352239600-5840-2-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> This patch adds support for setting basing LE advertising data. The
> three elements supported for now are the advertising flags, the TX power
> and the friendly name.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci.h | 15 ++++++
> include/net/bluetooth/hci_core.h | 4 ++
> net/bluetooth/hci_core.c | 97 ++++++++++++++++++++++++++++++++++++++
> net/bluetooth/hci_event.c | 11 ++++-
> 4 files changed, 126 insertions(+), 1 deletion(-)
>
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 344fea0..705e2f0 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -338,6 +338,13 @@ enum {
> #define EIR_SSP_RAND_R 0x0F /* Simple Pairing Randomizer R */
> #define EIR_DEVICE_ID 0x10 /* device ID */
>
> +/* Low Energy Advertising Flags */
> +#define LE_AD_LIMITED 0x01 /* Limited Discoverable */
> +#define LE_AD_GENERAL 0x02 /* General Discoverable */
> +#define LE_AD_NO_BREDR 0x04 /* BR/EDR not supported */
> +#define LE_AD_SIM_LE_BREDR_CTRL 0x08 /* Simultaneous LE & BR/EDR Controller */
> +#define LE_AD_SIM_LE_BREDR_HOST 0x10 /* Simultaneous LE & BR/EDR Host */
> +
is this bad formatting in the email client and they are actually
aligned.
> /* ----- HCI Commands ---- */
> #define HCI_OP_NOP 0x0000
>
> @@ -942,6 +949,14 @@ struct hci_rp_le_read_adv_tx_power {
> __s8 tx_power;
> } __packed;
>
> +#define HCI_MAX_AD_LENGTH 31
> +
> +#define HCI_OP_LE_SET_ADV_DATA 0x2008
> +struct hci_cp_le_set_adv_data {
> + __u8 length;
> + __u8 data[HCI_MAX_AD_LENGTH];
> +} __packed;
> +
This indentation looks weird.
> #define HCI_OP_LE_SET_SCAN_PARAM 0x200b
> struct hci_cp_le_set_scan_param {
> __u8 type;
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index ce6dbeb..ef5b85d 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -279,6 +279,8 @@ struct hci_dev {
> struct le_scan_params le_scan_params;
>
> __s8 adv_tx_power;
> + __u8 adv_data[HCI_MAX_AD_LENGTH];
> + __u8 adv_data_len;
>
> int (*open)(struct hci_dev *hdev);
> int (*close)(struct hci_dev *hdev);
> @@ -734,6 +736,8 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
> u8 *randomizer);
> int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
>
> +int hci_update_ad(struct hci_dev *hdev);
> +
> void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
>
> int hci_recv_frame(struct sk_buff *skb);
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 0af08f3..0af3ea8 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -594,6 +594,102 @@ done:
> return err;
> }
>
> +static u16 create_ad(struct hci_dev *hdev, u8 *data)
> +{
> + u8 *ptr = data;
> + u16 ad_len = 0;
> + size_t name_len;
> + u8 flags = 0;
> +
> + if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags))
> + flags |= LE_AD_GENERAL;
> +
> + if (!lmp_bredr_capable(hdev))
> + flags |= LE_AD_NO_BREDR;
> +
> + if (lmp_le_br_capable(hdev))
> + flags |= LE_AD_SIM_LE_BREDR_CTRL;
> +
> + if (lmp_host_le_br_capable(hdev))
> + flags |= LE_AD_SIM_LE_BREDR_HOST;
> +
> + if (flags) {
> + BT_DBG("adv flags 0x%02x", flags);
> +
> + ptr[0] = 2;
> + ptr[1] = EIR_FLAGS;
> + ptr[2] = flags;
> +
> + ad_len += 3;
> + ptr += 3;
> + }
> +
> + if (hdev->adv_tx_power != HCI_TX_POWER_INVALID) {
> + ptr[0] = 2;
> + ptr[1] = EIR_TX_POWER;
> + ptr[2] = (u8) hdev->adv_tx_power;
> +
> + ad_len += 3;
> + ptr += 3;
> + }
> +
> + name_len = strlen(hdev->dev_name);
> + if (name_len > 0) {
> + size_t max_len = HCI_MAX_AD_LENGTH - ad_len - 2;
> +
> + if (name_len > max_len) {
> + name_len = max_len;
> + ptr[1] = EIR_NAME_SHORT;
> + } else
> + ptr[1] = EIR_NAME_COMPLETE;
> +
> + ptr[0] = name_len + 1;
> +
> + memcpy(ptr + 2, hdev->dev_name, name_len);
> +
> + ad_len += (name_len + 2);
> + ptr += (name_len + 2);
> + }
> +
> + return ad_len;
> +}
> +
> +int hci_update_ad(struct hci_dev *hdev)
> +{
> + struct hci_cp_le_set_adv_data cp;
> + u16 len;
> + int err;
> +
> + hci_dev_lock(hdev);
> +
> + if (!lmp_le_capable(hdev)) {
> + err = -EINVAL;
> + goto unlock;
> + }
> +
> + memset(&cp, 0, sizeof(cp));
> +
> + len = create_ad(hdev, cp.data);
> +
> + if (hdev->adv_data_len == len &&
> + memcmp(cp.data, hdev->adv_data, len) == 0) {
> + err = 0;
> + goto unlock;
> + }
> +
> + memcpy(hdev->adv_data, cp.data, sizeof(cp.data));
> + hdev->adv_data_len = len;
> +
> + cp.length = cpu_to_le16(len);
> +
> + err = hci_send_cmd(hdev, HCI_OP_LE_SET_ADV_DATA, sizeof(cp), &cp);
> +
> +unlock:
> + hci_dev_unlock(hdev);
> +
> + return err;
> +}
> +
> /* ---- HCI ioctl helpers ---- */
>
> int hci_dev_open(__u16 dev)
> @@ -651,6 +747,7 @@ int hci_dev_open(__u16 dev)
> hci_dev_hold(hdev);
> set_bit(HCI_UP, &hdev->flags);
> hci_notify(hdev, HCI_DEV_UP);
> + hci_update_ad(hdev);
> if (!test_bit(HCI_SETUP, &hdev->dev_flags) &&
> mgmt_valid_hdev(hdev)) {
> hci_dev_lock(hdev);
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 09c6571..7caea1a 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -204,6 +204,9 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
> hdev->discovery.state = DISCOVERY_STOPPED;
> hdev->inq_tx_power = HCI_TX_POWER_INVALID;
> hdev->adv_tx_power = HCI_TX_POWER_INVALID;
> +
> + memset(hdev->adv_data, 0, sizeof(hdev->adv_data));
> + hdev->adv_data_len = 0;
> }
>
> static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
> @@ -226,6 +229,9 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
>
> hci_dev_unlock(hdev);
>
> + if (!status && !test_bit(HCI_INIT, &hdev->flags))
> + hci_update_ad(hdev);
> +
> hci_req_complete(hdev, HCI_OP_WRITE_LOCAL_NAME, status);
> }
>
> @@ -1091,8 +1097,11 @@ static void hci_cc_le_read_adv_tx_power(struct hci_dev *hdev,
>
> BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
>
> - if (!rp->status)
> + if (!rp->status) {
> hdev->adv_tx_power = rp->tx_power;
> + if (!test_bit(HCI_INIT, &hdev->flags))
> + hci_update_ad(hdev);
> + }
>
> hci_req_complete(hdev, HCI_OP_LE_READ_ADV_TX_POWER, rp->status);
> }
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 1/3] Bluetooth: Use proper invalid value for tx_power
From: Marcel Holtmann @ 2012-11-07 15:53 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <1352239600-5840-1-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> The core specification defines 127 as the "not available" value (well,
> "reserved" for BR/EDR and "not available" for LE - but essentially the
> same). Therefore, instead of testing for 0 (which is in fact a valid
> value) we should be using this invalid value to test if the tx_power is
> available.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci.h | 3 +++
> net/bluetooth/hci_core.c | 2 ++
> net/bluetooth/hci_event.c | 2 ++
> net/bluetooth/mgmt.c | 2 +-
> 4 files changed, 8 insertions(+), 1 deletion(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* [PATCH v2] neard: Set device name in cache
From: Frédéric Danis @ 2012-11-07 14:40 UTC (permalink / raw)
To: linux-bluetooth
If device existed previously, it has been removed before calling of
btd_event_remote_name(), so this just update storage cache and name
property change of device object is not emitted.
---
plugins/neard.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index 8018977..8f8381c 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -42,6 +42,7 @@
#include "storage.h"
#include "agent.h"
#include "hcid.h"
+#include "event.h"
#define NEARD_NAME "org.neard"
#define NEARD_PATH "/"
@@ -293,8 +294,8 @@ static int process_eir(struct btd_adapter *adapter, uint8_t *eir, size_t size,
/* TODO handle incomplete name? */
if (eir_data.name)
- write_device_name(adapter_get_address(adapter), &eir_data.addr,
- BDADDR_BREDR, eir_data.name);
+ btd_event_remote_name(adapter_get_address(adapter),
+ &eir_data.addr, eir_data.name);
if (eir_data.hash)
btd_adapter_add_remote_oob_data(adapter, &eir_data.addr,
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH BlueZ 1/2] AVRCP: Add supported events field to session structure
From: Johan Hedberg @ 2012-11-07 14:35 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1352284442-6855-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
On Wed, Nov 07, 2012, Luiz Augusto von Dentz wrote:
> This simplify detecting which events are available depending on the role
> and version of the session.
> ---
> audio/avrcp.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
Both patches have been applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH BlueZ 1/2] AVRCP: Add supported events field to session structure
From: Lucas De Marchi @ 2012-11-07 14:15 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1352284442-6855-1-git-send-email-luiz.dentz@gmail.com>
On Wed, Nov 7, 2012 at 8:34 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This simplify detecting which events are available depending on the role
> and version of the session.
> ---
> audio/avrcp.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/audio/avrcp.c b/audio/avrcp.c
> index 3d9ecc7..ab9ffbf 100644
> --- a/audio/avrcp.c
> +++ b/audio/avrcp.c
> @@ -197,6 +197,7 @@ struct avrcp {
>
> unsigned int control_id;
> unsigned int browsing_id;
> + uint16_t supported_events;
> uint16_t registered_events;
> uint8_t transaction;
> uint8_t transaction_events[AVRCP_EVENT_LAST + 1];
> @@ -858,12 +859,12 @@ static uint8_t avrcp_handle_get_capabilities(struct avrcp *session,
>
> return AVC_CTYPE_STABLE;
> case CAP_EVENTS_SUPPORTED:
> - pdu->params[1] = 5;
> - pdu->params[2] = AVRCP_EVENT_STATUS_CHANGED;
> - pdu->params[3] = AVRCP_EVENT_TRACK_CHANGED;
> - pdu->params[4] = AVRCP_EVENT_TRACK_REACHED_START;
> - pdu->params[5] = AVRCP_EVENT_TRACK_REACHED_END;
> - pdu->params[6] = AVRCP_EVENT_SETTINGS_CHANGED;
> + for (i = 0; i <= AVRCP_EVENT_LAST; i++) {
> + if (session->supported_events & (1 << i)) {
> + pdu->params[1]++;
> + pdu->params[pdu->params[1] + 1] = i;
> + }
> + }
>
> pdu->params_len = htons(2 + pdu->params[1]);
> return AVC_CTYPE_STABLE;
> @@ -2064,6 +2065,11 @@ static void session_tg_init(struct avrcp *session)
> }
>
> session->control_handlers = tg_control_handlers;
> + session->supported_events = (1 << AVRCP_EVENT_STATUS_CHANGED) |
> + (1 << AVRCP_EVENT_TRACK_CHANGED) |
> + (1 << AVRCP_EVENT_TRACK_REACHED_START) |
> + (1 << AVRCP_EVENT_TRACK_REACHED_END) |
> + (1 << AVRCP_EVENT_SETTINGS_CHANGED);
>
> if (session->version >= 0x0104) {
> avrcp_register_notification(session,
> --
> 1.7.11.7
>
Ack
Lucas De Marchi
^ permalink raw reply
* [PATCH] neard: Set device name in cache and device object
From: Frédéric Danis @ 2012-11-07 11:02 UTC (permalink / raw)
To: linux-bluetooth
---
plugins/neard.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index 8018977..8f8381c 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -42,6 +42,7 @@
#include "storage.h"
#include "agent.h"
#include "hcid.h"
+#include "event.h"
#define NEARD_NAME "org.neard"
#define NEARD_PATH "/"
@@ -293,8 +294,8 @@ static int process_eir(struct btd_adapter *adapter, uint8_t *eir, size_t size,
/* TODO handle incomplete name? */
if (eir_data.name)
- write_device_name(adapter_get_address(adapter), &eir_data.addr,
- BDADDR_BREDR, eir_data.name);
+ btd_event_remote_name(adapter_get_address(adapter),
+ &eir_data.addr, eir_data.name);
if (eir_data.hash)
btd_adapter_add_remote_oob_data(adapter, &eir_data.addr,
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ 2/2] AVRCP: Add support for GetCapabilities PDU when acting as controller
From: Luiz Augusto von Dentz @ 2012-11-07 10:34 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1352284442-6855-1-git-send-email-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds GetCapabilities PDU id to controller handlers vtable so it is
able to respond it properly.
---
audio/avrcp.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/audio/avrcp.c b/audio/avrcp.c
index ab9ffbf..e3ce2fb 100644
--- a/audio/avrcp.c
+++ b/audio/avrcp.c
@@ -1412,6 +1412,8 @@ static const struct control_pdu_handler tg_control_handlers[] = {
};
static const struct control_pdu_handler ct_control_handlers[] = {
+ { AVRCP_GET_CAPABILITIES, AVC_CTYPE_STATUS,
+ avrcp_handle_get_capabilities },
{ },
};
--
1.7.11.7
^ permalink raw reply related
* [PATCH BlueZ 1/2] AVRCP: Add supported events field to session structure
From: Luiz Augusto von Dentz @ 2012-11-07 10:34 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This simplify detecting which events are available depending on the role
and version of the session.
---
audio/avrcp.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/audio/avrcp.c b/audio/avrcp.c
index 3d9ecc7..ab9ffbf 100644
--- a/audio/avrcp.c
+++ b/audio/avrcp.c
@@ -197,6 +197,7 @@ struct avrcp {
unsigned int control_id;
unsigned int browsing_id;
+ uint16_t supported_events;
uint16_t registered_events;
uint8_t transaction;
uint8_t transaction_events[AVRCP_EVENT_LAST + 1];
@@ -858,12 +859,12 @@ static uint8_t avrcp_handle_get_capabilities(struct avrcp *session,
return AVC_CTYPE_STABLE;
case CAP_EVENTS_SUPPORTED:
- pdu->params[1] = 5;
- pdu->params[2] = AVRCP_EVENT_STATUS_CHANGED;
- pdu->params[3] = AVRCP_EVENT_TRACK_CHANGED;
- pdu->params[4] = AVRCP_EVENT_TRACK_REACHED_START;
- pdu->params[5] = AVRCP_EVENT_TRACK_REACHED_END;
- pdu->params[6] = AVRCP_EVENT_SETTINGS_CHANGED;
+ for (i = 0; i <= AVRCP_EVENT_LAST; i++) {
+ if (session->supported_events & (1 << i)) {
+ pdu->params[1]++;
+ pdu->params[pdu->params[1] + 1] = i;
+ }
+ }
pdu->params_len = htons(2 + pdu->params[1]);
return AVC_CTYPE_STABLE;
@@ -2064,6 +2065,11 @@ static void session_tg_init(struct avrcp *session)
}
session->control_handlers = tg_control_handlers;
+ session->supported_events = (1 << AVRCP_EVENT_STATUS_CHANGED) |
+ (1 << AVRCP_EVENT_TRACK_CHANGED) |
+ (1 << AVRCP_EVENT_TRACK_REACHED_START) |
+ (1 << AVRCP_EVENT_TRACK_REACHED_END) |
+ (1 << AVRCP_EVENT_SETTINGS_CHANGED);
if (session->version >= 0x0104) {
avrcp_register_notification(session,
--
1.7.11.7
^ permalink raw reply related
* Re: About a newer bluez version
From: Johan Hedberg @ 2012-11-06 22:29 UTC (permalink / raw)
To: Pacho Ramos; +Cc: linux-bluetooth
In-Reply-To: <1352233126.15613.19.camel@belkin4>
Hi Pacho,
On Tue, Nov 06, 2012, Pacho Ramos wrote:
> Looks like there are a lot of fixed committed to git since bluez-4.101,
> do you plan to release a new tarball including them soon?
The reason why there has been a longer delay is that we're busy
preparing BlueZ 5. The target is to have 5.0 out still this year.
Johan
^ permalink raw reply
* [PATCH 3/3] Bluetooth: Fix updating advertising state flags and data
From: Johan Hedberg @ 2012-11-06 22:06 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1352239600-5840-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch adds a callback for the HCI_LE_Set_Advertise_Enable command.
The callback is responsible for updating the HCI_LE_PERIPHERAL flag
updating as well as updating the advertising data flags field to
indicate undirected connectable advertising.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci.h | 2 ++
net/bluetooth/hci_event.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 705e2f0..a7ed8fe 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -957,6 +957,8 @@ struct hci_cp_le_set_adv_data {
__u8 data[HCI_MAX_AD_LENGTH];
} __packed;
+#define HCI_OP_LE_SET_ADV_ENABLE 0x200a
+
#define HCI_OP_LE_SET_SCAN_PARAM 0x200b
struct hci_cp_le_set_scan_param {
__u8 type;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 7caea1a..9f5c5f2 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1190,6 +1190,33 @@ static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev,
hci_dev_unlock(hdev);
}
+static void hci_cc_le_set_adv_enable(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ __u8 *sent, status = *((__u8 *) skb->data);
+
+ BT_DBG("%s status 0x%2.2x", hdev->name, status);
+
+ sent = hci_sent_cmd_data(hdev, HCI_OP_LE_SET_ADV_ENABLE);
+ if (!sent)
+ return;
+
+ hci_dev_lock(hdev);
+
+ if (!status) {
+ if (*sent)
+ set_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags);
+ else
+ clear_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags);
+ }
+
+ hci_dev_unlock(hdev);
+
+ if (!test_bit(HCI_INIT, &hdev->flags))
+ hci_update_ad(hdev);
+
+ hci_req_complete(hdev, HCI_OP_LE_SET_ADV_ENABLE, status);
+}
+
static void hci_cc_le_set_scan_param(struct hci_dev *hdev, struct sk_buff *skb)
{
__u8 status = *((__u8 *) skb->data);
@@ -2585,6 +2612,10 @@ static void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
hci_cc_le_set_scan_param(hdev, skb);
break;
+ case HCI_OP_LE_SET_ADV_ENABLE:
+ hci_cc_le_set_adv_enable(hdev, skb);
+ break;
+
case HCI_OP_LE_SET_SCAN_ENABLE:
hci_cc_le_set_scan_enable(hdev, skb);
break;
--
1.7.10.4
^ permalink raw reply related
* [PATCH 2/3] Bluetooth: Add support for setting LE advertising data
From: Johan Hedberg @ 2012-11-06 22:06 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1352239600-5840-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
This patch adds support for setting basing LE advertising data. The
three elements supported for now are the advertising flags, the TX power
and the friendly name.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci.h | 15 ++++++
include/net/bluetooth/hci_core.h | 4 ++
net/bluetooth/hci_core.c | 97 ++++++++++++++++++++++++++++++++++++++
net/bluetooth/hci_event.c | 11 ++++-
4 files changed, 126 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 344fea0..705e2f0 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -338,6 +338,13 @@ enum {
#define EIR_SSP_RAND_R 0x0F /* Simple Pairing Randomizer R */
#define EIR_DEVICE_ID 0x10 /* device ID */
+/* Low Energy Advertising Flags */
+#define LE_AD_LIMITED 0x01 /* Limited Discoverable */
+#define LE_AD_GENERAL 0x02 /* General Discoverable */
+#define LE_AD_NO_BREDR 0x04 /* BR/EDR not supported */
+#define LE_AD_SIM_LE_BREDR_CTRL 0x08 /* Simultaneous LE & BR/EDR Controller */
+#define LE_AD_SIM_LE_BREDR_HOST 0x10 /* Simultaneous LE & BR/EDR Host */
+
/* ----- HCI Commands ---- */
#define HCI_OP_NOP 0x0000
@@ -942,6 +949,14 @@ struct hci_rp_le_read_adv_tx_power {
__s8 tx_power;
} __packed;
+#define HCI_MAX_AD_LENGTH 31
+
+#define HCI_OP_LE_SET_ADV_DATA 0x2008
+struct hci_cp_le_set_adv_data {
+ __u8 length;
+ __u8 data[HCI_MAX_AD_LENGTH];
+} __packed;
+
#define HCI_OP_LE_SET_SCAN_PARAM 0x200b
struct hci_cp_le_set_scan_param {
__u8 type;
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index ce6dbeb..ef5b85d 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -279,6 +279,8 @@ struct hci_dev {
struct le_scan_params le_scan_params;
__s8 adv_tx_power;
+ __u8 adv_data[HCI_MAX_AD_LENGTH];
+ __u8 adv_data_len;
int (*open)(struct hci_dev *hdev);
int (*close)(struct hci_dev *hdev);
@@ -734,6 +736,8 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
u8 *randomizer);
int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
+int hci_update_ad(struct hci_dev *hdev);
+
void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
int hci_recv_frame(struct sk_buff *skb);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 0af08f3..0af3ea8 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -594,6 +594,102 @@ done:
return err;
}
+static u16 create_ad(struct hci_dev *hdev, u8 *data)
+{
+ u8 *ptr = data;
+ u16 ad_len = 0;
+ size_t name_len;
+ u8 flags = 0;
+
+ if (test_bit(HCI_LE_PERIPHERAL, &hdev->dev_flags))
+ flags |= LE_AD_GENERAL;
+
+ if (!lmp_bredr_capable(hdev))
+ flags |= LE_AD_NO_BREDR;
+
+ if (lmp_le_br_capable(hdev))
+ flags |= LE_AD_SIM_LE_BREDR_CTRL;
+
+ if (lmp_host_le_br_capable(hdev))
+ flags |= LE_AD_SIM_LE_BREDR_HOST;
+
+ if (flags) {
+ BT_DBG("adv flags 0x%02x", flags);
+
+ ptr[0] = 2;
+ ptr[1] = EIR_FLAGS;
+ ptr[2] = flags;
+
+ ad_len += 3;
+ ptr += 3;
+ }
+
+ if (hdev->adv_tx_power != HCI_TX_POWER_INVALID) {
+ ptr[0] = 2;
+ ptr[1] = EIR_TX_POWER;
+ ptr[2] = (u8) hdev->adv_tx_power;
+
+ ad_len += 3;
+ ptr += 3;
+ }
+
+ name_len = strlen(hdev->dev_name);
+ if (name_len > 0) {
+ size_t max_len = HCI_MAX_AD_LENGTH - ad_len - 2;
+
+ if (name_len > max_len) {
+ name_len = max_len;
+ ptr[1] = EIR_NAME_SHORT;
+ } else
+ ptr[1] = EIR_NAME_COMPLETE;
+
+ ptr[0] = name_len + 1;
+
+ memcpy(ptr + 2, hdev->dev_name, name_len);
+
+ ad_len += (name_len + 2);
+ ptr += (name_len + 2);
+ }
+
+ return ad_len;
+}
+
+int hci_update_ad(struct hci_dev *hdev)
+{
+ struct hci_cp_le_set_adv_data cp;
+ u16 len;
+ int err;
+
+ hci_dev_lock(hdev);
+
+ if (!lmp_le_capable(hdev)) {
+ err = -EINVAL;
+ goto unlock;
+ }
+
+ memset(&cp, 0, sizeof(cp));
+
+ len = create_ad(hdev, cp.data);
+
+ if (hdev->adv_data_len == len &&
+ memcmp(cp.data, hdev->adv_data, len) == 0) {
+ err = 0;
+ goto unlock;
+ }
+
+ memcpy(hdev->adv_data, cp.data, sizeof(cp.data));
+ hdev->adv_data_len = len;
+
+ cp.length = cpu_to_le16(len);
+
+ err = hci_send_cmd(hdev, HCI_OP_LE_SET_ADV_DATA, sizeof(cp), &cp);
+
+unlock:
+ hci_dev_unlock(hdev);
+
+ return err;
+}
+
/* ---- HCI ioctl helpers ---- */
int hci_dev_open(__u16 dev)
@@ -651,6 +747,7 @@ int hci_dev_open(__u16 dev)
hci_dev_hold(hdev);
set_bit(HCI_UP, &hdev->flags);
hci_notify(hdev, HCI_DEV_UP);
+ hci_update_ad(hdev);
if (!test_bit(HCI_SETUP, &hdev->dev_flags) &&
mgmt_valid_hdev(hdev)) {
hci_dev_lock(hdev);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 09c6571..7caea1a 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -204,6 +204,9 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
hdev->discovery.state = DISCOVERY_STOPPED;
hdev->inq_tx_power = HCI_TX_POWER_INVALID;
hdev->adv_tx_power = HCI_TX_POWER_INVALID;
+
+ memset(hdev->adv_data, 0, sizeof(hdev->adv_data));
+ hdev->adv_data_len = 0;
}
static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
@@ -226,6 +229,9 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
hci_dev_unlock(hdev);
+ if (!status && !test_bit(HCI_INIT, &hdev->flags))
+ hci_update_ad(hdev);
+
hci_req_complete(hdev, HCI_OP_WRITE_LOCAL_NAME, status);
}
@@ -1091,8 +1097,11 @@ static void hci_cc_le_read_adv_tx_power(struct hci_dev *hdev,
BT_DBG("%s status 0x%2.2x", hdev->name, rp->status);
- if (!rp->status)
+ if (!rp->status) {
hdev->adv_tx_power = rp->tx_power;
+ if (!test_bit(HCI_INIT, &hdev->flags))
+ hci_update_ad(hdev);
+ }
hci_req_complete(hdev, HCI_OP_LE_READ_ADV_TX_POWER, rp->status);
}
--
1.7.10.4
^ permalink raw reply related
* [PATCH 1/3] Bluetooth: Use proper invalid value for tx_power
From: Johan Hedberg @ 2012-11-06 22:06 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
The core specification defines 127 as the "not available" value (well,
"reserved" for BR/EDR and "not available" for LE - but essentially the
same). Therefore, instead of testing for 0 (which is in fact a valid
value) we should be using this invalid value to test if the tx_power is
available.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci.h | 3 +++
net/bluetooth/hci_core.c | 2 ++
net/bluetooth/hci_event.c | 2 ++
net/bluetooth/mgmt.c | 2 +-
4 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 6c414f4..344fea0 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -319,6 +319,9 @@ enum {
#define HCI_FLOW_CTL_MODE_PACKET_BASED 0x00
#define HCI_FLOW_CTL_MODE_BLOCK_BASED 0x01
+/* The core spec defines 127 as the "not available" value */
+#define HCI_TX_POWER_INVALID 127
+
/* Extended Inquiry Response field types */
#define EIR_FLAGS 0x01 /* flags */
#define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index c68c409..0af08f3 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1606,6 +1606,8 @@ struct hci_dev *hci_alloc_dev(void)
hdev->esco_type = (ESCO_HV1);
hdev->link_mode = (HCI_LM_ACCEPT);
hdev->io_capability = 0x03; /* No Input No Output */
+ hdev->inq_tx_power = HCI_TX_POWER_INVALID;
+ hdev->adv_tx_power = HCI_TX_POWER_INVALID;
hdev->sniff_max_interval = 800;
hdev->sniff_min_interval = 80;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index c08ac7c..09c6571 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -202,6 +202,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
BIT(HCI_PERIODIC_INQ));
hdev->discovery.state = DISCOVERY_STOPPED;
+ hdev->inq_tx_power = HCI_TX_POWER_INVALID;
+ hdev->adv_tx_power = HCI_TX_POWER_INVALID;
}
static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 26a0984..ad1054f 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -485,7 +485,7 @@ static void create_eir(struct hci_dev *hdev, u8 *data)
ptr += (name_len + 2);
}
- if (hdev->inq_tx_power) {
+ if (hdev->inq_tx_power != HCI_TX_POWER_INVALID) {
ptr[0] = 2;
ptr[1] = EIR_TX_POWER;
ptr[2] = (u8) hdev->inq_tx_power;
--
1.7.10.4
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox