* [PATCH] l2test: add support to the fixed channels
From: Gustavo F. Padovan @ 2010-07-12 21:31 UTC (permalink / raw)
To: linux-bluetooth
---
test/l2test.c | 26 +++++++++++++++++++++-----
1 files changed, 21 insertions(+), 5 deletions(-)
diff --git a/test/l2test.c b/test/l2test.c
index 0bb46f3..17883a9 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -85,9 +85,10 @@ static int max_transmit = 3;
static long data_size = -1;
static long buffer_size = 2048;
-/* Default addr and psm */
+/* Default addr and psm and cid */
static bdaddr_t bdaddr;
static unsigned short psm = 10;
+static unsigned short cid = 0;
/* Default number of frames to send (-1 = infinite) */
static int num_frames = -1;
@@ -287,7 +288,12 @@ static int do_connect(char *svr)
memset(&addr, 0, sizeof(addr));
addr.l2_family = AF_BLUETOOTH;
str2ba(svr, &addr.l2_bdaddr);
- addr.l2_psm = htobs(psm);
+ if (cid)
+ addr.l2_cid = htobs(cid);
+ else if (psm)
+ addr.l2_psm = htobs(psm);
+ else
+ goto error;
if (connect(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0 ) {
syslog(LOG_ERR, "Can't connect: %s (%d)",
@@ -351,7 +357,12 @@ static void do_listen(void (*handler)(int sk))
memset(&addr, 0, sizeof(addr));
addr.l2_family = AF_BLUETOOTH;
bacpy(&addr.l2_bdaddr, &bdaddr);
- addr.l2_psm = htobs(psm);
+ if (cid)
+ addr.l2_cid = htobs(cid);
+ else if (psm)
+ addr.l2_psm = htobs(psm);
+ else
+ goto error;
if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
syslog(LOG_ERR, "Can't bind socket: %s (%d)",
@@ -437,6 +448,7 @@ static void do_listen(void (*handler)(int sk))
}
psm = btohs(addr.l2_psm);
+ cid = btohs(addr.l2_cid);
syslog(LOG_INFO, "Waiting for connection on psm %d ...", psm);
@@ -1063,7 +1075,7 @@ static void usage(void)
"\t-z information request\n");
printf("Options:\n"
- "\t[-b bytes] [-i device] [-P psm]\n"
+ "\t[-b bytes] [-i device] [-P psm] [-J cid]\n"
"\t[-I imtu] [-O omtu]\n"
"\t[-L seconds] enable SO_LINGER\n"
"\t[-W seconds] enable deferred setup\n"
@@ -1092,7 +1104,7 @@ int main(int argc, char *argv[])
bacpy(&bdaddr, BDADDR_ANY);
- while ((opt=getopt(argc,argv,"rdscuwmntqxyzpb:i:P:I:O:B:N:L:W:C:D:X:F:Q:Z:RUGAESMT")) != EOF) {
+ while ((opt=getopt(argc,argv,"rdscuwmntqxyzpb:i:P:I:O:J:B:N:L:W:C:D:X:F:Q:Z:RUGAESMT")) != EOF) {
switch(opt) {
case 'r':
mode = RECV;
@@ -1256,6 +1268,10 @@ int main(int argc, char *argv[])
txwin_size = atoi(optarg);
break;
+ case 'J':
+ cid = atoi(optarg);
+ break;
+
default:
usage();
exit(1);
--
1.7.1
^ permalink raw reply related
* [PATCH 2/2] Bluetooth: Add Fixed Channels support to connect()
From: Gustavo F. Padovan @ 2010-07-12 21:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: marcel, Gustavo F. Padovan
In-Reply-To: <1278969545-26864-1-git-send-email-gustavo@padovan.org>
From: Gustavo F. Padovan <padovan@profusion.mobi>
All the Fixed Channel shall be set up with SOCK_DGRAM passing the channel
id too. If you don't inform the channel id, L2CAP will use the
Connectionless channel (0x0002), which was already the default channel for
SOCK_DGRAM.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
net/bluetooth/l2cap.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 39f047b..132197e 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -229,9 +229,14 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, struct so
/* Alloc CID for connection-oriented socket */
l2cap_pi(sk)->scid = l2cap_alloc_cid(l);
} else if (sk->sk_type == SOCK_DGRAM) {
- /* Connectionless socket */
- l2cap_pi(sk)->scid = L2CAP_CID_CONN_LESS;
- l2cap_pi(sk)->dcid = L2CAP_CID_CONN_LESS;
+ if (l2cap_pi(sk)->scid) {
+ /* Fixed channels */
+ l2cap_pi(sk)->dcid = l2cap_pi(sk)->scid;
+ } else {
+ /* Connectionless socket */
+ l2cap_pi(sk)->scid = L2CAP_CID_CONN_LESS;
+ l2cap_pi(sk)->dcid = L2CAP_CID_CONN_LESS;
+ }
l2cap_pi(sk)->omtu = L2CAP_DEFAULT_MTU;
} else {
/* Raw socket can send/recv signalling messages only */
@@ -1164,7 +1169,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al
len = min_t(unsigned int, sizeof(la), alen);
memcpy(&la, addr, len);
- if (la.l2_cid)
+ if (la.l2_psm && la.l2_cid)
return -EINVAL;
lock_sock(sk);
@@ -1213,6 +1218,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al
/* Set destination address and psm */
bacpy(&bt_sk(sk)->dst, &la.l2_bdaddr);
l2cap_pi(sk)->psm = la.l2_psm;
+ l2cap_pi(sk)->scid = la.l2_cid;
err = l2cap_do_connect(sk);
if (err)
--
1.7.1
^ permalink raw reply related
* [PATCH 1/2] Bluetooth: Add Fixed Channels support to bind syscall.
From: Gustavo F. Padovan @ 2010-07-12 21:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: marcel, Gustavo F. Padovan
From: Gustavo F. Padovan <padovan@profusion.mobi>
L2CAP nows support bind to a fixed channel, this is needed for Low Energy
and AMP.
bind returns error if you pass both PSM and CID values.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
net/bluetooth/l2cap.c | 48 +++++++++++++++++++++++++++++++++++-------------
1 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 449cbdd..39f047b 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -726,7 +726,7 @@ static inline void l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, stru
}
/* ---- Socket interface ---- */
-static struct sock *__l2cap_get_sock_by_addr(__le16 psm, bdaddr_t *src)
+static struct sock *__l2cap_sock_by_psm_addr(__le16 psm, bdaddr_t *src)
{
struct sock *sk;
struct hlist_node *node;
@@ -738,6 +738,16 @@ found:
return sk;
}
+static struct sock *__l2cap_sock_by_cid_addr(__le16 cid, bdaddr_t *src)
+{
+ struct sock *sk;
+ struct hlist_node *node;
+ sk_for_each(sk, node, &l2cap_sk_list.head)
+ if (l2cap_pi(sk)->scid == cid && !bacmp(&bt_sk(sk)->src, src))
+ return sk;
+ return NULL;
+}
+
/* Find socket with psm and source bdaddr.
* Returns closest match.
*/
@@ -996,7 +1006,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
len = min_t(unsigned int, sizeof(la), alen);
memcpy(&la, addr, len);
- if (la.l2_cid)
+ if (la.l2_cid && la.l2_psm)
return -EINVAL;
lock_sock(sk);
@@ -1014,18 +1024,30 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
write_lock_bh(&l2cap_sk_list.lock);
- if (la.l2_psm && __l2cap_get_sock_by_addr(la.l2_psm, &la.l2_bdaddr)) {
- err = -EADDRINUSE;
- } else {
- /* Save source address */
- bacpy(&bt_sk(sk)->src, &la.l2_bdaddr);
- l2cap_pi(sk)->psm = la.l2_psm;
- l2cap_pi(sk)->sport = la.l2_psm;
- sk->sk_state = BT_BOUND;
+ if (la.l2_psm) {
+ if (__l2cap_sock_by_psm_addr(la.l2_psm, &la.l2_bdaddr)) {
+ err = -EADDRINUSE;
+ } else {
+ /* Save source address */
+ bacpy(&bt_sk(sk)->src, &la.l2_bdaddr);
+ l2cap_pi(sk)->psm = la.l2_psm;
+ l2cap_pi(sk)->sport = la.l2_psm;
+ sk->sk_state = BT_BOUND;
- if (__le16_to_cpu(la.l2_psm) == 0x0001 ||
+ if (__le16_to_cpu(la.l2_psm) == 0x0001 ||
__le16_to_cpu(la.l2_psm) == 0x0003)
- l2cap_pi(sk)->sec_level = BT_SECURITY_SDP;
+ l2cap_pi(sk)->sec_level = BT_SECURITY_SDP;
+ }
+ } else if (la.l2_cid) {
+ /* Save source address */
+ if (__l2cap_sock_by_cid_addr(la.l2_cid, &la.l2_bdaddr)) {
+ err = -EADDRINUSE;
+ } else {
+ bacpy(&bt_sk(sk)->src, &la.l2_bdaddr);
+ l2cap_pi(sk)->scid = la.l2_cid;
+ l2cap_pi(sk)->sport = la.l2_cid;
+ sk->sk_state = BT_BOUND;
+ }
}
write_unlock_bh(&l2cap_sk_list.lock);
@@ -1241,7 +1263,7 @@ static int l2cap_sock_listen(struct socket *sock, int backlog)
write_lock_bh(&l2cap_sk_list.lock);
for (psm = 0x1001; psm < 0x1100; psm += 2)
- if (!__l2cap_get_sock_by_addr(cpu_to_le16(psm), src)) {
+ if (!__l2cap_sock_by_psm_addr(cpu_to_le16(psm), src)) {
l2cap_pi(sk)->psm = cpu_to_le16(psm);
l2cap_pi(sk)->sport = cpu_to_le16(psm);
err = 0;
--
1.7.1
^ permalink raw reply related
* Re: [PATCH 3/3] Bluetooth: Synchronize SCO/eSCO connection requests to ACL state
From: Ron Shaffer @ 2010-07-12 21:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: marcel, Ron Shaffer
In-Reply-To: <1278625779.10421.80.camel@localhost.localdomain>
Certain headsets such as the Motorola H350 will reject SCO and eSCO
connection requests while the ACL is transitioning from sniff mode
to active mode. Add synchronization so that SCO and eSCO connection
requests will wait until the ACL has fully transitioned to active mode.
Signed-off-by: Ron Shaffer <rshaffer@codeaurora.org>
---
include/net/bluetooth/hci_core.h | 1 +
net/bluetooth/hci_conn.c | 18 ++++++++++++++++++
net/bluetooth/hci_event.c | 22 +++++++++++++++++++++-
3 files changed, 40 insertions(+), 1 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index fd53323..c4a37fc 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -250,6 +250,7 @@ enum {
HCI_CONN_ENCRYPT_PEND,
HCI_CONN_RSWITCH_PEND,
HCI_CONN_MODE_CHANGE_PEND,
+ HCI_CONN_SCO_PEND,
};
static inline void hci_conn_hash_init(struct hci_dev *hdev)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 9bf4308..ffc67ac 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -117,9 +117,18 @@ void hci_add_sco(struct hci_conn *conn, __u16 handle)
{
struct hci_dev *hdev = conn->hdev;
struct hci_cp_add_sco cp;
+ struct hci_conn *acl = conn->link;
BT_DBG("%p", conn);
+ if (acl->mode == HCI_CM_SNIFF &&
+ test_bit(HCI_CONN_MODE_CHANGE_PEND, &acl->pend)) {
+ set_bit(HCI_CONN_SCO_PEND, &conn->pend);
+ return;
+ }
+
+ test_and_clear_bit(HCI_CONN_SCO_PEND, &conn->pend);
+
conn->state = BT_CONNECT;
conn->out = 1;
@@ -135,9 +144,18 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle)
{
struct hci_dev *hdev = conn->hdev;
struct hci_cp_setup_sync_conn cp;
+ struct hci_conn *acl = conn->link;
BT_DBG("%p", conn);
+ if (acl->mode == HCI_CM_SNIFF &&
+ test_bit(HCI_CONN_MODE_CHANGE_PEND, &acl->pend)) {
+ set_bit(HCI_CONN_SCO_PEND, &conn->pend);
+ return;
+ }
+
+ test_and_clear_bit(HCI_CONN_SCO_PEND, &conn->pend);
+
conn->state = BT_CONNECT;
conn->out = 1;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 3af537a..c3a05e1 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -615,6 +615,7 @@ static void hci_cs_add_sco(struct hci_dev *hdev, __u8 status)
acl = hci_conn_hash_lookup_handle(hdev, handle);
if (acl && (sco = acl->link)) {
sco->state = BT_CLOSED;
+ clear_bit(HCI_CONN_SCO_PEND, &sco->pend);
hci_proto_connect_cfm(sco, status);
hci_conn_del(sco);
@@ -760,6 +761,7 @@ static void hci_cs_setup_sync_conn(struct hci_dev *hdev, __u8 status)
acl = hci_conn_hash_lookup_handle(hdev, handle);
if (acl && (sco = acl->link)) {
sco->state = BT_CLOSED;
+ clear_bit(HCI_CONN_SCO_PEND, &sco->pend);
hci_proto_connect_cfm(sco, status);
hci_conn_del(sco);
@@ -795,6 +797,7 @@ static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status)
{
struct hci_cp_exit_sniff_mode *cp;
struct hci_conn *conn;
+ struct hci_conn *sco;
BT_DBG("%s status 0x%x", hdev->name, status);
@@ -808,9 +811,16 @@ static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status)
hci_dev_lock(hdev);
conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(cp->handle));
- if (conn)
+ if (conn) {
clear_bit(HCI_CONN_MODE_CHANGE_PEND, &conn->pend);
+ sco = conn->link;
+ if (sco && test_and_clear_bit(HCI_CONN_SCO_PEND, &sco->pend)) {
+ hci_proto_connect_cfm(sco, status);
+ hci_conn_del(sco);
+ }
+ }
+
hci_dev_unlock(hdev);
}
@@ -1463,6 +1473,7 @@ static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb
{
struct hci_ev_mode_change *ev = (void *) skb->data;
struct hci_conn *conn;
+ struct hci_conn *sco;
BT_DBG("%s status %d", hdev->name, ev->status);
@@ -1478,6 +1489,15 @@ static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb
conn->power_save = 1;
else
conn->power_save = 0;
+ } else {
+ sco = conn->link;
+ if (sco && test_and_clear_bit(HCI_CONN_SCO_PEND,
+ &sco->pend)) {
+ if (lmp_esco_capable(hdev))
+ hci_setup_sync(sco, conn->handle);
+ else
+ hci_add_sco(sco, conn->handle);
+ }
}
}
--
1.7.0.2
--
Ron Shaffer
Employee of the Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
^ permalink raw reply related
* [PATCH 05/36] drivers/bluetooth: Remove unnecessary casts of private_data
From: Joe Perches @ 2010-07-12 20:49 UTC (permalink / raw)
To: Jiri Kosina; +Cc: linux-kernel, Marcel Holtmann, linux-bluetooth
In-Reply-To: <cover.1278967120.git.joe@perches.com>
Signed-off-by: Joe Perches <joe@perches.com>
---
drivers/bluetooth/btmrvl_debugfs.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c
index b50b41d..54739b0 100644
--- a/drivers/bluetooth/btmrvl_debugfs.c
+++ b/drivers/bluetooth/btmrvl_debugfs.c
@@ -216,7 +216,7 @@ static const struct file_operations btmrvl_gpiogap_fops = {
static ssize_t btmrvl_hscmd_write(struct file *file, const char __user *ubuf,
size_t count, loff_t *ppos)
{
- struct btmrvl_private *priv = (struct btmrvl_private *) file->private_data;
+ struct btmrvl_private *priv = file->private_data;
char buf[16];
long result, ret;
--
1.7.1.337.g6068.dirty
^ permalink raw reply related
* Re: [PATCH] Proposed API for HDP
From: Marcel Holtmann @ 2010-07-12 20:40 UTC (permalink / raw)
To: Jose Antonio Santos Cadenas; +Cc: linux-bluetooth
In-Reply-To: <1278967013-8064-1-git-send-email-santoscadenas@gmail.com>
Hi Jose,
> ---
> doc/health-api.txt | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 168 insertions(+), 0 deletions(-)
> create mode 100644 doc/health-api.txt
patch has been applied. Thanks.
Regards
Marcel
^ permalink raw reply
* [PATCH] Proposed API for HDP
From: Jose Antonio Santos Cadenas @ 2010-07-12 20:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jose Antonio Santos Cadenas
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 5239 bytes --]
---
doc/health-api.txt | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 168 insertions(+), 0 deletions(-)
create mode 100644 doc/health-api.txt
diff --git a/doc/health-api.txt b/doc/health-api.txt
new file mode 100644
index 0000000..6b5a485
--- /dev/null
+++ b/doc/health-api.txt
@@ -0,0 +1,168 @@
+BlueZ D-Bus Health API description
+**********************************
+
+ Santiago Carot-Nemesio <sancane@gmail.com>
+ José Antonio Santos-Cadenas <santoscadenas@gmail.com>
+ Elvis Pfützenreuter <epx@signove.com>
+
+Health Device Profile hierarchy
+===============================
+
+Service org.bluez
+Interface org.bluez.HealthManager
+Object path /org/bluez/
+
+Methods:
+
+ object RegisterApplication(object agent, dict config)
+
+ Returns the path of the new registered application. The agent
+ parameter is the path of the object with the callbacks to
+ notify events (see org.bluez.HealthAgent at the end
+ of this document).
+
+ Dict is defined as bellow:
+ {
+ "DataType": uint16, (mandatory)
+ "Role" : ("Source" or "Sink"), (mandatory)
+ "Description" : string, (optional)
+ "ChannelType" : ("Reliable" or "Streaming")
+ (just for Sources, optional)
+ }
+
+ Application will be closed by the call or implicitly when the
+ programs leaves the bus.
+
+ Possible errors: org.bluez.Error.InvalidArguments
+
+ void UnregisterApplication(object application)
+
+ Closes the HDP application identified by the object path. Also
+ application will be closed if the process that started it leaves
+ the bus.
+
+ Possible errors: org.bluez.Error.InvalidArguments
+ org.bluez.Error.NotFound
+
+--------------------------------------------------------------------------------
+
+Service org.bluez
+Interface org.bluez.HealthApplication
+Object path [variable prefix]/health_app_ZZZZ
+
+Methods:
+
+ void Echo(object service)
+
+ Sends an echo petition to the remote service. Returns True if
+ response matches with the buffer sent. If some error is detected
+ False value is returned and the associated MCL is closed.
+
+ Possible errors: org.bluez.Error.InvalidArguments
+ org.bluez.Error.OutOfRange
+
+ object CreateChannel(object service, string type)
+
+ Creates a new data channel with the indicated config to the
+ remote Service.
+ The configuration should indicate the channel quality of
+ service using one of this values "Reliable", "Streaming", "Any".
+
+ Returns the object path that identifies the data channel that
+ is already connected.
+
+ Possible errors: org.bluez.Error.InvalidArguments
+ org.bluez.Error.HealthError
+
+ void DestroyChannel(object channel)
+
+ Destroys the data channel object.
+
+ Possible errors: org.bluez.Error.InvalidArguments
+ orb.bluez.Error.NotFound
+
+--------------------------------------------------------------------------------
+
+Service org.bluez
+Interface org.bluez.HealthService
+Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/hdp_YYYY
+
+--------------------------------------------------------------------------------
+
+Service org.bluez
+Interface org.bluez.HealthChannel
+Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/
+ hdp_YYYY/channel_ZZ
+
+Methods:
+
+ dict GetProperties()
+
+ Returns all properties for the interface. See the properties
+ section for available properties.
+
+ fd Acquire()
+
+ Returns the file descriptor for this data channel. If the data
+ channel is not connected it will also reconnect.
+
+ Possible errors: org.bluez.Error.NotConnected
+
+ void Release()
+
+ Releases the fd. Application should also need to close() it.
+
+Properties:
+
+ string Type (read only)
+
+ The quality of service of the data channel. ("Reliable" or
+ "Streaming")
+
+ object Service (read only)
+
+ Identifies the Remote Service that is connected with. Maps with
+ a HealthService object.
+
+HealthAgent hierarchy
+=====================
+
+(this object is implemented by the HDP user in order to receive notifications)
+
+Service unique name
+Interface org.bluez.HealthAgent
+Object path freely definable
+
+Methods:
+
+ void Release()
+
+ This method gets called when the service daemon unregisters the
+ agent. An agent can use it to do cleanup tasks. There is no need
+ to unregister the agent, because when this method gets called it
+ has already been unregistered.
+
+ void ServiceDiscovered(object service)
+
+ This method is called when a device containing an HDP
+ application is paired or when the method Update of the
+ HealthManager is called and new HealthServices are discovered.
+ The method will be called once for each HealthService.
+
+ void ServiceRemoved(object service)
+
+ This is called if during an Update some HealthServices
+ have disappeared. The method is called once for each removed
+ HealthService.
+
+ void ChannelConnected(object channel)
+
+ This method is called when a new data channel is created or when
+ a known data channel is reconnected.
+
+ void ChannelDeleted(object channel)
+
+ This method is called when a data channel is deleted.
+
+ After this call the data channel path will not be valid and can
+ be reused for future creation of data channels.
--
1.7.0.4
^ permalink raw reply related
* Re: [PATCH 2/2] Code consitency for signal strength in HFP maemo6
From: Hedberg Johan (Nokia-D/Helsinki) @ 2010-07-12 17:36 UTC (permalink / raw)
To: Dmitriy Paliy; +Cc: linux-bluetooth
In-Reply-To: <1278954361-3876-1-git-send-email-dmitriy.paliy@nokia.com>
Hi Dmitriy,
On Mon, Jul 12, 2010, Dmitriy Paliy wrote:
> This patch simplifies and makes maemo6 telephony driver code consistent
> with libscnet API regarding SignalBarsChanged. RSSI percents and RSSI
> dBs are not among the parameters when SignalBarsChanged emited.
> Therefore, these parameters are removed. Names are changed to reflect
> libscnet d-bus interface notations. Comments and debug information are
> updated in places where units or operations are unclear.
> ---
> audio/telephony-maemo6.c | 46 +++++++++++++++++++++++-----------------------
> 1 files changed, 23 insertions(+), 23 deletions(-)
This patch has also been pushed upstream, but I had to make the
following manual fixes before that:
> + /* Init as 0 meaning inactive mode. In modem power off state */
> + /* can be be -1, but we treat all values as 0s regardless */
> + /* inactive or power off. */
All three lines have tabs and spaces for intentation (one tab + one
space) and the second line has an extra space at the end before the
newline character.
> +static void update_signal_strength(int32_t signal_strength_bars)
The variable name is unnecessarlily long. Simply signal_bars is better
imho.
> + if (signal_strength_bars < 0) {
> + DBG("signal strength smaller than expected: %d<0", signal_strength_bars);
> + signal_strength_bars = 0;
> + } else if (signal_strength_bars > 5) {
> + DBG("signal strength greater than expected: %d>5", signal_strength_bars);
> + signal_strength_bars = 5;
You're going beyond the 80 character limit here and the extra long
variable name isn't really helping out with that.
> + telephony_update_indicator(maemo_indicators, "signal", signal_strength_bars);
Same here.
Normally I'd have asked you to fix these things, but since we're trying
to get a new release out I went ahead and did it myself. So in the
future please pay attention to this kind of issues :)
Johan
^ permalink raw reply
* Re: [PATCH 1/2] Fix signal strength for HFP in maemo6 telephony
From: Hedberg Johan (Nokia-D/Helsinki) @ 2010-07-12 17:31 UTC (permalink / raw)
To: Dmitriy Paliy; +Cc: linux-bluetooth
In-Reply-To: <1278954283-3832-1-git-send-email-dmitriy.paliy@nokia.com>
Hi Dmitriy,
On Mon, Jul 12, 2010, Dmitriy Paliy wrote:
> Signal strength in terms of bars units is updated by emited
> SignalBarsChanged instead of SignalStrengthChanged from libscnet library.
> It contains required number of bars to display in scale 0..5. Conversion
> from percent or decibel units to bars is not needed and therefore removed.
>
> Same holds when initializing by request of SignalBars, where bars are in
> 0..5 range. Conversion from percents is removed. Sanity check is done to
> prevent -1 that may be returned when the property is unavailabe (modem
> state off).
>
> RSSI percents and dBs are neither present among SignalBarsChanged
> properties nor requested during initialization and, therefore, removed.
> ---
> audio/telephony-maemo6.c | 20 +++++++++-----------
> 1 files changed, 9 insertions(+), 11 deletions(-)
This patch has been pushed upstream. Thanks.
Johan
^ permalink raw reply
* [PATCH 2/2] Code consitency for signal strength in HFP maemo6
From: Dmitriy Paliy @ 2010-07-12 17:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Dmitriy Paliy
This patch simplifies and makes maemo6 telephony driver code consistent
with libscnet API regarding SignalBarsChanged. RSSI percents and RSSI
dBs are not among the parameters when SignalBarsChanged emited.
Therefore, these parameters are removed. Names are changed to reflect
libscnet d-bus interface notations. Comments and debug information are
updated in places where units or operations are unclear.
---
audio/telephony-maemo6.c | 46 +++++++++++++++++++++++-----------------------
1 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/audio/telephony-maemo6.c b/audio/telephony-maemo6.c
index d5499ed..0e2a3d4 100644
--- a/audio/telephony-maemo6.c
+++ b/audio/telephony-maemo6.c
@@ -134,11 +134,14 @@ struct csd_call {
static struct {
char *operator_name;
uint8_t status;
- int32_t signals_bar;
+ int32_t signal_bars;
} net = {
.operator_name = NULL,
.status = NETWORK_REG_STATUS_UNKOWN,
- .signals_bar = 0,
+ /* Init as 0 meaning inactive mode. In modem power off state */
+ /* can be be -1, but we treat all values as 0s regardless */
+ /* inactive or power off. */
+ .signal_bars = 0,
};
static int get_property(const char *iface, const char *prop);
@@ -181,6 +184,7 @@ static guint create_request_timer = 0;
static struct indicator maemo_indicators[] =
{
{ "battchg", "0-5", 5, TRUE },
+ /* signal strength in terms of bars */
{ "signal", "0-5", 0, TRUE },
{ "service", "0,1", 0, TRUE },
{ "call", "0,1", 0, TRUE },
@@ -1227,41 +1231,37 @@ static void handle_registration_changed(DBusMessage *msg)
update_registration_status(status);
}
-static void update_signal_strength(int32_t signals_bar)
+static void update_signal_strength(int32_t signal_strength_bars)
{
- int signal;
-
- if (signals_bar < 0)
- signals_bar = 0;
- else if (signals_bar > 5) {
- DBG("signals_bar greater than expected: %u", signals_bar);
- signals_bar = 5;
+ if (signal_strength_bars < 0) {
+ DBG("signal strength smaller than expected: %d<0", signal_strength_bars);
+ signal_strength_bars = 0;
+ } else if (signal_strength_bars > 5) {
+ DBG("signal strength greater than expected: %d>5", signal_strength_bars);
+ signal_strength_bars = 5;
}
- if (net.signals_bar == signals_bar)
+ if (net.signal_bars == signal_strength_bars)
return;
- /* no need in any conversion */
- signal = signals_bar;
-
- telephony_update_indicator(maemo_indicators, "signal", signal);
+ telephony_update_indicator(maemo_indicators, "signal", signal_strength_bars);
- net.signals_bar = signals_bar;
- DBG("telephony-maemo6: signal strength updated: %d/5", signal);
+ net.signal_bars = signal_strength_bars;
+ DBG("telephony-maemo6: signal strength updated: %d/5", signal_strength_bars);
}
-static void handle_signal_strength_changed(DBusMessage *msg)
+static void handle_signal_bars_changed(DBusMessage *msg)
{
- int32_t signals_bar;
+ int32_t signal_bars;
if (!dbus_message_get_args(msg, NULL,
- DBUS_TYPE_INT32, &signals_bar,
+ DBUS_TYPE_INT32, &signal_bars,
DBUS_TYPE_INVALID)) {
error("Unexpected parameters in SignalBarsChanged");
return;
}
- update_signal_strength(signals_bar);
+ update_signal_strength(signal_bars);
}
static gboolean iter_get_basic_args(DBusMessageIter *iter,
@@ -1528,7 +1528,7 @@ static void get_property_reply(DBusPendingCall *call, void *user_data)
dbus_message_iter_get_basic(&sub, &name);
update_operator_name(name);
} else if (g_strcmp0(prop, "SignalBars") == 0) {
- int32_t signal_bars; /* signal bars can be -1 */
+ int32_t signal_bars;
dbus_message_iter_get_basic(&sub, &signal_bars);
update_signal_strength(signal_bars);
@@ -1898,7 +1898,7 @@ static DBusHandlerResult signal_filter(DBusConnection *conn,
handle_operator_name_changed(msg);
else if (dbus_message_is_signal(msg, CSD_CSNET_SIGNAL,
"SignalBarsChanged"))
- handle_signal_strength_changed(msg);
+ handle_signal_bars_changed(msg);
else if (dbus_message_is_signal(msg, "org.freedesktop.Hal.Device",
"PropertyModified"))
handle_hal_property_modified(msg);
--
1.7.0.4
^ permalink raw reply related
* Re: [PATCH 2/2] Show P-bit in the l2cap parser
From: Johan Hedberg @ 2010-07-12 17:04 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
In-Reply-To: <1278953750-18646-2-git-send-email-gustavo@padovan.org>
Hi Gustavo,
On Mon, Jul 12, 2010, Gustavo F. Padovan wrote:
> ---
> parser/l2cap.c | 2 ++
> 1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/parser/l2cap.c b/parser/l2cap.c
> index 174cd3a..ee869dc 100644
> --- a/parser/l2cap.c
> +++ b/parser/l2cap.c
> @@ -848,6 +848,8 @@ static void l2cap_parse(int level, struct frame *frm)
> printf(" ReqSeq %d", (ctrl & 0x3f00) >> 8);
> if (ctrl & 0x80)
> printf(" F-bit");
> + if (ctrl & 0x10)
> + printf(" P-bit");
> printf("\n");
> }
> }
This one is upstream now too. Thanks.
Johan
^ permalink raw reply
* [PATCH 1/2] Fix signal strength for HFP in maemo6 telephony
From: Dmitriy Paliy @ 2010-07-12 17:04 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Dmitriy Paliy
Signal strength in terms of bars units is updated by emited
SignalBarsChanged instead of SignalStrengthChanged from libscnet library.
It contains required number of bars to display in scale 0..5. Conversion
from percent or decibel units to bars is not needed and therefore removed.
Same holds when initializing by request of SignalBars, where bars are in
0..5 range. Conversion from percents is removed. Sanity check is done to
prevent -1 that may be returned when the property is unavailabe (modem
state off).
RSSI percents and dBs are neither present among SignalBarsChanged
properties nor requested during initialization and, therefore, removed.
---
audio/telephony-maemo6.c | 20 +++++++++-----------
1 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/audio/telephony-maemo6.c b/audio/telephony-maemo6.c
index 31704c3..d5499ed 100644
--- a/audio/telephony-maemo6.c
+++ b/audio/telephony-maemo6.c
@@ -1233,33 +1233,31 @@ static void update_signal_strength(int32_t signals_bar)
if (signals_bar < 0)
signals_bar = 0;
- else if (signals_bar > 100) {
+ else if (signals_bar > 5) {
DBG("signals_bar greater than expected: %u", signals_bar);
- signals_bar = 100;
+ signals_bar = 5;
}
if (net.signals_bar == signals_bar)
return;
- /* A simple conversion from 0-100 to 0-5 (used by HFP) */
- signal = (signals_bar + 20) / 21;
+ /* no need in any conversion */
+ signal = signals_bar;
telephony_update_indicator(maemo_indicators, "signal", signal);
net.signals_bar = signals_bar;
-
- DBG("telephony-maemo6: signal strength updated: %u/100, %d/5", signals_bar, signal);
+ DBG("telephony-maemo6: signal strength updated: %d/5", signal);
}
static void handle_signal_strength_changed(DBusMessage *msg)
{
- int32_t signals_bar, rssi_in_dbm;
+ int32_t signals_bar;
if (!dbus_message_get_args(msg, NULL,
DBUS_TYPE_INT32, &signals_bar,
- DBUS_TYPE_INT32, &rssi_in_dbm,
DBUS_TYPE_INVALID)) {
- error("Unexpected parameters in SignalStrengthChanged");
+ error("Unexpected parameters in SignalBarsChanged");
return;
}
@@ -1530,7 +1528,7 @@ static void get_property_reply(DBusPendingCall *call, void *user_data)
dbus_message_iter_get_basic(&sub, &name);
update_operator_name(name);
} else if (g_strcmp0(prop, "SignalBars") == 0) {
- uint32_t signal_bars;
+ int32_t signal_bars; /* signal bars can be -1 */
dbus_message_iter_get_basic(&sub, &signal_bars);
update_signal_strength(signal_bars);
@@ -1899,7 +1897,7 @@ static DBusHandlerResult signal_filter(DBusConnection *conn,
"OperatorNameChanged"))
handle_operator_name_changed(msg);
else if (dbus_message_is_signal(msg, CSD_CSNET_SIGNAL,
- "SignalStrengthChanged"))
+ "SignalBarsChanged"))
handle_signal_strength_changed(msg);
else if (dbus_message_is_signal(msg, "org.freedesktop.Hal.Device",
"PropertyModified"))
--
1.7.0.4
^ permalink raw reply related
* Re: [PATCH 1/2] Show F-bit instead of Retransmission Disable
From: Johan Hedberg @ 2010-07-12 17:04 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
In-Reply-To: <1278953750-18646-1-git-send-email-gustavo@padovan.org>
Hi Gustavo,
On Mon, Jul 12, 2010, Gustavo F. Padovan wrote:
> "F-bit" make more sense for the Enhanced Retranstransmission mode.
> ---
> parser/l2cap.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/parser/l2cap.c b/parser/l2cap.c
> index ad3b7ff..174cd3a 100644
> --- a/parser/l2cap.c
> +++ b/parser/l2cap.c
> @@ -847,7 +847,7 @@ static void l2cap_parse(int level, struct frame *frm)
> }
> printf(" ReqSeq %d", (ctrl & 0x3f00) >> 8);
> if (ctrl & 0x80)
> - printf(" Retransmission Disable");
> + printf(" F-bit");
> printf("\n");
> }
> }
The patch is now upstream. Thanks.
Johan
^ permalink raw reply
* [PATCH 2/2] Show P-bit in the l2cap parser
From: Gustavo F. Padovan @ 2010-07-12 16:55 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1278953750-18646-1-git-send-email-gustavo@padovan.org>
---
parser/l2cap.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/parser/l2cap.c b/parser/l2cap.c
index 174cd3a..ee869dc 100644
--- a/parser/l2cap.c
+++ b/parser/l2cap.c
@@ -848,6 +848,8 @@ static void l2cap_parse(int level, struct frame *frm)
printf(" ReqSeq %d", (ctrl & 0x3f00) >> 8);
if (ctrl & 0x80)
printf(" F-bit");
+ if (ctrl & 0x10)
+ printf(" P-bit");
printf("\n");
}
}
--
1.7.1
^ permalink raw reply related
* [PATCH 1/2] Show F-bit instead of Retransmission Disable
From: Gustavo F. Padovan @ 2010-07-12 16:55 UTC (permalink / raw)
To: linux-bluetooth
"F-bit" make more sense for the Enhanced Retranstransmission mode.
---
parser/l2cap.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/parser/l2cap.c b/parser/l2cap.c
index ad3b7ff..174cd3a 100644
--- a/parser/l2cap.c
+++ b/parser/l2cap.c
@@ -847,7 +847,7 @@ static void l2cap_parse(int level, struct frame *frm)
}
printf(" ReqSeq %d", (ctrl & 0x3f00) >> 8);
if (ctrl & 0x80)
- printf(" Retransmission Disable");
+ printf(" F-bit");
printf("\n");
}
}
--
1.7.1
^ permalink raw reply related
* Re: [PATCH] Bluetooth: Add HCIUARTSETFLAGS and HCIUARTGETFLAGS ioctls
From: Marcel Holtmann @ 2010-07-12 14:49 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth, Johan Hedberg
In-Reply-To: <1278945424-11047-1-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> This patch introduces two new ioctls: HCIUARTSETFLAGS and
> HCIUARTGETFLAGS. The only flag available for now is HCI_UART_RAW_DEVICE
> which allows to initialize a UART device into RAW mode from userspace.
> This is particularly useful for experimenting with Bluetooth controllers
> that don't yet have proper support in BlueZ.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
patch has been applied. Thanks.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH v5 1/3] Implements hci_reassembly to reassemble Rx packets
From: Marcel Holtmann @ 2010-07-12 14:45 UTC (permalink / raw)
To: Suraj Sumangala; +Cc: linux-bluetooth, Jothikumar.Mothilal
In-Reply-To: <1278936744-6003-1-git-send-email-suraj@atheros.com>
Hi Suraj,
> Implements feature to reassemble HCI frames received from an input stream.
>
> Signed-off-by: Suraj Sumangala <suraj@atheros.com>
> ---
> net/bluetooth/hci_core.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 106 insertions(+), 0 deletions(-)
>
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index aeb2982..e1ede0b 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -1033,6 +1033,112 @@ int hci_recv_frame(struct sk_buff *skb)
> }
> EXPORT_SYMBOL(hci_recv_frame);
>
> +static int hci_reassembly(struct hci_dev *hdev, int type, void *data,
> + int count, struct sk_buff **skb_ptr, gfp_t how)
> +{
so while reviewing this patch, I seems to make more sense to just give
an index to the reassembly SKB instead of trying to hand it as an extra
output parameter.
So reassembly[0] can be used for streams and [1..3] for packet specific
types then. That needs a small patch first to extend the array to 4
entries, but that should be just fine.
This meaning we do index = 0 for stream reassembly and index = type - 1
for packet type based reassembly.
Especially since this method is fully internal to bluetooth.ko I would
actually prefer this.
And "gfp_t gfp_mask" please.
> + int len = 0;
> + int header_len = 0;
We generally called this hlen.
> + int remain = count;
> + struct sk_buff *skb = *skb_ptr;
> + struct { struct bt_skb_cb cb_info; int expect; } *scb;
Why do we need this double scb. We could just extend our current
bt_skb_cb. Just put "u16 expect" after incoming.
Regards
Marcel
^ permalink raw reply
* [PATCH] Bluetooth: Add HCIUARTSETFLAGS and HCIUARTGETFLAGS ioctls
From: johan.hedberg @ 2010-07-12 14:37 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Johan Hedberg
From: Johan Hedberg <johan.hedberg@nokia.com>
This patch introduces two new ioctls: HCIUARTSETFLAGS and
HCIUARTGETFLAGS. The only flag available for now is HCI_UART_RAW_DEVICE
which allows to initialize a UART device into RAW mode from userspace.
This is particularly useful for experimenting with Bluetooth controllers
that don't yet have proper support in BlueZ.
Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
---
drivers/bluetooth/hci_ldisc.c | 12 ++++++++++++
drivers/bluetooth/hci_uart.h | 7 ++++++-
fs/compat_ioctl.c | 2 ++
3 files changed, 20 insertions(+), 1 deletions(-)
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index e8beffe..a57dbfc 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -395,6 +395,9 @@ static int hci_uart_register_dev(struct hci_uart *hu)
if (!reset)
set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
+ if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags))
+ set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
+
if (hci_register_dev(hdev) < 0) {
BT_ERR("Can't register HCI device");
hci_free_dev(hdev);
@@ -475,6 +478,15 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file,
return hu->hdev->id;
return -EUNATCH;
+ case HCIUARTSETFLAGS:
+ if (test_bit(HCI_UART_PROTO_SET, &hu->flags))
+ return -EBUSY;
+ hu->hdev_flags = arg;
+ break;
+
+ case HCIUARTGETFLAGS:
+ return hu->hdev_flags;
+
default:
err = n_tty_ioctl_helper(tty, file, cmd, arg);
break;
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h
index 50113db..9694d9d 100644
--- a/drivers/bluetooth/hci_uart.h
+++ b/drivers/bluetooth/hci_uart.h
@@ -31,6 +31,8 @@
#define HCIUARTSETPROTO _IOW('U', 200, int)
#define HCIUARTGETPROTO _IOR('U', 201, int)
#define HCIUARTGETDEVICE _IOR('U', 202, int)
+#define HCIUARTSETFLAGS _IOW('U', 203, int)
+#define HCIUARTGETFLAGS _IOR('U', 204, int)
/* UART protocols */
#define HCI_UART_MAX_PROTO 5
@@ -41,6 +43,8 @@
#define HCI_UART_H4DS 3
#define HCI_UART_LL 4
+#define HCI_UART_RAW_DEVICE 0
+
struct hci_uart;
struct hci_uart_proto {
@@ -57,6 +61,7 @@ struct hci_uart {
struct tty_struct *tty;
struct hci_dev *hdev;
unsigned long flags;
+ unsigned long hdev_flags;
struct hci_uart_proto *proto;
void *priv;
@@ -66,7 +71,7 @@ struct hci_uart {
spinlock_t rx_lock;
};
-/* HCI_UART flag bits */
+/* HCI_UART proto flag bits */
#define HCI_UART_PROTO_SET 0
/* TX states */
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 547452d..8ea5e33 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -604,6 +604,8 @@ static int ioc_settimeout(unsigned int fd, unsigned int cmd,
#define HCIUARTSETPROTO _IOW('U', 200, int)
#define HCIUARTGETPROTO _IOR('U', 201, int)
#define HCIUARTGETDEVICE _IOR('U', 202, int)
+#define HCIUARTSETFLAGS _IOW('U', 203, int)
+#define HCIUARTGETFLAGS _IOR('U', 204, int)
#define BNEPCONNADD _IOW('B', 200, int)
#define BNEPCONNDEL _IOW('B', 201, int)
--
1.7.0.4
^ permalink raw reply related
* HDP API
From: José Antonio Santos Cadenas @ 2010-07-12 14:25 UTC (permalink / raw)
To: linux-bluetooth
Hi all,
We have been working in a new version of the HDP D-Bus API.
It will be great to have your feedback about it, especially in some points:
- Two agents classes one for the hole application an other for each end
point.
- Signals for notifying the remote services and a property for getting
them also (Similar to the adapter API)
Regards
BlueZ D-Bus Health API description
**********************************
Santiago Carot-Nemesio <sancane@gmail.com>
José Antonio Santos-Cadenas <santoscadenas@gmail.com>
Elvis Pfützenreuter <epx@signove.com>
Health Device Profile hierarchy
===============================
Service org.bluez
Interface org.bluez.HealthManager
Object path [variable prefix]/
Methods:
path RegisterApplication(object agent, dict config)
Returns the path of the new registered application. The agent
parameter is the path of the object with the callbacks to
notify events (see org.bluez.HealthApplicationAgent at the end
of this document)
This petition starts an mcap instance on every adapter and also
registers a proper record in the SDP if needed.
Dict is defined as bellow:
{
"end_points" : [{ (optional)
"agent": path, (mapped with HealthApplicationAgent)
"role" : ("Source" or "Sink"), (mandatory)
"specs" :[{ (mandatory)
"data_type" : uint16, (mandatory)
"description" : string, (optional)
"config" : ("Reliable" or "Streaming") (for Sources)
}]
}]
}
Application will be closed by the call or implicitly when the
programs leaves the bus.
Possible errors: org.bluez.Error.InvalidArguments
void UnregisterApplication(object application)
Closes the HDP application identified by the object path. Also
application will be closed if the process that started it leaves
the bus. If there is a SDP record associated to this application
it will also be removed.
Possible errors: org.bluez.Error.InvalidArguments
org.bluez.Error.NotFound
void UpdateServices()
This method searches for HDP applications on the all remote
devices and notifies them to the appropriate agents.
dict GetProperties()
Returns all properties for the interface. See the
properties section for available properties.
Properties:
array Services (read only)
An array with the paths of all the services.
Signals:
void ServiceDiscovered(object service)
This signal is sent when a device containing an HDP
application is paired or when the method Update of the
HealthManager is called and new HealthServices are discovered.
The object path is the HealthService path. The signal will be
sent once for each HealthService.
void ServiceRemoved(object service)
This signal is sent if during an Update some HealthServices
have disappeared. The signal is sent once for each removed
HealthService.
--------------------------------------------------------------------------------
Service org.bluez
Interface org.bluez.HealthService
Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/hdp_YYYY
Methods:
dict GetProperties()
Returns all properties for the interface. See the properties
section for available properties.
boolean Echo(string app, array{byte})
Sends an echo petition to the remote service. Returns True if
response matches with the buffer sent. If some error is detected
False value is returned and the associated MCL is closed.
object OpenDataChannel(string app, string end_point, string conf)
Creates a new data channel with the indicated config to the
remote MCAP Data End Point.
The configuration should indicate the channel quality of
service using one of this values "Reliable", "Streaming", "Any".
Returns the object path that identifies the data channel.
Possible errors: org.bluez.Error.InvalidArguments
org.bluez.Error.HealthError
void DeleteAllDataChannels(string app)
Deletes all data channels so they will not be available for
future use.
Possible errors: org.bluez.Error.HealthError
Properties:
array EndPoints (read only)
An array with all the end points in this Service. Each one of
then has this format.
{
"end_point": string,
"role" : "source" or "sink" ,
"specs" : [{
"dtype" : uint16,
"description" : string, (optional)
}]
}
--------------------------------------------------------------------------------
Service org.bluez
Interface org.bluez.HealthDataChannel
Object path [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/
hdp_YYYY/channel_ZZ
Methods:
dict GetProperties()
Returns all properties for the interface. See the properties
section for available properties.
fd Acquire()
Returns the file descriptor for the data channel_ZZ
Possible errors: org.bluez.Error.NotConnected
void Remove()
Closes the data channel and no other future uses will be
possible. This object will be also removed.
void Reconnect()
Reconnects the data channel.
Properties:
string QualityOfService (read only)
The quality of service of the data channel.
boolean Connected (read only)
True if the data channel is connected
HealthApplicationAgent hierarchy
================================
(this object is implemented by the HDP user in order to receive notifications)
Service unique name
Interface org.bluez.HealthApplicationAgent
Object path freely definable
Methods:
void Release()
This method gets called when the service daemon unregisters the
agent. An agent can use it to do cleanup tasks. There is no need
to unregister the agent, because when this method gets called it
has already been unregistered.
void DataChannelRemoved(object service, string data_channel)
This method is called when a data channel is deleted.
After this call the data channel path will not be valid and can
be reused for future creation of data channels.
HealthEndPointAgent hierarchy
================================
(this object is implemented by the HDP user in order to receive notifications)
Service unique name
Interface org.bluez.HealthEndPointAgent
Object path freely definable
Methods:
void Release()
This method gets called when the service daemon unregisters the
agent. An agent can use it to do cleanup tasks. There is no need
to unregister the agent, because when this method gets called it
has already been unregistered.
void DataChannelCreated(string data_channel, boolean reconnection)
This method is called when a new data channel is created.
The service parameter contains the object path of the
HealthService that created the connection, data_channel is
the string that identifies the data channel, conf is the quality
of service of the data channel ("reliable" or "streaming"),
file_descriptor the file descriptor for reading and writing
data and reconnection indicates if it is a reconnection or a
data channel creation.
^ permalink raw reply
* RE: [RFC] Bluetooth: Add firmware load infrastructure for BT devices
From: Marcel Holtmann @ 2010-07-12 12:50 UTC (permalink / raw)
To: Shanmugamkamatchi Balashanmugam
Cc: Perelet, Oleg, linux-bluetooth@vger.kernel.org
In-Reply-To: <44EE5C37ADC36343B0625A05DD408C4850DB2A7D69@CHEXMB-01.global.atheros.com>
Hi Bala,
> > Firmware loading to target RAM needs to be done once when the device is inserted. Firmware loading will not be required every time
> > the device goes from DOWN to UP. I think each HCI driver requires
> > a separate firmware loading code as firmware loading is
> > different for different interfaces. Please advice if my understanding is wrong.
> >
> > I initially thought of registration
> > mechanism with btusb transport driver to load firmware, but before
> > the device is inserted btusb will not be loaded and registering the
> > firmware load function with btusb was not possible.
> >
> > Please advice alternate solution to load firmware from transport driver.
>
> >my advise would be to just build devices that change their USB VID/PID
> >after the firmware got loaded. That way it is easy to have a firmware
> >loading driver and just btusb for real operation. Why is it so hard to
> >build just simple hardware that would just work.
>
> Thanks for the suggestion.
> This is what is done for some of the devices.
> For performance reasons few other devices comes with
> small firmware in flash and the device gets detected as
> generic bluetooth device when plugged in. So control reaches btusb
> once the device is plugged in. In this case actual firmware
> needs to be downloaded to target from btusb transport driver.
is this simple firmware already talking HCI at that point or is it some
USB protocol to load the rest of the firmware.
Regards
Marcel
^ permalink raw reply
* Problem connecting headset with bluez >= 4.64
From: Michal 'vorner' Vaner @ 2010-07-12 12:48 UTC (permalink / raw)
To: linux-bluetooth
[-- Attachment #1: Type: text/plain, Size: 3168 bytes --]
Hello
I have a bluetooth headset/headphones. However, I have a problem to connect to
them on one of my machines (while other two machines work well). Downgrading to
version 4.63 helps. In that case, bluetooth outputs something like this (this is
for the HSP profile, the A2DP acts similarly):
bluetoothd[19610]: State changed /org/bluez/19610/hci0/dev_00_19_7F_1B_E8_BE: HEADSET_STATE_DISCONNECTED -> HEADSET_STATE_CONNECTING
bluetoothd[19610]: link_key_request (sba=00:19:86:00:10:FE, dba=00:19:7F:1B:E8:BE)
bluetoothd[19610]: kernel auth requirements = 0x00
bluetoothd[19610]: stored link key type = 0x00
bluetoothd[19610]: adapter_get_device(00:19:7F:1B:E8:BE)
bluetoothd[19610]: Discovered Handsfree service on channel 1
bluetoothd[19610]: /org/bluez/19610/hci0/dev_00_19_7F_1B_E8_BE: Connecting to 00:19:7F:1B:E8:BE channel 1
bluetoothd[19610]: /org/bluez/19610/hci0/dev_00_19_7F_1B_E8_BE: Connected to 00:19:7F:1B:E8:BE
bluetoothd[19610]: Received AT+BRSF=24
bluetoothd[19610]: HFP HF features: "Voice recognition activation" "Remote volume control"
Then, the headphones appear in pulseaudio as a sink and I can hear sound.
While, with 4.64 or anything newer, it outputs this:
bluetoothd[23165]: State changed /org/bluez/23165/hci0/dev_00_19_7F_1B_E8_BE: HEADSET_STATE_DISCONNECTED -> HEADSET_STATE_CONNECTING
bluetoothd[23165]: link_key_request (sba=00:19:86:00:10:FE, dba=00:19:7F:1B:E8:BE)
bluetoothd[23165]: kernel auth requirements = 0x00
bluetoothd[23165]: stored link key type = 0x00
bluetoothd[23165]: adapter_get_device(00:19:7F:1B:E8:BE)
bluetoothd[23165]: Discovered Handsfree service on channel 1
bluetoothd[23165]: /org/bluez/23165/hci0/dev_00_19_7F_1B_E8_BE: Connecting to 00:19:7F:1B:E8:BE channel 1
bluetoothd[23165]: hcid_dbus_bonding_process_complete: status=00
bluetoothd[23165]: adapter_get_device(00:19:7F:1B:E8:BE)
bluetoothd[23165]: hcid_dbus_bonding_process_complete: no pending auth request # Here is really long pause, 1-2 seconds
bluetoothd[23165]: Function not implemented (38)
bluetoothd[23165]: State changed /org/bluez/23165/hci0/dev_00_19_7F_1B_E8_BE: HEADSET_STATE_CONNECTING -> HEADSET_STATE_DISCONNECTED
And nothing appears, no sound, etc.
The string "Function not implemented" is not present anywhere in bluez sources,
so it must come from something else, but I do not know what it is.
I tried bisecting the sources and it seems the problem is introduced in commit
aee26b30bbc24cde464ba1a557c2b258ddec6432 "Make BtIO default security level
MEDIUM". When I compile version with all commits up to master except this one,
it works, so this confirms my problem comes from this commit.
A wild guess is that the machines differ in which adapter they have and that
this one does not support something needed for the medium level security. The
adaptor is "OMEGA MICRO BT140", while the other two computers are laptops and
have some onboard usb connected adaptors (I do not know which ones). Is it
possible? If so, is there a possibility forcing bluez not using the
not-implemented function in a cleaner way than omitting the commit?
Thank you
--
Michal 'vorner' Vaner
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
^ permalink raw reply
* [PATCH v5 3/3] Implemented HCI frame reassembly for stream Rx
From: Suraj Sumangala @ 2010-07-12 12:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jothikumar.Mothilal, Suraj Sumangala
In-Reply-To: <1278936744-6003-2-git-send-email-suraj@atheros.com>
Implemented frame reassembly implementation for reassembling fragments
received from stream.
Signed-off-by: Suraj Sumangala <suraj@atheros.com>
---
include/net/bluetooth/hci_core.h | 2 ++
net/bluetooth/hci_core.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 39 insertions(+), 0 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 600372d..345fc14 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -124,6 +124,7 @@ struct hci_dev {
struct sk_buff *sent_cmd;
struct sk_buff *reassembly[3];
+ struct sk_buff *stream_reassembly;
struct mutex req_lock;
wait_queue_head_t req_wait_q;
@@ -437,6 +438,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
int hci_recv_frame(struct sk_buff *skb);
int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count);
+int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count);
int hci_register_sysfs(struct hci_dev *hdev);
void hci_unregister_sysfs(struct hci_dev *hdev);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index ca6182c..6025257 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -917,6 +917,8 @@ int hci_register_dev(struct hci_dev *hdev)
for (i = 0; i < 3; i++)
hdev->reassembly[i] = NULL;
+ hdev->stream_reassembly = NULL;
+
init_waitqueue_head(&hdev->req_wait_q);
mutex_init(&hdev->req_lock);
@@ -976,6 +978,8 @@ int hci_unregister_dev(struct hci_dev *hdev)
for (i = 0; i < 3; i++)
kfree_skb(hdev->reassembly[i]);
+ kfree_skb(hdev->stream_reassembly);
+
hci_notify(hdev, HCI_DEV_UNREG);
if (hdev->rfkill) {
@@ -1166,6 +1170,39 @@ int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count)
}
EXPORT_SYMBOL(hci_recv_fragment);
+int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count)
+{
+ int type;
+ int rem = 0;
+
+ do {
+ struct sk_buff *skb = hdev->stream_reassembly;
+ if (!skb) {
+ struct { char type; } *pkt;
+
+ /* Start of the frame */
+ pkt = data;
+ type = pkt->type;
+
+ data++;
+ count--;
+ } else
+ type = bt_cb(skb)->pkt_type;
+
+ rem = hci_reassembly(hdev, type, data, count, &skb, GFP_ATOMIC);
+ if (rem < 0)
+ return rem;
+
+ hdev->stream_reassembly = skb;
+
+ data += (count - rem);
+ count = rem;
+ } while (count);
+
+ return rem;
+}
+EXPORT_SYMBOL(hci_recv_stream_fragment);
+
/* ---- Interface to upper protocols ---- */
/* Register/Unregister protocols.
--
1.7.0.4
^ permalink raw reply related
* [PATCH v5 2/3] Modified hci_recv_fragment() to use hci_reassembly
From: Suraj Sumangala @ 2010-07-12 12:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jothikumar.Mothilal, Suraj Sumangala
In-Reply-To: <1278936744-6003-1-git-send-email-suraj@atheros.com>
modified packet based reassembly function hci_recv_fragment() to use hci_reassembly()
Signed-off-by: Suraj Sumangala <suraj@atheros.com>
---
net/bluetooth/hci_core.c | 79 ++++++---------------------------------------
1 files changed, 11 insertions(+), 68 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index e1ede0b..ca6182c 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1144,82 +1144,25 @@ static int hci_reassembly(struct hci_dev *hdev, int type, void *data,
int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count)
{
+ int rem = 0;
+
if (type < HCI_ACLDATA_PKT || type > HCI_EVENT_PKT)
return -EILSEQ;
- while (count) {
+ do {
struct sk_buff *skb = __reassembly(hdev, type);
- struct { int expect; } *scb;
- int len = 0;
-
- if (!skb) {
- /* Start of the frame */
-
- switch (type) {
- case HCI_EVENT_PKT:
- if (count >= HCI_EVENT_HDR_SIZE) {
- struct hci_event_hdr *h = data;
- len = HCI_EVENT_HDR_SIZE + h->plen;
- } else
- return -EILSEQ;
- break;
- case HCI_ACLDATA_PKT:
- if (count >= HCI_ACL_HDR_SIZE) {
- struct hci_acl_hdr *h = data;
- len = HCI_ACL_HDR_SIZE + __le16_to_cpu(h->dlen);
- } else
- return -EILSEQ;
- break;
+ rem = hci_reassembly(hdev, type, data, count, &skb, GFP_ATOMIC);
+ if (rem < 0)
+ return rem;
- case HCI_SCODATA_PKT:
- if (count >= HCI_SCO_HDR_SIZE) {
- struct hci_sco_hdr *h = data;
- len = HCI_SCO_HDR_SIZE + h->dlen;
- } else
- return -EILSEQ;
- break;
- }
+ __reassembly(hdev, type) = skb;
- skb = bt_skb_alloc(len, GFP_ATOMIC);
- if (!skb) {
- BT_ERR("%s no memory for packet", hdev->name);
- return -ENOMEM;
- }
-
- skb->dev = (void *) hdev;
- bt_cb(skb)->pkt_type = type;
-
- __reassembly(hdev, type) = skb;
-
- scb = (void *) skb->cb;
- scb->expect = len;
- } else {
- /* Continuation */
-
- scb = (void *) skb->cb;
- len = scb->expect;
- }
+ data += (count - rem);
+ count = rem;
+ } while (count);
- len = min(len, count);
-
- memcpy(skb_put(skb, len), data, len);
-
- scb->expect -= len;
-
- if (scb->expect == 0) {
- /* Complete frame */
-
- __reassembly(hdev, type) = NULL;
-
- bt_cb(skb)->pkt_type = type;
- hci_recv_frame(skb);
- }
-
- count -= len; data += len;
- }
-
- return 0;
+ return rem;
}
EXPORT_SYMBOL(hci_recv_fragment);
--
1.7.0.4
^ permalink raw reply related
* [PATCH v5 1/3] Implements hci_reassembly to reassemble Rx packets
From: Suraj Sumangala @ 2010-07-12 12:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jothikumar.Mothilal, Suraj Sumangala
Implements feature to reassemble HCI frames received from an input stream.
Signed-off-by: Suraj Sumangala <suraj@atheros.com>
---
net/bluetooth/hci_core.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 106 insertions(+), 0 deletions(-)
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index aeb2982..e1ede0b 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1033,6 +1033,112 @@ int hci_recv_frame(struct sk_buff *skb)
}
EXPORT_SYMBOL(hci_recv_frame);
+static int hci_reassembly(struct hci_dev *hdev, int type, void *data,
+ int count, struct sk_buff **skb_ptr, gfp_t how)
+{
+ int len = 0;
+ int header_len = 0;
+ int remain = count;
+ struct sk_buff *skb = *skb_ptr;
+ struct { struct bt_skb_cb cb_info; int expect; } *scb;
+
+ if (type < HCI_ACLDATA_PKT || type > HCI_EVENT_PKT)
+ return -EILSEQ;
+
+ if (!skb) {
+ switch (type) {
+ case HCI_ACLDATA_PKT:
+ len = HCI_MAX_FRAME_SIZE;
+ header_len = HCI_ACL_HDR_SIZE;
+ break;
+ case HCI_EVENT_PKT:
+ len = HCI_MAX_EVENT_SIZE;
+ header_len = HCI_EVENT_HDR_SIZE;
+ break;
+ case HCI_SCODATA_PKT:
+ len = HCI_MAX_SCO_SIZE;
+ header_len = HCI_SCO_HDR_SIZE;
+ break;
+ }
+
+ skb = bt_skb_alloc(len, how);
+ if (!skb)
+ return -ENOMEM;
+
+ scb = (void *) skb->cb;
+ scb->expect = header_len;
+ scb->cb_info.pkt_type = type;
+
+ skb->dev = (void *) hdev;
+ *skb_ptr = skb;
+ }
+
+ while (count) {
+ scb = (void *) skb->cb;
+ len = min(scb->expect, count);
+
+ memcpy(skb_put(skb, len), data, len);
+
+ count -= len;
+ data += len;
+ scb->expect -= len;
+ remain = count;
+
+ switch (type) {
+ case HCI_EVENT_PKT:
+ if (skb->len == HCI_EVENT_HDR_SIZE) {
+ struct hci_event_hdr *h = hci_event_hdr(skb);
+ scb->expect = h->plen;
+
+ if (skb_tailroom(skb) < scb->expect) {
+ kfree_skb(skb);
+ *skb_ptr = NULL;
+ return -ENOMEM;
+ }
+ }
+ break;
+
+ case HCI_ACLDATA_PKT:
+ if (skb->len == HCI_ACL_HDR_SIZE) {
+ struct hci_acl_hdr *h = hci_acl_hdr(skb);
+ scb->expect = __le16_to_cpu(h->dlen);
+
+ if (skb_tailroom(skb) < scb->expect) {
+ kfree_skb(skb);
+ *skb_ptr = NULL;
+ return -ENOMEM;
+ }
+ }
+ break;
+
+ case HCI_SCODATA_PKT:
+ if (skb->len == HCI_SCO_HDR_SIZE) {
+ struct hci_sco_hdr *h = hci_sco_hdr(skb);
+ scb->expect = h->dlen;
+
+ if (skb_tailroom(skb) < scb->expect) {
+ kfree_skb(skb);
+ *skb_ptr = NULL;
+ return -ENOMEM;
+ }
+ }
+ break;
+ }
+
+ if (scb->expect == 0) {
+ /* Complete frame */
+
+ bt_cb(skb)->pkt_type = type;
+ hci_recv_frame(skb);
+
+ *skb_ptr = NULL;
+ return remain;
+ }
+ }
+
+ return remain;
+}
+
/* Receive packet type fragment */
#define __reassembly(hdev, type) ((hdev)->reassembly[(type) - 2])
--
1.7.0.4
^ permalink raw reply related
* RE: [RFC] Bluetooth: Add firmware load infrastructure for BT devices
From: Shanmugamkamatchi Balashanmugam @ 2010-07-12 6:31 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: Perelet, Oleg, linux-bluetooth@vger.kernel.org
In-Reply-To: <1278596572.10421.25.camel@localhost.localdomain>
Hi Marcel,
-----Original Message-----
From: Marcel Holtmann [mailto:marcel@holtmann.org]=20
Sent: Thursday, July 08, 2010 7:13 PM
To: Shanmugamkamatchi Balashanmugam
Cc: Perelet, Oleg; linux-bluetooth@vger.kernel.org
Subject: RE: [RFC] Bluetooth: Add firmware load infrastructure for BT devic=
es
Hi Bala,
> Firmware loading to target RAM needs to be done once when the device is i=
nserted. Firmware loading will not be required every time=20
> the device goes from DOWN to UP. I think each HCI driver requires
> a separate firmware loading code as firmware loading is=20
> different for different interfaces. Please advice if my understanding is=
wrong.
>=20
> I initially thought of registration=20
> mechanism with btusb transport driver to load firmware, but before
> the device is inserted btusb will not be loaded and registering the=20
> firmware load function with btusb was not possible.
>=20
> Please advice alternate solution to load firmware from transport driver.
>my advise would be to just build devices that change their USB VID/PID
>after the firmware got loaded. That way it is easy to have a firmware
>loading driver and just btusb for real operation. Why is it so hard to
>build just simple hardware that would just work.
>Regards
>Marcel
Thanks for the suggestion.
This is what is done for some of the devices.
For performance reasons few other devices comes with=20
small firmware in flash and the device gets detected as=20
generic bluetooth device when plugged in. So control reaches btusb
once the device is plugged in. In this case actual firmware
needs to be downloaded to target from btusb transport driver.
Please suggest if there is other way to handle these devices in linux.
Regards,
Bala.
^ 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