* Kernel Bug - Bluetooth
From: John Tobias @ 2012-08-18 0:17 UTC (permalink / raw)
To: linux-bluetooth
Hello Guys,
I am not sure if this mailing list is the right to post the bug.
I just ran "hciconfig hci1 leadv" then when I connect my iPhone apps,
it dumps the error messages below:
john
[ 260.111724] ======================================================
[ 260.118194] [ INFO: possible circular locking dependency detected ]
[ 260.124755] 3.5.2 #4 Not tainted
[ 260.128143] -------------------------------------------------------
[ 260.134704] kworker/u:0/5 is trying to acquire lock:
[ 260.139892] ([ 260.141662]
sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP){+.+...}, at: [<bf03b7ec>]
l2cap_chan_ready+0x1c/0xbc [bluetooth]
[ 260.152435] but task is already holding lock:
[ 260.157196] (&chan->lock){+.+...}, at: [<bf043474>]
l2cap_connect_cfm+0xf4/0x388 [bluetooth]
[ 260.166198]
[ 260.166198] which lock already depends on the new lock.
[ 260.166198]
[ 260.174774]
[ 260.174774] the existing dependency chain (in reverse order) is:
[ 260.182617]
-> #2 (&chan->lock){+.+...}:
[ 260.186950] [<c0090dc4>] lock_acquire+0x98/0x100
[ 260.192413] [<c0568290>] mutex_lock_nested+0x3c/0x2f4
[ 260.198364] [<bf043474>] l2cap_connect_cfm+0xf4/0x388 [bluetooth]
[ 260.205444] [<bf030388>] hci_event_packet+0x5304/0x6d9c [bluetooth]
[ 260.212707] [<bf026498>] hci_rx_work+0x288/0x358 [bluetooth]
[ 260.219299] [<c005ab38>] process_one_work+0x19c/0x4f4
[ 260.225250] [<c005d6f8>] worker_thread+0x170/0x378
[ 260.230926] [<c00623e4>] kthread+0x90/0x9c
[ 260.235870] [<c0014eb4>] kernel_thread_exit+0x0/0x8
[ 260.241638]
-> #1 (&conn->chan_lock){+.+...}:
[ 260.246429] [<c0090dc4>] lock_acquire+0x98/0x100
[ 260.251922] [<c0568290>] mutex_lock_nested+0x3c/0x2f4
[ 260.257843] [<bf04365c>] l2cap_connect_cfm+0x2dc/0x388 [bluetooth]
[ 260.265045] [<bf030388>] hci_event_packet+0x5304/0x6d9c [bluetooth]
[ 260.272308] [<bf026498>] hci_rx_work+0x288/0x358 [bluetooth]
[ 260.278900] [<c005ab38>] process_one_work+0x19c/0x4f4
[ 260.284851] [<c005d6f8>] worker_thread+0x170/0x378
[ 260.290527] [<c00623e4>] kthread+0x90/0x9c
[ 260.295471] [<c0014eb4>] kernel_thread_exit+0x0/0x8
[ 260.301239]
-> #0 (sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP){+.+...}:
[ 260.307647] [<c00906ec>] __lock_acquire+0x1cf8/0x1d88
[ 260.313598] [<c0090dc4>] lock_acquire+0x98/0x100
[ 260.319061] [<c043a454>] lock_sock_nested+0x6c/0x78
[ 260.324829] [<bf03b7ec>] l2cap_chan_ready+0x1c/0xbc [bluetooth]
[ 260.331756] [<bf043580>] l2cap_connect_cfm+0x200/0x388 [bluetooth]
[ 260.338928] [<bf030388>] hci_event_packet+0x5304/0x6d9c [bluetooth]
[ 260.346160] [<bf026498>] hci_rx_work+0x288/0x358 [bluetooth]
[ 260.352783] [<c005ab38>] process_one_work+0x19c/0x4f4
[ 260.358734] [<c005d6f8>] worker_thread+0x170/0x378
[ 260.364410] [<c00623e4>] kthread+0x90/0x9c
[ 260.369323] [<c0014eb4>] kernel_thread_exit+0x0/0x8
[ 260.375091]
[ 260.375091] other info that might help us debug this:
[ 260.375091]
[ 260.383483] Chain exists of:
sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP --> &conn->chan_lock --> &chan->lock
[ 260.393585] Possible unsafe locking scenario:
[ 260.393585]
[ 260.399780] CPU0 CPU1
[ 260.404510] ---- ----
[ 260.409271] lock(&chan->lock);
[ 260.412658] lock(&conn->chan_lock);
[ 260.419158] lock(&chan->lock);
[ 260.425201] lock(sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP);
[ 260.430664]
[ 260.430664] *** DEADLOCK ***
[ 260.430664]
[ 260.436889] 5 locks held by kworker/u:0/5:
[ 260.441192] #0: (hdev->name){.+.+.+}, at: [<c005aab8>]
process_one_work+0x11c/0x4f4
[ 260.449432] #1: ((&hdev->rx_work)){+.+.+.}, at: [<c005aab8>]
process_one_work+0x11c/0x4f4
[ 260.458221] #2: (&hdev->lock){+.+.+.}, at: [<bf02cf6c>]
hci_event_packet+0x1ee8/0x6d9c [bluetooth]
[ 260.467895] #3: (&conn->chan_lock){+.+...}, at: [<bf0433e4>]
l2cap_connect_cfm+0x64/0x388 [bluetooth]
[ 260.477844] #4: (&chan->lock){+.+...}, at: [<bf043474>]
l2cap_connect_cfm+0xf4/0x388 [bluetooth]
[ 260.487304]
[ 260.487304] stack backtrace:
[ 260.491912] [<c001b624>] (unwind_backtrace+0x0/0xf0) from
[<c008cf28>] (print_circular_bug+0x1c8/0x2d4)
[ 260.501770] [<c008cf28>] (print_circular_bug+0x1c8/0x2d4) from
[<c00906ec>] (__lock_acquire+0x1cf8/0x1d88)
[ 260.511901] [<c00906ec>] (__lock_acquire+0x1cf8/0x1d88) from
[<c0090dc4>] (lock_acquire+0x98/0x100)
[ 260.521392] [<c0090dc4>] (lock_acquire+0x98/0x100) from
[<c043a454>] (lock_sock_nested+0x6c/0x78)
[ 260.530761] [<c043a454>] (lock_sock_nested+0x6c/0x78) from
[<bf03b7ec>] (l2cap_chan_ready+0x1c/0xbc [bluetooth])
[ 260.541534] [<bf03b7ec>] (l2cap_chan_ready+0x1c/0xbc [bluetooth])
from [<bf043580>] (l2cap_connect_cfm+0x200/0x388 [bluetooth])
[ 260.553649] [<bf043580>] (l2cap_connect_cfm+0x200/0x388
[bluetooth]) from [<bf030388>] (hci_event_packet+0x5304/0x6d9c
[bluetooth])
[ 260.566131] [<bf030388>] (hci_event_packet+0x5304/0x6d9c
[bluetooth]) from [<bf026498>] (hci_rx_work+0x288/0x358 [bluetooth])
[ 260.578033] [<bf026498>] (hci_rx_work+0x288/0x358 [bluetooth]) from
[<c005ab38>] (process_one_work+0x19c/0x4f4)
[ 260.588623] [<c005ab38>] (process_one_work+0x19c/0x4f4) from
[<c005d6f8>] (worker_thread+0x170/0x378)
[ 260.598297] [<c005d6f8>] (worker_thread+0x170/0x378) from
[<c00623e4>] (kthread+0x90/0x9c)
[ 260.606964] [<c00623e4>] (kthread+0x90/0x9c) from [<c0014eb4>]
(kernel_thread_exit+0x0/0x8)
^ permalink raw reply
* Re: Setting up an A2DP server
From: Niklas Claesson @ 2012-08-17 21:50 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <CAAHv3KHnRM=7WYgy-teqUZfFYNoGPdkOb0dgf3t4XiuYtoUOOA@mail.gmail.com>
I've actually solved the issue myself by writing an Agent that accepts
all incoming requests, and another python script that polls 'pacmd
list-sources' every 2 seconds for new bluetooth sources. And third and
probably most important was setting "Master" option to "False" in
audio.conf.
Regards
Niklas Claesson
2012/8/17 Niklas Claesson <nicke.claesson@gmail.com>:
> Hi,
>
> I would like to use a computer as an A2DP sink (bluetooth devices
> should be able to play through the computers speakers). So far I can
> manually connect from the computer using dbus signals with bluez/pulse
> (org.bluez.AudioSource). But what I really want is for the external
> device to connect to my service. The goal is to let anyone with
> bluetooth play music in our common space at the university.
>
> What would be the most straight forward way to implement this?
>
> Med vänliga hälsningar
> Niklas Claesson
^ permalink raw reply
* [PATCH BlueZ v0 5/5] hog: Add writting Control Point
From: Claudio Takahasi @ 2012-08-17 21:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345237703-15342-1-git-send-email-claudio.takahasi@openbossa.org>
This patch adds GATT write without response operation when suspending
or resuming.
---
profiles/input/hog_device.c | 27 ++++++++++++++++++++++++++-
profiles/input/hog_device.h | 1 +
profiles/input/hog_manager.c | 14 ++++++++++++++
3 files changed, 41 insertions(+), 1 deletions(-)
diff --git a/profiles/input/hog_device.c b/profiles/input/hog_device.c
index a561876..2e9293d 100644
--- a/profiles/input/hog_device.c
+++ b/profiles/input/hog_device.c
@@ -55,6 +55,7 @@
#define HOG_REPORT_MAP_UUID 0x2A4B
#define HOG_REPORT_UUID 0x2A4D
#define HOG_PROTO_MODE_UUID 0x2A4E
+#define HOG_CONTROL_POINT_UUID 0x2A4C
#define HOG_REPORT_TYPE_INPUT 1
#define HOG_REPORT_TYPE_OUTPUT 2
@@ -82,6 +83,7 @@ struct hog_device {
uint16_t bcdhid;
uint8_t bcountrycode;
uint16_t proto_mode_handle;
+ uint16_t ctrlpt_handle;
uint8_t flags;
};
@@ -437,7 +439,8 @@ static void proto_mode_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
static void char_discovered_cb(GSList *chars, guint8 status, gpointer user_data)
{
struct hog_device *hogdev = user_data;
- bt_uuid_t report_uuid, report_map_uuid, info_uuid, proto_mode_uuid;
+ bt_uuid_t report_uuid, report_map_uuid, info_uuid, proto_mode_uuid,
+ ctrlpt_uuid;
struct report *report;
GSList *l;
uint16_t info_handle = 0, proto_mode_handle = 0;
@@ -452,6 +455,7 @@ static void char_discovered_cb(GSList *chars, guint8 status, gpointer user_data)
bt_uuid16_create(&report_map_uuid, HOG_REPORT_MAP_UUID);
bt_uuid16_create(&info_uuid, HOG_INFO_UUID);
bt_uuid16_create(&proto_mode_uuid, HOG_PROTO_MODE_UUID);
+ bt_uuid16_create(&ctrlpt_uuid, HOG_CONTROL_POINT_UUID);
for (l = chars; l; l = g_slist_next(l)) {
struct gatt_char *chr, *next;
@@ -480,6 +484,8 @@ static void char_discovered_cb(GSList *chars, guint8 status, gpointer user_data)
info_handle = chr->value_handle;
else if (bt_uuid_cmp(&uuid, &proto_mode_uuid) == 0)
proto_mode_handle = chr->value_handle;
+ else if (bt_uuid_cmp(&uuid, &ctrlpt_uuid) == 0)
+ hogdev->ctrlpt_handle = chr->value_handle;
}
if (proto_mode_handle) {
@@ -763,3 +769,22 @@ int hog_device_unregister(struct hog_device *hogdev)
return 0;
}
+
+int hog_device_set_control_point(struct hog_device *hogdev, gboolean suspend)
+{
+ uint8_t value = suspend ? 0x00 : 0x01;
+
+ if (hogdev->attrib == NULL)
+ return -ENOTCONN;
+
+ DBG("%s HID Control Point: %s", hogdev->path, suspend ?
+ "Suspend" : "Exit Suspend");
+
+ if (hogdev->ctrlpt_handle == 0)
+ return -ENOTSUP;
+
+ gatt_write_char(hogdev->attrib, hogdev->ctrlpt_handle, &value,
+ sizeof(value), NULL, NULL);
+
+ return 0;
+}
diff --git a/profiles/input/hog_device.h b/profiles/input/hog_device.h
index 5679527..54b2cde 100644
--- a/profiles/input/hog_device.h
+++ b/profiles/input/hog_device.h
@@ -30,3 +30,4 @@ struct hog_device *hog_device_register(struct btd_device *device,
const char *path, int *perr);
int hog_device_unregister(struct hog_device *hogdev);
struct hog_device *hog_device_find(GSList *list, const char *path);
+int hog_device_set_control_point(struct hog_device *hogdev, gboolean suspend);
diff --git a/profiles/input/hog_manager.c b/profiles/input/hog_manager.c
index ce8e2ff..7f1cdba 100644
--- a/profiles/input/hog_manager.c
+++ b/profiles/input/hog_manager.c
@@ -42,12 +42,26 @@ static gboolean upower_supported = FALSE;
static DBusConnection *connection = NULL;
static GSList *devices = NULL;
+static void set_suspend(gpointer data, gpointer user_data)
+{
+ struct hog_device *hogdev = data;
+ gboolean suspend = GPOINTER_TO_INT(user_data);
+
+ hog_device_set_control_point(hogdev, suspend);
+}
+
static void suspend_event_cb(void)
{
+ gboolean suspend = TRUE;
+
+ g_slist_foreach(devices, set_suspend, GINT_TO_POINTER(suspend));
}
static void resume_event_cb(void)
{
+ gboolean suspend = FALSE;
+
+ g_slist_foreach(devices, set_suspend, GINT_TO_POINTER(suspend));
}
static int hog_device_probe(struct btd_device *device, GSList *uuids)
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v0 4/5] hog: Move HoG device list to manager
From: Claudio Takahasi @ 2012-08-17 21:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345237703-15342-1-git-send-email-claudio.takahasi@openbossa.org>
This patch moves the HoG device list from hog_device.c to hog_manager.c
in order to be possible to easily notify suspend/resume events to each
created device.
---
profiles/input/hog_device.c | 46 ++++++++++++++++++++---------------------
profiles/input/hog_device.h | 8 +++++-
profiles/input/hog_manager.c | 22 ++++++++++++++++++-
3 files changed, 48 insertions(+), 28 deletions(-)
diff --git a/profiles/input/hog_device.c b/profiles/input/hog_device.c
index 5a1de12..a561876 100644
--- a/profiles/input/hog_device.c
+++ b/profiles/input/hog_device.c
@@ -92,8 +92,6 @@ struct report {
struct hog_device *hogdev;
};
-static GSList *devices = NULL;
-
static gint report_handle_cmp(gconstpointer a, gconstpointer b)
{
const struct report *report = a;
@@ -627,7 +625,7 @@ static void attio_disconnected_cb(gpointer user_data)
hogdev->attrib = NULL;
}
-static struct hog_device *find_device_by_path(GSList *list, const char *path)
+struct hog_device *hog_device_find(GSList *list, const char *path)
{
for (; list; list = list->next) {
struct hog_device *hogdev = list->data;
@@ -689,31 +687,33 @@ static void hog_device_free(struct hog_device *hogdev)
g_free(hogdev);
}
-int hog_device_register(struct btd_device *device, const char *path)
+struct hog_device *hog_device_register(struct btd_device *device,
+ const char *path, int *perr)
{
- struct hog_device *hogdev;
struct gatt_primary *prim;
+ struct hog_device *hogdev;
GIOCondition cond = G_IO_IN | G_IO_ERR | G_IO_NVAL;
GIOChannel *io;
-
- hogdev = find_device_by_path(devices, path);
- if (hogdev)
- return -EALREADY;
+ int err;
prim = load_hog_primary(device);
- if (!prim)
- return -EINVAL;
+ if (!prim) {
+ err = -EINVAL;
+ goto failed;
+ }
hogdev = hog_device_new(device, path);
- if (!hogdev)
- return -ENOMEM;
+ if (!hogdev) {
+ err = -ENOMEM;
+ goto failed;
+ }
hogdev->uhid_fd = open(UHID_DEVICE_FILE, O_RDWR | O_CLOEXEC);
if (hogdev->uhid_fd < 0) {
- int err = -errno;
+ err = -errno;
error("Failed to open uHID device: %s", strerror(-err));
hog_device_free(hogdev);
- return err;
+ goto failed;
}
io = g_io_channel_unix_new(hogdev->uhid_fd);
@@ -731,20 +731,19 @@ int hog_device_register(struct btd_device *device, const char *path)
device_set_auto_connect(device, TRUE);
- devices = g_slist_append(devices, hogdev);
+ return hogdev;
- return 0;
+failed:
+ if (perr)
+ *perr = err;
+
+ return NULL;
}
-int hog_device_unregister(const char *path)
+int hog_device_unregister(struct hog_device *hogdev)
{
- struct hog_device *hogdev;
struct uhid_event ev;
- hogdev = find_device_by_path(devices, path);
- if (hogdev == NULL)
- return -EINVAL;
-
btd_device_remove_attio_callback(hogdev->device, hogdev->attioid);
if (hogdev->uhid_watch_id) {
@@ -760,7 +759,6 @@ int hog_device_unregister(const char *path)
close(hogdev->uhid_fd);
hogdev->uhid_fd = -1;
- devices = g_slist_remove(devices, hogdev);
hog_device_free(hogdev);
return 0;
diff --git a/profiles/input/hog_device.h b/profiles/input/hog_device.h
index ce6a79e..5679527 100644
--- a/profiles/input/hog_device.h
+++ b/profiles/input/hog_device.h
@@ -24,5 +24,9 @@
#define HOG_UUID "00001812-0000-1000-8000-00805f9b34fb"
-int hog_device_register(struct btd_device *device, const char *path);
-int hog_device_unregister(const char *path);
+struct hog_device;
+
+struct hog_device *hog_device_register(struct btd_device *device,
+ const char *path, int *perr);
+int hog_device_unregister(struct hog_device *hogdev);
+struct hog_device *hog_device_find(GSList *list, const char *path);
diff --git a/profiles/input/hog_manager.c b/profiles/input/hog_manager.c
index f32405d..ce8e2ff 100644
--- a/profiles/input/hog_manager.c
+++ b/profiles/input/hog_manager.c
@@ -40,6 +40,7 @@
static gboolean upower_supported = FALSE;
static DBusConnection *connection = NULL;
+static GSList *devices = NULL;
static void suspend_event_cb(void)
{
@@ -52,19 +53,36 @@ static void resume_event_cb(void)
static int hog_device_probe(struct btd_device *device, GSList *uuids)
{
const char *path = device_get_path(device);
+ struct hog_device *hogdev;
+ int err;
DBG("path %s", path);
- return hog_device_register(device, path);
+ hogdev = hog_device_find(devices, path);
+ if (hogdev)
+ return -EALREADY;
+
+ hogdev = hog_device_register(device, path, &err);
+ if (hogdev == NULL)
+ return err;
+
+ devices = g_slist_append(devices, hogdev);
+
+ return 0;
}
static void hog_device_remove(struct btd_device *device)
{
const gchar *path = device_get_path(device);
+ struct hog_device *hogdev;
DBG("path %s", path);
- hog_device_unregister(path);
+ hogdev = hog_device_find(devices, path);
+ if (hogdev) {
+ devices = g_slist_remove(devices, hogdev);
+ hog_device_unregister(hogdev);
+ }
}
static struct btd_device_driver hog_driver = {
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v0 3/5] hog: Add Suspend/Resume callbacks
From: Claudio Takahasi @ 2012-08-17 21:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345237703-15342-1-git-send-email-claudio.takahasi@openbossa.org>
This patch declares the Suspend, and Resume callbacks that needs to
called when the system is entering or leaving suspend state.
---
profiles/input/hog_manager.c | 10 +++++++++-
profiles/input/upower.c | 21 ++++++++++++++++++---
profiles/input/upower.h | 6 +++++-
3 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/profiles/input/hog_manager.c b/profiles/input/hog_manager.c
index 5a5ac62..f32405d 100644
--- a/profiles/input/hog_manager.c
+++ b/profiles/input/hog_manager.c
@@ -41,6 +41,14 @@
static gboolean upower_supported = FALSE;
static DBusConnection *connection = NULL;
+static void suspend_event_cb(void)
+{
+}
+
+static void resume_event_cb(void)
+{
+}
+
static int hog_device_probe(struct btd_device *device, GSList *uuids)
{
const char *path = device_get_path(device);
@@ -74,7 +82,7 @@ static int hog_manager_init(void)
if (connection == NULL)
return -EIO;
- err = upower_init(connection);
+ err = upower_init(connection, suspend_event_cb, resume_event_cb);
if (err < 0) {
dbus_connection_unref(connection);
connection = NULL;
diff --git a/profiles/input/upower.c b/profiles/input/upower.c
index 18a4730..27b4753 100644
--- a/profiles/input/upower.c
+++ b/profiles/input/upower.c
@@ -39,12 +39,16 @@
static DBusConnection *connection = NULL;
static guint suspending_watch = 0;
static guint resuming_watch = 0;
+static suspend_event suspend_callback = NULL;
+static resume_event resume_callback = NULL;
static gboolean suspending_cb(DBusConnection *conn, DBusMessage *msg,
void *user_data)
{
DBG("UPOWER: Suspending ...");
+ suspend_callback();
+
return TRUE;
}
@@ -53,22 +57,33 @@ static gboolean resuming_cb(DBusConnection *conn, DBusMessage *msg,
{
DBG("UPOWER: Resuming ...");
+ resume_callback();
+
return TRUE;
}
-int upower_init(DBusConnection *conn)
+int upower_init(DBusConnection *conn, suspend_event suspend_cb,
+ resume_event resume_cb)
{
connection = dbus_connection_ref(conn);
- suspending_watch = g_dbus_add_signal_watch(connection, UPOWER_BUS_NAME,
+ if (suspend_cb) {
+ suspending_watch = g_dbus_add_signal_watch(connection,
+ UPOWER_BUS_NAME,
UPOWER_PATH, UPOWER_INTERFACE,
"Sleeping", suspending_cb,
NULL, NULL);
+ suspend_callback = suspend_cb;
+ }
- resuming_watch = g_dbus_add_signal_watch(connection, UPOWER_BUS_NAME,
+ if (resume_cb) {
+ resuming_watch = g_dbus_add_signal_watch(connection,
+ UPOWER_BUS_NAME,
UPOWER_PATH, UPOWER_INTERFACE,
"Resuming", resuming_cb,
NULL, NULL);
+ resume_callback = resume_cb;
+ }
return 0;
}
diff --git a/profiles/input/upower.h b/profiles/input/upower.h
index 90976ab..0ccad43 100644
--- a/profiles/input/upower.h
+++ b/profiles/input/upower.h
@@ -21,5 +21,9 @@
*
*/
-int upower_init(DBusConnection *conn);
+typedef void (*suspend_event) (void);
+typedef void (*resume_event) (void);
+
+int upower_init(DBusConnection *conn, suspend_event suspend_cb,
+ resume_event resume_cb);
void upower_exit(void);
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v0 2/5] hog: Add UPower Resuming/Suspending watch
From: Claudio Takahasi @ 2012-08-17 21:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345237703-15342-1-git-send-email-claudio.takahasi@openbossa.org>
This patch adds the DBus signal watcher for UPower Resuming, and
Suspending signals.
---
profiles/input/hog_manager.c | 19 ++++++++++++---
profiles/input/upower.c | 51 +++++++++++++++++++++++++++++++++++++++++-
profiles/input/upower.h | 2 +-
3 files changed, 66 insertions(+), 6 deletions(-)
diff --git a/profiles/input/hog_manager.c b/profiles/input/hog_manager.c
index 52b2c8a..5a5ac62 100644
--- a/profiles/input/hog_manager.c
+++ b/profiles/input/hog_manager.c
@@ -30,6 +30,7 @@
#include "log.h"
#include "../src/adapter.h"
#include "../src/device.h"
+#include "gdbus.h"
#include "plugin.h"
#include "hcid.h"
@@ -38,6 +39,7 @@
#include "hog_device.h"
static gboolean upower_supported = FALSE;
+static DBusConnection *connection = NULL;
static int hog_device_probe(struct btd_device *device, GSList *uuids)
{
@@ -68,10 +70,16 @@ static int hog_manager_init(void)
{
int err;
- err = upower_init();
- if (err < 0)
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+ if (connection == NULL)
+ return -EIO;
+
+ err = upower_init(connection);
+ if (err < 0) {
+ dbus_connection_unref(connection);
+ connection = NULL;
DBG("UPower: %s(%d)", strerror(-err), -err);
- else
+ } else
upower_supported = TRUE;
return btd_register_device_driver(&hog_driver);
@@ -79,8 +87,11 @@ static int hog_manager_init(void)
static void hog_manager_exit(void)
{
- if (upower_supported)
+ if (upower_supported) {
upower_exit();
+ dbus_connection_unref(connection);
+ connection = NULL;
+ }
btd_unregister_device_driver(&hog_driver);
}
diff --git a/profiles/input/upower.c b/profiles/input/upower.c
index 571b023..18a4730 100644
--- a/profiles/input/upower.c
+++ b/profiles/input/upower.c
@@ -25,13 +25,62 @@
#include <config.h>
#endif
+#include <errno.h>
+
+#include "gdbus.h"
+#include "log.h"
+
#include "upower.h"
-int upower_init(void)
+#define UPOWER_BUS_NAME "org.freedesktop.UPower"
+#define UPOWER_PATH "/org/freedesktop/UPower"
+#define UPOWER_INTERFACE UPOWER_BUS_NAME
+
+static DBusConnection *connection = NULL;
+static guint suspending_watch = 0;
+static guint resuming_watch = 0;
+
+static gboolean suspending_cb(DBusConnection *conn, DBusMessage *msg,
+ void *user_data)
{
+ DBG("UPOWER: Suspending ...");
+
+ return TRUE;
+}
+
+static gboolean resuming_cb(DBusConnection *conn, DBusMessage *msg,
+ void *user_data)
+{
+ DBG("UPOWER: Resuming ...");
+
+ return TRUE;
+}
+
+int upower_init(DBusConnection *conn)
+{
+ connection = dbus_connection_ref(conn);
+
+ suspending_watch = g_dbus_add_signal_watch(connection, UPOWER_BUS_NAME,
+ UPOWER_PATH, UPOWER_INTERFACE,
+ "Sleeping", suspending_cb,
+ NULL, NULL);
+
+ resuming_watch = g_dbus_add_signal_watch(connection, UPOWER_BUS_NAME,
+ UPOWER_PATH, UPOWER_INTERFACE,
+ "Resuming", resuming_cb,
+ NULL, NULL);
+
return 0;
}
void upower_exit(void)
{
+ if (suspending_watch)
+ g_dbus_remove_watch(connection, suspending_watch);
+
+ if (resuming_watch)
+ g_dbus_remove_watch(connection, resuming_watch);
+
+ dbus_connection_unref(connection);
+ connection = NULL;
}
diff --git a/profiles/input/upower.h b/profiles/input/upower.h
index f898d07..90976ab 100644
--- a/profiles/input/upower.h
+++ b/profiles/input/upower.h
@@ -21,5 +21,5 @@
*
*/
-int upower_init(void);
+int upower_init(DBusConnection *conn);
void upower_exit(void);
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v0 1/5] hog: Adds initial files for suspend support
From: Claudio Takahasi @ 2012-08-17 21:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345237703-15342-1-git-send-email-claudio.takahasi@openbossa.org>
This patch adds the initial files to support HoG suspend. The first
supported backend is UPower. The suspend concept for HoG is
implementation specific. For UPower, Suspend/Resume will be triggered
by "Sleeping" and "Resuming" signals.
When setting the Control Point, the report device can execute actions to
save power. eg: Reduce the cycle of the key press detection or disable
LEDs.
---
Makefile.am | 3 ++-
profiles/input/hog_manager.c | 14 ++++++++++++++
profiles/input/upower.c | 37 +++++++++++++++++++++++++++++++++++++
profiles/input/upower.h | 25 +++++++++++++++++++++++++
4 files changed, 78 insertions(+), 1 deletions(-)
create mode 100644 profiles/input/upower.c
create mode 100644 profiles/input/upower.h
diff --git a/Makefile.am b/Makefile.am
index a74709d..ec86e90 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -184,7 +184,8 @@ endif
if HOGPLUGIN
builtin_modules += hog
builtin_sources += profiles/input/hog_manager.c profiles/input/hog_device.h \
- profiles/input/hog_device.c profiles/input/uhid_copy.h
+ profiles/input/hog_device.c profiles/input/uhid_copy.h \
+ profiles/input/upower.c profiles/input/upower.h
endif
if NETWORKPLUGIN
diff --git a/profiles/input/hog_manager.c b/profiles/input/hog_manager.c
index ddc5baf..52b2c8a 100644
--- a/profiles/input/hog_manager.c
+++ b/profiles/input/hog_manager.c
@@ -34,8 +34,11 @@
#include "plugin.h"
#include "hcid.h"
#include "device.h"
+#include "upower.h"
#include "hog_device.h"
+static gboolean upower_supported = FALSE;
+
static int hog_device_probe(struct btd_device *device, GSList *uuids)
{
const char *path = device_get_path(device);
@@ -63,11 +66,22 @@ static struct btd_device_driver hog_driver = {
static int hog_manager_init(void)
{
+ int err;
+
+ err = upower_init();
+ if (err < 0)
+ DBG("UPower: %s(%d)", strerror(-err), -err);
+ else
+ upower_supported = TRUE;
+
return btd_register_device_driver(&hog_driver);
}
static void hog_manager_exit(void)
{
+ if (upower_supported)
+ upower_exit();
+
btd_unregister_device_driver(&hog_driver);
}
diff --git a/profiles/input/upower.c b/profiles/input/upower.c
new file mode 100644
index 0000000..571b023
--- /dev/null
+++ b/profiles/input/upower.c
@@ -0,0 +1,37 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "upower.h"
+
+int upower_init(void)
+{
+ return 0;
+}
+
+void upower_exit(void)
+{
+}
diff --git a/profiles/input/upower.h b/profiles/input/upower.h
new file mode 100644
index 0000000..f898d07
--- /dev/null
+++ b/profiles/input/upower.h
@@ -0,0 +1,25 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+int upower_init(void);
+void upower_exit(void);
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v0 0/5] HoG Suspend/Resume
From: Claudio Takahasi @ 2012-08-17 21:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
This patch series adds HID Control Point support. This control point
allows the report host(BlueZ) to notify the report device(HoG device)
when the host is entering or leaving the Suspend Mode.
The low power Suspend Mode concept is implementation specific. This
proposal adds the support for UPower backend. UPower signals Resuming
/Sleeping are used to trigger the control point writing.
Claudio Takahasi (5):
hog: Adds initial files for suspend support
hog: Add UPower Resuming/Suspending watch
hog: Add Suspend/Resume callbacks
hog: Move HoG device list to manager
hog: Add writting Control Point
Makefile.am | 3 +-
profiles/input/hog_device.c | 73 ++++++++++++++++++++----------
profiles/input/hog_device.h | 9 +++-
profiles/input/hog_manager.c | 69 ++++++++++++++++++++++++++++-
profiles/input/upower.c | 101 ++++++++++++++++++++++++++++++++++++++++++
profiles/input/upower.h | 29 ++++++++++++
6 files changed, 254 insertions(+), 30 deletions(-)
create mode 100644 profiles/input/upower.c
create mode 100644 profiles/input/upower.h
--
1.7.8.6
^ permalink raw reply
* Re: Bluez 4.101
From: John Tobias @ 2012-08-17 18:15 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: Chan-yeol Park, linux-bluetooth
In-Reply-To: <CAJdJm_OgdkmcXxFh_0pA3n+-RbPkWKB4ZZrsnDyndYrSGZ=rog@mail.gmail.com>
Hi Guys,
Do you have some references how to create a profile, publish a service
for bluetooth le using bluez?.
Regards,
John
On Thu, Aug 16, 2012 at 8:57 AM, Anderson Lizardo
<anderson.lizardo@openbossa.org> wrote:
> On Thu, Aug 16, 2012 at 11:38 AM, John Tobias <john.tobias.ph@gmail.com> wrote:
>> Hi Anderson,
>>
>> Thanks for the info.
>> May I know the difference between bluetooth.git and bluetooth-next.git repo?.
>
> I may be wrong, but I think it is like this:
>
> bluetooth-next.git contains what is going to the next kernel release
> cycle. E.g. if we are on 3.6-rc1, what is currently on bluetooth-next
> will probably enter upstream on 3.7. It may be less stable than
> bluetooth.git.
>
> bluetooth.git is for the current release cycle (i.e., will enter on 3.6).
>
> Regards,
> --
> Anderson Lizardo
> Instituto Nokia de Tecnologia - INdT
> Manaus - Brazil
^ permalink raw reply
* Re: [PATCH v3] Add device ID for Bluetooth on Macbook Pro 2012
From: Henrik Rydberg @ 2012-08-17 17:21 UTC (permalink / raw)
To: Daniel J Blueman
Cc: Marcel Holtmann, Gustavo Padovan, Johan Hedberg, linux-bluetooth,
linux-kernel
In-Reply-To: <1345182286-21776-1-git-send-email-daniel@quora.org>
Hi Daniel,
> Add the device ID for supporting the Macbook Pro 2012 'MacBookPro10,1'.
> The bluetooth device presents itself as:
>
> T: Bus=02 Lev=04 Prnt=04 Port=02 Cnt=03 Dev#= 8 Spd=12 MxCh= 0
> D: Ver= 2.00 Cls=ff(vend.) Sub=01 Prot=01 MxPS=64 #Cfgs= 1
> P: Vendor=05ac ProdID=8286 Rev=00.86
> S: Manufacturer=Apple Inc.
> S: Product=Bluetooth USB Host Controller
> C: #Ifs= 4 Cfg#= 1 Atr=e0 MxPwr=0mA
> I: If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=01 Prot=01 Driver=(none)
> I: If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=(none)
> I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
> I: If#= 3 Alt= 0 #EPs= 0 Cls=fe(app. ) Sub=01 Prot=01 Driver=(none)
>
> Patch originally written and tested by clipcarl (forums.opensuse.org).
>
> Signed-off-by: Daniel J Blueman <daniel@quora.org>
> Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
> ---
I did not sign off this patch. The author is different, the subject
and wording is different, the credits are different. It looks like you
sent a patch which I subsequently added my SOB to, but that is not the
case. Please do not do that.
If you meant to add your blessing somehow, or if you are the unknown
original author, adding an originally-by or tested-by or reviewed-by
would be more appropriate.
Either way, the patch is moot; With Gustavo's commit d81a5d195, the
plan is to support this machine via a more generic device entry.
Thanks.
Henrik
^ permalink raw reply
* [PATCH] input: Implement idle timeout for fakehid.
From: Jeff Hansen @ 2012-08-17 16:34 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Jeff Hansen
The batteries on my BD remote would die in a few days without this patch.
Now they've been going for weeks (hopefully months).
---
profiles/input/device.c | 6 ++++++
profiles/input/device.h | 4 ++++
profiles/input/fakehid.c | 18 ++++++++++++++++++
3 files changed, 28 insertions(+), 0 deletions(-)
diff --git a/profiles/input/device.c b/profiles/input/device.c
index 48d397a..31c970d 100644
--- a/profiles/input/device.c
+++ b/profiles/input/device.c
@@ -638,6 +638,7 @@ static int hidp_add_connection(const struct input_device *idev,
fake->disconnect = fake_hid_disconnect;
fake->priv = fake_hid;
fake->idev = idev;
+ fake->timeout = iconn->timeout * 1000;
fake = fake_hid_connadd(fake, iconn->intr_io, fake_hid);
if (fake == NULL)
err = -ENOMEM;
@@ -1307,3 +1308,8 @@ int input_device_close_channels(const bdaddr_t *src, const bdaddr_t *dst)
return 0;
}
+
+void input_device_request_disconnect(const struct input_device *idev)
+{
+ device_request_disconnect(idev->device, NULL);
+}
diff --git a/profiles/input/device.h b/profiles/input/device.h
index 509a353..1b490b4 100644
--- a/profiles/input/device.h
+++ b/profiles/input/device.h
@@ -37,6 +37,8 @@ struct fake_input {
int (*disconnect) (struct input_conn *iconn);
void *priv;
const struct input_device *idev;
+ guint idle_timeout;
+ uint32_t timeout;
};
int fake_input_register(DBusConnection *conn, struct btd_device *device,
@@ -49,3 +51,5 @@ int input_device_unregister(const char *path, const char *uuid);
int input_device_set_channel(const bdaddr_t *src, const bdaddr_t *dst, int psm,
GIOChannel *io);
int input_device_close_channels(const bdaddr_t *src, const bdaddr_t *dst);
+
+void input_device_request_disconnect(const struct input_device *idev);
diff --git a/profiles/input/fakehid.c b/profiles/input/fakehid.c
index 3be1489..a92622f 100644
--- a/profiles/input/fakehid.c
+++ b/profiles/input/fakehid.c
@@ -199,6 +199,13 @@ error:
return -1;
}
+static gboolean ps3remote_idle(gpointer data)
+{
+ struct fake_input *fake = data;
+ input_device_request_disconnect(fake->idev);
+ return FALSE;
+}
+
static gboolean ps3remote_event(GIOChannel *chan, GIOCondition cond,
gpointer data)
{
@@ -209,6 +216,13 @@ static gboolean ps3remote_event(GIOChannel *chan, GIOCondition cond,
char buff[50];
int fd;
+ if (fake->idle_timeout) {
+ g_source_remove(fake->idle_timeout);
+ fake->idle_timeout = 0;
+ }
+ if (fake->timeout)
+ fake->idle_timeout = g_timeout_add(fake->timeout, ps3remote_idle, fake);
+
if (cond & G_IO_NVAL)
return FALSE;
@@ -328,6 +342,10 @@ static gboolean fake_hid_common_connect(struct fake_input *fake, GError **err)
static int fake_hid_common_disconnect(struct fake_input *fake)
{
+ if (fake->idle_timeout) {
+ g_source_remove(fake->idle_timeout);
+ fake->idle_timeout = 0;
+ }
return 0;
}
--
1.7.8.6
^ permalink raw reply related
* [PATCH obexd 2/2] MAP: Add subject length parameter in GetMessageListing
From: Sunil Kumar Behera @ 2012-08-17 15:08 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sunil Kumar Behera
Add subject length parameter to allow MAP server to
create subject as per MAP client length preference.
---
plugins/mas.c | 7 ++++++-
plugins/messages-dummy.c | 1 +
plugins/messages-tracker.c | 4 ++--
plugins/messages.h | 2 ++
4 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/plugins/mas.c b/plugins/mas.c
index 57d9611..1c9199d 100644
--- a/plugins/mas.c
+++ b/plugins/mas.c
@@ -559,6 +559,9 @@ static void *msg_listing_open(const char *name, int oflag, mode_t mode,
/* 1024 is the default when there was no MaxListCount sent */
uint16_t max = 1024;
uint16_t offset = 0;
+ /* If MAP client does not specify the subject length,
+ then subject_len = 0 and subject should be sent unaltered. */
+ uint8_t subject_len = 0;
DBG("");
@@ -569,6 +572,8 @@ static void *msg_listing_open(const char *name, int oflag, mode_t mode,
g_obex_apparam_get_uint16(mas->inparams, MAP_AP_MAXLISTCOUNT, &max);
g_obex_apparam_get_uint16(mas->inparams, MAP_AP_STARTOFFSET, &offset);
+ g_obex_apparam_get_uint8(mas->inparams, MAP_AP_SUBJECTLENGTH,
+ &subject_len);
g_obex_apparam_get_uint32(mas->inparams, MAP_AP_PARAMETERMASK,
&filter.parameter_mask);
@@ -588,7 +593,7 @@ static void *msg_listing_open(const char *name, int oflag, mode_t mode,
&filter.priority);
*err = messages_get_messages_listing(mas->backend_data, name, max,
- offset, &filter,
+ offset, subject_len, &filter,
get_messages_listing_cb, mas);
mas->buffer = g_string_new("");
diff --git a/plugins/messages-dummy.c b/plugins/messages-dummy.c
index 833c31c..a47f143 100644
--- a/plugins/messages-dummy.c
+++ b/plugins/messages-dummy.c
@@ -331,6 +331,7 @@ int messages_get_folder_listing(void *s, const char *name, uint16_t max,
int messages_get_messages_listing(void *session, const char *name,
uint16_t max, uint16_t offset,
+ uint8_t subject_len,
const struct messages_filter *filter,
messages_get_messages_listing_cb callback,
void *user_data)
diff --git a/plugins/messages-tracker.c b/plugins/messages-tracker.c
index fb45210..92c1767 100644
--- a/plugins/messages-tracker.c
+++ b/plugins/messages-tracker.c
@@ -303,9 +303,9 @@ int messages_get_folder_listing(void *s, const char *name,
return 0;
}
-int messages_get_messages_listing(void *session,
- const char *name,
+int messages_get_messages_listing(void *session, const char *name,
uint16_t max, uint16_t offset,
+ uint8_t subject_len,
const struct messages_filter *filter,
messages_get_messages_listing_cb callback,
void *user_data)
diff --git a/plugins/messages.h b/plugins/messages.h
index beca3a8..669f7c2 100644
--- a/plugins/messages.h
+++ b/plugins/messages.h
@@ -216,6 +216,7 @@ int messages_get_folder_listing(void *session, const char *name, uint16_t max,
* name: Optional subdirectory name.
* max: Maximum number of entries to retrieve.
* offset: Offset of the first entry.
+ * subject_len: Maximum string length of the "subject" parameter in the entries.
* filter: Filter to apply on returned message listing.
* size: Total size of listing to be returned.
* newmsg: Indicates presence of unread messages.
@@ -230,6 +231,7 @@ typedef void (*messages_get_messages_listing_cb)(void *session, int err,
int messages_get_messages_listing(void *session, const char *name,
uint16_t max, uint16_t offset,
+ uint8_t subject_len,
const struct messages_filter *filter,
messages_get_messages_listing_cb callback,
void *user_data);
--
1.7.9.5
^ permalink raw reply related
* [PATCH obexd 1/2] MAP: Add offset parameter decription
From: Sunil Kumar Behera @ 2012-08-17 15:06 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sunil Kumar Behera
Add offset parameter description for
messages_get_messages_listing() function header
---
plugins/messages.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/plugins/messages.h b/plugins/messages.h
index 83e087a..beca3a8 100644
--- a/plugins/messages.h
+++ b/plugins/messages.h
@@ -215,6 +215,7 @@ int messages_get_folder_listing(void *session, const char *name, uint16_t max,
* session: Backend session.
* name: Optional subdirectory name.
* max: Maximum number of entries to retrieve.
+ * offset: Offset of the first entry.
* filter: Filter to apply on returned message listing.
* size: Total size of listing to be returned.
* newmsg: Indicates presence of unread messages.
--
1.7.9.5
^ permalink raw reply related
* [PATCH BlueZ v2 10/10] gatt: Map Appearance value 0x0000 to "unknown"
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345214611-9071-1-git-send-email-claudio.takahasi@openbossa.org>
According to Bluetooth SIG Assigned numbers, Appearance characteristic
value 0x0000 is designated to "unknown".
---
src/dbus-common.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/src/dbus-common.c b/src/dbus-common.c
index 7e1bc94..fb55027 100644
--- a/src/dbus-common.c
+++ b/src/dbus-common.c
@@ -247,6 +247,8 @@ const char *class_to_icon(uint32_t class)
const char *gap_appearance_to_icon(uint16_t appearance)
{
switch ((appearance & 0xffc0) >> 6) {
+ case 0x00:
+ return "unknown";
case 0x01:
return "phone";
case 0x02:
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v2 09/10] core: Add storing Appearance
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345214611-9071-1-git-send-email-claudio.takahasi@openbossa.org>
This patch stores the Appearance characteristic value read from the
remote GAP service.
---
src/device.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/device.c b/src/device.c
index d0d178c..f6161aa 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3021,6 +3021,7 @@ void device_set_appearance(struct btd_device *device, uint16_t value)
{
DBusConnection *conn = get_dbus_connection();
const char *icon = gap_appearance_to_icon(value);
+ bdaddr_t src;
emit_property_changed(conn, device->path, DEVICE_INTERFACE,
"Appearance", DBUS_TYPE_UINT16, &value);
@@ -3028,6 +3029,10 @@ void device_set_appearance(struct btd_device *device, uint16_t value)
if (icon)
emit_property_changed(conn, device->path, DEVICE_INTERFACE,
"Icon", DBUS_TYPE_STRING, &icon);
+
+ adapter_get_address(device_get_adapter(device), &src);
+ write_remote_appearance(&src, &device->bdaddr, device->bdaddr_type,
+ value);
}
static gboolean notify_attios(gpointer user_data)
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v2 08/10] core: PropertyChanged signal for Icon/Appearance
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345214611-9071-1-git-send-email-claudio.takahasi@openbossa.org>
This patch emits the PropertyChanged signal in the Device hierarchy when
the remote device Appearance characteristic is read. In general
Appearance is a static value, if the device doesn't expose the
Appearance value in the advertising data, the GAP plugin should read the
value using GATT read procedure.
---
src/device.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/device.c b/src/device.c
index 7657a74..d0d178c 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3020,9 +3020,14 @@ int device_get_appearance(struct btd_device *device, uint16_t *value)
void device_set_appearance(struct btd_device *device, uint16_t value)
{
DBusConnection *conn = get_dbus_connection();
+ const char *icon = gap_appearance_to_icon(value);
emit_property_changed(conn, device->path, DEVICE_INTERFACE,
"Appearance", DBUS_TYPE_UINT16, &value);
+
+ if (icon)
+ emit_property_changed(conn, device->path, DEVICE_INTERFACE,
+ "Icon", DBUS_TYPE_STRING, &icon);
}
static gboolean notify_attios(gpointer user_data)
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v2 07/10] core: PropertyChanged signal for Icon/class
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345214611-9071-1-git-send-email-claudio.takahasi@openbossa.org>
This patch emits the PropertyChanged signal in the Device hierarchy when
the remote device class is updated.
---
src/device.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/src/device.c b/src/device.c
index f612bb0..7657a74 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2988,9 +2988,14 @@ void btd_device_unref(struct btd_device *device)
void device_set_class(struct btd_device *device, uint32_t value)
{
DBusConnection *conn = get_dbus_connection();
+ const char *icon = class_to_icon(value);
emit_property_changed(conn, device->path, DEVICE_INTERFACE, "Class",
DBUS_TYPE_UINT32, &value);
+
+ if (icon)
+ emit_property_changed(conn, device->path, DEVICE_INTERFACE,
+ "Icon", DBUS_TYPE_STRING, &icon);
}
int device_get_appearance(struct btd_device *device, uint16_t *value)
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v2 06/10] gatt: Emit PropertyChanged for Appearance
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345214611-9071-1-git-send-email-claudio.takahasi@openbossa.org>
Emit PropertyChanged changed signal in the Device hierarchy when the
Appearance characteristic value is read from the remote GAP service.
---
profiles/gatt/gas.c | 3 +++
src/device.c | 8 ++++++++
src/device.h | 1 +
3 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index 76db130..54f5842 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -67,6 +67,7 @@ static gint cmp_device(gconstpointer a, gconstpointer b)
static void gap_appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
gpointer user_data)
{
+ struct gas *gas = user_data;
struct att_data_list *list = NULL;
uint16_t app;
uint8_t *atval;
@@ -91,6 +92,8 @@ static void gap_appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
DBG("GAP Appearance: 0x%04x", app);
+ device_set_appearance(gas->device, app);
+
done:
att_data_list_free(list);
}
diff --git a/src/device.c b/src/device.c
index 00ab760..f612bb0 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3012,6 +3012,14 @@ int device_get_appearance(struct btd_device *device, uint16_t *value)
return 0;
}
+void device_set_appearance(struct btd_device *device, uint16_t value)
+{
+ DBusConnection *conn = get_dbus_connection();
+
+ emit_property_changed(conn, device->path, DEVICE_INTERFACE,
+ "Appearance", DBUS_TYPE_UINT16, &value);
+}
+
static gboolean notify_attios(gpointer user_data)
{
struct btd_device *device = user_data;
diff --git a/src/device.h b/src/device.h
index eb4b41e..85d265a 100644
--- a/src/device.h
+++ b/src/device.h
@@ -104,6 +104,7 @@ guint device_add_disconnect_watch(struct btd_device *device,
void device_remove_disconnect_watch(struct btd_device *device, guint id);
void device_set_class(struct btd_device *device, uint32_t value);
int device_get_appearance(struct btd_device *device, uint16_t *value);
+void device_set_appearance(struct btd_device *device, uint16_t value);
#define BTD_UUIDS(args...) ((const char *[]) { args, NULL } )
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v2 05/10] core: Remove Appearance characteristic read
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345214611-9071-1-git-send-email-claudio.takahasi@openbossa.org>
This patch removes the Appearance characteristic read from the core.
Appearance characteristic is now being read by the GAP/GATT plugin.
---
src/device.c | 56 +-------------------------------------------------------
1 files changed, 1 insertions(+), 55 deletions(-)
diff --git a/src/device.c b/src/device.c
index 09a154d..00ab760 100644
--- a/src/device.c
+++ b/src/device.c
@@ -69,8 +69,6 @@
#define AUTO_CONNECTION_INTERVAL 5 /* Next connection attempt */
-#define APPEARANCE_CHR_UUID 0x2a01
-
struct btd_disconnect_data {
guint id;
disconnect_watch watch;
@@ -1832,51 +1830,10 @@ done:
return FALSE;
}
-static void appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
- gpointer user_data)
-{
- struct btd_device *device = user_data;
- struct btd_adapter *adapter = device->adapter;
- struct att_data_list *list = NULL;
- uint16_t app;
- bdaddr_t src;
- uint8_t *atval;
-
- if (status != 0) {
- DBG("Read characteristics by UUID failed: %s\n",
- att_ecode2str(status));
- goto done;
- }
-
- list = dec_read_by_type_resp(pdu, plen);
- if (list == NULL)
- goto done;
-
- if (list->len != 4) {
- DBG("Appearance value: invalid data");
- goto done;
- }
-
- /* A device shall have only one instance of the
- Appearance characteristic. */
- atval = list->data[0] + 2; /* skip handle value */
- app = att_get_u16(atval);
-
- adapter_get_address(adapter, &src);
- write_remote_appearance(&src, &device->bdaddr, device->bdaddr_type,
- app);
-
-done:
- att_data_list_free(list);
- if (device->attios == NULL && device->attios_offline == NULL)
- attio_cleanup(device);
-}
-
static void primary_cb(GSList *services, guint8 status, gpointer user_data)
{
struct browse_req *req = user_data;
struct btd_device *device = req->device;
- struct gatt_primary *gap_prim = NULL;
GSList *l, *uuids = NULL;
if (status) {
@@ -1894,24 +1851,13 @@ static void primary_cb(GSList *services, guint8 status, gpointer user_data)
for (l = services; l; l = l->next) {
struct gatt_primary *prim = l->data;
- if (strcmp(prim->uuid, GAP_UUID) == 0)
- gap_prim = prim;
-
uuids = g_slist_append(uuids, prim->uuid);
}
device_register_services(req->conn, device, g_slist_copy(services), -1);
device_probe_drivers(device, uuids);
- if (gap_prim) {
- /* Read appearance characteristic */
- bt_uuid_t uuid;
-
- bt_uuid16_create(&uuid, APPEARANCE_CHR_UUID);
-
- gatt_read_char_by_uuid(device->attrib, gap_prim->range.start,
- gap_prim->range.end, &uuid, appearance_cb, device);
- } else if (device->attios == NULL && device->attios_offline == NULL)
+ if (device->attios == NULL && device->attios_offline == NULL)
attio_cleanup(device);
g_slist_free(uuids);
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v2 04/10] gatt: Add read Appearance characteristic
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345214611-9071-1-git-send-email-claudio.takahasi@openbossa.org>
This patch registers the ATTIO callbacks, and triggers the Appearance
characteristic read by UUID when the ATT connection is established (if
appearance value is not found in the storage).
---
profiles/gatt/gas.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 69 insertions(+), 0 deletions(-)
diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index d13eadc..76db130 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -31,6 +31,7 @@
#include "device.h"
#include "att.h"
#include "gattrib.h"
+#include "attio.h"
#include "gatt.h"
#include "log.h"
#include "gas.h"
@@ -40,12 +41,17 @@ struct gas {
struct btd_device *device;
struct att_range gap; /* GAP Primary service range */
struct att_range gatt; /* GATT Primary service range */
+ GAttrib *attrib;
+ guint attioid;
};
static GSList *devices = NULL;
static void gas_free(struct gas *gas)
{
+ if (gas->attioid)
+ btd_device_remove_attio_callback(gas->device, gas->attioid);
+
btd_device_unref(gas->device);
g_free(gas);
}
@@ -58,6 +64,65 @@ static gint cmp_device(gconstpointer a, gconstpointer b)
return (gas->device == device ? 0 : -1);
}
+static void gap_appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
+ gpointer user_data)
+{
+ struct att_data_list *list = NULL;
+ uint16_t app;
+ uint8_t *atval;
+
+ if (status != 0) {
+ error("Read characteristics by UUID failed: %s",
+ att_ecode2str(status));
+ return;
+ }
+
+ list = dec_read_by_type_resp(pdu, plen);
+ if (list == NULL)
+ return;
+
+ if (list->len != 4) {
+ error("GAP Appearance value: invalid data");
+ goto done;
+ }
+
+ atval = list->data[0] + 2; /* skip handle value */
+ app = att_get_u16(atval);
+
+ DBG("GAP Appearance: 0x%04x", app);
+
+done:
+ att_data_list_free(list);
+}
+
+static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
+{
+ struct gas *gas = user_data;
+ uint16_t app;
+
+ gas->attrib = g_attrib_ref(attrib);
+
+ if (device_get_appearance(gas->device, &app) < 0) {
+ bt_uuid_t uuid;
+
+ bt_uuid16_create(&uuid, GATT_CHARAC_APPEARANCE);
+
+ gatt_read_char_by_uuid(gas->attrib, gas->gap.start,
+ gas->gap.end, &uuid,
+ gap_appearance_cb, gas);
+ }
+
+ /* TODO: Read other GAP characteristics - See Core spec page 1739 */
+}
+
+static void attio_disconnected_cb(gpointer user_data)
+{
+ struct gas *gas = user_data;
+
+ g_attrib_unref(gas->attrib);
+ gas->attrib = NULL;
+}
+
int gas_register(struct btd_device *device, struct att_range *gap,
struct att_range *gatt)
{
@@ -73,6 +138,10 @@ int gas_register(struct btd_device *device, struct att_range *gap,
devices = g_slist_append(devices, gas);
+ gas->attioid = btd_device_add_attio_callback(device,
+ attio_connected_cb,
+ attio_disconnected_cb, gas);
+
return 0;
}
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v2 03/10] core: Add device method to access "Appearance"
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345214611-9071-1-git-send-email-claudio.takahasi@openbossa.org>
This patch adds a new device method to access the Appearance GAP
characteristic value stored previously as result of the discovery
procedure or GATT characteristic read procedure.
---
src/device.c | 19 +++++++++++++++++++
src/device.h | 1 +
2 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/src/device.c b/src/device.c
index f781298..09a154d 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3047,6 +3047,25 @@ void device_set_class(struct btd_device *device, uint32_t value)
DBUS_TYPE_UINT32, &value);
}
+int device_get_appearance(struct btd_device *device, uint16_t *value)
+{
+ bdaddr_t src;
+ uint16_t app;
+ int err;
+
+ adapter_get_address(device_get_adapter(device), &src);
+
+ err = read_remote_appearance(&src, &device->bdaddr,
+ device->bdaddr_type, &app);
+ if (err < 0)
+ return err;
+
+ if (value)
+ *value = app;
+
+ return 0;
+}
+
static gboolean notify_attios(gpointer user_data)
{
struct btd_device *device = user_data;
diff --git a/src/device.h b/src/device.h
index 26e17f7..eb4b41e 100644
--- a/src/device.h
+++ b/src/device.h
@@ -103,6 +103,7 @@ guint device_add_disconnect_watch(struct btd_device *device,
GDestroyNotify destroy);
void device_remove_disconnect_watch(struct btd_device *device, guint id);
void device_set_class(struct btd_device *device, uint32_t value);
+int device_get_appearance(struct btd_device *device, uint16_t *value);
#define BTD_UUIDS(args...) ((const char *[]) { args, NULL } )
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v2 02/10] gatt: Add GAP/GATT device registration
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345214611-9071-1-git-send-email-claudio.takahasi@openbossa.org>
This patch adds GAP/GATT device driver probe function and the skeleton
of the register GAP/GATT device function.
---
Makefile.am | 3 +-
profiles/gatt/gas.c | 91 +++++++++++++++++++++++++++++++++++++++++++++++
profiles/gatt/gas.h | 25 +++++++++++++
profiles/gatt/manager.c | 29 ++++++++++++++-
4 files changed, 146 insertions(+), 2 deletions(-)
create mode 100644 profiles/gatt/gas.c
create mode 100644 profiles/gatt/gas.h
diff --git a/Makefile.am b/Makefile.am
index 6af33cb..4977a05 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -240,7 +240,8 @@ builtin_sources += profiles/thermometer/main.c \
profiles/deviceinfo/deviceinfo.h \
profiles/deviceinfo/deviceinfo.c \
profiles/gatt/main.c profiles/gatt/manager.h \
- profiles/gatt/manager.c
+ profiles/gatt/manager.c profiles/gatt/gas.h \
+ profiles/gatt/gas.c
endif
builtin_modules += formfactor
diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
new file mode 100644
index 0000000..d13eadc
--- /dev/null
+++ b/profiles/gatt/gas.c
@@ -0,0 +1,91 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <bluetooth/uuid.h>
+
+#include "adapter.h"
+#include "device.h"
+#include "att.h"
+#include "gattrib.h"
+#include "gatt.h"
+#include "log.h"
+#include "gas.h"
+
+/* Generic Attribute/Access Service */
+struct gas {
+ struct btd_device *device;
+ struct att_range gap; /* GAP Primary service range */
+ struct att_range gatt; /* GATT Primary service range */
+};
+
+static GSList *devices = NULL;
+
+static void gas_free(struct gas *gas)
+{
+ btd_device_unref(gas->device);
+ g_free(gas);
+}
+
+static gint cmp_device(gconstpointer a, gconstpointer b)
+{
+ const struct gas *gas = a;
+ const struct btd_device *device = b;
+
+ return (gas->device == device ? 0 : -1);
+}
+
+int gas_register(struct btd_device *device, struct att_range *gap,
+ struct att_range *gatt)
+{
+ struct gas *gas;
+
+ gas = g_new0(struct gas, 1);
+ gas->gap.start = gap->start;
+ gas->gap.end = gap->end;
+ gas->gatt.start = gatt->start;
+ gas->gatt.end = gatt->end;
+
+ gas->device = btd_device_ref(device);
+
+ devices = g_slist_append(devices, gas);
+
+ return 0;
+}
+
+void gas_unregister(struct btd_device *device)
+{
+ struct gas *gas;
+ GSList *l;
+
+ l = g_slist_find_custom(devices, device, cmp_device);
+ if (l == NULL)
+ return;
+
+ gas = l->data;
+ devices = g_slist_remove(devices, gas);
+ gas_free(gas);
+}
diff --git a/profiles/gatt/gas.h b/profiles/gatt/gas.h
new file mode 100644
index 0000000..34853c7
--- /dev/null
+++ b/profiles/gatt/gas.h
@@ -0,0 +1,25 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+int gas_register(struct btd_device *device, struct att_range *gap,
+ struct att_range *gatt);
+void gas_unregister(struct btd_device *device);
diff --git a/profiles/gatt/manager.c b/profiles/gatt/manager.c
index ab98f86..a1fa756 100644
--- a/profiles/gatt/manager.c
+++ b/profiles/gatt/manager.c
@@ -26,15 +26,42 @@
#include "adapter.h"
#include "device.h"
+#include "att.h"
+#include "gattrib.h"
+#include "gatt.h"
+#include "gas.h"
#include "manager.h"
+static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
+{
+ const struct gatt_primary *prim = a;
+ const char *uuid = b;
+
+ return g_strcmp0(prim->uuid, uuid);
+}
+
static int gatt_driver_probe(struct btd_device *device, GSList *uuids)
{
- return 0;
+ GSList *primaries, *l;
+ struct gatt_primary *gap = NULL, *gatt = NULL;
+
+ primaries = btd_device_get_primaries(device);
+
+ l = g_slist_find_custom(primaries, GAP_UUID, primary_uuid_cmp);
+ if (l)
+ gap = l->data;
+
+ l = g_slist_find_custom(primaries, GATT_UUID, primary_uuid_cmp);
+ if (l)
+ gatt = l->data;
+
+ return gas_register(device, gap ? &gap->range : NULL,
+ gatt ? &gatt->range : NULL);
}
static void gatt_driver_remove(struct btd_device *device)
{
+ gas_unregister(device);
}
static struct btd_device_driver gatt_device_driver = {
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v2 01/10] gatt: Add Generic Access/Attribute Profile plugin
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345214611-9071-1-git-send-email-claudio.takahasi@openbossa.org>
Initial patch to create GATT based plugin to handle Generic Access,
and Generic Attribute Profile services. GAP characteristics discovery
will be moved from device.c to this new plugin.
---
Makefile.am | 7 ++++-
profiles/gatt/main.c | 52 ++++++++++++++++++++++++++++++++++++++++++++
profiles/gatt/manager.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++
profiles/gatt/manager.h | 24 ++++++++++++++++++++
4 files changed, 136 insertions(+), 2 deletions(-)
create mode 100644 profiles/gatt/main.c
create mode 100644 profiles/gatt/manager.c
create mode 100644 profiles/gatt/manager.h
diff --git a/Makefile.am b/Makefile.am
index a74709d..6af33cb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -211,7 +211,8 @@ builtin_sources += profiles/health/hdp_main.c profiles/health/hdp_types.h \
endif
if GATTMODULES
-builtin_modules += thermometer alert time gatt_example proximity deviceinfo
+builtin_modules += thermometer alert time gatt_example proximity deviceinfo \
+ gatt
builtin_sources += profiles/thermometer/main.c \
profiles/thermometer/manager.h \
profiles/thermometer/manager.c \
@@ -237,7 +238,9 @@ builtin_sources += profiles/thermometer/main.c \
profiles/deviceinfo/manager.h \
profiles/deviceinfo/manager.c \
profiles/deviceinfo/deviceinfo.h \
- profiles/deviceinfo/deviceinfo.c
+ profiles/deviceinfo/deviceinfo.c \
+ profiles/gatt/main.c profiles/gatt/manager.h \
+ profiles/gatt/manager.c
endif
builtin_modules += formfactor
diff --git a/profiles/gatt/main.c b/profiles/gatt/main.c
new file mode 100644
index 0000000..efe92f5
--- /dev/null
+++ b/profiles/gatt/main.c
@@ -0,0 +1,52 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdint.h>
+#include <glib.h>
+#include <errno.h>
+
+#include "plugin.h"
+#include "manager.h"
+#include "hcid.h"
+#include "log.h"
+
+static int gatt_init(void)
+{
+ if (!main_opts.gatt_enabled) {
+ error("GATT can not start: EnableGatt is false");
+ return -ENOTSUP;
+ }
+
+ return gatt_manager_init();
+}
+
+static void gatt_exit(void)
+{
+ gatt_manager_exit();
+}
+
+BLUETOOTH_PLUGIN_DEFINE(gatt, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
+ gatt_init, gatt_exit)
diff --git a/profiles/gatt/manager.c b/profiles/gatt/manager.c
new file mode 100644
index 0000000..ab98f86
--- /dev/null
+++ b/profiles/gatt/manager.c
@@ -0,0 +1,55 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include <glib.h>
+#include <errno.h>
+#include <bluetooth/uuid.h>
+
+#include "adapter.h"
+#include "device.h"
+#include "manager.h"
+
+static int gatt_driver_probe(struct btd_device *device, GSList *uuids)
+{
+ return 0;
+}
+
+static void gatt_driver_remove(struct btd_device *device)
+{
+}
+
+static struct btd_device_driver gatt_device_driver = {
+ .name = "gap-gatt-driver",
+ .uuids = BTD_UUIDS(GAP_UUID, GATT_UUID),
+ .probe = gatt_driver_probe,
+ .remove = gatt_driver_remove
+};
+
+int gatt_manager_init(void)
+{
+ return btd_register_device_driver(&gatt_device_driver);
+}
+
+void gatt_manager_exit(void)
+{
+ btd_unregister_device_driver(&gatt_device_driver);
+}
diff --git a/profiles/gatt/manager.h b/profiles/gatt/manager.h
new file mode 100644
index 0000000..502fceb
--- /dev/null
+++ b/profiles/gatt/manager.h
@@ -0,0 +1,24 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+int gatt_manager_init(void);
+void gatt_manager_exit(void);
--
1.7.8.6
^ permalink raw reply related
* [PATCH BlueZ v2 00/10] GATT Plugin
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345147991-31320-1-git-send-email-claudio.takahasi@openbossa.org>
This patch series adds a new GATT based plugin for GAP and GATT service.
The objective is cleanup: moving some GATT related operations from the
device(core) to a GATT based plugin.
This first part is related to GAP appearance characteristic. A second
patch will be sent soon to manage Service Changed and GATT/ATT MTU.
Changes from v1: Removes direct access to appearance storage.
Claudio Takahasi (10):
gatt: Add Generic Access/Attribute Profile plugin
gatt: Add GAP/GATT device registration
core: Add device method to access "Appearance"
gatt: Add read Appearance characteristic
core: Remove Appearance characteristic read
gatt: Emit PropertyChanged for Appearance
core: PropertyChanged signal for Icon/class
core: PropertyChanged signal for Icon/Appearance
core: Add storing Appearance
gatt: Map Appearance value 0x0000 to "unknown"
Makefile.am | 8 ++-
profiles/gatt/gas.c | 163 +++++++++++++++++++++++++++++++++++++++++++++++
profiles/gatt/gas.h | 25 +++++++
profiles/gatt/main.c | 52 +++++++++++++++
profiles/gatt/manager.c | 82 ++++++++++++++++++++++++
profiles/gatt/manager.h | 24 +++++++
src/dbus-common.c | 2 +
src/device.c | 98 ++++++++++++----------------
src/device.h | 2 +
9 files changed, 399 insertions(+), 57 deletions(-)
create mode 100644 profiles/gatt/gas.c
create mode 100644 profiles/gatt/gas.h
create mode 100644 profiles/gatt/main.c
create mode 100644 profiles/gatt/manager.c
create mode 100644 profiles/gatt/manager.h
--
1.7.8.6
^ permalink raw reply
* Re: BLE - multiple connections
From: Ajay KV @ 2012-08-17 14:36 UTC (permalink / raw)
To: Andre Guedes, linux-bluetooth
In-Reply-To: <CACJA=fUW4a-B-1SGQmPbh+J5YKJ9bVEFbz8ZUezPOD3w0Hmsxw@mail.gmail.com>
Hi ,
I am facing some more issues regarding BLE multiple connection
, which is mentioned below . please show me the right direction , since
i got stucked
1: suppose device A and B is in connected state (B as initiator and
A as advertising mode) , so obviously role change happens and A
switches to slave mode . meanwhile i wanted to connect device C to A
(C as initiator and A as advertising mode) , since A has switched to
slave mode , it cant able to advertise again ( controller returns error
message " command disallowed") . Even i tried to change the role
forcefully through hcitool command , the result was same.
My intention is to make the device A as a server with
multiple clients. Currently im not using any of the profiles(ATT ,
GATT) . i want it to be done using L2CAP sockets
2. Is it possible to change the imtu of the LE connection other than
23bits( which is hardcoded in L2cap driver)
On 07/20/2012 10:21 AM, Andre Guedes wrote:
> Hi Ajay,
>
> On Fri, Jul 20, 2012 at 3:11 AM, Ajay KV<ajay.kv@globaledgesoft.com> wrote:
>
>> Hi all,
>>
>> Since im new to bluetooth low energy technology , i need some guidance from
>> you . Following are the issues that im searching for a solution
>>
>>
>> 1 : Is it possible to establish mutiple LE connection at a time . Im using
>> fedora 13 , linux 2.6.39 version with 4.0 LE supported dongles
>>
>> 2: now im not concentrating on user profiles like GATT and ATT . i wanted to
>> do it using HCI and L2cap connections
>>
> You are able to establish one LE connection at a time. If you have
> more than one device you want to connect to, you can use whitelist.
> Add the devices to whitelist and issue the LE connection command. As
> soon as one of the devices starts advertising, the connection will be
> established.
>
> You can use hcitool to add devices to whitelist and issue LE connection command.
>
> BR,
>
> Andre
>
>
^ 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