* [PATCH BlueZ v1 3/8] scan: Add ATTIO callbacks registration
From: Claudio Takahasi @ 2012-09-03 18:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1346695965-25422-1-git-send-email-claudio.takahasi@openbossa.org>
This patch add the functions to manage ATTIO callbacks. The current
registration mechanism is not suitable for this service since it needs
to be passive. Scan Parameters should not actively request connections,
it needs to be notified if the connections has been established
requested by other services.
---
Makefile.am | 3 +-
profiles/scanparam/manager.c | 26 ++++++++++-
profiles/scanparam/scan.c | 105 +++++++++++++++++++++++++++++++++++++++++++
profiles/scanparam/scan.h | 26 +++++++++++
4 files changed, 158 insertions(+), 2 deletions(-)
create mode 100644 profiles/scanparam/scan.c
create mode 100644 profiles/scanparam/scan.h
diff --git a/Makefile.am b/Makefile.am
index 0bc97ae..955c78f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -244,7 +244,8 @@ builtin_sources += profiles/thermometer/main.c \
profiles/gatt/gas.c \
profiles/scanparam/main.c \
profiles/scanparam/manager.h \
- profiles/scanparam/manager.c
+ profiles/scanparam/manager.c \
+ profiles/scanparam/scan.h profiles/scanparam/scan.c
endif
builtin_modules += formfactor
diff --git a/profiles/scanparam/manager.c b/profiles/scanparam/manager.c
index 94625f5..b413f41 100644
--- a/profiles/scanparam/manager.c
+++ b/profiles/scanparam/manager.c
@@ -27,24 +27,48 @@
#endif
#include <stdbool.h>
+#include <errno.h>
#include <glib.h>
+#include <bluetooth/uuid.h>
#include "log.h"
#include "adapter.h"
#include "device.h"
+#include "att.h"
+#include "gattrib.h"
+#include "gatt.h"
#include "manager.h"
+#include "scan.h"
#define SCAN_PARAMETERS_UUID "00001813-0000-1000-8000-00805f9b34fb"
+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 scan_param_probe(struct btd_device *device, GSList *uuids)
{
+ GSList *primaries, *l;
+
DBG("Probing Scan Parameters");
- return 0;
+ primaries = btd_device_get_primaries(device);
+
+ l = g_slist_find_custom(primaries, SCAN_PARAMETERS_UUID,
+ primary_uuid_cmp);
+ if (!l)
+ return -EINVAL;
+
+ return scan_register(device, l->data);
}
static void scan_param_remove(struct btd_device *device)
{
+ scan_unregister(device);
}
static struct btd_profile scan_profile = {
diff --git a/profiles/scanparam/scan.c b/profiles/scanparam/scan.c
new file mode 100644
index 0000000..c6aaf97
--- /dev/null
+++ b/profiles/scanparam/scan.c
@@ -0,0 +1,105 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Nordic Semiconductor Inc.
+ * 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 <stdbool.h>
+
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/uuid.h>
+
+#include "adapter.h"
+#include "device.h"
+#include "att.h"
+#include "gattrib.h"
+#include "gatt.h"
+#include "attio.h"
+#include "scan.h"
+
+struct scan {
+ struct btd_device *device;
+ GAttrib *attrib;
+ guint attioid;
+};
+
+GSList *servers = NULL;
+
+static gint scan_device_cmp(gconstpointer a, gconstpointer b)
+{
+ const struct scan *scan = a;
+ const struct btd_device *device = b;
+
+ return (device == scan->device ? 0 : -1);
+}
+
+static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
+{
+ struct scan *scan = user_data;
+
+ scan->attrib = g_attrib_ref(attrib);
+}
+
+static void attio_disconnected_cb(gpointer user_data)
+{
+ struct scan *scan = user_data;
+
+ g_attrib_unref(scan->attrib);
+ scan->attrib = NULL;
+}
+
+int scan_register(struct btd_device *device, struct gatt_primary *prim)
+{
+ struct scan *scan;
+
+ scan = g_new0(struct scan, 1);
+ scan->device = btd_device_ref(device);
+ scan->attioid = btd_device_add_attio_callback(device,
+ attio_connected_cb,
+ attio_disconnected_cb,
+ scan);
+
+ servers = g_slist_prepend(servers, scan);
+
+ return 0;
+}
+
+void scan_unregister(struct btd_device *device)
+{
+ struct scan *scan;
+ GSList *l;
+
+ l = g_slist_find_custom(servers, device, scan_device_cmp);
+ if (l == NULL)
+ return;
+
+ scan = l->data;
+ servers = g_slist_remove(servers, scan);
+
+ btd_device_remove_attio_callback(scan->device, scan->attioid);
+ btd_device_unref(scan->device);
+ g_attrib_unref(scan->attrib);
+ g_free(scan);
+}
diff --git a/profiles/scanparam/scan.h b/profiles/scanparam/scan.h
new file mode 100644
index 0000000..93f7edd
--- /dev/null
+++ b/profiles/scanparam/scan.h
@@ -0,0 +1,26 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Nordic Semiconductor Inc.
+ * 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 scan_register(struct btd_device *device, struct gatt_primary *prim);
+void scan_unregister(struct btd_device *device);
--
1.7.12
^ permalink raw reply related
* [PATCH BlueZ v1 2/8] scan: Register profile
From: Claudio Takahasi @ 2012-09-03 18:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1346695965-25422-1-git-send-email-claudio.takahasi@openbossa.org>
This patch add the probe and remove callbacks for the GATT Scan
Parameters service.
---
Makefile.am | 4 ++-
profiles/scanparam/main.c | 4 ++-
profiles/scanparam/manager.c | 66 ++++++++++++++++++++++++++++++++++++++++++++
profiles/scanparam/manager.h | 26 +++++++++++++++++
4 files changed, 98 insertions(+), 2 deletions(-)
create mode 100644 profiles/scanparam/manager.c
create mode 100644 profiles/scanparam/manager.h
diff --git a/Makefile.am b/Makefile.am
index 161586e..0bc97ae 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -242,7 +242,9 @@ builtin_sources += profiles/thermometer/main.c \
profiles/gatt/main.c profiles/gatt/manager.h \
profiles/gatt/manager.c profiles/gatt/gas.h \
profiles/gatt/gas.c \
- profiles/scanparam/main.c
+ profiles/scanparam/main.c \
+ profiles/scanparam/manager.h \
+ profiles/scanparam/manager.c
endif
builtin_modules += formfactor
diff --git a/profiles/scanparam/main.c b/profiles/scanparam/main.c
index 6e90929..ba4b2c0 100644
--- a/profiles/scanparam/main.c
+++ b/profiles/scanparam/main.c
@@ -33,6 +33,7 @@
#include "log.h"
#include "plugin.h"
#include "hcid.h"
+#include "manager.h"
static int scan_param_init(void)
{
@@ -41,11 +42,12 @@ static int scan_param_init(void)
return -ENOTSUP;
}
- return 0;
+ return scan_param_manager_init();
}
static void scan_param_exit(void)
{
+ scan_param_manager_exit();
}
BLUETOOTH_PLUGIN_DEFINE(scanparam, VERSION,
diff --git a/profiles/scanparam/manager.c b/profiles/scanparam/manager.c
new file mode 100644
index 0000000..94625f5
--- /dev/null
+++ b/profiles/scanparam/manager.c
@@ -0,0 +1,66 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Nordic Semiconductor Inc.
+ * 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 <stdbool.h>
+#include <glib.h>
+
+#include "log.h"
+#include "adapter.h"
+#include "device.h"
+#include "manager.h"
+
+#define SCAN_PARAMETERS_UUID "00001813-0000-1000-8000-00805f9b34fb"
+
+static int scan_param_probe(struct btd_device *device, GSList *uuids)
+{
+ DBG("Probing Scan Parameters");
+
+ return 0;
+}
+
+static void scan_param_remove(struct btd_device *device)
+{
+}
+
+static struct btd_profile scan_profile = {
+ .name = "Scan Parameters Client Driver",
+ .remote_uuids = BTD_UUIDS(SCAN_PARAMETERS_UUID),
+ .device_probe = scan_param_probe,
+ .device_remove = scan_param_remove,
+};
+
+int scan_param_manager_init(void)
+{
+ return btd_profile_register(&scan_profile);
+
+}
+
+void scan_param_manager_exit(void)
+{
+ btd_profile_unregister(&scan_profile);
+}
diff --git a/profiles/scanparam/manager.h b/profiles/scanparam/manager.h
new file mode 100644
index 0000000..1cf2e5e
--- /dev/null
+++ b/profiles/scanparam/manager.h
@@ -0,0 +1,26 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Nordic Semiconductor Inc.
+ * 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 scan_param_manager_init(void);
+void scan_param_manager_exit(void);
--
1.7.12
^ permalink raw reply related
* [PATCH BlueZ v1 1/8] scan: Add plugin skeleton
From: Claudio Takahasi @ 2012-09-03 18:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1346695965-25422-1-git-send-email-claudio.takahasi@openbossa.org>
This patch adds the Makefile changes and plugin declaration to support
Scan Parameters service. BlueZ will act as Scan Client writting to a Scan
Server the scanning parameters.
---
Makefile.am | 5 +++--
profiles/scanparam/main.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 2 deletions(-)
create mode 100644 profiles/scanparam/main.c
diff --git a/Makefile.am b/Makefile.am
index 4977a05..161586e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -212,7 +212,7 @@ endif
if GATTMODULES
builtin_modules += thermometer alert time gatt_example proximity deviceinfo \
- gatt
+ gatt scanparam
builtin_sources += profiles/thermometer/main.c \
profiles/thermometer/manager.h \
profiles/thermometer/manager.c \
@@ -241,7 +241,8 @@ builtin_sources += profiles/thermometer/main.c \
profiles/deviceinfo/deviceinfo.c \
profiles/gatt/main.c profiles/gatt/manager.h \
profiles/gatt/manager.c profiles/gatt/gas.h \
- profiles/gatt/gas.c
+ profiles/gatt/gas.c \
+ profiles/scanparam/main.c
endif
builtin_modules += formfactor
diff --git a/profiles/scanparam/main.c b/profiles/scanparam/main.c
new file mode 100644
index 0000000..6e90929
--- /dev/null
+++ b/profiles/scanparam/main.c
@@ -0,0 +1,53 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Nordic Semiconductor Inc.
+ * 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 <errno.h>
+#include <stdint.h>
+#include <glib.h>
+
+#include "log.h"
+#include "plugin.h"
+#include "hcid.h"
+
+static int scan_param_init(void)
+{
+ if (!main_opts.gatt_enabled) {
+ DBG("Scan Parameters: GATT is disabled");
+ return -ENOTSUP;
+ }
+
+ return 0;
+}
+
+static void scan_param_exit(void)
+{
+}
+
+BLUETOOTH_PLUGIN_DEFINE(scanparam, VERSION,
+ BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
+ scan_param_init, scan_param_exit)
--
1.7.12
^ permalink raw reply related
* [PATCH BlueZ v1 0/8] Scan Parameters Plugin
From: Claudio Takahasi @ 2012-09-03 18:12 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345664723-30814-1-git-send-email-claudio.takahasi@openbossa.org>
This patch series implements a new GATT based service/plugin for Scan
Parameters: Optional service for HID devices.
This service enables a GATT Client to store the LE scan parameters on
a GATT Server device, allowing the GATT Server to use this information
to adjust the scanning settings to optimize power consumption and/or
reconnection latency.
Changes from previous version: Using new profile abstraction (replaces
btd_device drivers)
Claudio Takahasi (8):
scan: Add plugin skeleton
scan: Register profile
scan: Add ATTIO callbacks registration
scan: Add write scan interval window
scan: Enable Scan Refresh notification
scan: Register notification handler
scan: Write parameters when requested
scan: Avoid discover if scan handle is known
Makefile.am | 8 +-
profiles/scanparam/main.c | 55 +++++++++
profiles/scanparam/manager.c | 90 ++++++++++++++
profiles/scanparam/manager.h | 26 ++++
profiles/scanparam/scan.c | 274 +++++++++++++++++++++++++++++++++++++++++++
profiles/scanparam/scan.h | 26 ++++
6 files changed, 477 insertions(+), 2 deletions(-)
create mode 100644 profiles/scanparam/main.c
create mode 100644 profiles/scanparam/manager.c
create mode 100644 profiles/scanparam/manager.h
create mode 100644 profiles/scanparam/scan.c
create mode 100644 profiles/scanparam/scan.h
--
1.7.12
^ permalink raw reply
* [PATCH v6] gatt: Translate Characteristic names
From: chen.ganir @ 2012-09-03 13:29 UTC (permalink / raw)
To: linux-bluetooth; +Cc: chen.ganir
From: Chen Ganir <chen.ganir@ti.com>
Translate Characteristic UUID's to name. This list was taken from
the Bluetooth SIG developer site.
---
attrib/client.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 75 insertions(+), 3 deletions(-)
diff --git a/attrib/client.c b/attrib/client.c
index 906d345..1bbe9aa 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -106,8 +106,79 @@ struct watcher {
struct gatt_service *gatt;
};
+struct characteristic_name {
+ const char *uuid;
+ const char *name;
+};
+
+static const struct characteristic_name char_name[] = {
+ { "00002a43-0000-1000-8000-00805f9b34fb", "Alert Category ID" },
+ { "00002a42-0000-1000-8000-00805f9b34fb", "Alert Category ID Bit Mask" },
+ { "00002a06-0000-1000-8000-00805f9b34fb", "Alert Level" },
+ { "00002a44-0000-1000-8000-00805f9b34fb", "Alert Notification Control Point" },
+ { "00002a3f-0000-1000-8000-00805f9b34fb", "Alert Status" },
+ { "00002a01-0000-1000-8000-00805f9b34fb", "Appearance" },
+ { "00002a49-0000-1000-8000-00805f9b34fb", "Blood Pressure Feature" },
+ { "00002a35-0000-1000-8000-00805f9b34fb", "Blood Pressure Measurement" },
+ { "00002a38-0000-1000-8000-00805f9b34fb", "Body Sensor Location" },
+ { "00002a2b-0000-1000-8000-00805f9b34fb", "Current Time" },
+ { "00002a08-0000-1000-8000-00805f9b34fb", "Date Time" },
+ { "00002a0a-0000-1000-8000-00805f9b34fb", "Day Date Time" },
+ { "00002a09-0000-1000-8000-00805f9b34fb", "Day of Week" },
+ { "00002a00-0000-1000-8000-00805f9b34fb", "Device Name" },
+ { "00002a0d-0000-1000-8000-00805f9b34fb", "DST Offset" },
+ { "00002a0c-0000-1000-8000-00805f9b34fb", "Exact Time 256" },
+ { "00002a26-0000-1000-8000-00805f9b34fb", "Firmware Revision String" },
+ { "00002a27-0000-1000-8000-00805f9b34fb", "Hardware Revision String" },
+ { "00002a39-0000-1000-8000-00805f9b34fb", "Heart Rate Control Point" },
+ { "00002a37-0000-1000-8000-00805f9b34fb", "Heart Rate Measurement" },
+ { "00002a2a-0000-1000-8000-00805f9b34fb", "IEEE 11073-20601 Regulatory" },
+ { "00002a36-0000-1000-8000-00805f9b34fb", "Intermediate Cuff Pressure" },
+ { "00002a1e-0000-1000-8000-00805f9b34fb", "Intermediate Temperature" },
+ { "00002a0f-0000-1000-8000-00805f9b34fb", "Local Time Information" },
+ { "00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String" },
+ { "00002a21-0000-1000-8000-00805f9b34fb", "Measurement Interval" },
+ { "00002a24-0000-1000-8000-00805f9b34fb", "Model Number String" },
+ { "00002a46-0000-1000-8000-00805f9b34fb", "New Alert" },
+ { "00002a04-0000-1000-8000-00805f9b34fb", "Peripheral Preferred Connection Parameters" },
+ { "00002a02-0000-1000-8000-00805f9b34fb", "Peripheral Privacy Flag" },
+ { "00002a03-0000-1000-8000-00805f9b34fb", "Reconnection Address" },
+ { "00002a14-0000-1000-8000-00805f9b34fb", "Reference Time Information" },
+ { "00002a40-0000-1000-8000-00805f9b34fb", "Ringer Control Point" },
+ { "00002a41-0000-1000-8000-00805f9b34fb", "Ringer Setting" },
+ { "00002a25-0000-1000-8000-00805f9b34fb", "Serial Number String" },
+ { "00002a05-0000-1000-8000-00805f9b34fb", "Service Changed" },
+ { "00002a28-0000-1000-8000-00805f9b34fb", "Software Revision String" },
+ { "00002a47-0000-1000-8000-00805f9b34fb", "Supported New Alert Category" },
+ { "00002a48-0000-1000-8000-00805f9b34fb", "Supported Unread Alert Category" },
+ { "00002a23-0000-1000-8000-00805f9b34fb", "System ID" },
+ { "00002a1c-0000-1000-8000-00805f9b34fb", "Temperature Measurement" },
+ { "00002a1d-0000-1000-8000-00805f9b34fb", "Temperature Type" },
+ { "00002a12-0000-1000-8000-00805f9b34fb", "Time Accuracy" },
+ { "00002a13-0000-1000-8000-00805f9b34fb", "Time Source" },
+ { "00002a16-0000-1000-8000-00805f9b34fb", "Time Update Control Point" },
+ { "00002a17-0000-1000-8000-00805f9b34fb", "Time Update State" },
+ { "00002a11-0000-1000-8000-00805f9b34fb", "Time with DST" },
+ { "00002a0e-0000-1000-8000-00805f9b34fb", "Time Zone" },
+ { "00002a07-0000-1000-8000-00805f9b34fb", "Tx Power Level" },
+ { "00002a45-0000-1000-8000-00805f9b34fb", "Unread Alert Status" },
+ { }
+};
+
static GSList *gatt_services = NULL;
+static const char *get_char_name(const char *uuid)
+{
+ const struct characteristic_name *c;
+
+ for (c = char_name; c->uuid; c++) {
+ if (bt_uuid_strcmp(c->uuid, uuid) == 0)
+ return c->name;
+ }
+
+ return NULL;
+}
+
static void characteristic_free(void *user_data)
{
struct characteristic *chr = user_data;
@@ -191,7 +262,7 @@ static int watcher_cmp(gconstpointer a, gconstpointer b)
static void append_char_dict(DBusMessageIter *iter, struct characteristic *chr)
{
DBusMessageIter dict;
- const char *name = "";
+ const char *name;
char *uuid;
dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
@@ -203,8 +274,9 @@ static void append_char_dict(DBusMessageIter *iter, struct characteristic *chr)
dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, &uuid);
g_free(uuid);
- /* FIXME: Translate UUID to name. */
- dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
+ name = get_char_name(chr->type);
+ if (name)
+ dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
if (chr->desc)
dict_append_entry(&dict, "Description", DBUS_TYPE_STRING,
--
1.7.9.5
^ permalink raw reply related
* [PATCH v5] gatt: Translate Characteristic names
From: chen.ganir @ 2012-09-03 13:20 UTC (permalink / raw)
To: linux-bluetooth; +Cc: chen.ganir
From: Chen Ganir <chen.ganir@ti.com>
Translate Characteristic UUID's to name. This list was taken from
the Bluetooth SIG developer site.
---
attrib/client.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 75 insertions(+), 3 deletions(-)
diff --git a/attrib/client.c b/attrib/client.c
index 906d345..479aac3 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -106,8 +106,79 @@ struct watcher {
struct gatt_service *gatt;
};
+struct characteristic_info {
+ const char *uuid;
+ const char *name;
+};
+
+static const struct characteristic_info charInfo[] = {
+ { "00002a43-0000-1000-8000-00805f9b34fb", "Alert Category ID" },
+ { "00002a42-0000-1000-8000-00805f9b34fb", "Alert Category ID Bit Mask" },
+ { "00002a06-0000-1000-8000-00805f9b34fb", "Alert Level" },
+ { "00002a44-0000-1000-8000-00805f9b34fb", "Alert Notification Control Point" },
+ { "00002a3f-0000-1000-8000-00805f9b34fb", "Alert Status" },
+ { "00002a01-0000-1000-8000-00805f9b34fb", "Appearance" },
+ { "00002a49-0000-1000-8000-00805f9b34fb", "Blood Pressure Feature" },
+ { "00002a35-0000-1000-8000-00805f9b34fb", "Blood Pressure Measurement" },
+ { "00002a38-0000-1000-8000-00805f9b34fb", "Body Sensor Location" },
+ { "00002a2b-0000-1000-8000-00805f9b34fb", "Current Time" },
+ { "00002a08-0000-1000-8000-00805f9b34fb", "Date Time" },
+ { "00002a0a-0000-1000-8000-00805f9b34fb", "Day Date Time" },
+ { "00002a09-0000-1000-8000-00805f9b34fb", "Day of Week" },
+ { "00002a00-0000-1000-8000-00805f9b34fb", "Device Name" },
+ { "00002a0d-0000-1000-8000-00805f9b34fb", "DST Offset" },
+ { "00002a0c-0000-1000-8000-00805f9b34fb", "Exact Time 256" },
+ { "00002a26-0000-1000-8000-00805f9b34fb", "Firmware Revision String" },
+ { "00002a27-0000-1000-8000-00805f9b34fb", "Hardware Revision String" },
+ { "00002a39-0000-1000-8000-00805f9b34fb", "Heart Rate Control Point" },
+ { "00002a37-0000-1000-8000-00805f9b34fb", "Heart Rate Measurement" },
+ { "00002a2a-0000-1000-8000-00805f9b34fb", "IEEE 11073-20601 Regulatory" },
+ { "00002a36-0000-1000-8000-00805f9b34fb", "Intermediate Cuff Pressure" },
+ { "00002a1e-0000-1000-8000-00805f9b34fb", "Intermediate Temperature" },
+ { "00002a0f-0000-1000-8000-00805f9b34fb", "Local Time Information" },
+ { "00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String" },
+ { "00002a21-0000-1000-8000-00805f9b34fb", "Measurement Interval" },
+ { "00002a24-0000-1000-8000-00805f9b34fb", "Model Number String" },
+ { "00002a46-0000-1000-8000-00805f9b34fb", "New Alert" },
+ { "00002a04-0000-1000-8000-00805f9b34fb", "Peripheral Preferred Connection Parameters" },
+ { "00002a02-0000-1000-8000-00805f9b34fb", "Peripheral Privacy Flag" },
+ { "00002a03-0000-1000-8000-00805f9b34fb", "Reconnection Address" },
+ { "00002a14-0000-1000-8000-00805f9b34fb", "Reference Time Information" },
+ { "00002a40-0000-1000-8000-00805f9b34fb", "Ringer Control Point" },
+ { "00002a41-0000-1000-8000-00805f9b34fb", "Ringer Setting" },
+ { "00002a25-0000-1000-8000-00805f9b34fb", "Serial Number String" },
+ { "00002a05-0000-1000-8000-00805f9b34fb", "Service Changed" },
+ { "00002a28-0000-1000-8000-00805f9b34fb", "Software Revision String" },
+ { "00002a47-0000-1000-8000-00805f9b34fb", "Supported New Alert Category" },
+ { "00002a48-0000-1000-8000-00805f9b34fb", "Supported Unread Alert Category" },
+ { "00002a23-0000-1000-8000-00805f9b34fb", "System ID" },
+ { "00002a1c-0000-1000-8000-00805f9b34fb", "Temperature Measurement" },
+ { "00002a1d-0000-1000-8000-00805f9b34fb", "Temperature Type" },
+ { "00002a12-0000-1000-8000-00805f9b34fb", "Time Accuracy" },
+ { "00002a13-0000-1000-8000-00805f9b34fb", "Time Source" },
+ { "00002a16-0000-1000-8000-00805f9b34fb", "Time Update Control Point" },
+ { "00002a17-0000-1000-8000-00805f9b34fb", "Time Update State" },
+ { "00002a11-0000-1000-8000-00805f9b34fb", "Time with DST" },
+ { "00002a0e-0000-1000-8000-00805f9b34fb", "Time Zone" },
+ { "00002a07-0000-1000-8000-00805f9b34fb", "Tx Power Level" },
+ { "00002a45-0000-1000-8000-00805f9b34fb", "Unread Alert Status" },
+ { }
+};
+
static GSList *gatt_services = NULL;
+static const char *get_char_name(const char *uuid)
+{
+ const struct characteristic_info *c;
+
+ for (c = charInfo; c->uuid; c++) {
+ if (bt_uuid_strcmp(c->uuid, uuid) == 0)
+ return c->name;
+ }
+
+ return NULL;
+}
+
static void characteristic_free(void *user_data)
{
struct characteristic *chr = user_data;
@@ -191,7 +262,7 @@ static int watcher_cmp(gconstpointer a, gconstpointer b)
static void append_char_dict(DBusMessageIter *iter, struct characteristic *chr)
{
DBusMessageIter dict;
- const char *name = "";
+ const char *name;
char *uuid;
dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
@@ -203,8 +274,9 @@ static void append_char_dict(DBusMessageIter *iter, struct characteristic *chr)
dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, &uuid);
g_free(uuid);
- /* FIXME: Translate UUID to name. */
- dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
+ name = get_char_name(chr->type);
+ if (name)
+ dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
if (chr->desc)
dict_append_entry(&dict, "Description", DBUS_TYPE_STRING,
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH] Bluetooth: Use GFP_KERNEL in read_index_list
From: Szymon Janc @ 2012-09-03 13:07 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: Gustavo Padovan, linux-bluetooth@vger.kernel.org
In-Reply-To: <4083892.2VCRePhfBH@uw000953>
On Monday 03 of September 2012 14:49:59 Szymon Janc wrote:
> On Monday 03 of September 2012 15:34:11 Andrei Emeltchenko wrote:
> > Hi all,
>
> Hi Andrei,
>
> >
> > On Fri, Aug 31, 2012 at 10:54:58AM -0700, Gustavo Padovan wrote:
> > > Hi Szymon,
> > >
> > > * Szymon Janc <szymon.janc@tieto.com> [2012-08-31 09:05:46 +0200]:
> > >
> > > > read_index_list is executed by user thread running in kernel-mode
> > > > thus is allowed to sleep.
> > > >
> > > > Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
> > > > ---
> > > > net/bluetooth/mgmt.c | 2 +-
> > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > Patch has been applied to bluetooth-next. Thanks.
> >
> > Was this tested? Gustavo please remove this patch from the tree untill
> > this issue is fixed.
>
> read_index_list() is only called from mgmt_control() (via mgmt_handlers[]).
> mgmt_control (as well as other mgmt_handlers) allocate memory with
> GFP_KERNEL flag.
>
> I'm not sure why do you get this warning...
Ahhh, rwlock is held while doing memory allocation..
Yes, this should be reverted.
--
Szymon Janc
^ permalink raw reply
* Re: [PATCH v4] gatt: Translate Characteristic names
From: Johan Hedberg @ 2012-09-03 12:59 UTC (permalink / raw)
To: chen.ganir; +Cc: linux-bluetooth
In-Reply-To: <1346671769-10072-1-git-send-email-chen.ganir@ti.com>
Hi Chen,
On Mon, Sep 03, 2012, chen.ganir@ti.com wrote:
> +static const struct characteristic_info charInfo[] = {
Only lower-case symbol names please, i.e. char_info[].
> +static const char *get_char_name(const char *uuid)
> +{
> + const struct characteristic_info *c;
> +
> + for (c = charInfo; c->uuid; c++) {
> + if (g_strcmp0(c->uuid, uuid) == 0)
Since these strings are in hexadecimal format you'd need to check both
lower and upper case characters. So probably strcasecmp is best (you
should anyway have a guarantee that both c->uuid and uuid are non-NULL).
You could also use bt_uuid_strcmp from lib/uuid.h which was recently
added to help g_slist_find_custom and similar situations.
> + if (name != NULL)
> + dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
"if (name)" would be more consistent with the rest of the code, such as
the lines coming right after it:
> if (chr->desc)
> dict_append_entry(&dict, "Description", DBUS_TYPE_STRING,
Johan
^ permalink raw reply
* Re: [PATCH] Bluetooth: Use GFP_KERNEL in read_index_list
From: Szymon Janc @ 2012-09-03 12:49 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: Gustavo Padovan, linux-bluetooth@vger.kernel.org
In-Reply-To: <20120903123404.GA2789@aemeltch-MOBL1>
On Monday 03 of September 2012 15:34:11 Andrei Emeltchenko wrote:
> Hi all,
Hi Andrei,
>
> On Fri, Aug 31, 2012 at 10:54:58AM -0700, Gustavo Padovan wrote:
> > Hi Szymon,
> >
> > * Szymon Janc <szymon.janc@tieto.com> [2012-08-31 09:05:46 +0200]:
> >
> > > read_index_list is executed by user thread running in kernel-mode
> > > thus is allowed to sleep.
> > >
> > > Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
> > > ---
> > > net/bluetooth/mgmt.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > Patch has been applied to bluetooth-next. Thanks.
>
> Was this tested? Gustavo please remove this patch from the tree untill
> this issue is fixed.
read_index_list() is only called from mgmt_control() (via mgmt_handlers[]).
mgmt_control (as well as other mgmt_handlers) allocate memory with
GFP_KERNEL flag.
I'm not sure why do you get this warning...
>
> [ 141.009142] BUG: sleeping function called from invalid context at
> mm/slub.c:943
> [ 141.009156] in_atomic(): 1, irqs_disabled(): 0, pid: 2476, name:
> bluetoothd
> [ 141.009159] 2 locks held by bluetoothd/2476:
> [ 141.009161] #0: (sk_lock-AF_BLUETOOTH-BTPROTO_HCI){+.+.+.}, at:
> [<f8a9c9da>] hci_sock_sendmsg+0x5a/0x310 [bluetooth]
> [ 141.009182] #1: (hci_dev_list_lock){++++.+}, at: [<f8a9623e>]
> read_index_list+0x2e/0x150 [bluetooth]
> [ 141.009200] Pid: 2476, comm: bluetoothd Tainted: G O 3.5.0+
> #56
> [ 141.009202] Call Trace:
> [ 141.009208] [<c10776c9>] __might_sleep+0xe9/0x120
> [ 141.009213] [<c114e249>] __kmalloc+0x1a9/0x240
> [ 141.009224] [<f8a96274>] ? read_index_list+0x64/0x150 [bluetooth]
> [ 141.009234] [<f8a96274>] read_index_list+0x64/0x150 [bluetooth]
> [ 141.009244] [<f8a9a2bc>] mgmt_control+0x22c/0x350 [bluetooth]
> [ 141.009248] [<c10a44fb>] ? trace_hardirqs_on+0xb/0x10
> [ 141.009252] [<c1051298>] ? local_bh_enable+0x68/0xd0
> [ 141.009264] [<f8a9c9da>] ? hci_sock_sendmsg+0x5a/0x310 [bluetooth]
> [ 141.009297] [<f8a9ca43>] hci_sock_sendmsg+0xc3/0x310 [bluetooth]
> [ 141.009302] [<c14f134d>] ? sock_update_classid+0x7d/0x120
> [ 141.009306] [<c14f1378>] ? sock_update_classid+0xa8/0x120
> [ 141.009311] [<c14ecc6b>] sock_aio_write+0xfb/0x120
> [ 141.009315] [<c14ee31e>] ? sys_sendto+0x10e/0x150
> [ 141.009320] [<c115fbf4>] do_sync_write+0xb4/0xf0
> [ 141.009326] [<c112f680>] ? might_fault+0x50/0xa0
> [ 141.009330] [<c11602cc>] ? rw_verify_area+0x6c/0x120
> [ 141.009334] [<c11606f1>] vfs_write+0x151/0x160
> [ 141.009337] [<c14eed02>] ? sys_socketcall+0x182/0x2e0
> [ 141.009341] [<c116090d>] sys_write+0x3d/0x70
> [ 141.009345] [<c15f739f>] sysenter_do_call+0x12/0x38
>
> Best regards
> Andrei Emeltchenko
--
BR
Szymon Janc
^ permalink raw reply
* Re: [PATCH] Bluetooth: Use GFP_KERNEL in read_index_list
From: Andrei Emeltchenko @ 2012-09-03 12:34 UTC (permalink / raw)
To: Gustavo Padovan, Szymon Janc, linux-bluetooth
In-Reply-To: <20120831175458.GA5599@joana>
Hi all,
On Fri, Aug 31, 2012 at 10:54:58AM -0700, Gustavo Padovan wrote:
> Hi Szymon,
>
> * Szymon Janc <szymon.janc@tieto.com> [2012-08-31 09:05:46 +0200]:
>
> > read_index_list is executed by user thread running in kernel-mode
> > thus is allowed to sleep.
> >
> > Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
> > ---
> > net/bluetooth/mgmt.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Patch has been applied to bluetooth-next. Thanks.
Was this tested? Gustavo please remove this patch from the tree untill
this issue is fixed.
[ 141.009142] BUG: sleeping function called from invalid context at
mm/slub.c:943
[ 141.009156] in_atomic(): 1, irqs_disabled(): 0, pid: 2476, name:
bluetoothd
[ 141.009159] 2 locks held by bluetoothd/2476:
[ 141.009161] #0: (sk_lock-AF_BLUETOOTH-BTPROTO_HCI){+.+.+.}, at:
[<f8a9c9da>] hci_sock_sendmsg+0x5a/0x310 [bluetooth]
[ 141.009182] #1: (hci_dev_list_lock){++++.+}, at: [<f8a9623e>]
read_index_list+0x2e/0x150 [bluetooth]
[ 141.009200] Pid: 2476, comm: bluetoothd Tainted: G O 3.5.0+
#56
[ 141.009202] Call Trace:
[ 141.009208] [<c10776c9>] __might_sleep+0xe9/0x120
[ 141.009213] [<c114e249>] __kmalloc+0x1a9/0x240
[ 141.009224] [<f8a96274>] ? read_index_list+0x64/0x150 [bluetooth]
[ 141.009234] [<f8a96274>] read_index_list+0x64/0x150 [bluetooth]
[ 141.009244] [<f8a9a2bc>] mgmt_control+0x22c/0x350 [bluetooth]
[ 141.009248] [<c10a44fb>] ? trace_hardirqs_on+0xb/0x10
[ 141.009252] [<c1051298>] ? local_bh_enable+0x68/0xd0
[ 141.009264] [<f8a9c9da>] ? hci_sock_sendmsg+0x5a/0x310 [bluetooth]
[ 141.009297] [<f8a9ca43>] hci_sock_sendmsg+0xc3/0x310 [bluetooth]
[ 141.009302] [<c14f134d>] ? sock_update_classid+0x7d/0x120
[ 141.009306] [<c14f1378>] ? sock_update_classid+0xa8/0x120
[ 141.009311] [<c14ecc6b>] sock_aio_write+0xfb/0x120
[ 141.009315] [<c14ee31e>] ? sys_sendto+0x10e/0x150
[ 141.009320] [<c115fbf4>] do_sync_write+0xb4/0xf0
[ 141.009326] [<c112f680>] ? might_fault+0x50/0xa0
[ 141.009330] [<c11602cc>] ? rw_verify_area+0x6c/0x120
[ 141.009334] [<c11606f1>] vfs_write+0x151/0x160
[ 141.009337] [<c14eed02>] ? sys_socketcall+0x182/0x2e0
[ 141.009341] [<c116090d>] sys_write+0x3d/0x70
[ 141.009345] [<c15f739f>] sysenter_do_call+0x12/0x38
Best regards
Andrei Emeltchenko
^ permalink raw reply
* Re: [PATCH -v3 2/2] rctest: add option to save received data to file
From: Johan Hedberg @ 2012-09-03 12:01 UTC (permalink / raw)
To: Gustavo Padovan; +Cc: linux-bluetooth, Gustavo Padovan
In-Reply-To: <1346446228-11105-2-git-send-email-gustavo@padovan.org>
Hi Gustavo,
On Fri, Aug 31, 2012, Gustavo Padovan wrote:
> + if (save_fd < 0)
> + syslog(LOG_ERR, "Failed to open file to save "
> + "recv data");
Please don't split strings like this if not necessary. It makes greping
harder (you see something in the command output and try to locate it in
the source). Split after "LOG_ERR," instead.
> +static void sig_child_exit(int code)
> +{
> + syslog(LOG_INFO, "Exit");
> + exit(0);
> +
> + if (save_fd >= 0)
> + close(save_fd);
> +}
This doesn't look right as nothing after the exit() call will get
executed. I suppose you meant to ahve the save_fd closing before the
exit call?
Johan
^ permalink raw reply
* Re: [PATCH] gatt: Fix whitespace in UUID definitions
From: Johan Hedberg @ 2012-09-03 11:56 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1346423792-29996-1-git-send-email-andrzej.kaczmarek@tieto.com>
Hi Andrzej,
On Fri, Aug 31, 2012, Andrzej Kaczmarek wrote:
> ---
> attrib/gatt.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] thermometer: Fix indentation
From: Johan Hedberg @ 2012-09-03 11:55 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: linux-bluetooth
In-Reply-To: <1346403084-9587-1-git-send-email-andrzej.kaczmarek@tieto.com>
Hi Andrzej,
On Fri, Aug 31, 2012, Andrzej Kaczmarek wrote:
> ---
> profiles/thermometer/manager.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH v3 2/2] Bluetooth: mgmt: Fix enabling LE while powered off
From: Johan Hedberg @ 2012-09-03 11:53 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: linux-bluetooth, stable
In-Reply-To: <1346227329-1686-2-git-send-email-andrzej.kaczmarek@tieto.com>
Hi Andrzej,
On Wed, Aug 29, 2012, Andrzej Kaczmarek wrote:
> When new BT USB adapter is plugged in it's configured while still being powered
> off (HCI_AUTO_OFF flag is set), thus Set LE will only set dev_flags but won't
> write changes to controller. As a result it's not possible to start device
> discovery session on LE controller as it uses interleaved discovery which
> requires LE Supported Host flag in extended features.
>
> This patch ensures HCI Write LE Host Supported is sent when Set Powered is
> called to power on controller and clear HCI_AUTO_OFF flag.
>
> Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com>
> Cc: stable@vger.kernel.org
> ---
> net/bluetooth/mgmt.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Johan
^ permalink raw reply
* Re: [PATCH v3 1/2] Bluetooth: mgmt: Fix enabling SSP while powered off
From: Johan Hedberg @ 2012-09-03 11:53 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: linux-bluetooth, stable
In-Reply-To: <1346227329-1686-1-git-send-email-andrzej.kaczmarek@tieto.com>
Hi Andrzej,
On Wed, Aug 29, 2012, Andrzej Kaczmarek wrote:
> When new BT USB adapter is plugged in it's configured while still being powered
> off (HCI_AUTO_OFF flag is set), thus Set SSP will only set dev_flags but won't
> write changes to controller. As a result remote devices won't use Secure Simple
> Pairing with our device due to SSP Host Support flag disabled in extended
> features and may also reject SSP attempt from our side (with possible fallback
> to legacy pairing).
>
> This patch ensures HCI Write Simple Pairing Mode is sent when Set Powered is
> called to power on controller and clear HCI_AUTO_OFF flag.
>
> Signed-off-by: Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com>
> Cc: stable@vger.kernel.org
> ---
> net/bluetooth/mgmt.c | 6 ++++++
> 1 file changed, 6 insertions(+)
Acked-by: Johan Hedberg <johan.hedberg@intel.com>
Johan
^ permalink raw reply
* Re: [PATCH v2 1/4] audio: remove redundant Media API option
From: Johan Hedberg @ 2012-09-03 11:51 UTC (permalink / raw)
To: chanyeol.park; +Cc: linux-bluetooth
In-Reply-To: <1346149495-9363-1-git-send-email-chanyeol.park@samsung.com>
Hi Chanyeol,
On Tue, Aug 28, 2012, chanyeol.park@samsung.com wrote:
> From: Chan-yeol Park <chanyeol.park@samsung.com>
>
> BlueZ supports only Media API. So option handler's are useless.
> ---
> audio/audio.conf | 2 +-
> audio/manager.c | 12 ++----------
> audio/manager.h | 2 --
> 3 files changed, 3 insertions(+), 13 deletions(-)
All four patches have been applied. Thanks!
Johan
^ permalink raw reply
* Re: [PATCH 0/7] RFC: proximity cleanup
From: Johan Hedberg @ 2012-09-03 11:33 UTC (permalink / raw)
To: Andrzej Kaczmarek; +Cc: Anderson Lizardo, linux-bluetooth@vger.kernel.org
In-Reply-To: <50445E09.9000909@tieto.com>
Hi Andrzej,
On Mon, Sep 03, 2012, Andrzej Kaczmarek wrote:
> On 08/31/2012 06:17 PM, Anderson Lizardo wrote:
> >Hi Andrzej,
> >
> >On Fri, Aug 31, 2012 at 8:48 AM, Andrzej Kaczmarek
> ><andrzej.kaczmarek@tieto.com> wrote:
> >>Hi,
> >>
> >>Here are few patches to cleanup proximity profile code a bit which seem to
> >>keep track of some data which are redundant and has minor issue with device
> >>driver registration.
> >>
> >>Most cleanup is done in patch #3 which removes tracking of DBusConnection
> >>across whole plugin and simply uses get_dbus_connection() wherever necessary.
> >>This is different than other profile plugins do, but reduces code size and
> >>memory footprint a bit so can be done for other plugins as well if accepted.
> >
> >While some cleanups here are very welcome, I'm worried that you are
> >cleaning up things before finishing the Proximity Reporter
> >implementation. Power Level characteristic for instance is currently a
> >stub, how do you plan to store it per adapter, without the struct
> >reporter_adapter?
>
> Ah, I didn't find it on TODO so assumed it's complete. But you're
> right, it probably should not be removed.
>
> >Therefore I suggest you split the "trivial" cleanups from the removal
> >of struct reporter_adapter.
>
> Please just consider patches #6 and #7 as invalid for now, I think
> there's no point in sending #1-5 once more until there are some
> comments to fix.
>
> >BTW, do you have plans to add more features to the Proximity Reporter
> >implementation?
>
> No plans at the moment, but perhaps I'll take a look on this in more
> details after HRP is finished (v2 will be sent soon).
I've applied patches 1-4. Patch 5 didn't really make sense anymore after
the btd_profile refactoring that went in just a moment ago, and as you
said patch 6 and 7 can be considered invalid for now.
Johan
^ permalink raw reply
* [PATCH v4] gatt: Translate Characteristic names
From: chen.ganir @ 2012-09-03 11:29 UTC (permalink / raw)
To: linux-bluetooth; +Cc: chen.ganir
From: Chen Ganir <chen.ganir@ti.com>
Translate Characteristic UUID's to name. This list was taken from
the Bluetooth SIG developer site.
---
attrib/client.c | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 75 insertions(+), 3 deletions(-)
diff --git a/attrib/client.c b/attrib/client.c
index bb6adf8..6abbb45 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -105,8 +105,79 @@ struct watcher {
struct gatt_service *gatt;
};
+struct characteristic_info {
+ const char *uuid;
+ const char *name;
+};
+
+static const struct characteristic_info charInfo[] = {
+ { "00002a43-0000-1000-8000-00805f9b34fb", "Alert Category ID" },
+ { "00002a42-0000-1000-8000-00805f9b34fb", "Alert Category ID Bit Mask" },
+ { "00002a06-0000-1000-8000-00805f9b34fb", "Alert Level" },
+ { "00002a44-0000-1000-8000-00805f9b34fb", "Alert Notification Control Point" },
+ { "00002a3f-0000-1000-8000-00805f9b34fb", "Alert Status" },
+ { "00002a01-0000-1000-8000-00805f9b34fb", "Appearance" },
+ { "00002a49-0000-1000-8000-00805f9b34fb", "Blood Pressure Feature" },
+ { "00002a35-0000-1000-8000-00805f9b34fb", "Blood Pressure Measurement" },
+ { "00002a38-0000-1000-8000-00805f9b34fb", "Body Sensor Location" },
+ { "00002a2b-0000-1000-8000-00805f9b34fb", "Current Time" },
+ { "00002a08-0000-1000-8000-00805f9b34fb", "Date Time" },
+ { "00002a0a-0000-1000-8000-00805f9b34fb", "Day Date Time" },
+ { "00002a09-0000-1000-8000-00805f9b34fb", "Day of Week" },
+ { "00002a00-0000-1000-8000-00805f9b34fb", "Device Name" },
+ { "00002a0d-0000-1000-8000-00805f9b34fb", "DST Offset" },
+ { "00002a0c-0000-1000-8000-00805f9b34fb", "Exact Time 256" },
+ { "00002a26-0000-1000-8000-00805f9b34fb", "Firmware Revision String" },
+ { "00002a27-0000-1000-8000-00805f9b34fb", "Hardware Revision String" },
+ { "00002a39-0000-1000-8000-00805f9b34fb", "Heart Rate Control Point" },
+ { "00002a37-0000-1000-8000-00805f9b34fb", "Heart Rate Measurement" },
+ { "00002a2a-0000-1000-8000-00805f9b34fb", "IEEE 11073-20601 Regulatory" },
+ { "00002a36-0000-1000-8000-00805f9b34fb", "Intermediate Cuff Pressure" },
+ { "00002a1e-0000-1000-8000-00805f9b34fb", "Intermediate Temperature" },
+ { "00002a0f-0000-1000-8000-00805f9b34fb", "Local Time Information" },
+ { "00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String" },
+ { "00002a21-0000-1000-8000-00805f9b34fb", "Measurement Interval" },
+ { "00002a24-0000-1000-8000-00805f9b34fb", "Model Number String" },
+ { "00002a46-0000-1000-8000-00805f9b34fb", "New Alert" },
+ { "00002a04-0000-1000-8000-00805f9b34fb", "Peripheral Preferred Connection Parameters" },
+ { "00002a02-0000-1000-8000-00805f9b34fb", "Peripheral Privacy Flag" },
+ { "00002a03-0000-1000-8000-00805f9b34fb", "Reconnection Address" },
+ { "00002a14-0000-1000-8000-00805f9b34fb", "Reference Time Information" },
+ { "00002a40-0000-1000-8000-00805f9b34fb", "Ringer Control Point" },
+ { "00002a41-0000-1000-8000-00805f9b34fb", "Ringer Setting" },
+ { "00002a25-0000-1000-8000-00805f9b34fb", "Serial Number String" },
+ { "00002a05-0000-1000-8000-00805f9b34fb", "Service Changed" },
+ { "00002a28-0000-1000-8000-00805f9b34fb", "Software Revision String" },
+ { "00002a47-0000-1000-8000-00805f9b34fb", "Supported New Alert Category" },
+ { "00002a48-0000-1000-8000-00805f9b34fb", "Supported Unread Alert Category" },
+ { "00002a23-0000-1000-8000-00805f9b34fb", "System ID" },
+ { "00002a1c-0000-1000-8000-00805f9b34fb", "Temperature Measurement" },
+ { "00002a1d-0000-1000-8000-00805f9b34fb", "Temperature Type" },
+ { "00002a12-0000-1000-8000-00805f9b34fb", "Time Accuracy" },
+ { "00002a13-0000-1000-8000-00805f9b34fb", "Time Source" },
+ { "00002a16-0000-1000-8000-00805f9b34fb", "Time Update Control Point" },
+ { "00002a17-0000-1000-8000-00805f9b34fb", "Time Update State" },
+ { "00002a11-0000-1000-8000-00805f9b34fb", "Time with DST" },
+ { "00002a0e-0000-1000-8000-00805f9b34fb", "Time Zone" },
+ { "00002a07-0000-1000-8000-00805f9b34fb", "Tx Power Level" },
+ { "00002a45-0000-1000-8000-00805f9b34fb", "Unread Alert Status" },
+ { }
+};
+
static GSList *gatt_services = NULL;
+static const char *get_char_name(const char *uuid)
+{
+ const struct characteristic_info *c;
+
+ for (c = charInfo; c->uuid; c++) {
+ if (g_strcmp0(c->uuid, uuid) == 0)
+ return c->name;
+ }
+
+ return NULL;
+}
+
static void characteristic_free(void *user_data)
{
struct characteristic *chr = user_data;
@@ -190,7 +261,7 @@ static int watcher_cmp(gconstpointer a, gconstpointer b)
static void append_char_dict(DBusMessageIter *iter, struct characteristic *chr)
{
DBusMessageIter dict;
- const char *name = "";
+ const char *name;
char *uuid;
dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
@@ -202,8 +273,9 @@ static void append_char_dict(DBusMessageIter *iter, struct characteristic *chr)
dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, &uuid);
g_free(uuid);
- /* FIXME: Translate UUID to name. */
- dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
+ name = get_char_name(chr->type);
+ if (name != NULL)
+ dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
if (chr->desc)
dict_append_entry(&dict, "Description", DBUS_TYPE_STRING,
--
1.7.9.5
^ permalink raw reply related
* Re: [RFC 03/15] sdp: Use helper functions instead of bt_get_unaligned macro
From: Szymon Janc @ 2012-09-03 10:28 UTC (permalink / raw)
To: Johan Hedberg; +Cc: Marcel Holtmann, linux-bluetooth@vger.kernel.org
In-Reply-To: <20120903095739.GA22824@x220>
On Monday 03 of September 2012 12:57:39 Johan Hedberg wrote:
> Hi Szymon,
Hi Johan,
>
> On Mon, Sep 03, 2012, Szymon Janc wrote:
> > > > This fix number of compilation errors on ARM similar to one below.
> > > >
> > > > lib/sdp.c: In function 'sdp_uuid_extract':
> > > > lib/sdp.c:1019:27: error: cast increases required alignment
> > > > of target type [-Werror=cast-align]
> > > > lib/sdp.c:1019:27: error: cast increases required alignment
> > > > of target type [-Werror=cast-align]
> > > > lib/sdp.c:1026:27: error: cast increases required alignment
> > > > of target type [-Werror=cast-align]
> > > > lib/sdp.c:1026:27: error: cast increases required alignment
> > > > of target type [-Werror=cast-align]
> > > >
> > > > Change-Id: I587fb99328d7e5b9053af81597bd48b3a4e610ad
> > > > ---
> > > > lib/sdp.c | 56 ++++++++++++++++++++++++++++----------------------------
> > > > 1 file changed, 28 insertions(+), 28 deletions(-)
> > > >
> > > > diff --git a/lib/sdp.c b/lib/sdp.c
> > > > index 36b4d08..d40500f 100644
> > > > --- a/lib/sdp.c
> > > > +++ b/lib/sdp.c
> > > > @@ -376,27 +376,27 @@ sdp_data_t *sdp_data_alloc_with_length(uint8_t dtd, const void *value,
> > > > d->unitSize += sizeof(int8_t);
> > > > break;
> > > > case SDP_UINT16:
> > > > - d->val.uint16 = bt_get_unaligned((uint16_t *) value);
> > > > + d->val.uint16 = bt_get_16(value);
> > > > d->unitSize += sizeof(uint16_t);
> > > > break;
> > >
> > > I do not like this. Either we use be16 here and store it in the native
> > > endian converted from the protocol endian or we leave it as it is.
> > >
> > > I want clear get_le16 and get_be16 and not another get_16. That just
> > > makes the code hard to read.
> >
> > This data is already in protocol order, so bt_get_le/be can't be used here.
> > If you don't like those non-converting helpers functions other option is to
> > use memcpy.
>
> I think the main point is that only PDU buffers used for writing/reading
> to/from the connection should contain protocol data order, and anything
> else (internal data structures and variables) should be in the host
> order. However, since this is a library interface (one which hopefully
> will be removed/replaced in the future though) such fixes might not
> always be possible, making e.g. your memcpy proposal the best we can do.
OK, will prepare v4 series with memcpy.
> Johan
--
BR
Szymon Janc
^ permalink raw reply
* Re: [RFC 03/15] sdp: Use helper functions instead of bt_get_unaligned macro
From: Johan Hedberg @ 2012-09-03 9:57 UTC (permalink / raw)
To: Szymon Janc; +Cc: Marcel Holtmann, linux-bluetooth@vger.kernel.org
In-Reply-To: <67335853.UVApWbuK0q@uw000953>
Hi Szymon,
On Mon, Sep 03, 2012, Szymon Janc wrote:
> > > This fix number of compilation errors on ARM similar to one below.
> > >
> > > lib/sdp.c: In function 'sdp_uuid_extract':
> > > lib/sdp.c:1019:27: error: cast increases required alignment
> > > of target type [-Werror=cast-align]
> > > lib/sdp.c:1019:27: error: cast increases required alignment
> > > of target type [-Werror=cast-align]
> > > lib/sdp.c:1026:27: error: cast increases required alignment
> > > of target type [-Werror=cast-align]
> > > lib/sdp.c:1026:27: error: cast increases required alignment
> > > of target type [-Werror=cast-align]
> > >
> > > Change-Id: I587fb99328d7e5b9053af81597bd48b3a4e610ad
> > > ---
> > > lib/sdp.c | 56 ++++++++++++++++++++++++++++----------------------------
> > > 1 file changed, 28 insertions(+), 28 deletions(-)
> > >
> > > diff --git a/lib/sdp.c b/lib/sdp.c
> > > index 36b4d08..d40500f 100644
> > > --- a/lib/sdp.c
> > > +++ b/lib/sdp.c
> > > @@ -376,27 +376,27 @@ sdp_data_t *sdp_data_alloc_with_length(uint8_t dtd, const void *value,
> > > d->unitSize += sizeof(int8_t);
> > > break;
> > > case SDP_UINT16:
> > > - d->val.uint16 = bt_get_unaligned((uint16_t *) value);
> > > + d->val.uint16 = bt_get_16(value);
> > > d->unitSize += sizeof(uint16_t);
> > > break;
> >
> > I do not like this. Either we use be16 here and store it in the native
> > endian converted from the protocol endian or we leave it as it is.
> >
> > I want clear get_le16 and get_be16 and not another get_16. That just
> > makes the code hard to read.
>
> This data is already in protocol order, so bt_get_le/be can't be used here.
> If you don't like those non-converting helpers functions other option is to
> use memcpy.
I think the main point is that only PDU buffers used for writing/reading
to/from the connection should contain protocol data order, and anything
else (internal data structures and variables) should be in the host
order. However, since this is a library interface (one which hopefully
will be removed/replaced in the future though) such fixes might not
always be possible, making e.g. your memcpy proposal the best we can do.
Johan
^ permalink raw reply
* Re: [PATCH 0/7] RFC: proximity cleanup
From: Andrzej Kaczmarek @ 2012-09-03 7:36 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CAJdJm_OxOaVeU=WS5RfprUBOj4wsoMMVwS9vH8S7ogxR1QPdsw@mail.gmail.com>
Hi Anderson,
On 08/31/2012 06:17 PM, Anderson Lizardo wrote:
> Hi Andrzej,
>
> On Fri, Aug 31, 2012 at 8:48 AM, Andrzej Kaczmarek
> <andrzej.kaczmarek@tieto.com> wrote:
>> Hi,
>>
>> Here are few patches to cleanup proximity profile code a bit which seem to
>> keep track of some data which are redundant and has minor issue with device
>> driver registration.
>>
>> Most cleanup is done in patch #3 which removes tracking of DBusConnection
>> across whole plugin and simply uses get_dbus_connection() wherever necessary.
>> This is different than other profile plugins do, but reduces code size and
>> memory footprint a bit so can be done for other plugins as well if accepted.
>
> While some cleanups here are very welcome, I'm worried that you are
> cleaning up things before finishing the Proximity Reporter
> implementation. Power Level characteristic for instance is currently a
> stub, how do you plan to store it per adapter, without the struct
> reporter_adapter?
Ah, I didn't find it on TODO so assumed it's complete. But you're right,
it probably should not be removed.
> Therefore I suggest you split the "trivial" cleanups from the removal
> of struct reporter_adapter.
Please just consider patches #6 and #7 as invalid for now, I think
there's no point in sending #1-5 once more until there are some comments
to fix.
> BTW, do you have plans to add more features to the Proximity Reporter
> implementation?
No plans at the moment, but perhaps I'll take a look on this in more
details after HRP is finished (v2 will be sent soon).
BR,
Andrzej
^ permalink raw reply
* Re: [RFC 03/15] sdp: Use helper functions instead of bt_get_unaligned macro
From: Szymon Janc @ 2012-09-03 7:06 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1346429676.23377.22.camel@aeonflux>
On Friday 31 of August 2012 19:14:36 Marcel Holtmann wrote:
> Hi Szymon,
Hi Marcel,
>
> > This fix number of compilation errors on ARM similar to one below.
> >
> > lib/sdp.c: In function 'sdp_uuid_extract':
> > lib/sdp.c:1019:27: error: cast increases required alignment
> > of target type [-Werror=cast-align]
> > lib/sdp.c:1019:27: error: cast increases required alignment
> > of target type [-Werror=cast-align]
> > lib/sdp.c:1026:27: error: cast increases required alignment
> > of target type [-Werror=cast-align]
> > lib/sdp.c:1026:27: error: cast increases required alignment
> > of target type [-Werror=cast-align]
> >
> > Change-Id: I587fb99328d7e5b9053af81597bd48b3a4e610ad
> > ---
> > lib/sdp.c | 56 ++++++++++++++++++++++++++++----------------------------
> > 1 file changed, 28 insertions(+), 28 deletions(-)
> >
> > diff --git a/lib/sdp.c b/lib/sdp.c
> > index 36b4d08..d40500f 100644
> > --- a/lib/sdp.c
> > +++ b/lib/sdp.c
> > @@ -376,27 +376,27 @@ sdp_data_t *sdp_data_alloc_with_length(uint8_t dtd, const void *value,
> > d->unitSize += sizeof(int8_t);
> > break;
> > case SDP_UINT16:
> > - d->val.uint16 = bt_get_unaligned((uint16_t *) value);
> > + d->val.uint16 = bt_get_16(value);
> > d->unitSize += sizeof(uint16_t);
> > break;
>
> I do not like this. Either we use be16 here and store it in the native
> endian converted from the protocol endian or we leave it as it is.
>
> I want clear get_le16 and get_be16 and not another get_16. That just
> makes the code hard to read.
This data is already in protocol order, so bt_get_le/be can't be used here.
If you don't like those non-converting helpers functions other option is to
use memcpy.
> Regards
>
> Marcel
>
--
BR
Szymon Janc
^ permalink raw reply
* Re: [RFC v2 15/15] hciemu: Fix build errors due to unaligned memory access
From: Szymon Janc @ 2012-09-03 6:42 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <CAJdJm_NHUsbuWvLwquROhq83+O0vQcv-w=g=CfpCje7rmSDdBA@mail.gmail.com>
On Friday 31 of August 2012 18:19:59 Anderson Lizardo wrote:
> Hi Szymon,
Hi Anderson,
> On Fri, Aug 31, 2012 at 8:40 AM, Szymon Janc <szymon.janc@tieto.com> wrote:
> > --- a/test/hciemu.c
> > +++ b/test/hciemu.c
> > @@ -426,8 +426,10 @@ static void num_completed_pkts(struct vhci_conn *conn)
> > np = (void *) ptr; ptr += EVT_NUM_COMP_PKTS_SIZE;
> > np->num_hndl = 1;
> >
> > - *((uint16_t *) ptr) = htobs(conn->handle); ptr += 2;
> > - *((uint16_t *) ptr) = htobs(vdev.acl_cnt); ptr += 2;
> > + bt_put_be16(conn->handle, ptr);
> > + ptr += 2;
> > + bt_put_be16(vdev.acl_cnt, ptr);
> > + ptr += 2;
>
> These should be bt_put_le16().
Will fix that in next version.
Thx for spotting this!
>
> Regards,
>
--
BR
Szymon Janc
^ permalink raw reply
* [PATCH v3] gatt: Translate Characteristic names
From: chen.ganir @ 2012-09-02 6:57 UTC (permalink / raw)
To: linux-bluetooth; +Cc: chen.ganir
From: Chen Ganir <chen.ganir@ti.com>
Translate Characteristic UUID's to name. This list was taken from
the Bluetooth SIG developer site.
---
attrib/client.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 76 insertions(+), 3 deletions(-)
diff --git a/attrib/client.c b/attrib/client.c
index bb6adf8..f96b56f 100644
--- a/attrib/client.c
+++ b/attrib/client.c
@@ -105,8 +105,78 @@ struct watcher {
struct gatt_service *gatt;
};
+struct characteristic_info {
+ const char *uuid;
+ const char *name;
+};
+
+static const struct characteristic_info charInfo[] = {
+ {"00002a43-0000-1000-8000-00805f9b34fb", "Alert Category ID" },
+ {"00002a42-0000-1000-8000-00805f9b34fb", "Alert Category ID Bit Mask" },
+ {"00002a06-0000-1000-8000-00805f9b34fb", "Alert Level" },
+ {"00002a44-0000-1000-8000-00805f9b34fb", "Alert Notification Control Point" },
+ {"00002a3f-0000-1000-8000-00805f9b34fb", "Alert Status" },
+ {"00002a01-0000-1000-8000-00805f9b34fb", "Appearance" },
+ {"00002a49-0000-1000-8000-00805f9b34fb", "Blood Pressure Feature" },
+ {"00002a35-0000-1000-8000-00805f9b34fb", "Blood Pressure Measurement" },
+ {"00002a38-0000-1000-8000-00805f9b34fb", "Body Sensor Location" },
+ {"00002a2b-0000-1000-8000-00805f9b34fb", "Current Time" },
+ {"00002a08-0000-1000-8000-00805f9b34fb", "Date Time" },
+ {"00002a0a-0000-1000-8000-00805f9b34fb", "Day Date Time" },
+ {"00002a09-0000-1000-8000-00805f9b34fb", "Day of Week" },
+ {"00002a00-0000-1000-8000-00805f9b34fb", "Device Name" },
+ {"00002a0d-0000-1000-8000-00805f9b34fb", "DST Offset" },
+ {"00002a0c-0000-1000-8000-00805f9b34fb", "Exact Time 256" },
+ {"00002a26-0000-1000-8000-00805f9b34fb", "Firmware Revision String" },
+ {"00002a27-0000-1000-8000-00805f9b34fb", "Hardware Revision String" },
+ {"00002a39-0000-1000-8000-00805f9b34fb", "Heart Rate Control Point" },
+ {"00002a37-0000-1000-8000-00805f9b34fb", "Heart Rate Measurement" },
+ {"00002a2a-0000-1000-8000-00805f9b34fb", "IEEE 11073-20601 Regulatory" },
+ {"00002a36-0000-1000-8000-00805f9b34fb", "Intermediate Cuff Pressure" },
+ {"00002a1e-0000-1000-8000-00805f9b34fb", "Intermediate Temperature" },
+ {"00002a0f-0000-1000-8000-00805f9b34fb", "Local Time Information" },
+ {"00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String" },
+ {"00002a21-0000-1000-8000-00805f9b34fb", "Measurement Interval" },
+ {"00002a24-0000-1000-8000-00805f9b34fb", "Model Number String" },
+ {"00002a46-0000-1000-8000-00805f9b34fb", "New Alert" },
+ {"00002a04-0000-1000-8000-00805f9b34fb", "Peripheral Preferred Connection Parameters" },
+ {"00002a02-0000-1000-8000-00805f9b34fb", "Peripheral Privacy Flag" },
+ {"00002a03-0000-1000-8000-00805f9b34fb", "Reconnection Address" },
+ {"00002a14-0000-1000-8000-00805f9b34fb", "Reference Time Information" },
+ {"00002a40-0000-1000-8000-00805f9b34fb", "Ringer Control Point" },
+ {"00002a41-0000-1000-8000-00805f9b34fb", "Ringer Setting" },
+ {"00002a25-0000-1000-8000-00805f9b34fb", "Serial Number String" },
+ {"00002a05-0000-1000-8000-00805f9b34fb", "Service Changed" },
+ {"00002a28-0000-1000-8000-00805f9b34fb", "Software Revision String" },
+ {"00002a47-0000-1000-8000-00805f9b34fb", "Supported New Alert Category" },
+ {"00002a48-0000-1000-8000-00805f9b34fb", "Supported Unread Alert Category" },
+ {"00002a23-0000-1000-8000-00805f9b34fb", "System ID" },
+ {"00002a1c-0000-1000-8000-00805f9b34fb", "Temperature Measurement" },
+ {"00002a1d-0000-1000-8000-00805f9b34fb", "Temperature Type" },
+ {"00002a12-0000-1000-8000-00805f9b34fb", "Time Accuracy" },
+ {"00002a13-0000-1000-8000-00805f9b34fb", "Time Source" },
+ {"00002a16-0000-1000-8000-00805f9b34fb", "Time Update Control Point" },
+ {"00002a17-0000-1000-8000-00805f9b34fb", "Time Update State" },
+ {"00002a11-0000-1000-8000-00805f9b34fb", "Time with DST" },
+ {"00002a0e-0000-1000-8000-00805f9b34fb", "Time Zone" },
+ {"00002a07-0000-1000-8000-00805f9b34fb", "Tx Power Level" },
+ {"00002a45-0000-1000-8000-00805f9b34fb", "Unread Alert Status" },
+ { }
+};
+
static GSList *gatt_services = NULL;
+static const char *get_char_name(const char *uuid)
+{
+ const struct characteristic_info *c;
+
+ for (c = charInfo; c->uuid; c++) {
+ if (g_strcmp0(c->uuid, uuid) == 0)
+ return c->name;
+ }
+ return NULL;
+}
+
static void characteristic_free(void *user_data)
{
struct characteristic *chr = user_data;
@@ -190,7 +260,7 @@ static int watcher_cmp(gconstpointer a, gconstpointer b)
static void append_char_dict(DBusMessageIter *iter, struct characteristic *chr)
{
DBusMessageIter dict;
- const char *name = "";
+ const char *name;
char *uuid;
dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
@@ -202,8 +272,11 @@ static void append_char_dict(DBusMessageIter *iter, struct characteristic *chr)
dict_append_entry(&dict, "UUID", DBUS_TYPE_STRING, &uuid);
g_free(uuid);
- /* FIXME: Translate UUID to name. */
- dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
+ name = get_char_name(chr->type);
+
+ if (name != NULL)
+ dict_append_entry(&dict, "Name", DBUS_TYPE_STRING, &name);
+
if (chr->desc)
dict_append_entry(&dict, "Description", DBUS_TYPE_STRING,
--
1.7.9.5
^ permalink raw reply related
* Re: [PATCH v2] gatt: Translate Characteristic names
From: Chen Ganir @ 2012-09-02 6:50 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <1652968.T8pSJl1pGy@uw000953>
Szymon :
On 08/30/2012 03:43 PM, Szymon Janc wrote:
> On Thursday 30 of August 2012 15:38:04 Chen Ganir wrote:
>
>>>> static GSList *gatt_services = NULL;
>>>>
>>>> +static const struct characteristic_info *get_char_info(const char* uuid)
>>>
>>> I would leave this function returning name directly and not whole struct characteristic_info.
>>>
>> Why ? We have this struct with characteristic information (maybe later
>> we'll add more information. Why limit ourselves to name only ?
>
> If you plan to add more data into that structure then it is OK to return whole struct.
> But if only name is to be used, then I would just call that function get_name() and
> return name.
>
For now, i believe this is the only information we have for the
characteristic. I will send an updated patch.
BR,
Chen Ganir
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox