* [PATCH BlueZ v0 00/10] GAP Plugin
@ 2012-08-15 14:19 Claudio Takahasi
2012-08-15 14:19 ` [PATCH BlueZ v0 01/10] gap: Add Generic Access Profile plugin skeleton Claudio Takahasi
` (10 more replies)
0 siblings, 11 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-15 14:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
This patch series adds a new GATT based plugin for GAP service. The
objective is cleanup: moving some GATT related operations from the
device(core) to a GATT based plugin.
Claudio Takahasi (10):
gap: Add Generic Access Profile plugin skeleton
gap: Add GAP device registration
gap: Add read Appearance characteristic
gap: Add storing Appearance
core: Remove Appearance characteristic read
gap: Emit PropertyChanged for Appearance
core: PropertyChanged signal for Icon/class
core: PropertyChanged signal for Icon/Appearance
gap: Map Appearance value 0x0000 to unknown
gap: Don't store Appearance if value is "unknown"
Makefile.am | 7 ++-
profiles/gap/gap.c | 174 ++++++++++++++++++++++++++++++++++++++++++++++++
profiles/gap/gap.h | 24 +++++++
profiles/gap/main.c | 52 ++++++++++++++
profiles/gap/manager.c | 75 +++++++++++++++++++++
profiles/gap/manager.h | 24 +++++++
src/dbus-common.c | 2 +
src/device.c | 74 +++++---------------
src/device.h | 1 +
9 files changed, 376 insertions(+), 57 deletions(-)
create mode 100644 profiles/gap/gap.c
create mode 100644 profiles/gap/gap.h
create mode 100644 profiles/gap/main.c
create mode 100644 profiles/gap/manager.c
create mode 100644 profiles/gap/manager.h
--
1.7.8.6
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH BlueZ v0 01/10] gap: Add Generic Access Profile plugin skeleton
2012-08-15 14:19 [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
@ 2012-08-15 14:19 ` Claudio Takahasi
2012-08-15 14:19 ` [PATCH BlueZ v0 02/10] gap: Add GAP device registration Claudio Takahasi
` (9 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-15 14:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
Initial patch to create GATT based plugin to handle Generic Access
Profile service. GAP characteristics discovery will be moved from
device.c to this new plugin.
---
Makefile.am | 6 +++-
profiles/gap/main.c | 52 +++++++++++++++++++++++++++++++++++++++++++++
profiles/gap/manager.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++
profiles/gap/manager.h | 24 +++++++++++++++++++++
4 files changed, 135 insertions(+), 2 deletions(-)
create mode 100644 profiles/gap/main.c
create mode 100644 profiles/gap/manager.c
create mode 100644 profiles/gap/manager.h
diff --git a/Makefile.am b/Makefile.am
index a74709d..2db3ce1 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -211,7 +211,7 @@ 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 gap
builtin_sources += profiles/thermometer/main.c \
profiles/thermometer/manager.h \
profiles/thermometer/manager.c \
@@ -237,7 +237,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/gap/main.c profiles/gap/manager.h \
+ profiles/gap/manager.c
endif
builtin_modules += formfactor
diff --git a/profiles/gap/main.c b/profiles/gap/main.c
new file mode 100644
index 0000000..7495807
--- /dev/null
+++ b/profiles/gap/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 gap_init(void)
+{
+ if (!main_opts.gatt_enabled) {
+ error("GAP can not start: GATT is disabled");
+ return -ENOTSUP;
+ }
+
+ return gap_manager_init();
+}
+
+static void gap_exit(void)
+{
+ gap_manager_exit();
+}
+
+BLUETOOTH_PLUGIN_DEFINE(gap, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
+ gap_init, gap_exit)
diff --git a/profiles/gap/manager.c b/profiles/gap/manager.c
new file mode 100644
index 0000000..f2e36f5
--- /dev/null
+++ b/profiles/gap/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 gap_driver_probe(struct btd_device *device, GSList *uuids)
+{
+ return 0;
+}
+
+static void gap_driver_remove(struct btd_device *device)
+{
+}
+
+static struct btd_device_driver gap_device_driver = {
+ .name = "gap-driver",
+ .uuids = BTD_UUIDS(GAP_UUID),
+ .probe = gap_driver_probe,
+ .remove = gap_driver_remove
+};
+
+int gap_manager_init(void)
+{
+ return btd_register_device_driver(&gap_device_driver);
+}
+
+void gap_manager_exit(void)
+{
+ btd_unregister_device_driver(&gap_device_driver);
+}
diff --git a/profiles/gap/manager.h b/profiles/gap/manager.h
new file mode 100644
index 0000000..7bc947f
--- /dev/null
+++ b/profiles/gap/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 gap_manager_init(void);
+void gap_manager_exit(void);
--
1.7.8.6
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH BlueZ v0 02/10] gap: Add GAP device registration
2012-08-15 14:19 [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
2012-08-15 14:19 ` [PATCH BlueZ v0 01/10] gap: Add Generic Access Profile plugin skeleton Claudio Takahasi
@ 2012-08-15 14:19 ` Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 03/10] gap: Add read Appearance characteristic Claudio Takahasi
` (8 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-15 14:19 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
This patch adds GAP device driver probe function and the skeleton of
the register GAP device function.
---
Makefile.am | 3 +-
profiles/gap/gap.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++
profiles/gap/gap.h | 24 +++++++++++++
profiles/gap/manager.c | 22 ++++++++++++-
4 files changed, 132 insertions(+), 2 deletions(-)
create mode 100644 profiles/gap/gap.c
create mode 100644 profiles/gap/gap.h
diff --git a/Makefile.am b/Makefile.am
index 2db3ce1..d0a8de6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -239,7 +239,8 @@ builtin_sources += profiles/thermometer/main.c \
profiles/deviceinfo/deviceinfo.h \
profiles/deviceinfo/deviceinfo.c \
profiles/gap/main.c profiles/gap/manager.h \
- profiles/gap/manager.c
+ profiles/gap/manager.c profiles/gap/gap.h \
+ profiles/gap/gap.c
endif
builtin_modules += formfactor
diff --git a/profiles/gap/gap.c b/profiles/gap/gap.c
new file mode 100644
index 0000000..7172975
--- /dev/null
+++ b/profiles/gap/gap.c
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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 "gap.h"
+
+struct gap {
+ struct btd_device *device;
+ struct att_range range; /* GAP Primary service range */
+};
+
+static GSList *devices = NULL;
+
+static void gap_free(struct gap *gap)
+{
+ btd_device_unref(gap->device);
+ g_free(gap);
+}
+
+static gint cmp_device(gconstpointer a, gconstpointer b)
+{
+ const struct gap *gap = a;
+ const struct btd_device *device = b;
+
+ return (gap->device == device ? 0 : -1);
+}
+
+int gap_register(struct btd_device *device, struct gatt_primary *prim)
+{
+ struct gap *gap;
+
+ gap = g_new0(struct gap, 1);
+ gap->range.start = prim->range.start;
+ gap->range.end = prim->range.end;
+ gap->device = btd_device_ref(device);
+
+ devices = g_slist_append(devices, gap);
+
+ return 0;
+}
+
+void gap_unregister(struct btd_device *device)
+{
+ struct gap *gap;
+ GSList *l;
+
+ l = g_slist_find_custom(devices, device, cmp_device);
+ if (l == NULL)
+ return;
+
+ gap = l->data;
+ devices = g_slist_remove(devices, gap);
+ gap_free(gap);
+}
diff --git a/profiles/gap/gap.h b/profiles/gap/gap.h
new file mode 100644
index 0000000..722750e
--- /dev/null
+++ b/profiles/gap/gap.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 gap_register(struct btd_device *device, struct gatt_primary *prim);
+void gap_unregister(struct btd_device *device);
diff --git a/profiles/gap/manager.c b/profiles/gap/manager.c
index f2e36f5..9c2f3eb 100644
--- a/profiles/gap/manager.c
+++ b/profiles/gap/manager.c
@@ -26,11 +26,31 @@
#include "adapter.h"
#include "device.h"
+#include "att.h"
+#include "gattrib.h"
+#include "gatt.h"
+#include "gap.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 gap_driver_probe(struct btd_device *device, GSList *uuids)
{
- return 0;
+ GSList *primaries, *l;
+
+ primaries = btd_device_get_primaries(device);
+
+ l = g_slist_find_custom(primaries, GAP_UUID, primary_uuid_cmp);
+ if (l == NULL)
+ return -EINVAL;
+
+ return gap_register(device, l->data);
}
static void gap_driver_remove(struct btd_device *device)
--
1.7.8.6
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH BlueZ v0 03/10] gap: Add read Appearance characteristic
2012-08-15 14:19 [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
2012-08-15 14:19 ` [PATCH BlueZ v0 01/10] gap: Add Generic Access Profile plugin skeleton Claudio Takahasi
2012-08-15 14:19 ` [PATCH BlueZ v0 02/10] gap: Add GAP device registration Claudio Takahasi
@ 2012-08-15 14:20 ` Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 04/10] gap: Add storing Appearance Claudio Takahasi
` (7 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-15 14:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
This patch registers the ATTIO callbacks, and triggers the Appearance
characteristic read by UUID when the ATT connection is established, and
it's value is not found in the storage.
---
profiles/gap/gap.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 76 insertions(+), 0 deletions(-)
diff --git a/profiles/gap/gap.c b/profiles/gap/gap.c
index 7172975..0ecadb3 100644
--- a/profiles/gap/gap.c
+++ b/profiles/gap/gap.c
@@ -29,22 +29,32 @@
#include "adapter.h"
#include "device.h"
+#include "storage.h"
+
#include "att.h"
#include "gattrib.h"
+#include "attio.h"
#include "gatt.h"
+
#include "log.h"
#include "gap.h"
struct gap {
struct btd_device *device;
struct att_range range; /* GAP Primary service range */
+ GAttrib *attrib;
+ guint attioid;
};
static GSList *devices = NULL;
static void gap_free(struct gap *gap)
{
+ if (gap->attioid)
+ btd_device_remove_attio_callback(gap->device, gap->attioid);
+
btd_device_unref(gap->device);
+
g_free(gap);
}
@@ -56,6 +66,69 @@ static gint cmp_device(gconstpointer a, gconstpointer b)
return (gap->device == device ? 0 : -1);
}
+static void 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) {
+ DBG("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) {
+ DBG("Appearance value: invalid data");
+ goto done;
+ }
+
+ atval = list->data[0] + 2; /* skip handle value */
+ app = att_get_u16(atval);
+
+ DBG("Appearance: 0x%04x", app);
+
+done:
+ att_data_list_free(list);
+}
+
+static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
+{
+ struct gap *gap = user_data;
+ bdaddr_t src, dst;
+ bt_uuid_t app_uuid;
+ uint16_t app;
+ uint8_t type;
+
+ gap->attrib = g_attrib_ref(attrib);
+
+ adapter_get_address(device_get_adapter(gap->device), &src);
+ device_get_address(gap->device, &dst, &type);
+
+ if (read_remote_appearance(&src, &dst, type, &app) == 0)
+ return;
+
+ bt_uuid16_create(&app_uuid, GATT_CHARAC_APPEARANCE);
+
+ gatt_read_char_by_uuid(gap->attrib, gap->range.start, gap->range.end,
+ &app_uuid, appearance_cb, gap);
+
+ /* TODO: Read other GAP characteristics - See Core spec page 1739 */
+}
+
+static void attio_disconnected_cb(gpointer user_data)
+{
+ struct gap *gap = user_data;
+
+ g_attrib_unref(gap->attrib);
+ gap->attrib = NULL;
+}
+
int gap_register(struct btd_device *device, struct gatt_primary *prim)
{
struct gap *gap;
@@ -67,6 +140,9 @@ int gap_register(struct btd_device *device, struct gatt_primary *prim)
devices = g_slist_append(devices, gap);
+ gap->attioid = btd_device_add_attio_callback(device, attio_connected_cb,
+ attio_disconnected_cb, gap);
+
return 0;
}
--
1.7.8.6
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH BlueZ v0 04/10] gap: Add storing Appearance
2012-08-15 14:19 [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
` (2 preceding siblings ...)
2012-08-15 14:20 ` [PATCH BlueZ v0 03/10] gap: Add read Appearance characteristic Claudio Takahasi
@ 2012-08-15 14:20 ` Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 05/10] core: Remove Appearance characteristic read Claudio Takahasi
` (6 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-15 14:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
This patch store the Appearance characteristic value read from the
remote device.
---
profiles/gap/gap.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/profiles/gap/gap.c b/profiles/gap/gap.c
index 0ecadb3..4d21fb6 100644
--- a/profiles/gap/gap.c
+++ b/profiles/gap/gap.c
@@ -69,8 +69,11 @@ static gint cmp_device(gconstpointer a, gconstpointer b)
static void appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
gpointer user_data)
{
+ struct gap *gap = user_data;
struct att_data_list *list = NULL;
+ bdaddr_t src, dst;
uint16_t app;
+ uint8_t type;
uint8_t *atval;
if (status != 0) {
@@ -93,6 +96,11 @@ static void appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
DBG("Appearance: 0x%04x", app);
+ adapter_get_address(device_get_adapter(gap->device), &src);
+ device_get_address(gap->device, &dst, &type);
+
+ write_remote_appearance(&src, &dst, type, app);
+
done:
att_data_list_free(list);
}
--
1.7.8.6
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH BlueZ v0 05/10] core: Remove Appearance characteristic read
2012-08-15 14:19 [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
` (3 preceding siblings ...)
2012-08-15 14:20 ` [PATCH BlueZ v0 04/10] gap: Add storing Appearance Claudio Takahasi
@ 2012-08-15 14:20 ` Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 06/10] gap: Emit PropertyChanged for Appearance Claudio Takahasi
` (5 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-15 14:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
This patch removes the Appearance characteristic read from the core.
Appearance characteristic is now being read by the GAP plugin.
---
src/device.c | 56 +-------------------------------------------------------
1 files changed, 1 insertions(+), 55 deletions(-)
diff --git a/src/device.c b/src/device.c
index f781298..aeb2a86 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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v0 06/10] gap: Emit PropertyChanged for Appearance
2012-08-15 14:19 [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
` (4 preceding siblings ...)
2012-08-15 14:20 ` [PATCH BlueZ v0 05/10] core: Remove Appearance characteristic read Claudio Takahasi
@ 2012-08-15 14:20 ` Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 07/10] core: PropertyChanged signal for Icon/class Claudio Takahasi
` (4 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-15 14:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
Emit PropertyChanged changed signal in the Device hierarchy when the
Appearance characteristic value is read from the remote GAP service.
---
profiles/gap/gap.c | 2 ++
src/device.c | 8 ++++++++
src/device.h | 1 +
3 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/profiles/gap/gap.c b/profiles/gap/gap.c
index 4d21fb6..ff5715b 100644
--- a/profiles/gap/gap.c
+++ b/profiles/gap/gap.c
@@ -96,6 +96,8 @@ static void appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
DBG("Appearance: 0x%04x", app);
+ device_set_appearance(gap->device, app);
+
adapter_get_address(device_get_adapter(gap->device), &src);
device_get_address(gap->device, &dst, &type);
diff --git a/src/device.c b/src/device.c
index aeb2a86..ef9f1b2 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2993,6 +2993,14 @@ void device_set_class(struct btd_device *device, uint32_t value)
DBUS_TYPE_UINT32, &value);
}
+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 26e17f7..c3a31e9 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);
+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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v0 07/10] core: PropertyChanged signal for Icon/class
2012-08-15 14:19 [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
` (5 preceding siblings ...)
2012-08-15 14:20 ` [PATCH BlueZ v0 06/10] gap: Emit PropertyChanged for Appearance Claudio Takahasi
@ 2012-08-15 14:20 ` Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 08/10] core: PropertyChanged signal for Icon/Appearance Claudio Takahasi
` (3 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-15 14:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 ef9f1b2..f14ea82 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);
}
void device_set_appearance(struct btd_device *device, uint16_t value)
--
1.7.8.6
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH BlueZ v0 08/10] core: PropertyChanged signal for Icon/Appearance
2012-08-15 14:19 [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
` (6 preceding siblings ...)
2012-08-15 14:20 ` [PATCH BlueZ v0 07/10] core: PropertyChanged signal for Icon/class Claudio Takahasi
@ 2012-08-15 14:20 ` Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 09/10] gap: Map Appearance value 0x0000 to unknown Claudio Takahasi
` (2 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-15 14:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 f14ea82..d052dd0 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3001,9 +3001,14 @@ void device_set_class(struct btd_device *device, uint32_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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v0 09/10] gap: Map Appearance value 0x0000 to unknown
2012-08-15 14:19 [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
` (7 preceding siblings ...)
2012-08-15 14:20 ` [PATCH BlueZ v0 08/10] core: PropertyChanged signal for Icon/Appearance Claudio Takahasi
@ 2012-08-15 14:20 ` Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 10/10] gap: Don't store Appearance if value is "unknown" Claudio Takahasi
2012-08-16 12:53 ` [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-15 14:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v0 10/10] gap: Don't store Appearance if value is "unknown"
2012-08-15 14:19 [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
` (8 preceding siblings ...)
2012-08-15 14:20 ` [PATCH BlueZ v0 09/10] gap: Map Appearance value 0x0000 to unknown Claudio Takahasi
@ 2012-08-15 14:20 ` Claudio Takahasi
2012-08-16 12:53 ` [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-15 14:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
The Core SPEC is not clear regarding the behaviour or the Appearance
characteristic. According to the SPEC, the Appearance characteristic
should be readable without authentication or authorization. This patch
will keep the Appearance characteristic value refresh (read) on every
re-connection if the value is 0x0000.
---
profiles/gap/gap.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/profiles/gap/gap.c b/profiles/gap/gap.c
index ff5715b..596d0b9 100644
--- a/profiles/gap/gap.c
+++ b/profiles/gap/gap.c
@@ -98,6 +98,9 @@ static void appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
device_set_appearance(gap->device, app);
+ if (app == 0x0000)
+ goto done;
+
adapter_get_address(device_get_adapter(gap->device), &src);
device_get_address(gap->device, &dst, &type);
--
1.7.8.6
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH BlueZ v0 00/10] GAP Plugin
2012-08-15 14:19 [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
` (9 preceding siblings ...)
2012-08-15 14:20 ` [PATCH BlueZ v0 10/10] gap: Don't store Appearance if value is "unknown" Claudio Takahasi
@ 2012-08-16 12:53 ` Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
10 siblings, 1 reply; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-16 12:53 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
Hi Johan:
On Wed, Aug 15, 2012 at 11:19 AM, Claudio Takahasi
<claudio.takahasi@openbossa.org> wrote:
> This patch series adds a new GATT based plugin for GAP service. The
> objective is cleanup: moving some GATT related operations from the
> device(core) to a GATT based plugin.
Ignore this patch series. As discussed in the IRC, a new GATT plugin
will be created to handle GAP and GATT services characteristics.
The term "GAP" for a GAP characteristics plug-in is not suitable since
it may create misinterpretation with GAP BR/EDR.
BR,
Claudio
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH BlueZ v1 00/10] GATT Plugin
2012-08-16 12:53 ` [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
@ 2012-08-16 20:13 ` Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 01/10] gatt: Add Generic Access/Attribute Profile plugin Claudio Takahasi
` (11 more replies)
0 siblings, 12 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-16 20:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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.
Claudio Takahasi (10):
gatt: Add Generic Access/Attribute Profile plugin
gatt: Add GAP/GATT device registration
gatt: Add read Appearance characteristic
gatt: Add storing Appearance
core: Remove Appearance characteristic read
gatt: Emit PropertyChanged for Appearance
core: PropertyChanged signal for Icon/class
core: PropertyChanged signal for Icon/Appearance
gatt: Map Appearance value 0x0000 to "unknown"
gatt: Don't store Appearance if value is "unknown"
Makefile.am | 8 ++-
profiles/gatt/gas.c | 179 +++++++++++++++++++++++++++++++++++++++++++++++
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 | 74 +++++--------------
src/device.h | 1 +
9 files changed, 390 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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v1 01/10] gatt: Add Generic Access/Attribute Profile plugin
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
@ 2012-08-16 20:13 ` Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 02/10] gatt: Add GAP/GATT device registration Claudio Takahasi
` (10 subsequent siblings)
11 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-16 20:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v1 02/10] gatt: Add GAP/GATT device registration
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 01/10] gatt: Add Generic Access/Attribute Profile plugin Claudio Takahasi
@ 2012-08-16 20:13 ` Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 03/10] gatt: Add read Appearance characteristic Claudio Takahasi
` (9 subsequent siblings)
11 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-16 20:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v1 03/10] gatt: Add read Appearance characteristic
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 01/10] gatt: Add Generic Access/Attribute Profile plugin Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 02/10] gatt: Add GAP/GATT device registration Claudio Takahasi
@ 2012-08-16 20:13 ` Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 04/10] gatt: Add storing Appearance Claudio Takahasi
` (8 subsequent siblings)
11 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-16 20:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 75 insertions(+), 0 deletions(-)
diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index d13eadc..2fb12ce 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -29,8 +29,10 @@
#include "adapter.h"
#include "device.h"
+#include "storage.h"
#include "att.h"
#include "gattrib.h"
+#include "attio.h"
#include "gatt.h"
#include "log.h"
#include "gas.h"
@@ -40,12 +42,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 +65,70 @@ 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;
+ bdaddr_t src, dst;
+ uint16_t app;
+ uint8_t type;
+
+ gas->attrib = g_attrib_ref(attrib);
+
+ adapter_get_address(device_get_adapter(gas->device), &src);
+ device_get_address(gas->device, &dst, &type);
+
+ if (read_remote_appearance(&src, &dst, type, &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 +144,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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v1 04/10] gatt: Add storing Appearance
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
` (2 preceding siblings ...)
2012-08-16 20:13 ` [PATCH BlueZ v1 03/10] gatt: Add read Appearance characteristic Claudio Takahasi
@ 2012-08-16 20:13 ` Claudio Takahasi
2012-08-17 8:28 ` Johan Hedberg
2012-08-16 20:13 ` [PATCH BlueZ v1 05/10] core: Remove Appearance characteristic read Claudio Takahasi
` (7 subsequent siblings)
11 siblings, 1 reply; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-16 20:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
This patch stores the Appearance characteristic value read from the
remote GAP service.
---
profiles/gatt/gas.c | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index 2fb12ce..bf603e8 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -68,8 +68,11 @@ 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;
+ bdaddr_t src, dst;
uint16_t app;
+ uint8_t type;
uint8_t *atval;
if (status != 0) {
@@ -92,6 +95,11 @@ static void gap_appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
DBG("GAP Appearance: 0x%04x", app);
+ adapter_get_address(device_get_adapter(gas->device), &src);
+ device_get_address(gas->device, &dst, &type);
+
+ write_remote_appearance(&src, &dst, type, app);
+
done:
att_data_list_free(list);
}
--
1.7.8.6
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH BlueZ v1 05/10] core: Remove Appearance characteristic read
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
` (3 preceding siblings ...)
2012-08-16 20:13 ` [PATCH BlueZ v1 04/10] gatt: Add storing Appearance Claudio Takahasi
@ 2012-08-16 20:13 ` Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 06/10] gatt: Emit PropertyChanged for Appearance Claudio Takahasi
` (6 subsequent siblings)
11 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-16 20:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 f781298..aeb2a86 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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v1 06/10] gatt: Emit PropertyChanged for Appearance
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
` (4 preceding siblings ...)
2012-08-16 20:13 ` [PATCH BlueZ v1 05/10] core: Remove Appearance characteristic read Claudio Takahasi
@ 2012-08-16 20:13 ` Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 07/10] core: PropertyChanged signal for Icon/class Claudio Takahasi
` (5 subsequent siblings)
11 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-16 20:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
Emit PropertyChanged changed signal in the Device hierarchy when the
Appearance characteristic value is read from the remote GAP service.
---
profiles/gatt/gas.c | 2 ++
src/device.c | 8 ++++++++
src/device.h | 1 +
3 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index bf603e8..8817e6d 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -95,6 +95,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);
+
adapter_get_address(device_get_adapter(gas->device), &src);
device_get_address(gas->device, &dst, &type);
diff --git a/src/device.c b/src/device.c
index aeb2a86..ef9f1b2 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2993,6 +2993,14 @@ void device_set_class(struct btd_device *device, uint32_t value)
DBUS_TYPE_UINT32, &value);
}
+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 26e17f7..c3a31e9 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);
+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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v1 07/10] core: PropertyChanged signal for Icon/class
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
` (5 preceding siblings ...)
2012-08-16 20:13 ` [PATCH BlueZ v1 06/10] gatt: Emit PropertyChanged for Appearance Claudio Takahasi
@ 2012-08-16 20:13 ` Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 08/10] core: PropertyChanged signal for Icon/Appearance Claudio Takahasi
` (4 subsequent siblings)
11 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-16 20:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 ef9f1b2..f14ea82 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);
}
void device_set_appearance(struct btd_device *device, uint16_t value)
--
1.7.8.6
^ permalink raw reply related [flat|nested] 39+ messages in thread
* [PATCH BlueZ v1 08/10] core: PropertyChanged signal for Icon/Appearance
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
` (6 preceding siblings ...)
2012-08-16 20:13 ` [PATCH BlueZ v1 07/10] core: PropertyChanged signal for Icon/class Claudio Takahasi
@ 2012-08-16 20:13 ` Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 09/10] gatt: Map Appearance value 0x0000 to "unknown" Claudio Takahasi
` (3 subsequent siblings)
11 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-16 20:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 f14ea82..d052dd0 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3001,9 +3001,14 @@ void device_set_class(struct btd_device *device, uint32_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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v1 09/10] gatt: Map Appearance value 0x0000 to "unknown"
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
` (7 preceding siblings ...)
2012-08-16 20:13 ` [PATCH BlueZ v1 08/10] core: PropertyChanged signal for Icon/Appearance Claudio Takahasi
@ 2012-08-16 20:13 ` Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 10/10] gatt: Don't store Appearance if value is "unknown" Claudio Takahasi
` (2 subsequent siblings)
11 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-16 20:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v1 10/10] gatt: Don't store Appearance if value is "unknown"
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
` (8 preceding siblings ...)
2012-08-16 20:13 ` [PATCH BlueZ v1 09/10] gatt: Map Appearance value 0x0000 to "unknown" Claudio Takahasi
@ 2012-08-16 20:13 ` Claudio Takahasi
2012-08-17 8:29 ` [PATCH BlueZ v1 00/10] GATT Plugin Johan Hedberg
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
11 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-16 20:13 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
The Core SPEC is not clear regarding the behaviour or the GAP Appearance
characteristic. According to the SPEC, the Appearance characteristic
should be readable without authentication or authorization. This patch
will keep the Appearance characteristic value refresh (read) on every
re-connection if the value is 0x0000.
---
profiles/gatt/gas.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index 8817e6d..248a88e 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -97,6 +97,9 @@ static void gap_appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
device_set_appearance(gas->device, app);
+ if (app == 0x0000)
+ goto done;
+
adapter_get_address(device_get_adapter(gas->device), &src);
device_get_address(gas->device, &dst, &type);
--
1.7.8.6
^ permalink raw reply related [flat|nested] 39+ messages in thread
* Re: [PATCH BlueZ v1 04/10] gatt: Add storing Appearance
2012-08-16 20:13 ` [PATCH BlueZ v1 04/10] gatt: Add storing Appearance Claudio Takahasi
@ 2012-08-17 8:28 ` Johan Hedberg
2012-08-17 14:00 ` Claudio Takahasi
0 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-08-17 8:28 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
Hi Claudio,
On Thu, Aug 16, 2012, Claudio Takahasi wrote:
> This patch stores the Appearance characteristic value read from the
> remote GAP service.
> ---
> profiles/gatt/gas.c | 8 ++++++++
> 1 files changed, 8 insertions(+), 0 deletions(-)
>
> diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
> index 2fb12ce..bf603e8 100644
> --- a/profiles/gatt/gas.c
> +++ b/profiles/gatt/gas.c
> @@ -68,8 +68,11 @@ 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;
> + bdaddr_t src, dst;
> uint16_t app;
> + uint8_t type;
> uint8_t *atval;
>
> if (status != 0) {
> @@ -92,6 +95,11 @@ static void gap_appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
>
> DBG("GAP Appearance: 0x%04x", app);
>
> + adapter_get_address(device_get_adapter(gas->device), &src);
> + device_get_address(gas->device, &dst, &type);
> +
> + write_remote_appearance(&src, &dst, type, app);
I'm not so sure it's a good idea to have plugins use the storage
functions directly. Instead I'd put this into the device_set_appearance
function which you add later in this patch set. If there really is a
need to access storage functions from within plugins (which there isn't
for this particular case) then we need to prefix all of the storage
functions with btd_* since those are the only types of symbols that
should be exported from the core daemon to plugins.
Johan
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH BlueZ v1 00/10] GATT Plugin
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
` (9 preceding siblings ...)
2012-08-16 20:13 ` [PATCH BlueZ v1 10/10] gatt: Don't store Appearance if value is "unknown" Claudio Takahasi
@ 2012-08-17 8:29 ` Johan Hedberg
2012-08-17 14:04 ` Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
11 siblings, 1 reply; 39+ messages in thread
From: Johan Hedberg @ 2012-08-17 8:29 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
Hi Claudio,
On Thu, Aug 16, 2012, Claudio Takahasi wrote:
> 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.
>
> Claudio Takahasi (10):
> gatt: Add Generic Access/Attribute Profile plugin
> gatt: Add GAP/GATT device registration
> gatt: Add read Appearance characteristic
> gatt: Add storing Appearance
> core: Remove Appearance characteristic read
> gatt: Emit PropertyChanged for Appearance
> core: PropertyChanged signal for Icon/class
> core: PropertyChanged signal for Icon/Appearance
> gatt: Map Appearance value 0x0000 to "unknown"
> gatt: Don't store Appearance if value is "unknown"
>
> Makefile.am | 8 ++-
> profiles/gatt/gas.c | 179 +++++++++++++++++++++++++++++++++++++++++++++++
> 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 | 74 +++++--------------
> src/device.h | 1 +
> 9 files changed, 390 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
Besides the one comment I already sent about this patch set it looks
more or less ok to me. Would it also make sense to move the server-side
GAP functionality into this plugin?
Johan
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH BlueZ v1 04/10] gatt: Add storing Appearance
2012-08-17 8:28 ` Johan Hedberg
@ 2012-08-17 14:00 ` Claudio Takahasi
0 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-17 14:00 UTC (permalink / raw)
To: Claudio Takahasi, linux-bluetooth
Hi Johan:
On Fri, Aug 17, 2012 at 5:28 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Claudio,
>
> On Thu, Aug 16, 2012, Claudio Takahasi wrote:
>> This patch stores the Appearance characteristic value read from the
>> remote GAP service.
>> ---
>> profiles/gatt/gas.c | 8 ++++++++
>> 1 files changed, 8 insertions(+), 0 deletions(-)
>>
>> diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
>> index 2fb12ce..bf603e8 100644
>> --- a/profiles/gatt/gas.c
>> +++ b/profiles/gatt/gas.c
>> @@ -68,8 +68,11 @@ 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;
>> + bdaddr_t src, dst;
>> uint16_t app;
>> + uint8_t type;
>> uint8_t *atval;
>>
>> if (status != 0) {
>> @@ -92,6 +95,11 @@ static void gap_appearance_cb(guint8 status, const guint8 *pdu, guint16 plen,
>>
>> DBG("GAP Appearance: 0x%04x", app);
>>
>> + adapter_get_address(device_get_adapter(gas->device), &src);
>> + device_get_address(gas->device, &dst, &type);
>> +
>> + write_remote_appearance(&src, &dst, type, app);
>
> I'm not so sure it's a good idea to have plugins use the storage
> functions directly. Instead I'd put this into the device_set_appearance
> function which you add later in this patch set. If there really is a
> need to access storage functions from within plugins (which there isn't
> for this particular case) then we need to prefix all of the storage
> functions with btd_* since those are the only types of symbols that
> should be exported from the core daemon to plugins.
>
> Johan
ok. Wait for a new patch series, write_remote_appearance call will be
moved to device_set_appearance.
BR,
Claudio
^ permalink raw reply [flat|nested] 39+ messages in thread
* Re: [PATCH BlueZ v1 00/10] GATT Plugin
2012-08-17 8:29 ` [PATCH BlueZ v1 00/10] GATT Plugin Johan Hedberg
@ 2012-08-17 14:04 ` Claudio Takahasi
0 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-17 14:04 UTC (permalink / raw)
To: Claudio Takahasi, linux-bluetooth
Hi Johan,
On Fri, Aug 17, 2012 at 5:29 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Claudio,
>
> On Thu, Aug 16, 2012, Claudio Takahasi wrote:
>> 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.
>>
>> Claudio Takahasi (10):
>> gatt: Add Generic Access/Attribute Profile plugin
>> gatt: Add GAP/GATT device registration
>> gatt: Add read Appearance characteristic
>> gatt: Add storing Appearance
>> core: Remove Appearance characteristic read
>> gatt: Emit PropertyChanged for Appearance
>> core: PropertyChanged signal for Icon/class
>> core: PropertyChanged signal for Icon/Appearance
>> gatt: Map Appearance value 0x0000 to "unknown"
>> gatt: Don't store Appearance if value is "unknown"
>>
>> Makefile.am | 8 ++-
>> profiles/gatt/gas.c | 179 +++++++++++++++++++++++++++++++++++++++++++++++
>> 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 | 74 +++++--------------
>> src/device.h | 1 +
>> 9 files changed, 390 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
>
> Besides the one comment I already sent about this patch set it looks
> more or less ok to me. Would it also make sense to move the server-side
> GAP functionality into this plugin?
>
> Johan
Probably yes. If we don't find impediments we will send patches to
move this code.
BR,
Claudio
^ permalink raw reply [flat|nested] 39+ messages in thread
* [PATCH BlueZ v2 00/10] GATT Plugin
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
` (10 preceding siblings ...)
2012-08-17 8:29 ` [PATCH BlueZ v1 00/10] GATT Plugin Johan Hedberg
@ 2012-08-17 14:43 ` Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 01/10] gatt: Add Generic Access/Attribute Profile plugin Claudio Takahasi
` (10 more replies)
11 siblings, 11 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v2 01/10] gatt: Add Generic Access/Attribute Profile plugin
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
@ 2012-08-17 14:43 ` Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 02/10] gatt: Add GAP/GATT device registration Claudio Takahasi
` (9 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v2 02/10] gatt: Add GAP/GATT device registration
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 01/10] gatt: Add Generic Access/Attribute Profile plugin Claudio Takahasi
@ 2012-08-17 14:43 ` Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 03/10] core: Add device method to access "Appearance" Claudio Takahasi
` (8 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v2 03/10] core: Add device method to access "Appearance"
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 01/10] gatt: Add Generic Access/Attribute Profile plugin Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 02/10] gatt: Add GAP/GATT device registration Claudio Takahasi
@ 2012-08-17 14:43 ` Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 04/10] gatt: Add read Appearance characteristic Claudio Takahasi
` (7 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v2 04/10] gatt: Add read Appearance characteristic
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
` (2 preceding siblings ...)
2012-08-17 14:43 ` [PATCH BlueZ v2 03/10] core: Add device method to access "Appearance" Claudio Takahasi
@ 2012-08-17 14:43 ` Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 05/10] core: Remove Appearance characteristic read Claudio Takahasi
` (6 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v2 05/10] core: Remove Appearance characteristic read
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
` (3 preceding siblings ...)
2012-08-17 14:43 ` [PATCH BlueZ v2 04/10] gatt: Add read Appearance characteristic Claudio Takahasi
@ 2012-08-17 14:43 ` Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 06/10] gatt: Emit PropertyChanged for Appearance Claudio Takahasi
` (5 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v2 06/10] gatt: Emit PropertyChanged for Appearance
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
` (4 preceding siblings ...)
2012-08-17 14:43 ` [PATCH BlueZ v2 05/10] core: Remove Appearance characteristic read Claudio Takahasi
@ 2012-08-17 14:43 ` Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 07/10] core: PropertyChanged signal for Icon/class Claudio Takahasi
` (4 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v2 07/10] core: PropertyChanged signal for Icon/class
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
` (5 preceding siblings ...)
2012-08-17 14:43 ` [PATCH BlueZ v2 06/10] gatt: Emit PropertyChanged for Appearance Claudio Takahasi
@ 2012-08-17 14:43 ` Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 08/10] core: PropertyChanged signal for Icon/Appearance Claudio Takahasi
` (3 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v2 08/10] core: PropertyChanged signal for Icon/Appearance
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
` (6 preceding siblings ...)
2012-08-17 14:43 ` [PATCH BlueZ v2 07/10] core: PropertyChanged signal for Icon/class Claudio Takahasi
@ 2012-08-17 14:43 ` Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 09/10] core: Add storing Appearance Claudio Takahasi
` (2 subsequent siblings)
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v2 09/10] core: Add storing Appearance
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
` (7 preceding siblings ...)
2012-08-17 14:43 ` [PATCH BlueZ v2 08/10] core: PropertyChanged signal for Icon/Appearance Claudio Takahasi
@ 2012-08-17 14:43 ` Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 10/10] gatt: Map Appearance value 0x0000 to "unknown" Claudio Takahasi
2012-08-20 9:20 ` [PATCH BlueZ v2 00/10] GATT Plugin Johan Hedberg
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* [PATCH BlueZ v2 10/10] gatt: Map Appearance value 0x0000 to "unknown"
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
` (8 preceding siblings ...)
2012-08-17 14:43 ` [PATCH BlueZ v2 09/10] core: Add storing Appearance Claudio Takahasi
@ 2012-08-17 14:43 ` Claudio Takahasi
2012-08-20 9:20 ` [PATCH BlueZ v2 00/10] GATT Plugin Johan Hedberg
10 siblings, 0 replies; 39+ messages in thread
From: Claudio Takahasi @ 2012-08-17 14:43 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
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 [flat|nested] 39+ messages in thread
* Re: [PATCH BlueZ v2 00/10] GATT Plugin
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
` (9 preceding siblings ...)
2012-08-17 14:43 ` [PATCH BlueZ v2 10/10] gatt: Map Appearance value 0x0000 to "unknown" Claudio Takahasi
@ 2012-08-20 9:20 ` Johan Hedberg
10 siblings, 0 replies; 39+ messages in thread
From: Johan Hedberg @ 2012-08-20 9:20 UTC (permalink / raw)
To: Claudio Takahasi; +Cc: linux-bluetooth
Hi Claudio,
On Fri, Aug 17, 2012, Claudio Takahasi wrote:
> 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
All patches in this set have been applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 39+ messages in thread
end of thread, other threads:[~2012-08-20 9:20 UTC | newest]
Thread overview: 39+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-15 14:19 [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
2012-08-15 14:19 ` [PATCH BlueZ v0 01/10] gap: Add Generic Access Profile plugin skeleton Claudio Takahasi
2012-08-15 14:19 ` [PATCH BlueZ v0 02/10] gap: Add GAP device registration Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 03/10] gap: Add read Appearance characteristic Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 04/10] gap: Add storing Appearance Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 05/10] core: Remove Appearance characteristic read Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 06/10] gap: Emit PropertyChanged for Appearance Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 07/10] core: PropertyChanged signal for Icon/class Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 08/10] core: PropertyChanged signal for Icon/Appearance Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 09/10] gap: Map Appearance value 0x0000 to unknown Claudio Takahasi
2012-08-15 14:20 ` [PATCH BlueZ v0 10/10] gap: Don't store Appearance if value is "unknown" Claudio Takahasi
2012-08-16 12:53 ` [PATCH BlueZ v0 00/10] GAP Plugin Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 00/10] GATT Plugin Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 01/10] gatt: Add Generic Access/Attribute Profile plugin Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 02/10] gatt: Add GAP/GATT device registration Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 03/10] gatt: Add read Appearance characteristic Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 04/10] gatt: Add storing Appearance Claudio Takahasi
2012-08-17 8:28 ` Johan Hedberg
2012-08-17 14:00 ` Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 05/10] core: Remove Appearance characteristic read Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 06/10] gatt: Emit PropertyChanged for Appearance Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 07/10] core: PropertyChanged signal for Icon/class Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 08/10] core: PropertyChanged signal for Icon/Appearance Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 09/10] gatt: Map Appearance value 0x0000 to "unknown" Claudio Takahasi
2012-08-16 20:13 ` [PATCH BlueZ v1 10/10] gatt: Don't store Appearance if value is "unknown" Claudio Takahasi
2012-08-17 8:29 ` [PATCH BlueZ v1 00/10] GATT Plugin Johan Hedberg
2012-08-17 14:04 ` Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 " Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 01/10] gatt: Add Generic Access/Attribute Profile plugin Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 02/10] gatt: Add GAP/GATT device registration Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 03/10] core: Add device method to access "Appearance" Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 04/10] gatt: Add read Appearance characteristic Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 05/10] core: Remove Appearance characteristic read Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 06/10] gatt: Emit PropertyChanged for Appearance Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 07/10] core: PropertyChanged signal for Icon/class Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 08/10] core: PropertyChanged signal for Icon/Appearance Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 09/10] core: Add storing Appearance Claudio Takahasi
2012-08-17 14:43 ` [PATCH BlueZ v2 10/10] gatt: Map Appearance value 0x0000 to "unknown" Claudio Takahasi
2012-08-20 9:20 ` [PATCH BlueZ v2 00/10] GATT Plugin Johan Hedberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).