* [PATCH 1/7] Bluetooth: Remove not used struct sock
From: Gustavo Padovan @ 2013-10-16 19:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
It is a leftover from the recent effort of remove sk usage from L2CAP
core.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/l2cap_core.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 8af34d2..5d99394 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3718,7 +3718,7 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
struct l2cap_conn_req *req = (struct l2cap_conn_req *) data;
struct l2cap_conn_rsp rsp;
struct l2cap_chan *chan = NULL, *pchan;
- struct sock *parent, *sk = NULL;
+ struct sock *parent;
int result, status = L2CAP_CS_NO_INFO;
u16 dcid = 0, scid = __le16_to_cpu(req->scid);
@@ -3757,8 +3757,6 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
if (!chan)
goto response;
- sk = chan->sk;
-
/* For certain devices (ex: HID mouse), support for authentication,
* pairing and bonding is optional. For such devices, inorder to avoid
* the ACL alive for too long after L2CAP disconnection, reset the ACL
--
1.8.3.1
^ permalink raw reply related
* [PATCH BlueZ] l2test: Set CID due to socket restrictions for LE
From: Claudio Takahasi @ 2013-10-16 19:05 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
Bluetooth kernel now restricts LE L2CAP sockets to ATT channels only.
For LE L2CAP socket bind, ATT CID is now mandatory. Reference: kernel patch
bfe4655f05d7ec4a7c0c1c7e4051862f824cd8ec
---
tools/l2test.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/l2test.c b/tools/l2test.c
index 125532b..c5c8763 100644
--- a/tools/l2test.c
+++ b/tools/l2test.c
@@ -280,6 +280,8 @@ static int do_connect(char *svr)
addr.l2_family = AF_BLUETOOTH;
bacpy(&addr.l2_bdaddr, &bdaddr);
addr.l2_bdaddr_type = bdaddr_type;
+ if (cid)
+ addr.l2_cid = htobs(cid);
if (bind(sk, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
syslog(LOG_ERR, "Can't bind socket: %s (%d)",
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH] Bluetooth: Remove not used struct sock
From: Gustavo Padovan @ 2013-10-16 17:14 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth, Gustavo Padovan
In-Reply-To: <121AE7E9-6B79-4132-8B59-DEDB1F6EBEE3@holtmann.org>
Hi Marcel,
2013-10-16 Marcel Holtmann <marcel@holtmann.org>:
> Hi Gustavo,
>
> > It is a leftover from the recent effort of remove sk usage from L2CAP
> > core.
> >
> > Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> > ---
> > net/bluetooth/l2cap_core.c | 4 +---
> > 1 file changed, 1 insertion(+), 3 deletions(-)
> >
> > diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> > index b77e178..2681880 100644
> > --- a/net/bluetooth/l2cap_core.c
> > +++ b/net/bluetooth/l2cap_core.c
> > @@ -3714,7 +3714,7 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
> > struct l2cap_conn_req *req = (struct l2cap_conn_req *) data;
> > struct l2cap_conn_rsp rsp;
> > struct l2cap_chan *chan = NULL, *pchan;
> > - struct sock *parent, *sk = NULL;
> > + struct sock *parent;
> > int result, status = L2CAP_CS_NO_INFO;
> >
> > u16 dcid = 0, scid = __le16_to_cpu(req->scid);
> > @@ -3753,8 +3753,6 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
> > if (!chan)
> > goto response;
> >
> > - sk = chan->sk;
> > -
>
> can we already do that? I still do not like the chan->data != sk magic check.
Yes, this is just a dead assignment. It is totally safe to remove it.
Gustavo
^ permalink raw reply
* Re: [PATCH] Bluetooth: Expose inquiry_cache debugfs only on BR/EDR controllers
From: Johan Hedberg @ 2013-10-16 16:54 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1381919335-59602-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Wed, Oct 16, 2013, Marcel Holtmann wrote:
> The inquiry_cache debugfs entry is only valid for BR/EDR capable
> controllers. In case of single mode LE-only controllers that
> entry is not valid.
>
> Move the creating of the debugfs entries to the end of controller
> init and only create the inquiry_cache entry if BR/EDR is actually
> supported.
>
> At the same time this avoids creating any debugfs entries for
> AMP controllers since none of the entries are valid there.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/hci_core.c | 57 +++++++++++++++++++++++++++++++++++++++++++++--
> net/bluetooth/hci_sysfs.c | 39 --------------------------------
> 2 files changed, 55 insertions(+), 41 deletions(-)
Applied to bluetooth-next. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Socket address parameter for CID is in little endian
From: Johan Hedberg @ 2013-10-16 16:53 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1381941077-6941-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Wed, Oct 16, 2013, Marcel Holtmann wrote:
> The L2CAP socket parameter for CID are actually provided in little
> endian. So convert our constants into little endian before comparing
> them.
>
> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
> ---
> net/bluetooth/l2cap_sock.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply
* [PATCH] Bluetooth: Socket address parameter for CID is in little endian
From: Marcel Holtmann @ 2013-10-16 16:31 UTC (permalink / raw)
To: linux-bluetooth
The L2CAP socket parameter for CID are actually provided in little
endian. So convert our constants into little endian before comparing
them.
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
---
net/bluetooth/l2cap_sock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 95498d5..34e5a58 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -77,7 +77,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
if (la.l2_psm)
return -EINVAL;
/* We only allow ATT user space socket */
- if (la.l2_cid != L2CAP_CID_ATT)
+ if (la.l2_cid != __constant_cpu_to_le16(L2CAP_CID_ATT))
return -EINVAL;
}
@@ -170,7 +170,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr,
if (la.l2_psm)
return -EINVAL;
/* We only allow ATT user space socket */
- if (la.l2_cid != L2CAP_CID_ATT)
+ if (la.l2_cid != __constant_cpu_to_le16(L2CAP_CID_ATT))
return -EINVAL;
}
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH] Bluetooth: Remove not used struct sock
From: Marcel Holtmann @ 2013-10-16 16:14 UTC (permalink / raw)
To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
In-Reply-To: <1381937991-12645-1-git-send-email-gustavo@padovan.org>
Hi Gustavo,
> It is a leftover from the recent effort of remove sk usage from L2CAP
> core.
>
> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
> ---
> net/bluetooth/l2cap_core.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index b77e178..2681880 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -3714,7 +3714,7 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
> struct l2cap_conn_req *req = (struct l2cap_conn_req *) data;
> struct l2cap_conn_rsp rsp;
> struct l2cap_chan *chan = NULL, *pchan;
> - struct sock *parent, *sk = NULL;
> + struct sock *parent;
> int result, status = L2CAP_CS_NO_INFO;
>
> u16 dcid = 0, scid = __le16_to_cpu(req->scid);
> @@ -3753,8 +3753,6 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
> if (!chan)
> goto response;
>
> - sk = chan->sk;
> -
can we already do that? I still do not like the chan->data != sk magic check.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 2/2] Bluetooth: Convert idle timer to use delayed work
From: Marcel Holtmann @ 2013-10-16 16:13 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1381936300-18629-2-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> There is no need to use a timer since the entire Bluetooth subsystem
> runs using workqueues these days.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 4 ++--
> net/bluetooth/hci_conn.c | 22 +++++++---------------
> 2 files changed, 9 insertions(+), 17 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH 1/2] Bluetooth: Convert auto accept timer to use delayed work
From: Marcel Holtmann @ 2013-10-16 16:13 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1381936300-18629-1-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> Since the entire Bluetooth subsystem runs in workqueues these days there
> is no need to use a timer for deferring work.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/hci_core.h | 2 +-
> net/bluetooth/hci_conn.c | 14 ++++++--------
> net/bluetooth/hci_event.c | 3 ++-
> 3 files changed, 9 insertions(+), 10 deletions(-)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH] Bluetooth: Expose inquiry_cache debugfs only on BR/EDR controllers
From: Marcel Holtmann @ 2013-10-16 16:07 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20131016152018.GA18754@x220.p-661hnu-f1>
Hi Johan,
>> static void hci_req_sync_complete(struct hci_dev *hdev, u8 result)
>> @@ -734,7 +772,22 @@ static int __hci_init(struct hci_dev *hdev)
>> if (err < 0)
>> return err;
>>
>> - return __hci_req_sync(hdev, hci_init4_req, 0, HCI_INIT_TIMEOUT);
>> + err = __hci_req_sync(hdev, hci_init4_req, 0, HCI_INIT_TIMEOUT);
>> + if (err < 0)
>> + return err;
>> +
>> + /* Only create debugfs entries during the initial setup
>> + * phase and not every time the controller gets powered on.
>> + */
>> + if (!test_bit(HCI_SETUP, &hdev->dev_flags))
>> + return 0;
>> +
>> + if (lmp_bredr_capable(hdev)) {
>> + debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
>> + hdev, &inquiry_cache_fops);
>> + }
>
> The patch looks good but just a minor nit-pick here: do you really want
> to have the curly braces for this one? Even though the function call is
> split across two lines it doesn't make it any harder to read without the
> braces, for me at least.
that is because I am planning to add more in future patches.
Regards
Marcel
^ permalink raw reply
* Re: [PATCHv4 04/11] android: sdp: Reuse BlueZ SDP server in Android
From: Johan Hedberg @ 2013-10-16 15:48 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1381934198-7955-5-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Wed, Oct 16, 2013, Andrei Emeltchenko wrote:
> Reuse existing SDP server code in Android GPL daemon.
> ---
> Makefile.android | 4 +++-
> android/Android.mk | 8 ++++++++
> android/main.c | 5 +++++
> 3 files changed, 16 insertions(+), 1 deletion(-)
I've applied patches 1-4 upstream, however from there onwards there were
some issues that will still need to be resolved.
Johan
^ permalink raw reply
* Re: [PATCHv4 06/11] android: Implement read_info_complete callback
From: Johan Hedberg @ 2013-10-16 15:47 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1381934198-7955-7-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Wed, Oct 16, 2013, Andrei Emeltchenko wrote:
> --- a/android/adapter.h
> +++ b/android/adapter.h
> @@ -34,3 +34,7 @@ struct bt_adapter *bt_adapter_new(uint16_t index, struct mgmt *mgmt_if);
>
> void bt_adapter_start(struct bt_adapter *adapter);
> void bt_adapter_stop(struct bt_adapter *adapter);
> +
> +void read_info_complete(uint8_t status, uint16_t length, const void *param,
> + void *user_data);
> +void load_link_keys(struct bt_adapter *adapter, GSList *keys);
Shouldn't you be following the appropriate name space for this header
file? I.e. bt_adapter_*.
That said, it seems to me like you don't need to have any public
functions like this at all if you just do the read_info from the
bt_adapter_new function since you get the mgmt context there anyway.
Johan
^ permalink raw reply
* Re: [PATCHv4 05/11] android: Add cap to bind to port < 1024
From: Johan Hedberg @ 2013-10-16 15:44 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1381934198-7955-6-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Wed, Oct 16, 2013, Andrei Emeltchenko wrote:
> For SDP server we need to bind to lower port, acquire this capability.
You might want to mention here exactly which capability it is instead of
just saying "this" :)
The patch also seems to do more than just related to POSIX capabilities
so you should also mention these things in the commit message.
> diff --git a/android/main.c b/android/main.c
> index 3a20148..091ef20 100644
> --- a/android/main.c
> +++ b/android/main.c
> @@ -32,6 +32,21 @@
> #include <stdlib.h>
> #include <stdbool.h>
> #include <string.h>
> +#include <unistd.h>
> +#include <errno.h>
> +#include <sys/prctl.h>
> +
> +/**
> + * Include <sys/capability.h> for host build and
> + * also for Android 4.3 when it is added to bionic
> + */
> +#if !defined(ANDROID) || (PLATFORM_SDK_VERSION > 17)
> +#include <sys/capability.h>
> +#endif
> +
> +#if defined(ANDROID)
> +#include <private/android_filesystem_config.h>
> +#endif
>
> #include <glib.h>
>
> @@ -230,6 +245,58 @@ static void cleanup_mgmt_interface(void)
> mgmt_if = NULL;
> }
>
> +static bool set_capabilities(void)
This whole function seems to me like something that's not needed on
non-android (since we can just execute the daemon as root if necessary),
so I'd consider putting its entire contents behind #if defined(ANDROID)
^ permalink raw reply
* [PATCH] Bluetooth: Remove not used struct sock
From: Gustavo Padovan @ 2013-10-16 15:39 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Gustavo Padovan
From: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
It is a leftover from the recent effort of remove sk usage from L2CAP
core.
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
---
net/bluetooth/l2cap_core.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index b77e178..2681880 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3714,7 +3714,7 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
struct l2cap_conn_req *req = (struct l2cap_conn_req *) data;
struct l2cap_conn_rsp rsp;
struct l2cap_chan *chan = NULL, *pchan;
- struct sock *parent, *sk = NULL;
+ struct sock *parent;
int result, status = L2CAP_CS_NO_INFO;
u16 dcid = 0, scid = __le16_to_cpu(req->scid);
@@ -3753,8 +3753,6 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
if (!chan)
goto response;
- sk = chan->sk;
-
/* For certain devices (ex: HID mouse), support for authentication,
* pairing and bonding is optional. For such devices, inorder to avoid
* the ACL alive for too long after L2CAP disconnection, reset the ACL
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH v3 0/5] Stack independent BT HAL test tool
From: Johan Hedberg @ 2013-10-16 15:34 UTC (permalink / raw)
To: Jerzy Kasenberg; +Cc: linux-bluetooth
In-Reply-To: <1381932012-29641-1-git-send-email-jerzy.kasenberg@tieto.com>
Hi Jerzy,
On Wed, Oct 16, 2013, Jerzy Kasenberg wrote:
> v3:
> - underscores changed to dash in file names.
> - corrected cast style (space after cast).
> - structure initialization with explicit filed names.
> v2:
> - license changed to apache
> - source folder changed to hal-client (underscore to dash)
> v1:
> This tool is for testing Android HAL interfaces from command line.
> Due to lack of readline on Android simple equivalent is hand coded.
> This tool can be used with bluedroid stack so no glib dependency.
>
> Tool source code is in folder hal_client, please comment if it should be
> somewhere else.
>
> Comments welcome.
>
> Best regards
> Jerzy Kasenberg
>
> Jerzy Kasenberg (5):
> android: Add haltest skeleton
> android: Add line editing to haltest
> android: Add history to line editor in haltest
> android: Add text conversion helpers to haltest
> android: Add calls to adapter methods in haltest
>
> android/Android.mk | 21 ++
> android/client/haltest.c | 161 +++++++++++
> android/client/history.c | 98 +++++++
> android/client/history.h | 21 ++
> android/client/if-bt.c | 631 ++++++++++++++++++++++++++++++++++++++++++
> android/client/if-main.h | 99 +++++++
> android/client/pollhandler.c | 123 ++++++++
> android/client/pollhandler.h | 26 ++
> android/client/terminal.c | 538 +++++++++++++++++++++++++++++++++++
> android/client/terminal.h | 59 ++++
> android/client/textconv.c | 205 ++++++++++++++
> android/client/textconv.h | 113 ++++++++
> 12 files changed, 2095 insertions(+)
> create mode 100644 android/client/haltest.c
> create mode 100644 android/client/history.c
> create mode 100644 android/client/history.h
> create mode 100644 android/client/if-bt.c
> create mode 100644 android/client/if-main.h
> create mode 100644 android/client/pollhandler.c
> create mode 100644 android/client/pollhandler.h
> create mode 100644 android/client/terminal.c
> create mode 100644 android/client/terminal.h
> create mode 100644 android/client/textconv.c
> create mode 100644 android/client/textconv.h
All five patches have been pushed upstream. I did have to fix "empty
line before EOL" errors for each of the first three patches though, so
please avoid that in the future.
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Expose inquiry_cache debugfs only on BR/EDR controllers
From: Johan Hedberg @ 2013-10-16 15:20 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth
In-Reply-To: <1381919335-59602-1-git-send-email-marcel@holtmann.org>
Hi Marcel,
On Wed, Oct 16, 2013, Marcel Holtmann wrote:
> static void hci_req_sync_complete(struct hci_dev *hdev, u8 result)
> @@ -734,7 +772,22 @@ static int __hci_init(struct hci_dev *hdev)
> if (err < 0)
> return err;
>
> - return __hci_req_sync(hdev, hci_init4_req, 0, HCI_INIT_TIMEOUT);
> + err = __hci_req_sync(hdev, hci_init4_req, 0, HCI_INIT_TIMEOUT);
> + if (err < 0)
> + return err;
> +
> + /* Only create debugfs entries during the initial setup
> + * phase and not every time the controller gets powered on.
> + */
> + if (!test_bit(HCI_SETUP, &hdev->dev_flags))
> + return 0;
> +
> + if (lmp_bredr_capable(hdev)) {
> + debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
> + hdev, &inquiry_cache_fops);
> + }
The patch looks good but just a minor nit-pick here: do you really want
to have the curly braces for this one? Even though the function call is
split across two lines it doesn't make it any harder to read without the
braces, for me at least.
Johan
^ permalink raw reply
* [PATCH 2/2] Bluetooth: Convert idle timer to use delayed work
From: johan.hedberg @ 2013-10-16 15:11 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381936300-18629-1-git-send-email-johan.hedberg@gmail.com>
From: Johan Hedberg <johan.hedberg@intel.com>
There is no need to use a timer since the entire Bluetooth subsystem
runs using workqueues these days.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 4 ++--
net/bluetooth/hci_conn.c | 22 +++++++---------------
2 files changed, 9 insertions(+), 17 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 2504a25..07c2da4 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -342,7 +342,7 @@ struct hci_conn {
struct delayed_work disc_work;
struct delayed_work auto_accept_work;
- struct timer_list idle_timer;
+ struct delayed_work idle_work;
struct device dev;
@@ -651,7 +651,7 @@ static inline void hci_conn_drop(struct hci_conn *conn)
switch (conn->type) {
case ACL_LINK:
case LE_LINK:
- del_timer(&conn->idle_timer);
+ cancel_delayed_work(&conn->idle_work);
if (conn->state == BT_CONNECTED) {
timeo = conn->disc_timeout;
if (!conn->out)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 8d1f466..4e72650 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -317,8 +317,10 @@ static void hci_conn_timeout(struct work_struct *work)
}
/* Enter sniff mode */
-static void hci_conn_enter_sniff_mode(struct hci_conn *conn)
+static void hci_conn_idle(struct work_struct *work)
{
+ struct hci_conn *conn = container_of(work, struct hci_conn,
+ idle_work.work);
struct hci_dev *hdev = conn->hdev;
BT_DBG("hcon %p mode %d", conn, conn->mode);
@@ -352,15 +354,6 @@ static void hci_conn_enter_sniff_mode(struct hci_conn *conn)
}
}
-static void hci_conn_idle(unsigned long arg)
-{
- struct hci_conn *conn = (void *) arg;
-
- BT_DBG("hcon %p mode %d", conn, conn->mode);
-
- hci_conn_enter_sniff_mode(conn);
-}
-
static void hci_conn_auto_accept(struct work_struct *work)
{
struct hci_conn *conn = container_of(work, struct hci_conn,
@@ -416,7 +409,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
INIT_DELAYED_WORK(&conn->disc_work, hci_conn_timeout);
INIT_DELAYED_WORK(&conn->auto_accept_work, hci_conn_auto_accept);
- setup_timer(&conn->idle_timer, hci_conn_idle, (unsigned long)conn);
+ INIT_DELAYED_WORK(&conn->idle_work, hci_conn_idle);
atomic_set(&conn->refcnt, 0);
@@ -437,10 +430,9 @@ int hci_conn_del(struct hci_conn *conn)
BT_DBG("%s hcon %p handle %d", hdev->name, conn, conn->handle);
- del_timer(&conn->idle_timer);
-
cancel_delayed_work_sync(&conn->disc_work);
cancel_delayed_work_sync(&conn->auto_accept_work);
+ cancel_delayed_work_sync(&conn->idle_work);
if (conn->type == ACL_LINK) {
struct hci_conn *sco = conn->link;
@@ -920,8 +912,8 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
timer:
if (hdev->idle_timeout > 0)
- mod_timer(&conn->idle_timer,
- jiffies + msecs_to_jiffies(hdev->idle_timeout));
+ queue_delayed_work(hdev->workqueue, &conn->idle_work,
+ msecs_to_jiffies(hdev->idle_timeout));
}
/* Drop all connection on the device */
--
1.8.3.1
^ permalink raw reply related
* [PATCH 1/2] Bluetooth: Convert auto accept timer to use delayed work
From: johan.hedberg @ 2013-10-16 15:11 UTC (permalink / raw)
To: linux-bluetooth
From: Johan Hedberg <johan.hedberg@intel.com>
Since the entire Bluetooth subsystem runs in workqueues these days there
is no need to use a timer for deferring work.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
include/net/bluetooth/hci_core.h | 2 +-
net/bluetooth/hci_conn.c | 14 ++++++--------
net/bluetooth/hci_event.c | 3 ++-
3 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index d987c79..2504a25 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -341,8 +341,8 @@ struct hci_conn {
struct list_head chan_list;
struct delayed_work disc_work;
+ struct delayed_work auto_accept_work;
struct timer_list idle_timer;
- struct timer_list auto_accept_timer;
struct device dev;
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index ff04b05..8d1f466 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -361,12 +361,12 @@ static void hci_conn_idle(unsigned long arg)
hci_conn_enter_sniff_mode(conn);
}
-static void hci_conn_auto_accept(unsigned long arg)
+static void hci_conn_auto_accept(struct work_struct *work)
{
- struct hci_conn *conn = (void *) arg;
- struct hci_dev *hdev = conn->hdev;
+ struct hci_conn *conn = container_of(work, struct hci_conn,
+ auto_accept_work.work);
- hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_REPLY, sizeof(conn->dst),
+ hci_send_cmd(conn->hdev, HCI_OP_USER_CONFIRM_REPLY, sizeof(conn->dst),
&conn->dst);
}
@@ -415,9 +415,8 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
INIT_LIST_HEAD(&conn->chan_list);
INIT_DELAYED_WORK(&conn->disc_work, hci_conn_timeout);
+ INIT_DELAYED_WORK(&conn->auto_accept_work, hci_conn_auto_accept);
setup_timer(&conn->idle_timer, hci_conn_idle, (unsigned long)conn);
- setup_timer(&conn->auto_accept_timer, hci_conn_auto_accept,
- (unsigned long) conn);
atomic_set(&conn->refcnt, 0);
@@ -441,8 +440,7 @@ int hci_conn_del(struct hci_conn *conn)
del_timer(&conn->idle_timer);
cancel_delayed_work_sync(&conn->disc_work);
-
- del_timer(&conn->auto_accept_timer);
+ cancel_delayed_work_sync(&conn->auto_accept_work);
if (conn->type == ACL_LINK) {
struct hci_conn *sco = conn->link;
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index e71c98f..6c3b193 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -3188,7 +3188,8 @@ static void hci_user_confirm_request_evt(struct hci_dev *hdev,
if (hdev->auto_accept_delay > 0) {
int delay = msecs_to_jiffies(hdev->auto_accept_delay);
- mod_timer(&conn->auto_accept_timer, jiffies + delay);
+ queue_delayed_work(conn->hdev->workqueue,
+ &conn->auto_accept_work, delay);
goto unlock;
}
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH v2] Bluetooth: Reintroduce socket restrictions for LE sockets
From: Marcel Holtmann @ 2013-10-16 14:37 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1381932806-13506-1-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> Right now we do not allow user space to use connection oriented channels
> on LE, and the only CID that can be used is the Attribute Protocol one.
> These restrictions went away together with the recent refactoring of the
> L2CAP code, but this patch puts them back to their appropriate places.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/l2cap_sock.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
patch has been applied to bluetooth-next tree.
Regards
Marcel
^ permalink raw reply
* [PATCHv4 11/11] android: Add PAN skeleton
From: Andrei Emeltchenko @ 2013-10-16 14:36 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381934198-7955-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Add skeleton for pan Android HAL. This is modified version
from Frederic Danis earlier patch set.
---
android/Android.mk | 1 +
android/hal-bluetooth.c | 4 ++
android/hal-pan.c | 120 +++++++++++++++++++++++++++++++++++++++++++++++
android/hal.h | 1 +
4 files changed, 126 insertions(+)
create mode 100644 android/hal-pan.c
diff --git a/android/Android.mk b/android/Android.mk
index ab2171c..f369e34 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -54,6 +54,7 @@ LOCAL_SRC_FILES := \
hal-bluetooth.c \
hal-bt-sock.c \
hal-hidhost.c \
+ hal-pan.c \
LOCAL_SHARED_LIBRARIES := \
libcutils \
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 488606d..5f9d00b 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -23,6 +23,7 @@
#include <hardware/bluetooth.h>
#include <hardware/bt_sock.h>
#include <hardware/bt_hh.h>
+#include <hardware/bt_pan.h>
#include <cutils/sockets.h>
#include <cutils/properties.h>
@@ -289,6 +290,9 @@ static const void *get_profile_interface(const char *profile_id)
if (!strcmp(profile_id, BT_PROFILE_HIDHOST_ID))
return bt_get_hidhost_interface();
+ if (!strcmp(profile_id, BT_PROFILE_PAN_ID))
+ return bt_get_pan_interface();
+
return NULL;
}
diff --git a/android/hal-pan.c b/android/hal-pan.c
new file mode 100644
index 0000000..373494e
--- /dev/null
+++ b/android/hal-pan.c
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdbool.h>
+
+#include <hardware/bluetooth.h>
+#include <hardware/bt_pan.h>
+
+#define LOG_TAG "BlueZ"
+#include <cutils/log.h>
+
+const btpan_callbacks_t *bt_pan_cbacks = NULL;
+
+static bool interface_ready(void)
+{
+ return bt_pan_cbacks != NULL;
+}
+
+static bt_status_t bt_pan_enable(int local_role)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int bt_pan_get_local_role(void)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BTPAN_ROLE_NONE;
+
+ return BTPAN_ROLE_NONE;
+}
+
+static bt_status_t bt_pan_connect(const bt_bdaddr_t *bd_addr, int local_role,
+ int remote_role)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_pan_disconnect(const bt_bdaddr_t *bd_addr)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_pan_init(const btpan_callbacks_t *callbacks)
+{
+ ALOGI(__func__);
+
+ bt_pan_cbacks = callbacks;
+
+ /* TODO: start HID Host thread */
+
+ /* TODO: enable service */
+
+ return BT_STATUS_SUCCESS;
+}
+
+static void bt_pan_cleanup()
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return;
+
+ /* TODO: disable service */
+
+ /* TODO: stop PAN thread */
+
+ bt_pan_cbacks = NULL;
+}
+
+static btpan_interface_t bt_pan_if = {
+ sizeof(bt_pan_if),
+ bt_pan_init,
+ bt_pan_enable,
+ bt_pan_get_local_role,
+ bt_pan_connect,
+ bt_pan_disconnect,
+ bt_pan_cleanup
+};
+
+btpan_interface_t *bt_get_pan_interface()
+{
+ return &bt_pan_if;
+}
diff --git a/android/hal.h b/android/hal.h
index be69339..38b90b2 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -17,3 +17,4 @@
btsock_interface_t *bt_get_sock_interface(void);
bthh_interface_t *bt_get_hidhost_interface(void);
+btpan_interface_t *bt_get_pan_interface(void);
--
1.7.10.4
^ permalink raw reply related
* [PATCHv4 10/11] android: Add HID Host skeleton
From: Andrei Emeltchenko @ 2013-10-16 14:36 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381934198-7955-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Add skeleton for hidhost Android HAL. This is modified version
from Frederic Danis earlier patch set.
---
android/Android.mk | 1 +
android/hal-bluetooth.c | 4 +
android/hal-hidhost.c | 204 +++++++++++++++++++++++++++++++++++++++++++++++
android/hal.h | 1 +
4 files changed, 210 insertions(+)
create mode 100644 android/hal-hidhost.c
diff --git a/android/Android.mk b/android/Android.mk
index fb4383d..ab2171c 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -53,6 +53,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
hal-bluetooth.c \
hal-bt-sock.c \
+ hal-hidhost.c \
LOCAL_SHARED_LIBRARIES := \
libcutils \
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
index 89b8ebb..488606d 100644
--- a/android/hal-bluetooth.c
+++ b/android/hal-bluetooth.c
@@ -22,6 +22,7 @@
#include <hardware/bluetooth.h>
#include <hardware/bt_sock.h>
+#include <hardware/bt_hh.h>
#include <cutils/sockets.h>
#include <cutils/properties.h>
@@ -285,6 +286,9 @@ static const void *get_profile_interface(const char *profile_id)
if (!strcmp(profile_id, BT_PROFILE_SOCKETS_ID))
return bt_get_sock_interface();
+ if (!strcmp(profile_id, BT_PROFILE_HIDHOST_ID))
+ return bt_get_hidhost_interface();
+
return NULL;
}
diff --git a/android/hal-hidhost.c b/android/hal-hidhost.c
new file mode 100644
index 0000000..27cd1be
--- /dev/null
+++ b/android/hal-hidhost.c
@@ -0,0 +1,204 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdbool.h>
+
+#include <hardware/bluetooth.h>
+#include <hardware/bt_hh.h>
+
+#define LOG_TAG "BlueZ"
+#include <cutils/log.h>
+
+bthh_callbacks_t *bt_hh_cbacks;
+
+static bool interface_ready(void)
+{
+ return bt_hh_cbacks != NULL;
+}
+
+static bt_status_t bt_hidhost_connect(bt_bdaddr_t *bd_addr)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_disconnect(bt_bdaddr_t *bd_addr)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_virtual_unplug(bt_bdaddr_t *bd_addr)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_set_info(bt_bdaddr_t *bd_addr,
+ bthh_hid_info_t hid_info)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_get_protocol(bt_bdaddr_t *bd_addr,
+ bthh_protocol_mode_t protocolMode)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_set_protocol(bt_bdaddr_t *bd_addr,
+ bthh_protocol_mode_t protocolMode)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_get_report(bt_bdaddr_t *bd_addr,
+ bthh_report_type_t reportType,
+ uint8_t reportId,
+ int bufferSize)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_set_report(bt_bdaddr_t *bd_addr,
+ bthh_report_type_t reportType,
+ char *report)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr || !report)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_send_data(bt_bdaddr_t *bd_addr, char *data)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr || !data)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t bt_hidhost_init(bthh_callbacks_t *callbacks)
+{
+ ALOGI(__func__);
+
+ /* store reference to user callbacks */
+ bt_hh_cbacks = callbacks;
+
+ /* TODO: start HID Host thread */
+
+ /* TODO: enable service */
+
+ return BT_STATUS_SUCCESS;
+}
+
+static void bt_hidhost_cleanup(void)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return;
+
+ /* TODO: disable service */
+
+ /* TODO: stop HID Host thread */
+
+ bt_hh_cbacks = NULL;
+}
+
+static bthh_interface_t bt_hidhost_if = {
+ sizeof(bt_hidhost_if),
+ bt_hidhost_init,
+ bt_hidhost_connect,
+ bt_hidhost_disconnect,
+ bt_hidhost_virtual_unplug,
+ bt_hidhost_set_info,
+ bt_hidhost_get_protocol,
+ bt_hidhost_set_protocol,
+ bt_hidhost_get_report,
+ bt_hidhost_set_report,
+ bt_hidhost_send_data,
+ bt_hidhost_cleanup
+};
+
+bthh_interface_t *bt_get_hidhost_interface(void)
+{
+ return &bt_hidhost_if;
+}
diff --git a/android/hal.h b/android/hal.h
index 40fbf03..be69339 100644
--- a/android/hal.h
+++ b/android/hal.h
@@ -16,3 +16,4 @@
*/
btsock_interface_t *bt_get_sock_interface(void);
+bthh_interface_t *bt_get_hidhost_interface(void);
--
1.7.10.4
^ permalink raw reply related
* [PATCHv4 09/11] android: Rename hal_bt_sock.c to hal-bt-sock.c
From: Andrei Emeltchenko @ 2013-10-16 14:36 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381934198-7955-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/Android.mk | 2 +-
android/hal-bt-sock.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++
android/hal_bt_sock.c | 85 -------------------------------------------------
3 files changed, 86 insertions(+), 86 deletions(-)
create mode 100644 android/hal-bt-sock.c
delete mode 100644 android/hal_bt_sock.c
diff --git a/android/Android.mk b/android/Android.mk
index 021bb91..fb4383d 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -52,7 +52,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
hal-bluetooth.c \
- hal_bt_sock.c \
+ hal-bt-sock.c \
LOCAL_SHARED_LIBRARIES := \
libcutils \
diff --git a/android/hal-bt-sock.c b/android/hal-bt-sock.c
new file mode 100644
index 0000000..3a6d173
--- /dev/null
+++ b/android/hal-bt-sock.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdlib.h>
+
+#include <hardware/bluetooth.h>
+#include <hardware/bt_sock.h>
+
+#define LOG_TAG "BlueZ"
+#include <cutils/log.h>
+
+static bt_status_t btsock_listen_rfcomm(const char *service_name,
+ const uint8_t *uuid, int chan,
+ int *sock, int flags)
+{
+ ALOGD(__func__);
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t listen(btsock_type_t type, const char *service_name,
+ const uint8_t *uuid, int chan,
+ int *sock, int flags)
+{
+ if ((!uuid && chan <= 0) || !sock) {
+ ALOGE("%s: invalid params: uuid %p, chan %d, sock %p",
+ __func__, uuid, chan, sock);
+ return BT_STATUS_PARM_INVALID;
+ }
+
+ ALOGD("%s: uuid %p chan %d sock %p type %d service_name %s",
+ __func__, uuid, chan, sock, type, service_name);
+
+ switch (type) {
+ case BTSOCK_RFCOMM:
+ return btsock_listen_rfcomm(service_name, uuid, chan,
+ sock, flags);
+ default:
+ ALOGE("%s: Socket type %d not supported", __func__, type);
+ break;
+ }
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static bt_status_t connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
+ const uint8_t *uuid, int chan,
+ int *sock, int flags)
+{
+ if ((!uuid && chan <= 0) || !bdaddr || !sock) {
+ ALOGE("invalid params: bd_addr %p, uuid %p, chan %d, sock %p",
+ bdaddr, uuid, chan, sock);
+ return BT_STATUS_PARM_INVALID;
+ }
+
+ ALOGD("%s: uuid %p chan %d sock %p type %d", __func__, uuid, chan,
+ sock, type);
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static btsock_interface_t btsock_if = {
+ sizeof(btsock_if),
+ listen,
+ connect
+};
+
+btsock_interface_t *bt_get_sock_interface(void)
+{
+ return &btsock_if;
+}
diff --git a/android/hal_bt_sock.c b/android/hal_bt_sock.c
deleted file mode 100644
index 3a6d173..0000000
--- a/android/hal_bt_sock.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2013 Intel Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdlib.h>
-
-#include <hardware/bluetooth.h>
-#include <hardware/bt_sock.h>
-
-#define LOG_TAG "BlueZ"
-#include <cutils/log.h>
-
-static bt_status_t btsock_listen_rfcomm(const char *service_name,
- const uint8_t *uuid, int chan,
- int *sock, int flags)
-{
- ALOGD(__func__);
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static bt_status_t listen(btsock_type_t type, const char *service_name,
- const uint8_t *uuid, int chan,
- int *sock, int flags)
-{
- if ((!uuid && chan <= 0) || !sock) {
- ALOGE("%s: invalid params: uuid %p, chan %d, sock %p",
- __func__, uuid, chan, sock);
- return BT_STATUS_PARM_INVALID;
- }
-
- ALOGD("%s: uuid %p chan %d sock %p type %d service_name %s",
- __func__, uuid, chan, sock, type, service_name);
-
- switch (type) {
- case BTSOCK_RFCOMM:
- return btsock_listen_rfcomm(service_name, uuid, chan,
- sock, flags);
- default:
- ALOGE("%s: Socket type %d not supported", __func__, type);
- break;
- }
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static bt_status_t connect(const bt_bdaddr_t *bdaddr, btsock_type_t type,
- const uint8_t *uuid, int chan,
- int *sock, int flags)
-{
- if ((!uuid && chan <= 0) || !bdaddr || !sock) {
- ALOGE("invalid params: bd_addr %p, uuid %p, chan %d, sock %p",
- bdaddr, uuid, chan, sock);
- return BT_STATUS_PARM_INVALID;
- }
-
- ALOGD("%s: uuid %p chan %d sock %p type %d", __func__, uuid, chan,
- sock, type);
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static btsock_interface_t btsock_if = {
- sizeof(btsock_if),
- listen,
- connect
-};
-
-btsock_interface_t *bt_get_sock_interface(void)
-{
- return &btsock_if;
-}
--
1.7.10.4
^ permalink raw reply related
* [PATCHv4 08/11] android: Rename hal_bluetooth.c to hal-bluetooth.c
From: Andrei Emeltchenko @ 2013-10-16 14:36 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381934198-7955-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/Android.mk | 2 +-
android/hal-bluetooth.c | 384 +++++++++++++++++++++++++++++++++++++++++++++++
android/hal_bluetooth.c | 384 -----------------------------------------------
3 files changed, 385 insertions(+), 385 deletions(-)
create mode 100644 android/hal-bluetooth.c
delete mode 100644 android/hal_bluetooth.c
diff --git a/android/Android.mk b/android/Android.mk
index 821f1dc..021bb91 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -51,7 +51,7 @@ include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
- hal_bluetooth.c \
+ hal-bluetooth.c \
hal_bt_sock.c \
LOCAL_SHARED_LIBRARIES := \
diff --git a/android/hal-bluetooth.c b/android/hal-bluetooth.c
new file mode 100644
index 0000000..89b8ebb
--- /dev/null
+++ b/android/hal-bluetooth.c
@@ -0,0 +1,384 @@
+/*
+ * Copyright (C) 2013 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdbool.h>
+
+#include <hardware/bluetooth.h>
+#include <hardware/bt_sock.h>
+
+#include <cutils/sockets.h>
+#include <cutils/properties.h>
+
+#define LOG_TAG "BlueZ"
+#include <cutils/log.h>
+
+#include "hal.h"
+
+#define SERVICE_NAME "bluetoothd"
+
+bt_callbacks_t *bt_hal_cbacks = NULL;
+
+static bool interface_ready(void)
+{
+ return bt_hal_cbacks != NULL;
+}
+
+static bool start_bt_daemon(void)
+{
+ int tries = 40; /* wait 4 seconds for completion */
+
+ ALOGD(__func__);
+
+ /* Start Android Bluetooth daemon service */
+ property_set("ctl.start", SERVICE_NAME);
+
+ while (tries-- > 0) {
+ char val[PROPERTY_VALUE_MAX];
+
+ if (property_get("init.svc." SERVICE_NAME, val, NULL)) {
+ if (!strcmp(val, "running")) {
+ ALOGI("Android BlueZ daemon started");
+ return true;
+ }
+ } else {
+ return false;
+ }
+
+ usleep(100000);
+ }
+
+ return false;
+}
+
+static int init(bt_callbacks_t *callbacks)
+{
+ ALOGD(__func__);
+
+ if (interface_ready())
+ return BT_STATUS_SUCCESS;
+
+ if (start_bt_daemon()) {
+ /* TODO: open channel */
+
+ bt_hal_cbacks = callbacks;
+
+ return BT_STATUS_SUCCESS;
+ }
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int enable(void)
+{
+ ALOGD(__func__);
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int disable(void)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static void cleanup(void)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return;
+
+ bt_hal_cbacks = NULL;
+}
+
+static int get_adapter_properties(void)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int get_adapter_property(bt_property_type_t type)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int set_adapter_property(const bt_property_t *property)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (property == NULL)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int get_remote_device_properties(bt_bdaddr_t *remote_addr)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int get_remote_device_property(bt_bdaddr_t *remote_addr,
+ bt_property_type_t type)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int set_remote_device_property(bt_bdaddr_t *remote_addr,
+ const bt_property_t *property)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int get_remote_service_record(bt_bdaddr_t *remote_addr, bt_uuid_t *uuid)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int get_remote_services(bt_bdaddr_t *remote_addr)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int start_discovery(void)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int cancel_discovery(void)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int create_bond(const bt_bdaddr_t *bd_addr)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int cancel_bond(const bt_bdaddr_t *bd_addr)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int remove_bond(const bt_bdaddr_t *bd_addr)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int pin_reply(const bt_bdaddr_t *bd_addr, uint8_t accept,
+ uint8_t pin_len, bt_pin_code_t *pin_code)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int ssp_reply(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
+ uint8_t accept, uint32_t passkey)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ if (!bd_addr)
+ return BT_STATUS_PARM_INVALID;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static const void *get_profile_interface(const char *profile_id)
+{
+ ALOGD("%s: %s", __func__, profile_id);
+
+ if (!interface_ready())
+ return NULL;
+
+ if (!strcmp(profile_id, BT_PROFILE_SOCKETS_ID))
+ return bt_get_sock_interface();
+
+ return NULL;
+}
+
+static int dut_mode_configure(uint8_t enable)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static int dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t len)
+{
+ ALOGD(__func__);
+
+ if (!interface_ready())
+ return BT_STATUS_NOT_READY;
+
+ return BT_STATUS_UNSUPPORTED;
+}
+
+static const bt_interface_t bluetooth_if = {
+ .size = sizeof(bt_interface_t),
+ .init = init,
+ .enable = enable,
+ .disable = disable,
+ .cleanup = cleanup,
+ .get_adapter_properties = get_adapter_properties,
+ .get_adapter_property = get_adapter_property,
+ .set_adapter_property = set_adapter_property,
+ .get_remote_device_properties = get_remote_device_properties,
+ .get_remote_device_property = get_remote_device_property,
+ .set_remote_device_property = set_remote_device_property,
+ .get_remote_service_record = get_remote_service_record,
+ .get_remote_services = get_remote_services,
+ .start_discovery = start_discovery,
+ .cancel_discovery = cancel_discovery,
+ .create_bond = create_bond,
+ .remove_bond = remove_bond,
+ .cancel_bond = cancel_bond,
+ .pin_reply = pin_reply,
+ .ssp_reply = ssp_reply,
+ .get_profile_interface = get_profile_interface,
+ .dut_mode_configure = dut_mode_configure,
+ .dut_mode_send = dut_mode_send
+};
+
+static const bt_interface_t *get_bluetooth_interface(void)
+{
+ ALOGD(__func__);
+
+ return &bluetooth_if;
+}
+
+static int close_bluetooth(struct hw_device_t *device)
+{
+ ALOGD(__func__);
+
+ cleanup();
+
+ return 0;
+}
+
+static int open_bluetooth(const struct hw_module_t *module, char const *name,
+ struct hw_device_t **device)
+{
+ bluetooth_device_t *dev = malloc(sizeof(bluetooth_device_t));
+
+ ALOGD(__func__);
+
+ memset(dev, 0, sizeof(bluetooth_device_t));
+ dev->common.tag = HARDWARE_DEVICE_TAG;
+ dev->common.version = 0;
+ dev->common.module = (struct hw_module_t *) module;
+ dev->common.close = close_bluetooth;
+ dev->get_bluetooth_interface = get_bluetooth_interface;
+
+ *device = (struct hw_device_t *) dev;
+
+ return 0;
+}
+
+static struct hw_module_methods_t bluetooth_module_methods = {
+ .open = open_bluetooth,
+};
+
+struct hw_module_t HAL_MODULE_INFO_SYM = {
+ .tag = HARDWARE_MODULE_TAG,
+ .version_major = 1,
+ .version_minor = 0,
+ .id = BT_HARDWARE_MODULE_ID,
+ .name = "BlueZ Bluetooth stack",
+ .author = "Intel Corporation",
+ .methods = &bluetooth_module_methods
+};
diff --git a/android/hal_bluetooth.c b/android/hal_bluetooth.c
deleted file mode 100644
index 89b8ebb..0000000
--- a/android/hal_bluetooth.c
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * Copyright (C) 2013 Intel Corporation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdbool.h>
-
-#include <hardware/bluetooth.h>
-#include <hardware/bt_sock.h>
-
-#include <cutils/sockets.h>
-#include <cutils/properties.h>
-
-#define LOG_TAG "BlueZ"
-#include <cutils/log.h>
-
-#include "hal.h"
-
-#define SERVICE_NAME "bluetoothd"
-
-bt_callbacks_t *bt_hal_cbacks = NULL;
-
-static bool interface_ready(void)
-{
- return bt_hal_cbacks != NULL;
-}
-
-static bool start_bt_daemon(void)
-{
- int tries = 40; /* wait 4 seconds for completion */
-
- ALOGD(__func__);
-
- /* Start Android Bluetooth daemon service */
- property_set("ctl.start", SERVICE_NAME);
-
- while (tries-- > 0) {
- char val[PROPERTY_VALUE_MAX];
-
- if (property_get("init.svc." SERVICE_NAME, val, NULL)) {
- if (!strcmp(val, "running")) {
- ALOGI("Android BlueZ daemon started");
- return true;
- }
- } else {
- return false;
- }
-
- usleep(100000);
- }
-
- return false;
-}
-
-static int init(bt_callbacks_t *callbacks)
-{
- ALOGD(__func__);
-
- if (interface_ready())
- return BT_STATUS_SUCCESS;
-
- if (start_bt_daemon()) {
- /* TODO: open channel */
-
- bt_hal_cbacks = callbacks;
-
- return BT_STATUS_SUCCESS;
- }
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int enable(void)
-{
- ALOGD(__func__);
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int disable(void)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static void cleanup(void)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return;
-
- bt_hal_cbacks = NULL;
-}
-
-static int get_adapter_properties(void)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int get_adapter_property(bt_property_type_t type)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int set_adapter_property(const bt_property_t *property)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- if (property == NULL)
- return BT_STATUS_PARM_INVALID;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int get_remote_device_properties(bt_bdaddr_t *remote_addr)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int get_remote_device_property(bt_bdaddr_t *remote_addr,
- bt_property_type_t type)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int set_remote_device_property(bt_bdaddr_t *remote_addr,
- const bt_property_t *property)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int get_remote_service_record(bt_bdaddr_t *remote_addr, bt_uuid_t *uuid)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int get_remote_services(bt_bdaddr_t *remote_addr)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int start_discovery(void)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int cancel_discovery(void)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int create_bond(const bt_bdaddr_t *bd_addr)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- if (!bd_addr)
- return BT_STATUS_PARM_INVALID;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int cancel_bond(const bt_bdaddr_t *bd_addr)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int remove_bond(const bt_bdaddr_t *bd_addr)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int pin_reply(const bt_bdaddr_t *bd_addr, uint8_t accept,
- uint8_t pin_len, bt_pin_code_t *pin_code)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int ssp_reply(const bt_bdaddr_t *bd_addr, bt_ssp_variant_t variant,
- uint8_t accept, uint32_t passkey)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- if (!bd_addr)
- return BT_STATUS_PARM_INVALID;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static const void *get_profile_interface(const char *profile_id)
-{
- ALOGD("%s: %s", __func__, profile_id);
-
- if (!interface_ready())
- return NULL;
-
- if (!strcmp(profile_id, BT_PROFILE_SOCKETS_ID))
- return bt_get_sock_interface();
-
- return NULL;
-}
-
-static int dut_mode_configure(uint8_t enable)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static int dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t len)
-{
- ALOGD(__func__);
-
- if (!interface_ready())
- return BT_STATUS_NOT_READY;
-
- return BT_STATUS_UNSUPPORTED;
-}
-
-static const bt_interface_t bluetooth_if = {
- .size = sizeof(bt_interface_t),
- .init = init,
- .enable = enable,
- .disable = disable,
- .cleanup = cleanup,
- .get_adapter_properties = get_adapter_properties,
- .get_adapter_property = get_adapter_property,
- .set_adapter_property = set_adapter_property,
- .get_remote_device_properties = get_remote_device_properties,
- .get_remote_device_property = get_remote_device_property,
- .set_remote_device_property = set_remote_device_property,
- .get_remote_service_record = get_remote_service_record,
- .get_remote_services = get_remote_services,
- .start_discovery = start_discovery,
- .cancel_discovery = cancel_discovery,
- .create_bond = create_bond,
- .remove_bond = remove_bond,
- .cancel_bond = cancel_bond,
- .pin_reply = pin_reply,
- .ssp_reply = ssp_reply,
- .get_profile_interface = get_profile_interface,
- .dut_mode_configure = dut_mode_configure,
- .dut_mode_send = dut_mode_send
-};
-
-static const bt_interface_t *get_bluetooth_interface(void)
-{
- ALOGD(__func__);
-
- return &bluetooth_if;
-}
-
-static int close_bluetooth(struct hw_device_t *device)
-{
- ALOGD(__func__);
-
- cleanup();
-
- return 0;
-}
-
-static int open_bluetooth(const struct hw_module_t *module, char const *name,
- struct hw_device_t **device)
-{
- bluetooth_device_t *dev = malloc(sizeof(bluetooth_device_t));
-
- ALOGD(__func__);
-
- memset(dev, 0, sizeof(bluetooth_device_t));
- dev->common.tag = HARDWARE_DEVICE_TAG;
- dev->common.version = 0;
- dev->common.module = (struct hw_module_t *) module;
- dev->common.close = close_bluetooth;
- dev->get_bluetooth_interface = get_bluetooth_interface;
-
- *device = (struct hw_device_t *) dev;
-
- return 0;
-}
-
-static struct hw_module_methods_t bluetooth_module_methods = {
- .open = open_bluetooth,
-};
-
-struct hw_module_t HAL_MODULE_INFO_SYM = {
- .tag = HARDWARE_MODULE_TAG,
- .version_major = 1,
- .version_minor = 0,
- .id = BT_HARDWARE_MODULE_ID,
- .name = "BlueZ Bluetooth stack",
- .author = "Intel Corporation",
- .methods = &bluetooth_module_methods
-};
--
1.7.10.4
^ permalink raw reply related
* [PATCHv4 07/11] android: Use kernel style to initialize struct fields
From: Andrei Emeltchenko @ 2013-10-16 14:36 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381934198-7955-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
android/hal_bluetooth.c | 46 +++++++++++++++++++++++-----------------------
1 file changed, 23 insertions(+), 23 deletions(-)
diff --git a/android/hal_bluetooth.c b/android/hal_bluetooth.c
index 9bb9dcf..89b8ebb 100644
--- a/android/hal_bluetooth.c
+++ b/android/hal_bluetooth.c
@@ -309,29 +309,29 @@ static int dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t len)
}
static const bt_interface_t bluetooth_if = {
- sizeof(bt_interface_t),
- init,
- enable,
- disable,
- cleanup,
- get_adapter_properties,
- get_adapter_property,
- set_adapter_property,
- get_remote_device_properties,
- get_remote_device_property,
- set_remote_device_property,
- get_remote_service_record,
- get_remote_services,
- start_discovery,
- cancel_discovery,
- create_bond,
- remove_bond,
- cancel_bond,
- pin_reply,
- ssp_reply,
- get_profile_interface,
- dut_mode_configure,
- dut_mode_send
+ .size = sizeof(bt_interface_t),
+ .init = init,
+ .enable = enable,
+ .disable = disable,
+ .cleanup = cleanup,
+ .get_adapter_properties = get_adapter_properties,
+ .get_adapter_property = get_adapter_property,
+ .set_adapter_property = set_adapter_property,
+ .get_remote_device_properties = get_remote_device_properties,
+ .get_remote_device_property = get_remote_device_property,
+ .set_remote_device_property = set_remote_device_property,
+ .get_remote_service_record = get_remote_service_record,
+ .get_remote_services = get_remote_services,
+ .start_discovery = start_discovery,
+ .cancel_discovery = cancel_discovery,
+ .create_bond = create_bond,
+ .remove_bond = remove_bond,
+ .cancel_bond = cancel_bond,
+ .pin_reply = pin_reply,
+ .ssp_reply = ssp_reply,
+ .get_profile_interface = get_profile_interface,
+ .dut_mode_configure = dut_mode_configure,
+ .dut_mode_send = dut_mode_send
};
static const bt_interface_t *get_bluetooth_interface(void)
--
1.7.10.4
^ permalink raw reply related
* [PATCHv4 06/11] android: Implement read_info_complete callback
From: Andrei Emeltchenko @ 2013-10-16 14:36 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1381934198-7955-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Handle read info complete callback from mgmt interface.
---
Makefile.android | 3 +-
android/Android.mk | 1 +
android/adapter.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++
android/adapter.h | 4 +++
android/main.c | 21 +++++++------
5 files changed, 103 insertions(+), 10 deletions(-)
diff --git a/Makefile.android b/Makefile.android
index 4d7da39..11eadc2 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -7,7 +7,8 @@ android_bluetoothd_SOURCES = android/main.c \
src/sdpd-database.c src/sdpd-server.c \
src/sdpd-service.c src/sdpd-request.c \
src/shared/util.h src/shared/util.c \
- src/shared/mgmt.h src/shared/mgmt.c
+ src/shared/mgmt.h src/shared/mgmt.c \
+ android/adapter.h android/adapter.c
android_bluetoothd_LDADD = lib/libbluetooth-internal.la @GLIB_LIBS@
endif
diff --git a/android/Android.mk b/android/Android.mk
index 560fb0a..821f1dc 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -15,6 +15,7 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
main.c \
log.c \
+ adapter.c \
../src/shared/mgmt.c \
../src/shared/util.c \
../src/sdpd-database.c \
diff --git a/android/adapter.c b/android/adapter.c
index 9763530..a660ed0 100644
--- a/android/adapter.c
+++ b/android/adapter.c
@@ -21,14 +21,25 @@
*
*/
+#include "lib/bluetooth.h"
#include "src/shared/mgmt.h"
+#include "lib/mgmt.h"
#include "log.h"
#include "adapter.h"
struct bt_adapter {
struct mgmt *mgmt;
+ bdaddr_t bdaddr;
+ uint32_t dev_class;
+
+ char *name;
+
+ uint32_t supported_settings;
+ uint32_t current_settings;
};
+extern struct bt_adapter *default_adapter;
+
struct bt_adapter *bt_adapter_new(uint16_t index, struct mgmt *mgmt_if)
{
struct bt_adapter *adapter;
@@ -52,3 +63,76 @@ void bt_adapter_stop(struct bt_adapter *adapter)
{
DBG("");
}
+
+static void load_link_keys_complete(uint8_t status, uint16_t length,
+ const void *param, void *user_data)
+{
+ DBG("status %u", status);
+}
+
+void load_link_keys(struct bt_adapter *adapter, GSList *keys)
+{
+ struct mgmt_cp_load_link_keys *cp;
+ size_t key_len = g_slist_length(keys);
+ struct mgmt_link_key_info *key;
+ size_t len;
+
+ DBG("");
+
+ len = sizeof(*cp) + key_len * sizeof(*key);
+ cp = g_malloc0(len);
+
+ cp->debug_keys = 0;
+ cp->key_count = htobs(key_len);
+
+ mgmt_send(adapter->mgmt, MGMT_OP_LOAD_LINK_KEYS, 0, len,
+ cp, load_link_keys_complete, adapter, NULL);
+
+ free(cp);
+}
+
+void read_info_complete(uint8_t status, uint16_t length, const void *param,
+ void *user_data)
+{
+ struct bt_adapter *adapter = user_data;
+ const struct mgmt_rp_read_info *rp = param;
+
+ DBG("");
+
+ if (status) {
+ error("Failed to read info for index %u: %s (0x%02x)",
+ 0, mgmt_errstr(status), status);
+ goto failed;
+ }
+
+ if (length < sizeof(*rp)) {
+ error("Too small read info complete response");
+ goto failed;
+ }
+
+ if (!bacmp(&rp->bdaddr, BDADDR_ANY)) {
+ error("No Bluetooth address");
+ goto failed;
+ }
+
+ /* Store adapter information */
+ bacpy(&adapter->bdaddr, &rp->bdaddr);
+ adapter->dev_class = rp->dev_class[0] | (rp->dev_class[1] << 8) |
+ (rp->dev_class[2] << 16);
+ adapter->name = g_strdup((const char *) rp->name);
+
+ adapter->supported_settings = btohs(rp->supported_settings);
+ adapter->current_settings = btohs(rp->current_settings);
+
+ /* TODO: Register all event notification handlers */
+
+ if (adapter->current_settings & MGMT_SETTING_POWERED)
+ bt_adapter_start(adapter);
+
+ load_link_keys(adapter, NULL);
+
+ return;
+
+failed:
+ default_adapter = NULL;
+}
diff --git a/android/adapter.h b/android/adapter.h
index 0f1445a..3025f89 100644
--- a/android/adapter.h
+++ b/android/adapter.h
@@ -34,3 +34,7 @@ struct bt_adapter *bt_adapter_new(uint16_t index, struct mgmt *mgmt_if);
void bt_adapter_start(struct bt_adapter *adapter);
void bt_adapter_stop(struct bt_adapter *adapter);
+
+void read_info_complete(uint8_t status, uint16_t length, const void *param,
+ void *user_data);
+void load_link_keys(struct bt_adapter *adapter, GSList *keys);
diff --git a/android/main.c b/android/main.c
index 091ef20..39d6266 100644
--- a/android/main.c
+++ b/android/main.c
@@ -57,6 +57,8 @@
#include "lib/mgmt.h"
#include "src/shared/mgmt.h"
+#include "adapter.h"
+
#define SHUTDOWN_GRACE_SECONDS 10
static GMainLoop *event_loop;
@@ -65,6 +67,8 @@ static struct mgmt *mgmt_if = NULL;
static uint8_t mgmt_version = 0;
static uint8_t mgmt_revision = 0;
+struct bt_adapter *default_adapter = NULL;
+
static gboolean quit_eventloop(gpointer user_data)
{
g_main_loop_quit(event_loop);
@@ -92,21 +96,20 @@ static GOptionEntry options[] = {
{ NULL }
};
-static void read_info_complete(uint8_t status, uint16_t length,
- const void *param, void *user_data)
-{
- /* TODO: Store Controller information */
-
- /* TODO: Register all event notification handlers */
-}
-
static void mgmt_index_added_event(uint16_t index, uint16_t length,
const void *param, void *user_data)
{
DBG("index %u", index);
+ if (default_adapter) {
+ DBG("skip event for index %u", index);
+ return;
+ }
+
+ default_adapter = bt_adapter_new(index, mgmt_if);
+
if (mgmt_send(mgmt_if, MGMT_OP_READ_INFO, index, 0, NULL,
- read_info_complete, NULL, NULL) > 0)
+ read_info_complete, default_adapter, NULL) > 0)
return;
error("Failed to read adapter info for index %u", index);
--
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