* [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles
@ 2012-09-24 18:00 Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 01/25] doc: Introduce Alert API Anderson Lizardo
` (25 more replies)
0 siblings, 26 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Hi,
This series implement most of mandatory features for Phone Alert Status (PASP)
and Alert Notification (ANP) profiles. The only major mandatory feature
currently missing is support for ANP control point (which will be added on a
future series).
Note: for those planning to use ANP/PASP in BlueZ using these patches, it is
necessary to implement an "agent" that forwards platform events (SMS, calls,
e-mail, and ringer/display/vibra status) to BlueZ. See doc/alert-api.txt and
test/test-alert for more details. Alternatively, the components that generate
these events can register themselves and report alerts directly to BlueZ.
This implementation was tested against PTS and all tests passed (except for the
features not yet implemented). The D-Bus API was implemented accordingly to the
previously proposed Alert API (documented on the first patch).
Comments/suggestions are welcome.
Anderson Lizardo (11):
doc: Introduce Alert API
alert: Introduce manager abstraction layer
alert: Initial profile registration
alert: Initial Alert Notification
alert: Add initial support for UnreadAlert D-Bus method
alert: Add per adapter attribute handle information
alert: Update Supported New/Unread Category characteristic values
alert: Update new alert characteristic value
alert: Update unread alert characteristic value
alert: Implement MuteOnce command
alert: Update Alert Status and Ringer Setting characteristic values
Bruna Moreira (4):
alert: Add Phone Alert Status Service
alert: Add Ringer Control Point characteristic
alert: Add Ringer Setting characteristic
alert: Add Alert Status characteristic
Eder Ruiz Maria (10):
alert: Implement category registration in RegisterAlert()
alert: Add initial support for NewAlert D-Bus method
alert: Automatically unregister alert when agent leaves D-Bus
alert: Add support for calling MuteOnce()
alert: Add support for calling SetRinger()
alert: Add test-alert script
alert: Add support for ringer setting notification
alert: Add support for alert status notification
alert: Add support for new alert notification
alert: Add support for unread alert notification
Makefile.am | 3 +-
doc/alert-api.txt | 124 ++++++
profiles/alert/main.c | 6 +-
profiles/alert/manager.c | 40 ++
profiles/alert/manager.h | 26 ++
profiles/alert/server.c | 944 ++++++++++++++++++++++++++++++++++++++++++++++
test/test-alert | 173 +++++++++
7 files changed, 1312 insertions(+), 4 deletions(-)
create mode 100644 doc/alert-api.txt
create mode 100644 profiles/alert/manager.c
create mode 100644 profiles/alert/manager.h
create mode 100755 test/test-alert
--
1.7.9.5
^ permalink raw reply [flat|nested] 88+ messages in thread
* [PATCH BlueZ 01/25] doc: Introduce Alert API
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 02/25] alert: Introduce manager abstraction layer Anderson Lizardo
` (24 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This API will be implemented and initially used by Phone Alert Status
and Alert Notification GATT profiles (server role).
---
doc/alert-api.txt | 124 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 124 insertions(+)
create mode 100644 doc/alert-api.txt
diff --git a/doc/alert-api.txt b/doc/alert-api.txt
new file mode 100644
index 0000000..79d65b8
--- /dev/null
+++ b/doc/alert-api.txt
@@ -0,0 +1,124 @@
+BlueZ D-Bus Alert API description
+*********************************
+
+Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT
+
+Introduction
+------------
+
+Currently, there are two different GATT server profiles that depend on
+receiving alerts or notifications from the platform: Phone Alert Status (PASP)
+and Alert Notification (ANP). PASP is very specific to mobile phones, and also
+allows limited control to alerts (i.e. mute once or switch to a silent mode).
+
+This document presents a unified API that allows to register and notify alerts,
+and to control some alerts (using the provided agent object).
+
+
+Alert hierarchy
+===============
+
+Service org.bluez
+Interface org.bluez.Alert
+Object path /org/bluez
+
+Methods void RegisterAlert(string category, object agent)
+
+ Register a new alert category and an agent for it. This
+ means the application will be responsible for notifying
+ BlueZ of any alerts of that category, using the
+ NewAlert() method.
+
+ Supported ANP categories: simple, email, news, call,
+ missed_call, sms_mms, voice_mail, schedule,
+ high_priority, instant_message
+ Supported PASP categories: ringer, vibrate, display
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void NewAlert(string category, uint16 count, string description)
+
+ Notify BlueZ of new alert(s) for the given category. The
+ description is relative to the last received alert and
+ can be sender name, caller ID, title, or other
+ information specific to the category.
+
+ For ringer, vibrate and display categories, valid
+ descriptions are "active" and "not active". Alerts from
+ ringer category also accept "enabled" and "disabled",
+ depending on whether ringer is in silent mode or not.
+
+ Description must not exceed 18 bytes when encoded in
+ UTF-8 format, otherwise an error is returned. If there
+ is no description, an empty string should be used.
+
+ The count argument contains the number of alerts not
+ yet acknowledged by the user on the UI. To save D-Bus
+ traffic, events that may generate multiple alerts at
+ the same time (like email, sms, news) should trigger a
+ single NewAlert().
+
+ If there are more than 254 new alerts, count must be
+ set to 255. PASP alerts should always set count to 1.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void UnreadAlert(string category, uint16 count)
+
+ Some services (like SMS and e-mail) keep track of
+ number of unread items. This method allows to update
+ this counter, so peer devices can be notified using
+ Alert Notification Profile.
+
+ If there are more than 254 unread alerts, count must be
+ set to 255.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+Alert Agent hierarchy
+=====================
+
+Service org.bluez
+Interface org.bluez.AlertAgent
+Object path freely definable
+
+Methods void MuteOnce()
+
+ This method is only called if "ringer" alert category
+ is specified when registering the agent.
+
+ Mute the ringer once (e.g. during a incoming call). If
+ ringer is not active, does nothing.
+
+ void SetRinger(string mode)
+
+ This method is only called if "ringer" alert category
+ is specified when registering the agent.
+
+ Set ringer to the specified mode. If mode is "enabled",
+ ringer is set to the default mode, as defined by the
+ current active profile. If mode is "disabled", ringer
+ will not activate on incoming calls, until it is set
+ back to "enabled" mode.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void Suspend(string category)
+
+ Suspend alerts for this category, which means that
+ new/unread alerts should not be reported to save D-Bus
+ traffic. This means that no client has enabled this
+ alert yet.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void Resume(string category)
+
+ Resume alerts for this category.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void Release()
+
+ Release this agent. At this point, it will be not used
+ by BlueZ anymore and can be destroyed by the owner.
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 02/25] alert: Introduce manager abstraction layer
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 01/25] doc: Introduce Alert API Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 03/25] alert: Initial profile registration Anderson Lizardo
` (23 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This abstraction layer makes the GATT Phone Alert Status and Alert
Notification implementation consistent with other GATT profiles.
---
Makefile.am | 3 ++-
profiles/alert/main.c | 6 +++---
profiles/alert/manager.c | 40 ++++++++++++++++++++++++++++++++++++++++
profiles/alert/manager.h | 26 ++++++++++++++++++++++++++
4 files changed, 71 insertions(+), 4 deletions(-)
create mode 100644 profiles/alert/manager.c
create mode 100644 profiles/alert/manager.h
diff --git a/Makefile.am b/Makefile.am
index 372111a..c982110 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -218,7 +218,8 @@ builtin_sources += profiles/thermometer/main.c \
profiles/thermometer/thermometer.h \
profiles/thermometer/thermometer.c \
profiles/alert/main.c profiles/alert/server.h \
- profiles/alert/server.c \
+ profiles/alert/server.c profiles/alert/manager.h \
+ profiles/alert/manager.c \
profiles/time/main.c profiles/time/server.h \
profiles/time/server.c profiles/time/manager.c \
profiles/time/manager.h \
diff --git a/profiles/alert/main.c b/profiles/alert/main.c
index ec4ab6d..5e6910a 100644
--- a/profiles/alert/main.c
+++ b/profiles/alert/main.c
@@ -33,7 +33,7 @@
#include "plugin.h"
#include "hcid.h"
#include "log.h"
-#include "server.h"
+#include "manager.h"
static int alert_init(void)
{
@@ -42,7 +42,7 @@ static int alert_init(void)
return -ENOTSUP;
}
- return alert_server_init();
+ return alert_manager_init();
}
static void alert_exit(void)
@@ -50,7 +50,7 @@ static void alert_exit(void)
if (!main_opts.gatt_enabled)
return;
- alert_server_exit();
+ alert_manager_exit();
}
BLUETOOTH_PLUGIN_DEFINE(alert, VERSION,
diff --git a/profiles/alert/manager.c b/profiles/alert/manager.c
new file mode 100644
index 0000000..eb2d627
--- /dev/null
+++ b/profiles/alert/manager.c
@@ -0,0 +1,40 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Nokia Corporation
+ * Copyright (C) 2012 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * 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 "manager.h"
+#include "server.h"
+
+int alert_manager_init(void)
+{
+ return alert_server_init();
+}
+
+void alert_manager_exit(void)
+{
+ alert_server_exit();
+}
diff --git a/profiles/alert/manager.h b/profiles/alert/manager.h
new file mode 100644
index 0000000..e4c6bd0
--- /dev/null
+++ b/profiles/alert/manager.h
@@ -0,0 +1,26 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Nokia Corporation
+ * Copyright (C) 2012 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * 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 alert_manager_init(void);
+void alert_manager_exit(void);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 03/25] alert: Initial profile registration
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 01/25] doc: Introduce Alert API Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 02/25] alert: Introduce manager abstraction layer Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 04/25] alert: Add Phone Alert Status Service Anderson Lizardo
` (22 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
---
profiles/alert/server.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index d91b156..cc6ff19 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -26,13 +26,35 @@
#include <config.h>
#endif
+#include <stdbool.h>
+
+#include "adapter.h"
#include "server.h"
+#include "profile.h"
+
+static int alert_server_probe(struct btd_adapter *adapter)
+{
+ return 0;
+}
+
+static void alert_server_remove(struct btd_adapter *adapter)
+{
+}
+
+static struct btd_profile alert_profile = {
+ .name = "gatt-alert-server",
+ .adapter_probe = alert_server_probe,
+ .adapter_remove = alert_server_remove,
+};
int alert_server_init(void)
{
+ btd_profile_register(&alert_profile);
+
return 0;
}
void alert_server_exit(void)
{
+ btd_profile_unregister(&alert_profile);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 04/25] alert: Add Phone Alert Status Service
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (2 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 03/25] alert: Initial profile registration Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 05/25] alert: Add Ringer Control Point characteristic Anderson Lizardo
` (21 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
From: Bruna Moreira <bruna.moreira@openbossa.org>
Add Phone Alert Status service for PASP.
---
profiles/alert/server.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index cc6ff19..a35da99 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -27,13 +27,34 @@
#endif
#include <stdbool.h>
+#include <glib.h>
+#include <bluetooth/uuid.h>
+#include "att.h"
#include "adapter.h"
+#include "gatt-service.h"
+#include "gattrib.h"
+#include "gatt.h"
#include "server.h"
#include "profile.h"
+#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
+
+static void register_phone_alert_service(struct btd_adapter *adapter)
+{
+ bt_uuid_t uuid;
+
+ bt_uuid16_create(&uuid, PHONE_ALERT_STATUS_SVC_UUID);
+
+ /* Phone Alert Status Service */
+ gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ GATT_OPT_INVALID);
+}
+
static int alert_server_probe(struct btd_adapter *adapter)
{
+ register_phone_alert_service(adapter);
+
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 05/25] alert: Add Ringer Control Point characteristic
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (3 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 04/25] alert: Add Phone Alert Status Service Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 06/25] alert: Add Ringer Setting characteristic Anderson Lizardo
` (20 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
From: Bruna Moreira <bruna.moreira@openbossa.org>
Ringer CP characteristic is used for configuring "silent mode" or muting
the ringer once.
---
profiles/alert/server.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index a35da99..68ef0c0 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -32,6 +32,9 @@
#include "att.h"
#include "adapter.h"
+#include "device.h"
+#include "att-database.h"
+#include "log.h"
#include "gatt-service.h"
#include "gattrib.h"
#include "gatt.h"
@@ -39,6 +42,16 @@
#include "profile.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
+#define RINGER_CP_CHR_UUID 0x2A40
+
+static uint8_t ringer_cp_write(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ DBG("a = %p", a);
+
+ return 0;
+}
static void register_phone_alert_service(struct btd_adapter *adapter)
{
@@ -48,6 +61,11 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
/* Phone Alert Status Service */
gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ /* Ringer Control Point characteristic */
+ GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
+ ringer_cp_write, NULL,
GATT_OPT_INVALID);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 06/25] alert: Add Ringer Setting characteristic
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (4 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 05/25] alert: Add Ringer Control Point characteristic Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 07/25] alert: Add Alert Status characteristic Anderson Lizardo
` (19 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
From: Bruna Moreira <bruna.moreira@openbossa.org>
This characteristic allows to read or notify the ringer mode (silent or
normal).
---
profiles/alert/server.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 68ef0c0..a66d431 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -37,12 +37,22 @@
#include "log.h"
#include "gatt-service.h"
#include "gattrib.h"
+#include "attrib-server.h"
#include "gatt.h"
#include "server.h"
#include "profile.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
#define RINGER_CP_CHR_UUID 0x2A40
+#define RINGER_SETTING_CHR_UUID 0x2A41
+
+/* Ringer Setting characteristic values */
+enum {
+ RINGER_SILENT,
+ RINGER_NORMAL,
+};
+
+static uint8_t ringer_setting = RINGER_NORMAL;
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
@@ -53,6 +63,21 @@ static uint8_t ringer_cp_write(struct attribute *a,
return 0;
}
+static uint8_t ringer_setting_read(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ struct btd_adapter *adapter = user_data;
+
+ DBG("a = %p", a);
+
+ if (a->data == NULL || a->data[0] != ringer_setting)
+ attrib_db_update(adapter, a->handle, NULL, &ringer_setting,
+ sizeof(ringer_setting), NULL);
+
+ return 0;
+}
+
static void register_phone_alert_service(struct btd_adapter *adapter)
{
bt_uuid_t uuid;
@@ -66,6 +91,12 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
ringer_cp_write, NULL,
+ /* Ringer Setting characteristic */
+ GATT_OPT_CHR_UUID, RINGER_SETTING_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
+ ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+ ringer_setting_read, adapter,
GATT_OPT_INVALID);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 07/25] alert: Add Alert Status characteristic
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (5 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 06/25] alert: Add Ringer Setting characteristic Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 08/25] alert: Initial Alert Notification Anderson Lizardo
` (18 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
From: Bruna Moreira <bruna.moreira@openbossa.org>
This characteristic allows to read/notify the status of the ringer,
display and vibration motor.
---
profiles/alert/server.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index a66d431..0dcefbb 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -43,6 +43,8 @@
#include "profile.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
+
+#define ALERT_STATUS_CHR_UUID 0x2A3F
#define RINGER_CP_CHR_UUID 0x2A40
#define RINGER_SETTING_CHR_UUID 0x2A41
@@ -53,6 +55,7 @@ enum {
};
static uint8_t ringer_setting = RINGER_NORMAL;
+static uint8_t alert_status = 0;
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
@@ -63,6 +66,21 @@ static uint8_t ringer_cp_write(struct attribute *a,
return 0;
}
+static uint8_t alert_status_read(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ struct btd_adapter *adapter = user_data;
+
+ DBG("a = %p", a);
+
+ if (a->data == NULL || a->data[0] != alert_status)
+ attrib_db_update(adapter, a->handle, NULL, &alert_status,
+ sizeof(alert_status), NULL);
+
+ return 0;
+}
+
static uint8_t ringer_setting_read(struct attribute *a,
struct btd_device *device,
gpointer user_data)
@@ -86,6 +104,12 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
/* Phone Alert Status Service */
gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ /* Alert Status characteristic */
+ GATT_OPT_CHR_UUID, ALERT_STATUS_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
+ ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+ alert_status_read, adapter,
/* Ringer Control Point characteristic */
GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 08/25] alert: Initial Alert Notification
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (6 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 07/25] alert: Add Alert Status characteristic Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 09/25] alert: Implement category registration in RegisterAlert() Anderson Lizardo
` (17 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Initial implementation for Alert Notification Profile (ANP).
---
profiles/alert/server.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 154 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 0dcefbb..0df77c5 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -27,9 +27,12 @@
#endif
#include <stdbool.h>
+#include <errno.h>
+#include <gdbus.h>
#include <glib.h>
#include <bluetooth/uuid.h>
+#include "dbus-common.h"
#include "att.h"
#include "adapter.h"
#include "device.h"
@@ -41,13 +44,33 @@
#include "gatt.h"
#include "server.h"
#include "profile.h"
+#include "error.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
+#define ALERT_NOTIF_SVC_UUID 0x1811
#define ALERT_STATUS_CHR_UUID 0x2A3F
#define RINGER_CP_CHR_UUID 0x2A40
#define RINGER_SETTING_CHR_UUID 0x2A41
+#define ALERT_NOTIF_CP_CHR_UUID 0x2A44
+#define UNREAD_ALERT_CHR_UUID 0x2A45
+#define NEW_ALERT_CHR_UUID 0x2A46
+#define SUPP_NEW_ALERT_CAT_CHR_UUID 0x2A47
+#define SUPP_UNREAD_ALERT_CAT_CHR_UUID 0x2A48
+
+#define ALERT_OBJECT_PATH "/org/bluez"
+#define ALERT_INTERFACE "org.bluez.Alert"
+
+enum {
+ ENABLE_NEW_INCOMING,
+ ENABLE_UNREAD_CAT,
+ DISABLE_NEW_INCOMING,
+ DISABLE_UNREAD_CAT,
+ NOTIFY_NEW_INCOMING,
+ NOTIFY_UNREAD_CAT,
+};
+
/* Ringer Setting characteristic values */
enum {
RINGER_SILENT,
@@ -57,6 +80,20 @@ enum {
static uint8_t ringer_setting = RINGER_NORMAL;
static uint8_t alert_status = 0;
+static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ const char *category;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
+ DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+
+ DBG("RegisterAlert: %s", category);
+
+ return dbus_message_new_method_return(msg);
+}
+
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
gpointer user_data)
@@ -124,9 +161,106 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
GATT_OPT_INVALID);
}
+static uint8_t supp_new_alert_cat_read(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ struct btd_adapter *adapter = user_data;
+ uint8_t value[] = {0x00, 0x00};
+
+ DBG("a = %p", a);
+
+ if (a->data == NULL)
+ attrib_db_update(adapter, a->handle, NULL, value, sizeof(value),
+ NULL);
+
+ return 0;
+}
+
+static uint8_t supp_unread_alert_cat_read(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ struct btd_adapter *adapter = user_data;
+ uint8_t value[] = {0x00, 0x00};
+
+ DBG("a = %p", a);
+
+ if (a->data == NULL)
+ attrib_db_update(adapter, a->handle, NULL, value, sizeof(value),
+ NULL);
+
+ return 0;
+}
+
+static uint8_t alert_notif_cp_write(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ DBG("a = %p", a);
+
+ switch (a->data[0]) {
+ case ENABLE_NEW_INCOMING:
+ DBG("ENABLE_NEW_INCOMING: 0x%02x", a->data[1]);
+ break;
+ case ENABLE_UNREAD_CAT:
+ DBG("ENABLE_UNREAD_CAT: 0x%02x", a->data[1]);
+ break;
+ case DISABLE_NEW_INCOMING:
+ DBG("DISABLE_NEW_INCOMING: 0x%02x", a->data[1]);
+ break;
+ case DISABLE_UNREAD_CAT:
+ DBG("DISABLE_UNREAD_CAT: 0x%02x", a->data[1]);
+ break;
+ case NOTIFY_NEW_INCOMING:
+ DBG("NOTIFY_NEW_INCOMING: 0x%02x", a->data[1]);
+ break;
+ case NOTIFY_UNREAD_CAT:
+ DBG("NOTIFY_UNREAD_CAT: 0x%02x", a->data[1]);
+ break;
+ default:
+ DBG("0x%02x 0x%02x", a->data[0], a->data[1]);
+ }
+
+ return 0;
+}
+
+static void register_alert_notif_service(struct btd_adapter *adapter)
+{
+ bt_uuid_t uuid;
+
+ bt_uuid16_create(&uuid, ALERT_NOTIF_SVC_UUID);
+
+ /* Alert Notification Service */
+ gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ /* Supported New Alert Category */
+ GATT_OPT_CHR_UUID, SUPP_NEW_ALERT_CAT_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+ supp_new_alert_cat_read, adapter,
+ /* New Alert */
+ GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ /* Supported Unread Alert Category */
+ GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+ supp_unread_alert_cat_read, adapter,
+ /* Unread Alert Status */
+ GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ /* Alert Notification Control Point */
+ GATT_OPT_CHR_UUID, ALERT_NOTIF_CP_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
+ alert_notif_cp_write, NULL,
+ GATT_OPT_INVALID);
+}
+
static int alert_server_probe(struct btd_adapter *adapter)
{
register_phone_alert_service(adapter);
+ register_alert_notif_service(adapter);
return 0;
}
@@ -141,8 +275,25 @@ static struct btd_profile alert_profile = {
.adapter_remove = alert_server_remove,
};
+static const GDBusMethodTable alert_methods[] = {
+ { GDBUS_METHOD("RegisterAlert",
+ GDBUS_ARGS({ "category", "s" },
+ { "agent", "o" }), NULL,
+ register_alert) },
+ { }
+};
+
int alert_server_init(void)
{
+ if (!g_dbus_register_interface(btd_get_dbus_connection(),
+ ALERT_OBJECT_PATH, ALERT_INTERFACE,
+ alert_methods, NULL, NULL, NULL,
+ NULL)) {
+ error("D-Bus failed to register %s interface",
+ ALERT_INTERFACE);
+ return -EIO;
+ }
+
btd_profile_register(&alert_profile);
return 0;
@@ -151,4 +302,7 @@ int alert_server_init(void)
void alert_server_exit(void)
{
btd_profile_unregister(&alert_profile);
+
+ g_dbus_unregister_interface(btd_get_dbus_connection(),
+ ALERT_OBJECT_PATH, ALERT_INTERFACE);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 09/25] alert: Implement category registration in RegisterAlert()
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (7 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 08/25] alert: Initial Alert Notification Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 10/25] alert: Add initial support for NewAlert D-Bus method Anderson Lizardo
` (16 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
The given alert category is now validated and registered.
---
profiles/alert/server.c | 102 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 98 insertions(+), 4 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 0df77c5..533d47e 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -77,19 +77,113 @@ enum {
RINGER_NORMAL,
};
+struct alert_data {
+ const char *category;
+ char *srv;
+ char *path;
+};
+
+static GSList *registered_alerts = NULL;
static uint8_t ringer_setting = RINGER_NORMAL;
static uint8_t alert_status = 0;
+static const char *anp_categories[] = {
+ "simple",
+ "email",
+ "news",
+ "call",
+ "missed_call",
+ "sms_mms",
+ "voice_mail",
+ "schedule",
+ "high_priority",
+ "instant_message",
+};
+
+static const char *pasp_categories[] = {
+ "ringer",
+ "vibrate",
+ "display",
+};
+
+static void alert_data_destroy(gpointer user_data)
+{
+ struct alert_data *alert = user_data;
+
+ g_free(alert->srv);
+ g_free(alert->path);
+ g_free(alert);
+}
+
+static void alert_destroy(gpointer user_data)
+{
+ g_slist_free_full(registered_alerts, alert_data_destroy);
+ registered_alerts = NULL;
+}
+
+static const char *valid_category(const char *category)
+{
+ unsigned i;
+
+ for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+ if (g_str_equal(anp_categories[i], category))
+ return anp_categories[i];
+ }
+
+ for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
+ if (g_str_equal(pasp_categories[i], category))
+ return pasp_categories[i];
+ }
+
+ return NULL;
+}
+
+static gboolean registered_category(const char *category)
+{
+ GSList *l;
+ struct alert_data *alert;
+
+ for (l = registered_alerts; l; l = g_slist_next(l)) {
+ alert = l->data;
+ if (g_str_equal(alert->category, category))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
+ const char *sender = dbus_message_get_sender(msg);
+ char *path;
const char *category;
+ const char *c;
+ struct alert_data *alert;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &c,
+ DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
- if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
- DBUS_TYPE_INVALID))
+ category = valid_category(c);
+ if (!category) {
+ DBG("Invalid category: %s", c);
return btd_error_invalid_args(msg);
+ }
+
+ if (registered_category(category)) {
+ DBG("Category %s already registered", category);
+ return dbus_message_new_method_return(msg);
+ }
+
+ alert = g_new0(struct alert_data, 1);
+ alert->srv = g_strdup(sender);
+ alert->path = g_strdup(path);
+ alert->category = category;
+
+ registered_alerts = g_slist_append(registered_alerts, alert);
- DBG("RegisterAlert: %s", category);
+ DBG("RegisterAlert(\"%s\", \"%s\")", alert->category, alert->path);
return dbus_message_new_method_return(msg);
}
@@ -288,7 +382,7 @@ int alert_server_init(void)
if (!g_dbus_register_interface(btd_get_dbus_connection(),
ALERT_OBJECT_PATH, ALERT_INTERFACE,
alert_methods, NULL, NULL, NULL,
- NULL)) {
+ alert_destroy)) {
error("D-Bus failed to register %s interface",
ALERT_INTERFACE);
return -EIO;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 10/25] alert: Add initial support for NewAlert D-Bus method
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (8 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 09/25] alert: Implement category registration in RegisterAlert() Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 11/25] alert: Add initial support for UnreadAlert " Anderson Lizardo
` (15 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
NewAlert() is used for notifying BlueZ of new alert(s) for the given
category.
---
profiles/alert/server.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 105 insertions(+), 1 deletion(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 533d47e..d70f82a 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -62,6 +62,9 @@
#define ALERT_OBJECT_PATH "/org/bluez"
#define ALERT_INTERFACE "org.bluez.Alert"
+/* Maximum length for "Text String Information" */
+#define NEW_ALERT_MAX_INFO_SIZE 18
+
enum {
ENABLE_NEW_INCOMING,
ENABLE_UNREAD_CAT,
@@ -138,7 +141,7 @@ static const char *valid_category(const char *category)
return NULL;
}
-static gboolean registered_category(const char *category)
+static struct alert_data *get_alert_data_by_category(const char *category)
{
GSList *l;
struct alert_data *alert;
@@ -146,9 +149,64 @@ static gboolean registered_category(const char *category)
for (l = registered_alerts; l; l = g_slist_next(l)) {
alert = l->data;
if (g_str_equal(alert->category, category))
+ return alert;
+ }
+
+ return NULL;
+}
+
+static gboolean registered_category(const char *category)
+{
+ struct alert_data *alert;
+
+ alert = get_alert_data_by_category(category);
+ if (alert)
+ return TRUE;
+
+ return FALSE;
+}
+
+static gboolean pasp_category(const char *category)
+{
+ unsigned i;
+
+ for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++)
+ if (g_str_equal(category, pasp_categories[i]))
return TRUE;
+
+ return FALSE;
+}
+
+static gboolean valid_description(const char *category,
+ const char *description)
+{
+ if (!pasp_category(category)) {
+ if (strlen(description) >= NEW_ALERT_MAX_INFO_SIZE)
+ return FALSE;
+
+ return TRUE;
}
+ if (g_str_equal(description, "active") ||
+ g_str_equal(description, "not active"))
+ return TRUE;
+
+ if (g_str_equal(category, "ringer"))
+ if (g_str_equal(description, "enabled") ||
+ g_str_equal(description, "disabled"))
+ return TRUE;
+
+ return FALSE;
+}
+
+static gboolean valid_count(const char *category, uint16_t count)
+{
+ if (!pasp_category(category) && count > 0 && count <= 255)
+ return TRUE;
+
+ if (pasp_category(category) && count == 1)
+ return TRUE;
+
return FALSE;
}
@@ -188,6 +246,47 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ const char *sender = dbus_message_get_sender(msg);
+ const char *category, *description;
+ struct alert_data *alert;
+ uint16_t count;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
+ DBUS_TYPE_UINT16, &count, DBUS_TYPE_STRING,
+ &description, DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+
+ alert = get_alert_data_by_category(category);
+ if (!alert) {
+ DBG("Category %s not registered", category);
+ return btd_error_invalid_args(msg);
+ }
+
+ if (!g_str_equal(alert->srv, sender)) {
+ DBG("Sender %s is not registered in category %s", sender,
+ category);
+ return btd_error_invalid_args(msg);
+ }
+
+ if (!valid_description(category, description)) {
+ DBG("Description %s is invalid for %s category",
+ description, category);
+ return btd_error_invalid_args(msg);
+ }
+
+ if (!valid_count(category, count)) {
+ DBG("Count %d is invalid for %s category", count, category);
+ return btd_error_invalid_args(msg);
+ }
+
+ DBG("NewAlert(\"%s\", %d, \"%s\")", category, count, description);
+
+ return dbus_message_new_method_return(msg);
+}
+
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
gpointer user_data)
@@ -374,6 +473,11 @@ static const GDBusMethodTable alert_methods[] = {
GDBUS_ARGS({ "category", "s" },
{ "agent", "o" }), NULL,
register_alert) },
+ { GDBUS_METHOD("NewAlert",
+ GDBUS_ARGS({ "category", "s" },
+ { "count", "q" },
+ { "description", "s" }), NULL,
+ new_alert) },
{ }
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 11/25] alert: Add initial support for UnreadAlert D-Bus method
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (9 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 10/25] alert: Add initial support for NewAlert D-Bus method Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 12/25] alert: Automatically unregister alert when agent leaves D-Bus Anderson Lizardo
` (14 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This method is used for updating the "unread" counter for categories
that support it.
---
profiles/alert/server.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index d70f82a..8630931 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -287,6 +287,36 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ const char *sender = dbus_message_get_sender(msg);
+ struct alert_data *alert;
+ const char *category;
+ uint16_t count;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
+ DBUS_TYPE_UINT16, &count,
+ DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+
+ alert = get_alert_data_by_category(category);
+ if (!alert) {
+ DBG("Category %s not registered", category);
+ return btd_error_invalid_args(msg);
+ }
+
+ if (!g_str_equal(alert->srv, sender)) {
+ DBG("Sender %s is not registered in category %s", sender,
+ category);
+ return btd_error_invalid_args(msg);
+ }
+
+ DBG("category %s, count %d", category, count);
+
+ return dbus_message_new_method_return(msg);
+}
+
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
gpointer user_data)
@@ -478,6 +508,9 @@ static const GDBusMethodTable alert_methods[] = {
{ "count", "q" },
{ "description", "s" }), NULL,
new_alert) },
+ { GDBUS_METHOD("UnreadAlert",
+ GDBUS_ARGS({ "category", "s" }, { "count", "q" }), NULL,
+ unread_alert) },
{ }
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 12/25] alert: Automatically unregister alert when agent leaves D-Bus
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (10 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 11/25] alert: Add initial support for UnreadAlert " Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 13/25] alert: Add per adapter attribute handle information Anderson Lizardo
` (13 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
---
profiles/alert/server.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 8630931..e6402b7 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -84,6 +84,7 @@ struct alert_data {
const char *category;
char *srv;
char *path;
+ guint watcher;
};
static GSList *registered_alerts = NULL;
@@ -113,6 +114,9 @@ static void alert_data_destroy(gpointer user_data)
{
struct alert_data *alert = user_data;
+ if (alert->watcher)
+ g_dbus_remove_watch(btd_get_dbus_connection(), alert->watcher);
+
g_free(alert->srv);
g_free(alert->path);
g_free(alert);
@@ -210,6 +214,16 @@ static gboolean valid_count(const char *category, uint16_t count)
return FALSE;
}
+static void watcher_disconnect(DBusConnection *conn, void *user_data)
+{
+ struct alert_data *alert = user_data;
+
+ DBG("Category %s was disconnected", alert->category);
+
+ registered_alerts = g_slist_remove(registered_alerts, alert);
+ alert_data_destroy(alert);
+}
+
static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -238,6 +252,15 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
alert->srv = g_strdup(sender);
alert->path = g_strdup(path);
alert->category = category;
+ alert->watcher = g_dbus_add_disconnect_watch(conn, alert->srv,
+ watcher_disconnect, alert, NULL);
+
+ if (alert->watcher == 0) {
+ alert_data_destroy(alert);
+ DBG("Could not register disconnect watcher");
+ return btd_error_failed(msg,
+ "Could not register disconnect watcher");
+ }
registered_alerts = g_slist_append(registered_alerts, alert);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 13/25] alert: Add per adapter attribute handle information
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (11 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 12/25] alert: Automatically unregister alert when agent leaves D-Bus Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 14/25] alert: Update Supported New/Unread Category characteristic values Anderson Lizardo
` (12 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Each adapter may have different GATT services running, therefore any
attribute handles (e.g. for updating characteristic values) need to be
saved per adapter.
---
profiles/alert/server.c | 57 ++++++++++++++++++++++++++++++++++++++---------
1 file changed, 47 insertions(+), 10 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index e6402b7..fb95f09 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -87,7 +87,13 @@ struct alert_data {
guint watcher;
};
+struct alert_adapter {
+ struct btd_adapter *adapter;
+ /* TODO: store characteristic value handles */
+};
+
static GSList *registered_alerts = NULL;
+static GSList *alert_adapters = NULL;
static uint8_t ringer_setting = RINGER_NORMAL;
static uint8_t alert_status = 0;
@@ -110,6 +116,21 @@ static const char *pasp_categories[] = {
"display",
};
+static int adapter_cmp(gconstpointer a, gconstpointer b)
+{
+ const struct alert_adapter *al_adapter = a;
+ const struct btd_adapter *adapter = b;
+
+ return (al_adapter->adapter == adapter ? 0 : -1);
+}
+
+static struct alert_adapter *find_alert_adapter(struct btd_adapter *adapter)
+{
+ GSList *l = g_slist_find_custom(alert_adapters, adapter, adapter_cmp);
+
+ return (l ? l->data : NULL);
+}
+
static void alert_data_destroy(gpointer user_data)
{
struct alert_data *alert = user_data;
@@ -379,20 +400,20 @@ static uint8_t ringer_setting_read(struct attribute *a,
return 0;
}
-static void register_phone_alert_service(struct btd_adapter *adapter)
+static void register_phone_alert_service(struct alert_adapter *al_adapter)
{
bt_uuid_t uuid;
bt_uuid16_create(&uuid, PHONE_ALERT_STATUS_SVC_UUID);
/* Phone Alert Status Service */
- gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ gatt_service_add(al_adapter->adapter, GATT_PRIM_SVC_UUID, &uuid,
/* Alert Status characteristic */
GATT_OPT_CHR_UUID, ALERT_STATUS_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
- alert_status_read, adapter,
+ alert_status_read, al_adapter->adapter,
/* Ringer Control Point characteristic */
GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
@@ -403,7 +424,7 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
- ringer_setting_read, adapter,
+ ringer_setting_read, al_adapter->adapter,
GATT_OPT_INVALID);
}
@@ -471,19 +492,19 @@ static uint8_t alert_notif_cp_write(struct attribute *a,
return 0;
}
-static void register_alert_notif_service(struct btd_adapter *adapter)
+static void register_alert_notif_service(struct alert_adapter *al_adapter)
{
bt_uuid_t uuid;
bt_uuid16_create(&uuid, ALERT_NOTIF_SVC_UUID);
/* Alert Notification Service */
- gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ gatt_service_add(al_adapter->adapter, GATT_PRIM_SVC_UUID, &uuid,
/* Supported New Alert Category */
GATT_OPT_CHR_UUID, SUPP_NEW_ALERT_CAT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
- supp_new_alert_cat_read, adapter,
+ supp_new_alert_cat_read, al_adapter->adapter,
/* New Alert */
GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
@@ -491,7 +512,7 @@ static void register_alert_notif_service(struct btd_adapter *adapter)
GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
- supp_unread_alert_cat_read, adapter,
+ supp_unread_alert_cat_read, al_adapter->adapter,
/* Unread Alert Status */
GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
@@ -505,14 +526,30 @@ static void register_alert_notif_service(struct btd_adapter *adapter)
static int alert_server_probe(struct btd_adapter *adapter)
{
- register_phone_alert_service(adapter);
- register_alert_notif_service(adapter);
+ struct alert_adapter *al_adapter;
+
+ al_adapter = g_new0(struct alert_adapter, 1);
+ al_adapter->adapter = btd_adapter_ref(adapter);
+
+ alert_adapters = g_slist_append(alert_adapters, al_adapter);
+
+ register_phone_alert_service(al_adapter);
+ register_alert_notif_service(al_adapter);
return 0;
}
static void alert_server_remove(struct btd_adapter *adapter)
{
+ struct alert_adapter *al_adapter;
+
+ al_adapter = find_alert_adapter(adapter);
+ if (!al_adapter)
+ return;
+
+ alert_adapters = g_slist_remove(alert_adapters, al_adapter);
+ btd_adapter_unref(al_adapter->adapter);
+ g_free(al_adapter);
}
static struct btd_profile alert_profile = {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 14/25] alert: Update Supported New/Unread Category characteristic values
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (12 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 13/25] alert: Add per adapter attribute handle information Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 15/25] alert: Update new alert characteristic value Anderson Lizardo
` (11 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
The value is now kept up-to-date when new/unread alerts arrive. This
value is not notified yet.
---
profiles/alert/server.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index fb95f09..f1021cc 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -89,7 +89,8 @@ struct alert_data {
struct alert_adapter {
struct btd_adapter *adapter;
- /* TODO: store characteristic value handles */
+ uint16_t supp_new_alert_cat_handle;
+ uint16_t supp_unread_alert_cat_handle;
};
static GSList *registered_alerts = NULL;
@@ -235,6 +236,29 @@ static gboolean valid_count(const char *category, uint16_t count)
return FALSE;
}
+static void update_supported_categories(gpointer data, gpointer user_data)
+{
+ struct alert_adapter *al_adapter = data;
+ struct btd_adapter *adapter = al_adapter->adapter;
+ uint8_t value[2];
+ unsigned int i;
+
+ memset(value, 0, sizeof(value));
+
+ for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+ if (registered_category(anp_categories[i]))
+ hci_set_bit(i, value);
+ }
+
+ attrib_db_update(adapter, al_adapter->supp_new_alert_cat_handle, NULL,
+ value, sizeof(value), NULL);
+
+ /* FIXME: For now report all registered categories as supporting unread
+ * status, until it is known which ones should be supported */
+ attrib_db_update(adapter, al_adapter->supp_unread_alert_cat_handle,
+ NULL, value, sizeof(value), NULL);
+}
+
static void watcher_disconnect(DBusConnection *conn, void *user_data)
{
struct alert_data *alert = user_data;
@@ -243,6 +267,8 @@ static void watcher_disconnect(DBusConnection *conn, void *user_data)
registered_alerts = g_slist_remove(registered_alerts, alert);
alert_data_destroy(alert);
+
+ g_slist_foreach(alert_adapters, update_supported_categories, NULL);
}
static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
@@ -285,6 +311,8 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
registered_alerts = g_slist_append(registered_alerts, alert);
+ g_slist_foreach(alert_adapters, update_supported_categories, NULL);
+
DBG("RegisterAlert(\"%s\", \"%s\")", alert->category, alert->path);
return dbus_message_new_method_return(msg);
@@ -505,6 +533,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
supp_new_alert_cat_read, al_adapter->adapter,
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->supp_new_alert_cat_handle,
/* New Alert */
GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
@@ -513,6 +543,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
supp_unread_alert_cat_read, al_adapter->adapter,
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->supp_unread_alert_cat_handle,
/* Unread Alert Status */
GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 15/25] alert: Update new alert characteristic value
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (13 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 14/25] alert: Update Supported New/Unread Category characteristic values Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 16/25] alert: Update unread " Anderson Lizardo
` (10 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Update the attribute value when a new alert is reported to BlueZ.
---
profiles/alert/server.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index f1021cc..9e389d6 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -64,6 +64,8 @@
/* Maximum length for "Text String Information" */
#define NEW_ALERT_MAX_INFO_SIZE 18
+/* Maximum length for New Alert Characteristic Value */
+#define NEW_ALERT_CHR_MAX_VALUE_SIZE (NEW_ALERT_MAX_INFO_SIZE + 2)
enum {
ENABLE_NEW_INCOMING,
@@ -91,6 +93,7 @@ struct alert_adapter {
struct btd_adapter *adapter;
uint16_t supp_new_alert_cat_handle;
uint16_t supp_unread_alert_cat_handle;
+ uint16_t new_alert_handle;
};
static GSList *registered_alerts = NULL;
@@ -318,6 +321,16 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static void update_new_alert(gpointer data, gpointer user_data)
+{
+ struct alert_adapter *al_adapter = data;
+ struct btd_adapter *adapter = al_adapter->adapter;
+ uint8_t *value = user_data;
+
+ attrib_db_update(adapter, al_adapter->new_alert_handle, NULL, &value[1],
+ value[0], NULL);
+}
+
static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -325,6 +338,7 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
const char *category, *description;
struct alert_data *alert;
uint16_t count;
+ unsigned int i;
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
DBUS_TYPE_UINT16, &count, DBUS_TYPE_STRING,
@@ -354,6 +368,29 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
return btd_error_invalid_args(msg);
}
+ for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+ if (g_str_equal(anp_categories[i], category)) {
+ uint8_t value[NEW_ALERT_CHR_MAX_VALUE_SIZE + 1];
+ size_t dlen = strlen(description);
+ uint8_t *ptr = value;
+
+ memset(value, 0, sizeof(value));
+
+ *ptr++ = 2; /* Attribute value size */
+ *ptr++ = i; /* Category ID (mandatory) */
+ *ptr++ = count; /* Number of New Alert (mandatory) */
+ /* Text String Information (optional) */
+ strncpy((char *) ptr, description,
+ NEW_ALERT_MAX_INFO_SIZE - 1);
+
+ if (dlen > 0)
+ *value += dlen + 1;
+
+ g_slist_foreach(alert_adapters, update_new_alert,
+ value);
+ }
+ }
+
DBG("NewAlert(\"%s\", %d, \"%s\")", category, count, description);
return dbus_message_new_method_return(msg);
@@ -538,6 +575,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
/* New Alert */
GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->new_alert_handle,
/* Supported Unread Alert Category */
GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 16/25] alert: Update unread alert characteristic value
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (14 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 15/25] alert: Update new alert characteristic value Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 17/25] alert: Implement MuteOnce command Anderson Lizardo
` (9 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Update the attribute value when the unread alert count is changed.
---
profiles/alert/server.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 9e389d6..eede2fd 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -94,6 +94,7 @@ struct alert_adapter {
uint16_t supp_new_alert_cat_handle;
uint16_t supp_unread_alert_cat_handle;
uint16_t new_alert_handle;
+ uint16_t unread_alert_handle;
};
static GSList *registered_alerts = NULL;
@@ -396,12 +397,23 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static void update_unread_alert(gpointer data, gpointer user_data)
+{
+ struct alert_adapter *al_adapter = data;
+ struct btd_adapter *adapter = al_adapter->adapter;
+ uint8_t *value = user_data;
+
+ attrib_db_update(adapter, al_adapter->unread_alert_handle, NULL, value,
+ 2, NULL);
+}
+
static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
const char *sender = dbus_message_get_sender(msg);
struct alert_data *alert;
const char *category;
+ unsigned int i;
uint16_t count;
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
@@ -415,12 +427,29 @@ static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
return btd_error_invalid_args(msg);
}
+ if (!valid_count(category, count)) {
+ DBG("Count %d is invalid for %s category", count, category);
+ return btd_error_invalid_args(msg);
+ }
+
if (!g_str_equal(alert->srv, sender)) {
DBG("Sender %s is not registered in category %s", sender,
category);
return btd_error_invalid_args(msg);
}
+ for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+ if (g_str_equal(anp_categories[i], category)) {
+ uint8_t value[2];
+
+ value[0] = i; /* Category ID */
+ value[1] = count; /* Unread count */
+
+ g_slist_foreach(alert_adapters, update_unread_alert,
+ value);
+ }
+ }
+
DBG("category %s, count %d", category, count);
return dbus_message_new_method_return(msg);
@@ -587,6 +616,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
/* Unread Alert Status */
GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->unread_alert_handle,
/* Alert Notification Control Point */
GATT_OPT_CHR_UUID, ALERT_NOTIF_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 17/25] alert: Implement MuteOnce command
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (15 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 16/25] alert: Update unread " Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 18/25] alert: Add support for calling MuteOnce() Anderson Lizardo
` (8 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
MuteOnce() is called by BlueZ to instruct the agent to mute the ringer
during a incoming call.
---
profiles/alert/server.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index eede2fd..bf67d7d 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -76,6 +76,12 @@ enum {
NOTIFY_UNREAD_CAT,
};
+enum {
+ RINGER_SILENT_MODE = 1,
+ RINGER_MUTE_ONCE,
+ RINGER_CANCEL_SILENT_MODE,
+};
+
/* Ringer Setting characteristic values */
enum {
RINGER_SILENT,
@@ -461,6 +467,25 @@ static uint8_t ringer_cp_write(struct attribute *a,
{
DBG("a = %p", a);
+ if (a->len > 1) {
+ DBG("Invalid command size (%zu)", a->len);
+ return 0;
+ }
+
+ switch (a->data[0]) {
+ case RINGER_SILENT_MODE:
+ DBG("Silent Mode");
+ break;
+ case RINGER_MUTE_ONCE:
+ DBG("Mute Once");
+ break;
+ case RINGER_CANCEL_SILENT_MODE:
+ DBG("Cancel Silent Mode");
+ break;
+ default:
+ DBG("Invalid command (0x%02x)", a->data[0]);
+ }
+
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 18/25] alert: Add support for calling MuteOnce()
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (16 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 17/25] alert: Implement MuteOnce command Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 19/25] alert: Add support for calling SetRinger() Anderson Lizardo
` (7 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When BlueZ wants to call MuteOnce() method from org.bluez.AlertAgent
interface for a registered agent, the function agent_ringer_mute_once()
must be called.
---
profiles/alert/server.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index bf67d7d..75eb414 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -61,6 +61,7 @@
#define ALERT_OBJECT_PATH "/org/bluez"
#define ALERT_INTERFACE "org.bluez.Alert"
+#define ALERT_AGENT_INTERFACE "org.bluez.AlertAgent"
/* Maximum length for "Text String Information" */
#define NEW_ALERT_MAX_INFO_SIZE 18
@@ -403,6 +404,28 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static int agent_ringer_mute_once(void)
+{
+ struct alert_data *alert;
+ DBusMessage *msg;
+
+ alert = get_alert_data_by_category("ringer");
+ if (!alert) {
+ DBG("Category ringer is not registered");
+ return -EINVAL;
+ }
+
+ msg = dbus_message_new_method_call(alert->srv, alert->path,
+ ALERT_AGENT_INTERFACE, "MuteOnce");
+ if (!msg)
+ return -ENOMEM;
+
+ dbus_message_set_no_reply(msg, TRUE);
+ g_dbus_send_message(btd_get_dbus_connection(), msg);
+
+ return 0;
+}
+
static void update_unread_alert(gpointer data, gpointer user_data)
{
struct alert_adapter *al_adapter = data;
@@ -478,6 +501,7 @@ static uint8_t ringer_cp_write(struct attribute *a,
break;
case RINGER_MUTE_ONCE:
DBG("Mute Once");
+ agent_ringer_mute_once();
break;
case RINGER_CANCEL_SILENT_MODE:
DBG("Cancel Silent Mode");
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 19/25] alert: Add support for calling SetRinger()
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (17 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 18/25] alert: Add support for calling MuteOnce() Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 20/25] alert: Add test-alert script Anderson Lizardo
` (6 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When BlueZ wants to call SetRinger() method from org.bluez.AlertAgent
interface for a registered agent, the function agent_ringer_set_ringer()
must be called.
---
profiles/alert/server.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 75eb414..952d982 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -426,6 +426,31 @@ static int agent_ringer_mute_once(void)
return 0;
}
+static int agent_ringer_set_ringer(const char *mode)
+{
+ struct alert_data *alert;
+ DBusMessage *msg;
+
+ alert = get_alert_data_by_category("ringer");
+ if (!alert) {
+ DBG("Category ringer is not registered");
+ return -EINVAL;
+ }
+
+ msg = dbus_message_new_method_call(alert->srv, alert->path,
+ ALERT_AGENT_INTERFACE, "SetRinger");
+ if (!msg)
+ return -ENOMEM;
+
+ dbus_message_append_args(msg, DBUS_TYPE_STRING, &mode,
+ DBUS_TYPE_INVALID);
+
+ dbus_message_set_no_reply(msg, TRUE);
+ g_dbus_send_message(btd_get_dbus_connection(), msg);
+
+ return 0;
+}
+
static void update_unread_alert(gpointer data, gpointer user_data)
{
struct alert_adapter *al_adapter = data;
@@ -498,6 +523,7 @@ static uint8_t ringer_cp_write(struct attribute *a,
switch (a->data[0]) {
case RINGER_SILENT_MODE:
DBG("Silent Mode");
+ agent_ringer_set_ringer("disabled");
break;
case RINGER_MUTE_ONCE:
DBG("Mute Once");
@@ -505,6 +531,7 @@ static uint8_t ringer_cp_write(struct attribute *a,
break;
case RINGER_CANCEL_SILENT_MODE:
DBG("Cancel Silent Mode");
+ agent_ringer_set_ringer("enabled");
break;
default:
DBG("Invalid command (0x%02x)", a->data[0]);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 20/25] alert: Add test-alert script
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (18 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 19/25] alert: Add support for calling SetRinger() Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 21/25] alert: Update Alert Status and Ringer Setting characteristic values Anderson Lizardo
` (5 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
This script is useful for testing the Alert API and testing the
implementation with PTS.
---
test/test-alert | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 173 insertions(+)
create mode 100755 test/test-alert
diff --git a/test/test-alert b/test/test-alert
new file mode 100755
index 0000000..c92a719
--- /dev/null
+++ b/test/test-alert
@@ -0,0 +1,173 @@
+#!/usr/bin/python
+from __future__ import absolute_import, print_function, unicode_literals
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+import gobject
+import optparse
+import sys
+import os
+
+BUS_NAME = 'org.bluez'
+ALERT_INTERFACE = 'org.bluez.Alert'
+ALERT_AGENT_INTERFACE = 'org.bluez.AlertAgent'
+BLUEZ_OBJECT_PATH = '/org/bluez'
+TEST_OBJECT_PATH = '/org/bluez/test'
+
+class AlertAgent(dbus.service.Object):
+ def __init__(self, bus, object_path, alert):
+ dbus.service.Object.__init__(self, bus, object_path)
+ self.alert = alert
+
+ @dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='',
+ out_signature='')
+ def MuteOnce(self):
+ print('method MuteOnce() was called')
+ self.alert.NewAlert('ringer', 1, 'not active')
+
+ @dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='s',
+ out_signature='')
+ def SetRinger(self, mode):
+ print('method SetRinger(%s) was called' % mode)
+ self.alert.NewAlert('ringer', 1, mode)
+
+def print_command_line(options):
+ if not options.verbose:
+ return False
+
+ print('-w: ' + str(options.wait))
+
+ if options.times:
+ print('-t: ' + str(options.times))
+
+ if options.register:
+ print('-r: ' + options.register)
+ else:
+ print('-r: ' + str(None))
+
+ if options.new_alert:
+ print('-n:')
+ for i in options.new_alert:
+ print(' ' + i[0] + ', ' + i[1] + ', ' + i[2])
+ else:
+ print('-n: ' + str(None))
+
+ if options.unread_alert:
+ print('-u:')
+ for i in options.unread_alert:
+ print(' ' + i[0] + ', ' + i[1])
+ else:
+ print('-u: ' + str(None))
+
+ print()
+
+ return True
+
+def read_count(param):
+ try:
+ return int(param)
+ except ValueError:
+ print('<count> must be integer, not \"%s\"' % param)
+ sys.exit(1)
+
+def new_alert(alert, params):
+ if not params:
+ return False
+
+ for param in params:
+ category = param[0]
+ count = read_count(param[1])
+ description = param[2]
+
+ alert.NewAlert(category, count, description)
+
+def unread_alert(alert, params):
+ if not params:
+ return False
+
+ for param in params:
+ category = param[0]
+ count = read_count(param[1])
+
+ alert.UnreadAlert(category, count)
+
+option_list = [
+ optparse.make_option('-v', None,
+ action = 'store_true',
+ default = False,
+ dest = 'verbose',
+ help = 'verbose'),
+
+ optparse.make_option('-w', None,
+ action = 'store_true',
+ default = False,
+ dest = 'wait',
+ help = 'wait for dbus events'),
+
+ optparse.make_option('-t', None,
+ action = 'store',
+ default = 1,
+ type = "int",
+ dest = 'times',
+ help = 'repeat UnreadAlert/NewAlert <times> times',
+ metavar = '<times>'),
+
+ optparse.make_option('-r', None,
+ action = 'store',
+ dest = 'register',
+ type = 'string',
+ metavar = '<category>',
+ help = 'register alert'),
+
+ optparse.make_option('-n', None,
+ action = 'append',
+ dest = 'new_alert',
+ type = 'string',
+ nargs = 3,
+ metavar = '<category> <count> <description>',
+ help = 'send new alert'),
+
+ optparse.make_option('-u', None,
+ action = 'append',
+ dest = 'unread_alert',
+ type = 'string',
+ nargs = 2,
+ metavar = '<category> <count>',
+ help = 'send unread alert'),
+]
+
+parser = optparse.OptionParser(option_list=option_list)
+parser.disable_interspersed_args()
+(options, args) = parser.parse_args()
+
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+bus = dbus.SystemBus()
+mainloop = gobject.MainLoop()
+alert = dbus.Interface(bus.get_object(BUS_NAME, BLUEZ_OBJECT_PATH),
+ ALERT_INTERFACE)
+alert_agent = AlertAgent(bus, TEST_OBJECT_PATH, alert)
+
+print_command_line(options)
+
+if not (options.register or options.new_alert or options.unread_alert or
+ options.wait):
+ parser.print_usage()
+ sys.exit(1)
+
+if options.register:
+ alert.RegisterAlert(options.register, TEST_OBJECT_PATH)
+
+times = 0
+while times < options.times:
+ times += 1
+
+ new_alert(alert, options.new_alert)
+ unread_alert(alert, options.unread_alert)
+
+if not options.wait:
+ sys.exit(0)
+
+try:
+ mainloop.run()
+except:
+ pass
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 21/25] alert: Update Alert Status and Ringer Setting characteristic values
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (19 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 20/25] alert: Add test-alert script Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 22/25] alert: Add support for ringer setting notification Anderson Lizardo
` (4 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Now these characteristic values are updated when the agent changes any
PASP alert state or setting.
---
profiles/alert/server.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 952d982..58d7c5f 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -339,6 +339,27 @@ static void update_new_alert(gpointer data, gpointer user_data)
value[0], NULL);
}
+static void update_phone_alerts(const char *category, const char *description)
+{
+ unsigned int i;
+
+ if (g_str_equal(category, "ringer")) {
+ if (g_str_equal(description, "enabled"))
+ ringer_setting = RINGER_NORMAL;
+ else if (g_str_equal(description, "disabled"))
+ ringer_setting = RINGER_SILENT;
+ }
+
+ for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
+ if (g_str_equal(pasp_categories[i], category)) {
+ if (g_str_equal(description, "active"))
+ alert_status |= (1 << i);
+ else if (g_str_equal(description, "not active"))
+ alert_status &= ~(1 << i);
+ }
+ }
+}
+
static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -399,6 +420,9 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
}
}
+ if (pasp_category(category))
+ update_phone_alerts(category, description);
+
DBG("NewAlert(\"%s\", %d, \"%s\")", category, count, description);
return dbus_message_new_method_return(msg);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 22/25] alert: Add support for ringer setting notification
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (20 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 21/25] alert: Update Alert Status and Ringer Setting characteristic values Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 23/25] alert: Add support for alert status notification Anderson Lizardo
` (3 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When the agent reports a ringer setting change, a ringer setting
notification is sent to the peer device (if notification is enabled).
---
profiles/alert/server.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 154 insertions(+), 2 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 58d7c5f..d14f98e 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -31,6 +31,7 @@
#include <gdbus.h>
#include <glib.h>
#include <bluetooth/uuid.h>
+#include <stdlib.h>
#include "dbus-common.h"
#include "att.h"
@@ -45,6 +46,8 @@
#include "server.h"
#include "profile.h"
#include "error.h"
+#include "textfile.h"
+#include "attio.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
#define ALERT_NOTIF_SVC_UUID 0x1811
@@ -89,6 +92,11 @@ enum {
RINGER_NORMAL,
};
+enum notify_type {
+ NOTIFY_RINGER_SETTING = 0,
+ NOTIFY_SIZE,
+};
+
struct alert_data {
const char *category;
char *srv;
@@ -102,6 +110,21 @@ struct alert_adapter {
uint16_t supp_unread_alert_cat_handle;
uint16_t new_alert_handle;
uint16_t unread_alert_handle;
+ uint16_t hnd_ccc[NOTIFY_SIZE];
+ uint16_t hnd_value[NOTIFY_SIZE];
+};
+
+struct notify_data {
+ struct alert_adapter *al_adapter;
+ enum notify_type type;
+ uint8_t *value;
+ size_t len;
+};
+
+struct notify_callback {
+ struct notify_data *notify_data;
+ struct btd_device *device;
+ guint id;
};
static GSList *registered_alerts = NULL;
@@ -282,6 +305,125 @@ static void watcher_disconnect(DBusConnection *conn, void *user_data)
g_slist_foreach(alert_adapters, update_supported_categories, NULL);
}
+static struct btd_device *get_notifiable_device(struct btd_adapter *adapter,
+ char *key, char *value,
+ uint16_t ccc)
+{
+ struct btd_device *device;
+ char addr[18];
+ uint16_t hnd, val;
+ uint8_t bdaddr_type;
+
+ sscanf(key, "%17s#%hhu#%04hX", addr, &bdaddr_type, &hnd);
+
+ if (hnd != ccc)
+ return NULL;
+
+ val = strtol(value, NULL, 16);
+ if (!(val & 0x0001))
+ return NULL;
+
+ device = adapter_find_device(adapter, addr);
+ if (device == NULL)
+ return NULL;
+
+ return btd_device_ref(device);
+}
+
+static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
+{
+ struct notify_callback *cb = user_data;
+ struct notify_data *nd = cb->notify_data;
+ enum notify_type type = nd->type;
+ struct alert_adapter *al_adapter = nd->al_adapter;
+ uint8_t pdu[ATT_MAX_MTU];
+ size_t len = 0;
+
+ switch (type) {
+ case NOTIFY_RINGER_SETTING:
+ len = enc_notification(al_adapter->hnd_value[type],
+ &ringer_setting, sizeof(ringer_setting),
+ pdu, sizeof(pdu));
+ break;
+ default:
+ DBG("Unknown type, could not send notification");
+ goto end;
+ }
+
+ DBG("Send notification for handle: 0x%04x, ccc: 0x%04x",
+ al_adapter->hnd_value[type],
+ al_adapter->hnd_ccc[type]);
+
+ g_attrib_send(attrib, 0, ATT_OP_HANDLE_NOTIFY, pdu, len,
+ NULL, NULL, NULL);
+
+end:
+ btd_device_remove_attio_callback(cb->device, cb->id);
+ btd_device_unref(cb->device);
+ g_free(cb->notify_data->value);
+ g_free(cb->notify_data);
+ g_free(cb);
+}
+
+static void filter_devices_notify(char *key, char *value, void *user_data)
+{
+ struct notify_data *notify_data = user_data;
+ struct alert_adapter *al_adapter = notify_data->al_adapter;
+ enum notify_type type = notify_data->type;
+ struct btd_device *device;
+ struct notify_callback *cb;
+
+ device = get_notifiable_device(al_adapter->adapter, key, value,
+ al_adapter->hnd_ccc[type]);
+ if (device == NULL)
+ return;
+
+ cb = g_new0(struct notify_callback, 1);
+ cb->notify_data = notify_data;
+ cb->device = device;
+ cb->id = btd_device_add_attio_callback(device,
+ attio_connected_cb, NULL, cb);
+}
+
+static void create_filename(char *filename, struct btd_adapter *adapter)
+{
+ char srcaddr[18];
+ bdaddr_t src;
+
+ adapter_get_address(adapter, &src);
+ ba2str(&src, srcaddr);
+
+ create_name(filename, PATH_MAX, STORAGEDIR, srcaddr, "ccc");
+}
+
+static void notify_devices(struct alert_adapter *al_adapter,
+ enum notify_type type, uint8_t *value, size_t len)
+{
+ struct notify_data *notify_data;
+ char filename[PATH_MAX + 1];
+
+ notify_data = g_new0(struct notify_data, 1);
+ notify_data->al_adapter = al_adapter;
+ notify_data->type = type;
+ notify_data->value = g_memdup(value, len);
+ notify_data->len = len;
+
+ create_filename(filename, al_adapter->adapter);
+ textfile_foreach(filename, filter_devices_notify, notify_data);
+}
+
+static void pasp_notification(enum notify_type type)
+{
+ GSList *it;
+ struct alert_adapter *al_adapter;
+
+ for (it = alert_adapters; it; it = g_slist_next(it)) {
+ al_adapter = it->data;
+
+ notify_devices(al_adapter, type, NULL, 0);
+ }
+}
+
static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -344,10 +486,15 @@ static void update_phone_alerts(const char *category, const char *description)
unsigned int i;
if (g_str_equal(category, "ringer")) {
- if (g_str_equal(description, "enabled"))
+ if (g_str_equal(description, "enabled")) {
ringer_setting = RINGER_NORMAL;
- else if (g_str_equal(description, "disabled"))
+ pasp_notification(NOTIFY_RINGER_SETTING);
+ return;
+ } else if (g_str_equal(description, "disabled")) {
ringer_setting = RINGER_SILENT;
+ pasp_notification(NOTIFY_RINGER_SETTING);
+ return;
+ }
}
for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
@@ -619,6 +766,10 @@ static void register_phone_alert_service(struct alert_adapter *al_adapter)
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
ringer_setting_read, al_adapter->adapter,
+ GATT_OPT_CCC_GET_HANDLE,
+ &al_adapter->hnd_ccc[NOTIFY_RINGER_SETTING],
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->hnd_value[NOTIFY_RINGER_SETTING],
GATT_OPT_INVALID);
}
@@ -751,6 +902,7 @@ static void alert_server_remove(struct btd_adapter *adapter)
alert_adapters = g_slist_remove(alert_adapters, al_adapter);
btd_adapter_unref(al_adapter->adapter);
+
g_free(al_adapter);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 23/25] alert: Add support for alert status notification
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (21 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 22/25] alert: Add support for ringer setting notification Anderson Lizardo
@ 2012-09-24 18:00 ` Anderson Lizardo
2012-09-24 18:01 ` [PATCH BlueZ 24/25] alert: Add support for new alert notification Anderson Lizardo
` (2 subsequent siblings)
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
The notification is sent (to peer devices that have it enabled on the
CCC descriptor) every time the alert status characteristic value
changes.
---
profiles/alert/server.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index d14f98e..c531e02 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -94,6 +94,7 @@ enum {
enum notify_type {
NOTIFY_RINGER_SETTING = 0,
+ NOTIFY_ALERT_STATUS,
NOTIFY_SIZE,
};
@@ -345,6 +346,11 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
&ringer_setting, sizeof(ringer_setting),
pdu, sizeof(pdu));
break;
+ case NOTIFY_ALERT_STATUS:
+ len = enc_notification(al_adapter->hnd_value[type],
+ &alert_status, sizeof(alert_status),
+ pdu, sizeof(pdu));
+ break;
default:
DBG("Unknown type, could not send notification");
goto end;
@@ -499,10 +505,14 @@ static void update_phone_alerts(const char *category, const char *description)
for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
if (g_str_equal(pasp_categories[i], category)) {
- if (g_str_equal(description, "active"))
+ if (g_str_equal(description, "active")) {
alert_status |= (1 << i);
- else if (g_str_equal(description, "not active"))
+ pasp_notification(NOTIFY_ALERT_STATUS);
+ } else if (g_str_equal(description, "not active")) {
alert_status &= ~(1 << i);
+ pasp_notification(NOTIFY_ALERT_STATUS);
+ }
+ break;
}
}
}
@@ -755,6 +765,10 @@ static void register_phone_alert_service(struct alert_adapter *al_adapter)
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
alert_status_read, al_adapter->adapter,
+ GATT_OPT_CCC_GET_HANDLE,
+ &al_adapter->hnd_ccc[NOTIFY_ALERT_STATUS],
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->hnd_value[NOTIFY_ALERT_STATUS],
/* Ringer Control Point characteristic */
GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 24/25] alert: Add support for new alert notification
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (22 preceding siblings ...)
2012-09-24 18:00 ` [PATCH BlueZ 23/25] alert: Add support for alert status notification Anderson Lizardo
@ 2012-09-24 18:01 ` Anderson Lizardo
2012-09-24 18:01 ` [PATCH BlueZ 25/25] alert: Add support for unread " Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:01 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When NewAlert D-Bus method is called for one category from Alert
Notification Profile, the new alert characteristic value is notified.
---
profiles/alert/server.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index c531e02..497891b 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -95,6 +95,7 @@ enum {
enum notify_type {
NOTIFY_RINGER_SETTING = 0,
NOTIFY_ALERT_STATUS,
+ NOTIFY_NEW_ALERT,
NOTIFY_SIZE,
};
@@ -109,7 +110,6 @@ struct alert_adapter {
struct btd_adapter *adapter;
uint16_t supp_new_alert_cat_handle;
uint16_t supp_unread_alert_cat_handle;
- uint16_t new_alert_handle;
uint16_t unread_alert_handle;
uint16_t hnd_ccc[NOTIFY_SIZE];
uint16_t hnd_value[NOTIFY_SIZE];
@@ -351,6 +351,10 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
&alert_status, sizeof(alert_status),
pdu, sizeof(pdu));
break;
+ case NOTIFY_NEW_ALERT:
+ len = enc_notification(al_adapter->hnd_value[type],
+ nd->value, nd->len, pdu, sizeof(pdu));
+ break;
default:
DBG("Unknown type, could not send notification");
goto end;
@@ -483,8 +487,11 @@ static void update_new_alert(gpointer data, gpointer user_data)
struct btd_adapter *adapter = al_adapter->adapter;
uint8_t *value = user_data;
- attrib_db_update(adapter, al_adapter->new_alert_handle, NULL, &value[1],
- value[0], NULL);
+ attrib_db_update(adapter,
+ al_adapter->hnd_value[NOTIFY_NEW_ALERT],
+ NULL, &value[1], value[0], NULL);
+
+ notify_devices(al_adapter, NOTIFY_NEW_ALERT, &value[1], value[0]);
}
static void update_phone_alerts(const char *category, const char *description)
@@ -869,8 +876,10 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
/* New Alert */
GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CCC_GET_HANDLE,
+ &al_adapter->hnd_ccc[NOTIFY_NEW_ALERT],
GATT_OPT_CHR_VALUE_GET_HANDLE,
- &al_adapter->new_alert_handle,
+ &al_adapter->hnd_value[NOTIFY_NEW_ALERT],
/* Supported Unread Alert Category */
GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH BlueZ 25/25] alert: Add support for unread alert notification
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (23 preceding siblings ...)
2012-09-24 18:01 ` [PATCH BlueZ 24/25] alert: Add support for new alert notification Anderson Lizardo
@ 2012-09-24 18:01 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
25 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-24 18:01 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When UnreadAlert D-Bus method is called for a registered category
from Alert Notification Profile, The unread alert characteristic value
is notified.
---
profiles/alert/server.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 497891b..bc1af0b 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -96,6 +96,7 @@ enum notify_type {
NOTIFY_RINGER_SETTING = 0,
NOTIFY_ALERT_STATUS,
NOTIFY_NEW_ALERT,
+ NOTIFY_UNREAD_ALERT,
NOTIFY_SIZE,
};
@@ -110,7 +111,6 @@ struct alert_adapter {
struct btd_adapter *adapter;
uint16_t supp_new_alert_cat_handle;
uint16_t supp_unread_alert_cat_handle;
- uint16_t unread_alert_handle;
uint16_t hnd_ccc[NOTIFY_SIZE];
uint16_t hnd_value[NOTIFY_SIZE];
};
@@ -352,6 +352,7 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
pdu, sizeof(pdu));
break;
case NOTIFY_NEW_ALERT:
+ case NOTIFY_UNREAD_ALERT:
len = enc_notification(al_adapter->hnd_value[type],
nd->value, nd->len, pdu, sizeof(pdu));
break;
@@ -645,8 +646,11 @@ static void update_unread_alert(gpointer data, gpointer user_data)
struct btd_adapter *adapter = al_adapter->adapter;
uint8_t *value = user_data;
- attrib_db_update(adapter, al_adapter->unread_alert_handle, NULL, value,
- 2, NULL);
+ attrib_db_update(adapter,
+ al_adapter->hnd_value[NOTIFY_UNREAD_ALERT], NULL, value,
+ 2, NULL);
+
+ notify_devices(al_adapter, NOTIFY_UNREAD_ALERT, value, 2);
}
static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
@@ -890,8 +894,10 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
/* Unread Alert Status */
GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CCC_GET_HANDLE,
+ &al_adapter->hnd_ccc[NOTIFY_UNREAD_ALERT],
GATT_OPT_CHR_VALUE_GET_HANDLE,
- &al_adapter->unread_alert_handle,
+ &al_adapter->hnd_value[NOTIFY_UNREAD_ALERT],
/* Alert Notification Control Point */
GATT_OPT_CHR_UUID, ALERT_NOTIF_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
` (24 preceding siblings ...)
2012-09-24 18:01 ` [PATCH BlueZ 25/25] alert: Add support for unread " Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 01/27] doc: Introduce Alert API Anderson Lizardo
` (27 more replies)
25 siblings, 28 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Hi,
This series implement most of mandatory features for Phone Alert Status (PASP)
and Alert Notification (ANP) profiles. The only major mandatory feature
currently missing is support for ANP control point (which will be added on a
future series).
Note: for those planning to use ANP/PASP in BlueZ using these patches, it is
necessary to implement an "agent" that forwards platform events (SMS, calls,
e-mail, and ringer/display/vibra status) to BlueZ. See doc/alert-api.txt and
test/test-alert for more details. Alternatively, the components that generate
these events can register themselves and report alerts directly to BlueZ.
This implementation was tested against PTS and all tests passed (except for the
features not yet implemented). The D-Bus API was implemented accordingly to the
previously proposed Alert API (documented on the first patch).
Comments/suggestions are welcome.
Changes since v1:
* Rebase against latest btd_profile changes
* Add test-alert to Makefile.tools and alert-api.txt to Makefile.am
* Add org.bluez.AlertAgent to D-Bus policy file (patch 27/27)
* Implement Release() agent method (patch 26/27)
* Remove Suspend()/Resume() from documentation (they are not implemented, and
they are optimizations that can be added later if necessary).
Anderson Lizardo (13):
doc: Introduce Alert API
alert: Introduce manager abstraction layer
alert: Initial profile registration
alert: Initial Alert Notification
alert: Add initial support for UnreadAlert D-Bus method
alert: Add per adapter attribute handle information
alert: Update Supported New/Unread Category characteristic values
alert: Update new alert characteristic value
alert: Update unread alert characteristic value
alert: Implement MuteOnce command
alert: Update Alert Status and Ringer Setting characteristic values
alert: Implement Release() agent method
alert: Add org.bluez.AlertAgent to D-Bus policy file
Bruna Moreira (4):
alert: Add Phone Alert Status Service
alert: Add Ringer Control Point characteristic
alert: Add Ringer Setting characteristic
alert: Add Alert Status characteristic
Eder Ruiz Maria (10):
alert: Implement category registration in RegisterAlert()
alert: Add initial support for NewAlert D-Bus method
alert: Automatically unregister alert when agent leaves D-Bus
alert: Add support for calling MuteOnce()
alert: Add support for calling SetRinger()
alert: Add test-alert script
alert: Add support for ringer setting notification
alert: Add support for alert status notification
alert: Add support for new alert notification
alert: Add support for unread alert notification
Makefile.am | 5 +-
Makefile.tools | 3 +-
doc/alert-api.txt | 109 ++++++
profiles/alert/main.c | 6 +-
profiles/alert/manager.c | 40 ++
profiles/alert/manager.h | 26 ++
profiles/alert/server.c | 962 ++++++++++++++++++++++++++++++++++++++++++++++
src/bluetooth.conf | 1 +
test/test-alert | 180 +++++++++
9 files changed, 1326 insertions(+), 6 deletions(-)
create mode 100644 doc/alert-api.txt
create mode 100644 profiles/alert/manager.c
create mode 100644 profiles/alert/manager.h
create mode 100755 test/test-alert
--
1.7.9.5
^ permalink raw reply [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 01/27] doc: Introduce Alert API
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 02/27] alert: Introduce manager abstraction layer Anderson Lizardo
` (26 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This API will be implemented and initially used by Phone Alert Status
and Alert Notification GATT profiles (server role).
---
Makefile.am | 2 +-
doc/alert-api.txt | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+), 1 deletion(-)
create mode 100644 doc/alert-api.txt
diff --git a/Makefile.am b/Makefile.am
index 315077f..a42544d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -385,7 +385,7 @@ EXTRA_DIST += doc/manager-api.txt \
doc/network-api.txt doc/input-api.txt doc/audio-api.txt \
doc/control-api.txt doc/hfp-api.txt doc/health-api.txt \
doc/sap-api.txt doc/media-api.txt doc/assigned-numbers.txt \
- doc/supported-features.txt
+ doc/supported-features.txt doc/alert-api.txt
AM_YFLAGS = -d
diff --git a/doc/alert-api.txt b/doc/alert-api.txt
new file mode 100644
index 0000000..e58430c
--- /dev/null
+++ b/doc/alert-api.txt
@@ -0,0 +1,109 @@
+BlueZ D-Bus Alert API description
+*********************************
+
+Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT
+
+Introduction
+------------
+
+Currently, there are two different GATT server profiles that depend on
+receiving alerts or notifications from the platform: Phone Alert Status (PASP)
+and Alert Notification (ANP). PASP is very specific to mobile phones, and also
+allows limited control to alerts (i.e. mute once or switch to a silent mode).
+
+This document presents a unified API that allows to register and notify alerts,
+and to control some alerts (using the provided agent object).
+
+
+Alert hierarchy
+===============
+
+Service org.bluez
+Interface org.bluez.Alert
+Object path /org/bluez
+
+Methods void RegisterAlert(string category, object agent)
+
+ Register a new alert category and an agent for it. This
+ means the application will be responsible for notifying
+ BlueZ of any alerts of that category, using the
+ NewAlert() method.
+
+ Supported ANP categories: simple, email, news, call,
+ missed_call, sms_mms, voice_mail, schedule,
+ high_priority, instant_message
+ Supported PASP categories: ringer, vibrate, display
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void NewAlert(string category, uint16 count, string description)
+
+ Notify BlueZ of new alert(s) for the given category. The
+ description is relative to the last received alert and
+ can be sender name, caller ID, title, or other
+ information specific to the category.
+
+ For ringer, vibrate and display categories, valid
+ descriptions are "active" and "not active". Alerts from
+ ringer category also accept "enabled" and "disabled",
+ depending on whether ringer is in silent mode or not.
+
+ Description must not exceed 18 bytes when encoded in
+ UTF-8 format, otherwise an error is returned. If there
+ is no description, an empty string should be used.
+
+ The count argument contains the number of alerts not
+ yet acknowledged by the user on the UI. To save D-Bus
+ traffic, events that may generate multiple alerts at
+ the same time (like email, sms, news) should trigger a
+ single NewAlert().
+
+ If there are more than 254 new alerts, count must be
+ set to 255. PASP alerts should always set count to 1.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void UnreadAlert(string category, uint16 count)
+
+ Some services (like SMS and e-mail) keep track of
+ number of unread items. This method allows to update
+ this counter, so peer devices can be notified using
+ Alert Notification Profile.
+
+ If there are more than 254 unread alerts, count must be
+ set to 255.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+Alert Agent hierarchy
+=====================
+
+Service org.bluez
+Interface org.bluez.AlertAgent
+Object path freely definable
+
+Methods void MuteOnce()
+
+ This method is only called if "ringer" alert category
+ is specified when registering the agent.
+
+ Mute the ringer once (e.g. during a incoming call). If
+ ringer is not active, does nothing.
+
+ void SetRinger(string mode)
+
+ This method is only called if "ringer" alert category
+ is specified when registering the agent.
+
+ Set ringer to the specified mode. If mode is "enabled",
+ ringer is set to the default mode, as defined by the
+ current active profile. If mode is "disabled", ringer
+ will not activate on incoming calls, until it is set
+ back to "enabled" mode.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void Release()
+
+ Release this agent. At this point, it will not be used
+ by BlueZ anymore and can be destroyed by the owner.
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 02/27] alert: Introduce manager abstraction layer
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 01/27] doc: Introduce Alert API Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 03/27] alert: Initial profile registration Anderson Lizardo
` (25 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This abstraction layer makes the GATT Phone Alert Status and Alert
Notification implementation consistent with other GATT profiles.
---
Makefile.am | 3 ++-
profiles/alert/main.c | 6 +++---
profiles/alert/manager.c | 40 ++++++++++++++++++++++++++++++++++++++++
profiles/alert/manager.h | 26 ++++++++++++++++++++++++++
4 files changed, 71 insertions(+), 4 deletions(-)
create mode 100644 profiles/alert/manager.c
create mode 100644 profiles/alert/manager.h
diff --git a/Makefile.am b/Makefile.am
index a42544d..e86bd4d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -218,7 +218,8 @@ builtin_sources += profiles/thermometer/main.c \
profiles/thermometer/thermometer.h \
profiles/thermometer/thermometer.c \
profiles/alert/main.c profiles/alert/server.h \
- profiles/alert/server.c \
+ profiles/alert/server.c profiles/alert/manager.h \
+ profiles/alert/manager.c \
profiles/time/main.c profiles/time/server.h \
profiles/time/server.c profiles/time/manager.c \
profiles/time/manager.h \
diff --git a/profiles/alert/main.c b/profiles/alert/main.c
index ec4ab6d..5e6910a 100644
--- a/profiles/alert/main.c
+++ b/profiles/alert/main.c
@@ -33,7 +33,7 @@
#include "plugin.h"
#include "hcid.h"
#include "log.h"
-#include "server.h"
+#include "manager.h"
static int alert_init(void)
{
@@ -42,7 +42,7 @@ static int alert_init(void)
return -ENOTSUP;
}
- return alert_server_init();
+ return alert_manager_init();
}
static void alert_exit(void)
@@ -50,7 +50,7 @@ static void alert_exit(void)
if (!main_opts.gatt_enabled)
return;
- alert_server_exit();
+ alert_manager_exit();
}
BLUETOOTH_PLUGIN_DEFINE(alert, VERSION,
diff --git a/profiles/alert/manager.c b/profiles/alert/manager.c
new file mode 100644
index 0000000..eb2d627
--- /dev/null
+++ b/profiles/alert/manager.c
@@ -0,0 +1,40 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Nokia Corporation
+ * Copyright (C) 2012 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * 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 "manager.h"
+#include "server.h"
+
+int alert_manager_init(void)
+{
+ return alert_server_init();
+}
+
+void alert_manager_exit(void)
+{
+ alert_server_exit();
+}
diff --git a/profiles/alert/manager.h b/profiles/alert/manager.h
new file mode 100644
index 0000000..e4c6bd0
--- /dev/null
+++ b/profiles/alert/manager.h
@@ -0,0 +1,26 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Nokia Corporation
+ * Copyright (C) 2012 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * 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 alert_manager_init(void);
+void alert_manager_exit(void);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 03/27] alert: Initial profile registration
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 01/27] doc: Introduce Alert API Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 02/27] alert: Introduce manager abstraction layer Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 04/27] alert: Add Phone Alert Status Service Anderson Lizardo
` (24 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
---
profiles/alert/server.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index d91b156..dc844d3 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -26,13 +26,37 @@
#include <config.h>
#endif
+#include <stdbool.h>
+
+#include "adapter.h"
#include "server.h"
+#include "profile.h"
+
+static int alert_server_probe(struct btd_profile *p,
+ struct btd_adapter *adapter)
+{
+ return 0;
+}
+
+static void alert_server_remove(struct btd_profile *p,
+ struct btd_adapter *adapter)
+{
+}
+
+static struct btd_profile alert_profile = {
+ .name = "gatt-alert-server",
+ .adapter_probe = alert_server_probe,
+ .adapter_remove = alert_server_remove,
+};
int alert_server_init(void)
{
+ btd_profile_register(&alert_profile);
+
return 0;
}
void alert_server_exit(void)
{
+ btd_profile_unregister(&alert_profile);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 04/27] alert: Add Phone Alert Status Service
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (2 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 03/27] alert: Initial profile registration Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 05/27] alert: Add Ringer Control Point characteristic Anderson Lizardo
` (23 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
From: Bruna Moreira <bruna.moreira@openbossa.org>
Add Phone Alert Status service for PASP.
---
profiles/alert/server.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index dc844d3..b39ef8a 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -27,14 +27,35 @@
#endif
#include <stdbool.h>
+#include <glib.h>
+#include <bluetooth/uuid.h>
+#include "att.h"
#include "adapter.h"
+#include "gatt-service.h"
+#include "gattrib.h"
+#include "gatt.h"
#include "server.h"
#include "profile.h"
+#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
+
+static void register_phone_alert_service(struct btd_adapter *adapter)
+{
+ bt_uuid_t uuid;
+
+ bt_uuid16_create(&uuid, PHONE_ALERT_STATUS_SVC_UUID);
+
+ /* Phone Alert Status Service */
+ gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ GATT_OPT_INVALID);
+}
+
static int alert_server_probe(struct btd_profile *p,
struct btd_adapter *adapter)
{
+ register_phone_alert_service(adapter);
+
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 05/27] alert: Add Ringer Control Point characteristic
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (3 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 04/27] alert: Add Phone Alert Status Service Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 06/27] alert: Add Ringer Setting characteristic Anderson Lizardo
` (22 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
From: Bruna Moreira <bruna.moreira@openbossa.org>
Ringer CP characteristic is used for configuring "silent mode" or muting
the ringer once.
---
profiles/alert/server.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index b39ef8a..8337c38 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -32,6 +32,9 @@
#include "att.h"
#include "adapter.h"
+#include "device.h"
+#include "att-database.h"
+#include "log.h"
#include "gatt-service.h"
#include "gattrib.h"
#include "gatt.h"
@@ -39,6 +42,16 @@
#include "profile.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
+#define RINGER_CP_CHR_UUID 0x2A40
+
+static uint8_t ringer_cp_write(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ DBG("a = %p", a);
+
+ return 0;
+}
static void register_phone_alert_service(struct btd_adapter *adapter)
{
@@ -48,6 +61,11 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
/* Phone Alert Status Service */
gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ /* Ringer Control Point characteristic */
+ GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
+ ringer_cp_write, NULL,
GATT_OPT_INVALID);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 06/27] alert: Add Ringer Setting characteristic
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (4 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 05/27] alert: Add Ringer Control Point characteristic Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 07/27] alert: Add Alert Status characteristic Anderson Lizardo
` (21 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
From: Bruna Moreira <bruna.moreira@openbossa.org>
This characteristic allows to read or notify the ringer mode (silent or
normal).
---
profiles/alert/server.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 8337c38..59e6fdc 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -37,12 +37,22 @@
#include "log.h"
#include "gatt-service.h"
#include "gattrib.h"
+#include "attrib-server.h"
#include "gatt.h"
#include "server.h"
#include "profile.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
#define RINGER_CP_CHR_UUID 0x2A40
+#define RINGER_SETTING_CHR_UUID 0x2A41
+
+/* Ringer Setting characteristic values */
+enum {
+ RINGER_SILENT,
+ RINGER_NORMAL,
+};
+
+static uint8_t ringer_setting = RINGER_NORMAL;
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
@@ -53,6 +63,21 @@ static uint8_t ringer_cp_write(struct attribute *a,
return 0;
}
+static uint8_t ringer_setting_read(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ struct btd_adapter *adapter = user_data;
+
+ DBG("a = %p", a);
+
+ if (a->data == NULL || a->data[0] != ringer_setting)
+ attrib_db_update(adapter, a->handle, NULL, &ringer_setting,
+ sizeof(ringer_setting), NULL);
+
+ return 0;
+}
+
static void register_phone_alert_service(struct btd_adapter *adapter)
{
bt_uuid_t uuid;
@@ -66,6 +91,12 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
ringer_cp_write, NULL,
+ /* Ringer Setting characteristic */
+ GATT_OPT_CHR_UUID, RINGER_SETTING_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
+ ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+ ringer_setting_read, adapter,
GATT_OPT_INVALID);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 07/27] alert: Add Alert Status characteristic
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (5 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 06/27] alert: Add Ringer Setting characteristic Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 08/27] alert: Initial Alert Notification Anderson Lizardo
` (20 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
From: Bruna Moreira <bruna.moreira@openbossa.org>
This characteristic allows to read/notify the status of the ringer,
display and vibration motor.
---
profiles/alert/server.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 59e6fdc..90536d5 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -43,6 +43,8 @@
#include "profile.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
+
+#define ALERT_STATUS_CHR_UUID 0x2A3F
#define RINGER_CP_CHR_UUID 0x2A40
#define RINGER_SETTING_CHR_UUID 0x2A41
@@ -53,6 +55,7 @@ enum {
};
static uint8_t ringer_setting = RINGER_NORMAL;
+static uint8_t alert_status = 0;
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
@@ -63,6 +66,21 @@ static uint8_t ringer_cp_write(struct attribute *a,
return 0;
}
+static uint8_t alert_status_read(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ struct btd_adapter *adapter = user_data;
+
+ DBG("a = %p", a);
+
+ if (a->data == NULL || a->data[0] != alert_status)
+ attrib_db_update(adapter, a->handle, NULL, &alert_status,
+ sizeof(alert_status), NULL);
+
+ return 0;
+}
+
static uint8_t ringer_setting_read(struct attribute *a,
struct btd_device *device,
gpointer user_data)
@@ -86,6 +104,12 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
/* Phone Alert Status Service */
gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ /* Alert Status characteristic */
+ GATT_OPT_CHR_UUID, ALERT_STATUS_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
+ ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+ alert_status_read, adapter,
/* Ringer Control Point characteristic */
GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 08/27] alert: Initial Alert Notification
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (6 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 07/27] alert: Add Alert Status characteristic Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 09/27] alert: Implement category registration in RegisterAlert() Anderson Lizardo
` (19 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Initial implementation for Alert Notification Profile (ANP).
---
profiles/alert/server.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 154 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 90536d5..c0434a4 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -27,9 +27,12 @@
#endif
#include <stdbool.h>
+#include <errno.h>
+#include <gdbus.h>
#include <glib.h>
#include <bluetooth/uuid.h>
+#include "dbus-common.h"
#include "att.h"
#include "adapter.h"
#include "device.h"
@@ -41,13 +44,33 @@
#include "gatt.h"
#include "server.h"
#include "profile.h"
+#include "error.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
+#define ALERT_NOTIF_SVC_UUID 0x1811
#define ALERT_STATUS_CHR_UUID 0x2A3F
#define RINGER_CP_CHR_UUID 0x2A40
#define RINGER_SETTING_CHR_UUID 0x2A41
+#define ALERT_NOTIF_CP_CHR_UUID 0x2A44
+#define UNREAD_ALERT_CHR_UUID 0x2A45
+#define NEW_ALERT_CHR_UUID 0x2A46
+#define SUPP_NEW_ALERT_CAT_CHR_UUID 0x2A47
+#define SUPP_UNREAD_ALERT_CAT_CHR_UUID 0x2A48
+
+#define ALERT_OBJECT_PATH "/org/bluez"
+#define ALERT_INTERFACE "org.bluez.Alert"
+
+enum {
+ ENABLE_NEW_INCOMING,
+ ENABLE_UNREAD_CAT,
+ DISABLE_NEW_INCOMING,
+ DISABLE_UNREAD_CAT,
+ NOTIFY_NEW_INCOMING,
+ NOTIFY_UNREAD_CAT,
+};
+
/* Ringer Setting characteristic values */
enum {
RINGER_SILENT,
@@ -57,6 +80,20 @@ enum {
static uint8_t ringer_setting = RINGER_NORMAL;
static uint8_t alert_status = 0;
+static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ const char *category;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
+ DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+
+ DBG("RegisterAlert: %s", category);
+
+ return dbus_message_new_method_return(msg);
+}
+
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
gpointer user_data)
@@ -124,10 +161,107 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
GATT_OPT_INVALID);
}
+static uint8_t supp_new_alert_cat_read(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ struct btd_adapter *adapter = user_data;
+ uint8_t value[] = {0x00, 0x00};
+
+ DBG("a = %p", a);
+
+ if (a->data == NULL)
+ attrib_db_update(adapter, a->handle, NULL, value, sizeof(value),
+ NULL);
+
+ return 0;
+}
+
+static uint8_t supp_unread_alert_cat_read(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ struct btd_adapter *adapter = user_data;
+ uint8_t value[] = {0x00, 0x00};
+
+ DBG("a = %p", a);
+
+ if (a->data == NULL)
+ attrib_db_update(adapter, a->handle, NULL, value, sizeof(value),
+ NULL);
+
+ return 0;
+}
+
+static uint8_t alert_notif_cp_write(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ DBG("a = %p", a);
+
+ switch (a->data[0]) {
+ case ENABLE_NEW_INCOMING:
+ DBG("ENABLE_NEW_INCOMING: 0x%02x", a->data[1]);
+ break;
+ case ENABLE_UNREAD_CAT:
+ DBG("ENABLE_UNREAD_CAT: 0x%02x", a->data[1]);
+ break;
+ case DISABLE_NEW_INCOMING:
+ DBG("DISABLE_NEW_INCOMING: 0x%02x", a->data[1]);
+ break;
+ case DISABLE_UNREAD_CAT:
+ DBG("DISABLE_UNREAD_CAT: 0x%02x", a->data[1]);
+ break;
+ case NOTIFY_NEW_INCOMING:
+ DBG("NOTIFY_NEW_INCOMING: 0x%02x", a->data[1]);
+ break;
+ case NOTIFY_UNREAD_CAT:
+ DBG("NOTIFY_UNREAD_CAT: 0x%02x", a->data[1]);
+ break;
+ default:
+ DBG("0x%02x 0x%02x", a->data[0], a->data[1]);
+ }
+
+ return 0;
+}
+
+static void register_alert_notif_service(struct btd_adapter *adapter)
+{
+ bt_uuid_t uuid;
+
+ bt_uuid16_create(&uuid, ALERT_NOTIF_SVC_UUID);
+
+ /* Alert Notification Service */
+ gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ /* Supported New Alert Category */
+ GATT_OPT_CHR_UUID, SUPP_NEW_ALERT_CAT_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+ supp_new_alert_cat_read, adapter,
+ /* New Alert */
+ GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ /* Supported Unread Alert Category */
+ GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+ supp_unread_alert_cat_read, adapter,
+ /* Unread Alert Status */
+ GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ /* Alert Notification Control Point */
+ GATT_OPT_CHR_UUID, ALERT_NOTIF_CP_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
+ alert_notif_cp_write, NULL,
+ GATT_OPT_INVALID);
+}
+
static int alert_server_probe(struct btd_profile *p,
struct btd_adapter *adapter)
{
register_phone_alert_service(adapter);
+ register_alert_notif_service(adapter);
return 0;
}
@@ -143,8 +277,25 @@ static struct btd_profile alert_profile = {
.adapter_remove = alert_server_remove,
};
+static const GDBusMethodTable alert_methods[] = {
+ { GDBUS_METHOD("RegisterAlert",
+ GDBUS_ARGS({ "category", "s" },
+ { "agent", "o" }), NULL,
+ register_alert) },
+ { }
+};
+
int alert_server_init(void)
{
+ if (!g_dbus_register_interface(btd_get_dbus_connection(),
+ ALERT_OBJECT_PATH, ALERT_INTERFACE,
+ alert_methods, NULL, NULL, NULL,
+ NULL)) {
+ error("D-Bus failed to register %s interface",
+ ALERT_INTERFACE);
+ return -EIO;
+ }
+
btd_profile_register(&alert_profile);
return 0;
@@ -153,4 +304,7 @@ int alert_server_init(void)
void alert_server_exit(void)
{
btd_profile_unregister(&alert_profile);
+
+ g_dbus_unregister_interface(btd_get_dbus_connection(),
+ ALERT_OBJECT_PATH, ALERT_INTERFACE);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 09/27] alert: Implement category registration in RegisterAlert()
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (7 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 08/27] alert: Initial Alert Notification Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 10/27] alert: Add initial support for NewAlert D-Bus method Anderson Lizardo
` (18 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
The given alert category is now validated and registered.
---
profiles/alert/server.c | 102 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 98 insertions(+), 4 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index c0434a4..2c7373c 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -77,19 +77,113 @@ enum {
RINGER_NORMAL,
};
+struct alert_data {
+ const char *category;
+ char *srv;
+ char *path;
+};
+
+static GSList *registered_alerts = NULL;
static uint8_t ringer_setting = RINGER_NORMAL;
static uint8_t alert_status = 0;
+static const char *anp_categories[] = {
+ "simple",
+ "email",
+ "news",
+ "call",
+ "missed_call",
+ "sms_mms",
+ "voice_mail",
+ "schedule",
+ "high_priority",
+ "instant_message",
+};
+
+static const char *pasp_categories[] = {
+ "ringer",
+ "vibrate",
+ "display",
+};
+
+static void alert_data_destroy(gpointer user_data)
+{
+ struct alert_data *alert = user_data;
+
+ g_free(alert->srv);
+ g_free(alert->path);
+ g_free(alert);
+}
+
+static void alert_destroy(gpointer user_data)
+{
+ g_slist_free_full(registered_alerts, alert_data_destroy);
+ registered_alerts = NULL;
+}
+
+static const char *valid_category(const char *category)
+{
+ unsigned i;
+
+ for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+ if (g_str_equal(anp_categories[i], category))
+ return anp_categories[i];
+ }
+
+ for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
+ if (g_str_equal(pasp_categories[i], category))
+ return pasp_categories[i];
+ }
+
+ return NULL;
+}
+
+static gboolean registered_category(const char *category)
+{
+ GSList *l;
+ struct alert_data *alert;
+
+ for (l = registered_alerts; l; l = g_slist_next(l)) {
+ alert = l->data;
+ if (g_str_equal(alert->category, category))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
+ const char *sender = dbus_message_get_sender(msg);
+ char *path;
const char *category;
+ const char *c;
+ struct alert_data *alert;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &c,
+ DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
- if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
- DBUS_TYPE_INVALID))
+ category = valid_category(c);
+ if (!category) {
+ DBG("Invalid category: %s", c);
return btd_error_invalid_args(msg);
+ }
+
+ if (registered_category(category)) {
+ DBG("Category %s already registered", category);
+ return dbus_message_new_method_return(msg);
+ }
+
+ alert = g_new0(struct alert_data, 1);
+ alert->srv = g_strdup(sender);
+ alert->path = g_strdup(path);
+ alert->category = category;
+
+ registered_alerts = g_slist_append(registered_alerts, alert);
- DBG("RegisterAlert: %s", category);
+ DBG("RegisterAlert(\"%s\", \"%s\")", alert->category, alert->path);
return dbus_message_new_method_return(msg);
}
@@ -290,7 +384,7 @@ int alert_server_init(void)
if (!g_dbus_register_interface(btd_get_dbus_connection(),
ALERT_OBJECT_PATH, ALERT_INTERFACE,
alert_methods, NULL, NULL, NULL,
- NULL)) {
+ alert_destroy)) {
error("D-Bus failed to register %s interface",
ALERT_INTERFACE);
return -EIO;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 10/27] alert: Add initial support for NewAlert D-Bus method
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (8 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 09/27] alert: Implement category registration in RegisterAlert() Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 11/27] alert: Add initial support for UnreadAlert " Anderson Lizardo
` (17 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
NewAlert() is used for notifying BlueZ of new alert(s) for the given
category.
---
profiles/alert/server.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 105 insertions(+), 1 deletion(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 2c7373c..ce8404c 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -62,6 +62,9 @@
#define ALERT_OBJECT_PATH "/org/bluez"
#define ALERT_INTERFACE "org.bluez.Alert"
+/* Maximum length for "Text String Information" */
+#define NEW_ALERT_MAX_INFO_SIZE 18
+
enum {
ENABLE_NEW_INCOMING,
ENABLE_UNREAD_CAT,
@@ -138,7 +141,7 @@ static const char *valid_category(const char *category)
return NULL;
}
-static gboolean registered_category(const char *category)
+static struct alert_data *get_alert_data_by_category(const char *category)
{
GSList *l;
struct alert_data *alert;
@@ -146,9 +149,64 @@ static gboolean registered_category(const char *category)
for (l = registered_alerts; l; l = g_slist_next(l)) {
alert = l->data;
if (g_str_equal(alert->category, category))
+ return alert;
+ }
+
+ return NULL;
+}
+
+static gboolean registered_category(const char *category)
+{
+ struct alert_data *alert;
+
+ alert = get_alert_data_by_category(category);
+ if (alert)
+ return TRUE;
+
+ return FALSE;
+}
+
+static gboolean pasp_category(const char *category)
+{
+ unsigned i;
+
+ for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++)
+ if (g_str_equal(category, pasp_categories[i]))
return TRUE;
+
+ return FALSE;
+}
+
+static gboolean valid_description(const char *category,
+ const char *description)
+{
+ if (!pasp_category(category)) {
+ if (strlen(description) >= NEW_ALERT_MAX_INFO_SIZE)
+ return FALSE;
+
+ return TRUE;
}
+ if (g_str_equal(description, "active") ||
+ g_str_equal(description, "not active"))
+ return TRUE;
+
+ if (g_str_equal(category, "ringer"))
+ if (g_str_equal(description, "enabled") ||
+ g_str_equal(description, "disabled"))
+ return TRUE;
+
+ return FALSE;
+}
+
+static gboolean valid_count(const char *category, uint16_t count)
+{
+ if (!pasp_category(category) && count > 0 && count <= 255)
+ return TRUE;
+
+ if (pasp_category(category) && count == 1)
+ return TRUE;
+
return FALSE;
}
@@ -188,6 +246,47 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ const char *sender = dbus_message_get_sender(msg);
+ const char *category, *description;
+ struct alert_data *alert;
+ uint16_t count;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
+ DBUS_TYPE_UINT16, &count, DBUS_TYPE_STRING,
+ &description, DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+
+ alert = get_alert_data_by_category(category);
+ if (!alert) {
+ DBG("Category %s not registered", category);
+ return btd_error_invalid_args(msg);
+ }
+
+ if (!g_str_equal(alert->srv, sender)) {
+ DBG("Sender %s is not registered in category %s", sender,
+ category);
+ return btd_error_invalid_args(msg);
+ }
+
+ if (!valid_description(category, description)) {
+ DBG("Description %s is invalid for %s category",
+ description, category);
+ return btd_error_invalid_args(msg);
+ }
+
+ if (!valid_count(category, count)) {
+ DBG("Count %d is invalid for %s category", count, category);
+ return btd_error_invalid_args(msg);
+ }
+
+ DBG("NewAlert(\"%s\", %d, \"%s\")", category, count, description);
+
+ return dbus_message_new_method_return(msg);
+}
+
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
gpointer user_data)
@@ -376,6 +475,11 @@ static const GDBusMethodTable alert_methods[] = {
GDBUS_ARGS({ "category", "s" },
{ "agent", "o" }), NULL,
register_alert) },
+ { GDBUS_METHOD("NewAlert",
+ GDBUS_ARGS({ "category", "s" },
+ { "count", "q" },
+ { "description", "s" }), NULL,
+ new_alert) },
{ }
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 11/27] alert: Add initial support for UnreadAlert D-Bus method
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (9 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 10/27] alert: Add initial support for NewAlert D-Bus method Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 12/27] alert: Automatically unregister alert when agent leaves D-Bus Anderson Lizardo
` (16 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This method is used for updating the "unread" counter for categories
that support it.
---
profiles/alert/server.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index ce8404c..e7eb38f 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -287,6 +287,36 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ const char *sender = dbus_message_get_sender(msg);
+ struct alert_data *alert;
+ const char *category;
+ uint16_t count;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
+ DBUS_TYPE_UINT16, &count,
+ DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+
+ alert = get_alert_data_by_category(category);
+ if (!alert) {
+ DBG("Category %s not registered", category);
+ return btd_error_invalid_args(msg);
+ }
+
+ if (!g_str_equal(alert->srv, sender)) {
+ DBG("Sender %s is not registered in category %s", sender,
+ category);
+ return btd_error_invalid_args(msg);
+ }
+
+ DBG("category %s, count %d", category, count);
+
+ return dbus_message_new_method_return(msg);
+}
+
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
gpointer user_data)
@@ -480,6 +510,9 @@ static const GDBusMethodTable alert_methods[] = {
{ "count", "q" },
{ "description", "s" }), NULL,
new_alert) },
+ { GDBUS_METHOD("UnreadAlert",
+ GDBUS_ARGS({ "category", "s" }, { "count", "q" }), NULL,
+ unread_alert) },
{ }
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 12/27] alert: Automatically unregister alert when agent leaves D-Bus
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (10 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 11/27] alert: Add initial support for UnreadAlert " Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 13/27] alert: Add per adapter attribute handle information Anderson Lizardo
` (15 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
---
profiles/alert/server.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index e7eb38f..465496c 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -84,6 +84,7 @@ struct alert_data {
const char *category;
char *srv;
char *path;
+ guint watcher;
};
static GSList *registered_alerts = NULL;
@@ -113,6 +114,9 @@ static void alert_data_destroy(gpointer user_data)
{
struct alert_data *alert = user_data;
+ if (alert->watcher)
+ g_dbus_remove_watch(btd_get_dbus_connection(), alert->watcher);
+
g_free(alert->srv);
g_free(alert->path);
g_free(alert);
@@ -210,6 +214,16 @@ static gboolean valid_count(const char *category, uint16_t count)
return FALSE;
}
+static void watcher_disconnect(DBusConnection *conn, void *user_data)
+{
+ struct alert_data *alert = user_data;
+
+ DBG("Category %s was disconnected", alert->category);
+
+ registered_alerts = g_slist_remove(registered_alerts, alert);
+ alert_data_destroy(alert);
+}
+
static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -238,6 +252,15 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
alert->srv = g_strdup(sender);
alert->path = g_strdup(path);
alert->category = category;
+ alert->watcher = g_dbus_add_disconnect_watch(conn, alert->srv,
+ watcher_disconnect, alert, NULL);
+
+ if (alert->watcher == 0) {
+ alert_data_destroy(alert);
+ DBG("Could not register disconnect watcher");
+ return btd_error_failed(msg,
+ "Could not register disconnect watcher");
+ }
registered_alerts = g_slist_append(registered_alerts, alert);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 13/27] alert: Add per adapter attribute handle information
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (11 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 12/27] alert: Automatically unregister alert when agent leaves D-Bus Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 14/27] alert: Update Supported New/Unread Category characteristic values Anderson Lizardo
` (14 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Each adapter may have different GATT services running, therefore any
attribute handles (e.g. for updating characteristic values) need to be
saved per adapter.
---
profiles/alert/server.c | 57 ++++++++++++++++++++++++++++++++++++++---------
1 file changed, 47 insertions(+), 10 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 465496c..9288ffe 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -87,7 +87,13 @@ struct alert_data {
guint watcher;
};
+struct alert_adapter {
+ struct btd_adapter *adapter;
+ /* TODO: store characteristic value handles */
+};
+
static GSList *registered_alerts = NULL;
+static GSList *alert_adapters = NULL;
static uint8_t ringer_setting = RINGER_NORMAL;
static uint8_t alert_status = 0;
@@ -110,6 +116,21 @@ static const char *pasp_categories[] = {
"display",
};
+static int adapter_cmp(gconstpointer a, gconstpointer b)
+{
+ const struct alert_adapter *al_adapter = a;
+ const struct btd_adapter *adapter = b;
+
+ return (al_adapter->adapter == adapter ? 0 : -1);
+}
+
+static struct alert_adapter *find_alert_adapter(struct btd_adapter *adapter)
+{
+ GSList *l = g_slist_find_custom(alert_adapters, adapter, adapter_cmp);
+
+ return (l ? l->data : NULL);
+}
+
static void alert_data_destroy(gpointer user_data)
{
struct alert_data *alert = user_data;
@@ -379,20 +400,20 @@ static uint8_t ringer_setting_read(struct attribute *a,
return 0;
}
-static void register_phone_alert_service(struct btd_adapter *adapter)
+static void register_phone_alert_service(struct alert_adapter *al_adapter)
{
bt_uuid_t uuid;
bt_uuid16_create(&uuid, PHONE_ALERT_STATUS_SVC_UUID);
/* Phone Alert Status Service */
- gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ gatt_service_add(al_adapter->adapter, GATT_PRIM_SVC_UUID, &uuid,
/* Alert Status characteristic */
GATT_OPT_CHR_UUID, ALERT_STATUS_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
- alert_status_read, adapter,
+ alert_status_read, al_adapter->adapter,
/* Ringer Control Point characteristic */
GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
@@ -403,7 +424,7 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
- ringer_setting_read, adapter,
+ ringer_setting_read, al_adapter->adapter,
GATT_OPT_INVALID);
}
@@ -471,19 +492,19 @@ static uint8_t alert_notif_cp_write(struct attribute *a,
return 0;
}
-static void register_alert_notif_service(struct btd_adapter *adapter)
+static void register_alert_notif_service(struct alert_adapter *al_adapter)
{
bt_uuid_t uuid;
bt_uuid16_create(&uuid, ALERT_NOTIF_SVC_UUID);
/* Alert Notification Service */
- gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ gatt_service_add(al_adapter->adapter, GATT_PRIM_SVC_UUID, &uuid,
/* Supported New Alert Category */
GATT_OPT_CHR_UUID, SUPP_NEW_ALERT_CAT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
- supp_new_alert_cat_read, adapter,
+ supp_new_alert_cat_read, al_adapter->adapter,
/* New Alert */
GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
@@ -491,7 +512,7 @@ static void register_alert_notif_service(struct btd_adapter *adapter)
GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
- supp_unread_alert_cat_read, adapter,
+ supp_unread_alert_cat_read, al_adapter->adapter,
/* Unread Alert Status */
GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
@@ -506,8 +527,15 @@ static void register_alert_notif_service(struct btd_adapter *adapter)
static int alert_server_probe(struct btd_profile *p,
struct btd_adapter *adapter)
{
- register_phone_alert_service(adapter);
- register_alert_notif_service(adapter);
+ struct alert_adapter *al_adapter;
+
+ al_adapter = g_new0(struct alert_adapter, 1);
+ al_adapter->adapter = btd_adapter_ref(adapter);
+
+ alert_adapters = g_slist_append(alert_adapters, al_adapter);
+
+ register_phone_alert_service(al_adapter);
+ register_alert_notif_service(al_adapter);
return 0;
}
@@ -515,6 +543,15 @@ static int alert_server_probe(struct btd_profile *p,
static void alert_server_remove(struct btd_profile *p,
struct btd_adapter *adapter)
{
+ struct alert_adapter *al_adapter;
+
+ al_adapter = find_alert_adapter(adapter);
+ if (!al_adapter)
+ return;
+
+ alert_adapters = g_slist_remove(alert_adapters, al_adapter);
+ btd_adapter_unref(al_adapter->adapter);
+ g_free(al_adapter);
}
static struct btd_profile alert_profile = {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 14/27] alert: Update Supported New/Unread Category characteristic values
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (12 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 13/27] alert: Add per adapter attribute handle information Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 15/27] alert: Update new alert characteristic value Anderson Lizardo
` (13 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
The value is now kept up-to-date when new/unread alerts arrive. This
value is not notified yet.
---
profiles/alert/server.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 9288ffe..f38761b 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -89,7 +89,8 @@ struct alert_data {
struct alert_adapter {
struct btd_adapter *adapter;
- /* TODO: store characteristic value handles */
+ uint16_t supp_new_alert_cat_handle;
+ uint16_t supp_unread_alert_cat_handle;
};
static GSList *registered_alerts = NULL;
@@ -235,6 +236,29 @@ static gboolean valid_count(const char *category, uint16_t count)
return FALSE;
}
+static void update_supported_categories(gpointer data, gpointer user_data)
+{
+ struct alert_adapter *al_adapter = data;
+ struct btd_adapter *adapter = al_adapter->adapter;
+ uint8_t value[2];
+ unsigned int i;
+
+ memset(value, 0, sizeof(value));
+
+ for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+ if (registered_category(anp_categories[i]))
+ hci_set_bit(i, value);
+ }
+
+ attrib_db_update(adapter, al_adapter->supp_new_alert_cat_handle, NULL,
+ value, sizeof(value), NULL);
+
+ /* FIXME: For now report all registered categories as supporting unread
+ * status, until it is known which ones should be supported */
+ attrib_db_update(adapter, al_adapter->supp_unread_alert_cat_handle,
+ NULL, value, sizeof(value), NULL);
+}
+
static void watcher_disconnect(DBusConnection *conn, void *user_data)
{
struct alert_data *alert = user_data;
@@ -243,6 +267,8 @@ static void watcher_disconnect(DBusConnection *conn, void *user_data)
registered_alerts = g_slist_remove(registered_alerts, alert);
alert_data_destroy(alert);
+
+ g_slist_foreach(alert_adapters, update_supported_categories, NULL);
}
static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
@@ -285,6 +311,8 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
registered_alerts = g_slist_append(registered_alerts, alert);
+ g_slist_foreach(alert_adapters, update_supported_categories, NULL);
+
DBG("RegisterAlert(\"%s\", \"%s\")", alert->category, alert->path);
return dbus_message_new_method_return(msg);
@@ -505,6 +533,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
supp_new_alert_cat_read, al_adapter->adapter,
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->supp_new_alert_cat_handle,
/* New Alert */
GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
@@ -513,6 +543,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
supp_unread_alert_cat_read, al_adapter->adapter,
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->supp_unread_alert_cat_handle,
/* Unread Alert Status */
GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 15/27] alert: Update new alert characteristic value
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (13 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 14/27] alert: Update Supported New/Unread Category characteristic values Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 16/27] alert: Update unread " Anderson Lizardo
` (12 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Update the attribute value when a new alert is reported to BlueZ.
---
profiles/alert/server.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index f38761b..49cf530 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -64,6 +64,8 @@
/* Maximum length for "Text String Information" */
#define NEW_ALERT_MAX_INFO_SIZE 18
+/* Maximum length for New Alert Characteristic Value */
+#define NEW_ALERT_CHR_MAX_VALUE_SIZE (NEW_ALERT_MAX_INFO_SIZE + 2)
enum {
ENABLE_NEW_INCOMING,
@@ -91,6 +93,7 @@ struct alert_adapter {
struct btd_adapter *adapter;
uint16_t supp_new_alert_cat_handle;
uint16_t supp_unread_alert_cat_handle;
+ uint16_t new_alert_handle;
};
static GSList *registered_alerts = NULL;
@@ -318,6 +321,16 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static void update_new_alert(gpointer data, gpointer user_data)
+{
+ struct alert_adapter *al_adapter = data;
+ struct btd_adapter *adapter = al_adapter->adapter;
+ uint8_t *value = user_data;
+
+ attrib_db_update(adapter, al_adapter->new_alert_handle, NULL, &value[1],
+ value[0], NULL);
+}
+
static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -325,6 +338,7 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
const char *category, *description;
struct alert_data *alert;
uint16_t count;
+ unsigned int i;
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
DBUS_TYPE_UINT16, &count, DBUS_TYPE_STRING,
@@ -354,6 +368,29 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
return btd_error_invalid_args(msg);
}
+ for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+ if (g_str_equal(anp_categories[i], category)) {
+ uint8_t value[NEW_ALERT_CHR_MAX_VALUE_SIZE + 1];
+ size_t dlen = strlen(description);
+ uint8_t *ptr = value;
+
+ memset(value, 0, sizeof(value));
+
+ *ptr++ = 2; /* Attribute value size */
+ *ptr++ = i; /* Category ID (mandatory) */
+ *ptr++ = count; /* Number of New Alert (mandatory) */
+ /* Text String Information (optional) */
+ strncpy((char *) ptr, description,
+ NEW_ALERT_MAX_INFO_SIZE - 1);
+
+ if (dlen > 0)
+ *value += dlen + 1;
+
+ g_slist_foreach(alert_adapters, update_new_alert,
+ value);
+ }
+ }
+
DBG("NewAlert(\"%s\", %d, \"%s\")", category, count, description);
return dbus_message_new_method_return(msg);
@@ -538,6 +575,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
/* New Alert */
GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->new_alert_handle,
/* Supported Unread Alert Category */
GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 16/27] alert: Update unread alert characteristic value
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (14 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 15/27] alert: Update new alert characteristic value Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 17/27] alert: Implement MuteOnce command Anderson Lizardo
` (11 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Update the attribute value when the unread alert count is changed.
---
profiles/alert/server.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 49cf530..e025cb2 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -94,6 +94,7 @@ struct alert_adapter {
uint16_t supp_new_alert_cat_handle;
uint16_t supp_unread_alert_cat_handle;
uint16_t new_alert_handle;
+ uint16_t unread_alert_handle;
};
static GSList *registered_alerts = NULL;
@@ -396,12 +397,23 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static void update_unread_alert(gpointer data, gpointer user_data)
+{
+ struct alert_adapter *al_adapter = data;
+ struct btd_adapter *adapter = al_adapter->adapter;
+ uint8_t *value = user_data;
+
+ attrib_db_update(adapter, al_adapter->unread_alert_handle, NULL, value,
+ 2, NULL);
+}
+
static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
const char *sender = dbus_message_get_sender(msg);
struct alert_data *alert;
const char *category;
+ unsigned int i;
uint16_t count;
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
@@ -415,12 +427,29 @@ static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
return btd_error_invalid_args(msg);
}
+ if (!valid_count(category, count)) {
+ DBG("Count %d is invalid for %s category", count, category);
+ return btd_error_invalid_args(msg);
+ }
+
if (!g_str_equal(alert->srv, sender)) {
DBG("Sender %s is not registered in category %s", sender,
category);
return btd_error_invalid_args(msg);
}
+ for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+ if (g_str_equal(anp_categories[i], category)) {
+ uint8_t value[2];
+
+ value[0] = i; /* Category ID */
+ value[1] = count; /* Unread count */
+
+ g_slist_foreach(alert_adapters, update_unread_alert,
+ value);
+ }
+ }
+
DBG("category %s, count %d", category, count);
return dbus_message_new_method_return(msg);
@@ -587,6 +616,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
/* Unread Alert Status */
GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->unread_alert_handle,
/* Alert Notification Control Point */
GATT_OPT_CHR_UUID, ALERT_NOTIF_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 17/27] alert: Implement MuteOnce command
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (15 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 16/27] alert: Update unread " Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 18/27] alert: Add support for calling MuteOnce() Anderson Lizardo
` (10 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
MuteOnce() is called by BlueZ to instruct the agent to mute the ringer
during a incoming call.
---
profiles/alert/server.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index e025cb2..64458f4 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -76,6 +76,12 @@ enum {
NOTIFY_UNREAD_CAT,
};
+enum {
+ RINGER_SILENT_MODE = 1,
+ RINGER_MUTE_ONCE,
+ RINGER_CANCEL_SILENT_MODE,
+};
+
/* Ringer Setting characteristic values */
enum {
RINGER_SILENT,
@@ -461,6 +467,25 @@ static uint8_t ringer_cp_write(struct attribute *a,
{
DBG("a = %p", a);
+ if (a->len > 1) {
+ DBG("Invalid command size (%zu)", a->len);
+ return 0;
+ }
+
+ switch (a->data[0]) {
+ case RINGER_SILENT_MODE:
+ DBG("Silent Mode");
+ break;
+ case RINGER_MUTE_ONCE:
+ DBG("Mute Once");
+ break;
+ case RINGER_CANCEL_SILENT_MODE:
+ DBG("Cancel Silent Mode");
+ break;
+ default:
+ DBG("Invalid command (0x%02x)", a->data[0]);
+ }
+
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 18/27] alert: Add support for calling MuteOnce()
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (16 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 17/27] alert: Implement MuteOnce command Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 19/27] alert: Add support for calling SetRinger() Anderson Lizardo
` (9 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When BlueZ wants to call MuteOnce() method from org.bluez.AlertAgent
interface for a registered agent, the function agent_ringer_mute_once()
must be called.
---
profiles/alert/server.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 64458f4..feac7c8 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -61,6 +61,7 @@
#define ALERT_OBJECT_PATH "/org/bluez"
#define ALERT_INTERFACE "org.bluez.Alert"
+#define ALERT_AGENT_INTERFACE "org.bluez.AlertAgent"
/* Maximum length for "Text String Information" */
#define NEW_ALERT_MAX_INFO_SIZE 18
@@ -403,6 +404,28 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static int agent_ringer_mute_once(void)
+{
+ struct alert_data *alert;
+ DBusMessage *msg;
+
+ alert = get_alert_data_by_category("ringer");
+ if (!alert) {
+ DBG("Category ringer is not registered");
+ return -EINVAL;
+ }
+
+ msg = dbus_message_new_method_call(alert->srv, alert->path,
+ ALERT_AGENT_INTERFACE, "MuteOnce");
+ if (!msg)
+ return -ENOMEM;
+
+ dbus_message_set_no_reply(msg, TRUE);
+ g_dbus_send_message(btd_get_dbus_connection(), msg);
+
+ return 0;
+}
+
static void update_unread_alert(gpointer data, gpointer user_data)
{
struct alert_adapter *al_adapter = data;
@@ -478,6 +501,7 @@ static uint8_t ringer_cp_write(struct attribute *a,
break;
case RINGER_MUTE_ONCE:
DBG("Mute Once");
+ agent_ringer_mute_once();
break;
case RINGER_CANCEL_SILENT_MODE:
DBG("Cancel Silent Mode");
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 19/27] alert: Add support for calling SetRinger()
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (17 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 18/27] alert: Add support for calling MuteOnce() Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 20/27] alert: Add test-alert script Anderson Lizardo
` (8 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When BlueZ wants to call SetRinger() method from org.bluez.AlertAgent
interface for a registered agent, the function agent_ringer_set_ringer()
must be called.
---
profiles/alert/server.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index feac7c8..3b74ad8 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -426,6 +426,31 @@ static int agent_ringer_mute_once(void)
return 0;
}
+static int agent_ringer_set_ringer(const char *mode)
+{
+ struct alert_data *alert;
+ DBusMessage *msg;
+
+ alert = get_alert_data_by_category("ringer");
+ if (!alert) {
+ DBG("Category ringer is not registered");
+ return -EINVAL;
+ }
+
+ msg = dbus_message_new_method_call(alert->srv, alert->path,
+ ALERT_AGENT_INTERFACE, "SetRinger");
+ if (!msg)
+ return -ENOMEM;
+
+ dbus_message_append_args(msg, DBUS_TYPE_STRING, &mode,
+ DBUS_TYPE_INVALID);
+
+ dbus_message_set_no_reply(msg, TRUE);
+ g_dbus_send_message(btd_get_dbus_connection(), msg);
+
+ return 0;
+}
+
static void update_unread_alert(gpointer data, gpointer user_data)
{
struct alert_adapter *al_adapter = data;
@@ -498,6 +523,7 @@ static uint8_t ringer_cp_write(struct attribute *a,
switch (a->data[0]) {
case RINGER_SILENT_MODE:
DBG("Silent Mode");
+ agent_ringer_set_ringer("disabled");
break;
case RINGER_MUTE_ONCE:
DBG("Mute Once");
@@ -505,6 +531,7 @@ static uint8_t ringer_cp_write(struct attribute *a,
break;
case RINGER_CANCEL_SILENT_MODE:
DBG("Cancel Silent Mode");
+ agent_ringer_set_ringer("enabled");
break;
default:
DBG("Invalid command (0x%02x)", a->data[0]);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 20/27] alert: Add test-alert script
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (18 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 19/27] alert: Add support for calling SetRinger() Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 21/27] alert: Update Alert Status and Ringer Setting characteristic values Anderson Lizardo
` (7 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
This script is useful for testing the Alert API and testing the
implementation with PTS.
---
Makefile.tools | 3 +-
test/test-alert | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 175 insertions(+), 1 deletion(-)
create mode 100755 test/test-alert
diff --git a/Makefile.tools b/Makefile.tools
index 15fe4e2..b803af5 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -212,4 +212,5 @@ EXTRA_DIST += test/sap_client.py test/hsplay test/hsmicro \
test/test-proximity test/test-thermometer test/test-profile \
test/test-health test/test-health-sink test/service-record.dtd \
test/service-did.xml test/service-spp.xml test/service-opp.xml \
- test/service-ftp.xml test/simple-player test/test-nap
+ test/service-ftp.xml test/simple-player test/test-nap \
+ test/test-alert
diff --git a/test/test-alert b/test/test-alert
new file mode 100755
index 0000000..c92a719
--- /dev/null
+++ b/test/test-alert
@@ -0,0 +1,173 @@
+#!/usr/bin/python
+from __future__ import absolute_import, print_function, unicode_literals
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+import gobject
+import optparse
+import sys
+import os
+
+BUS_NAME = 'org.bluez'
+ALERT_INTERFACE = 'org.bluez.Alert'
+ALERT_AGENT_INTERFACE = 'org.bluez.AlertAgent'
+BLUEZ_OBJECT_PATH = '/org/bluez'
+TEST_OBJECT_PATH = '/org/bluez/test'
+
+class AlertAgent(dbus.service.Object):
+ def __init__(self, bus, object_path, alert):
+ dbus.service.Object.__init__(self, bus, object_path)
+ self.alert = alert
+
+ @dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='',
+ out_signature='')
+ def MuteOnce(self):
+ print('method MuteOnce() was called')
+ self.alert.NewAlert('ringer', 1, 'not active')
+
+ @dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='s',
+ out_signature='')
+ def SetRinger(self, mode):
+ print('method SetRinger(%s) was called' % mode)
+ self.alert.NewAlert('ringer', 1, mode)
+
+def print_command_line(options):
+ if not options.verbose:
+ return False
+
+ print('-w: ' + str(options.wait))
+
+ if options.times:
+ print('-t: ' + str(options.times))
+
+ if options.register:
+ print('-r: ' + options.register)
+ else:
+ print('-r: ' + str(None))
+
+ if options.new_alert:
+ print('-n:')
+ for i in options.new_alert:
+ print(' ' + i[0] + ', ' + i[1] + ', ' + i[2])
+ else:
+ print('-n: ' + str(None))
+
+ if options.unread_alert:
+ print('-u:')
+ for i in options.unread_alert:
+ print(' ' + i[0] + ', ' + i[1])
+ else:
+ print('-u: ' + str(None))
+
+ print()
+
+ return True
+
+def read_count(param):
+ try:
+ return int(param)
+ except ValueError:
+ print('<count> must be integer, not \"%s\"' % param)
+ sys.exit(1)
+
+def new_alert(alert, params):
+ if not params:
+ return False
+
+ for param in params:
+ category = param[0]
+ count = read_count(param[1])
+ description = param[2]
+
+ alert.NewAlert(category, count, description)
+
+def unread_alert(alert, params):
+ if not params:
+ return False
+
+ for param in params:
+ category = param[0]
+ count = read_count(param[1])
+
+ alert.UnreadAlert(category, count)
+
+option_list = [
+ optparse.make_option('-v', None,
+ action = 'store_true',
+ default = False,
+ dest = 'verbose',
+ help = 'verbose'),
+
+ optparse.make_option('-w', None,
+ action = 'store_true',
+ default = False,
+ dest = 'wait',
+ help = 'wait for dbus events'),
+
+ optparse.make_option('-t', None,
+ action = 'store',
+ default = 1,
+ type = "int",
+ dest = 'times',
+ help = 'repeat UnreadAlert/NewAlert <times> times',
+ metavar = '<times>'),
+
+ optparse.make_option('-r', None,
+ action = 'store',
+ dest = 'register',
+ type = 'string',
+ metavar = '<category>',
+ help = 'register alert'),
+
+ optparse.make_option('-n', None,
+ action = 'append',
+ dest = 'new_alert',
+ type = 'string',
+ nargs = 3,
+ metavar = '<category> <count> <description>',
+ help = 'send new alert'),
+
+ optparse.make_option('-u', None,
+ action = 'append',
+ dest = 'unread_alert',
+ type = 'string',
+ nargs = 2,
+ metavar = '<category> <count>',
+ help = 'send unread alert'),
+]
+
+parser = optparse.OptionParser(option_list=option_list)
+parser.disable_interspersed_args()
+(options, args) = parser.parse_args()
+
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+bus = dbus.SystemBus()
+mainloop = gobject.MainLoop()
+alert = dbus.Interface(bus.get_object(BUS_NAME, BLUEZ_OBJECT_PATH),
+ ALERT_INTERFACE)
+alert_agent = AlertAgent(bus, TEST_OBJECT_PATH, alert)
+
+print_command_line(options)
+
+if not (options.register or options.new_alert or options.unread_alert or
+ options.wait):
+ parser.print_usage()
+ sys.exit(1)
+
+if options.register:
+ alert.RegisterAlert(options.register, TEST_OBJECT_PATH)
+
+times = 0
+while times < options.times:
+ times += 1
+
+ new_alert(alert, options.new_alert)
+ unread_alert(alert, options.unread_alert)
+
+if not options.wait:
+ sys.exit(0)
+
+try:
+ mainloop.run()
+except:
+ pass
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 21/27] alert: Update Alert Status and Ringer Setting characteristic values
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (19 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 20/27] alert: Add test-alert script Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 22/27] alert: Add support for ringer setting notification Anderson Lizardo
` (6 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Now these characteristic values are updated when the agent changes any
PASP alert state or setting.
---
profiles/alert/server.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 3b74ad8..bde9056 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -339,6 +339,27 @@ static void update_new_alert(gpointer data, gpointer user_data)
value[0], NULL);
}
+static void update_phone_alerts(const char *category, const char *description)
+{
+ unsigned int i;
+
+ if (g_str_equal(category, "ringer")) {
+ if (g_str_equal(description, "enabled"))
+ ringer_setting = RINGER_NORMAL;
+ else if (g_str_equal(description, "disabled"))
+ ringer_setting = RINGER_SILENT;
+ }
+
+ for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
+ if (g_str_equal(pasp_categories[i], category)) {
+ if (g_str_equal(description, "active"))
+ alert_status |= (1 << i);
+ else if (g_str_equal(description, "not active"))
+ alert_status &= ~(1 << i);
+ }
+ }
+}
+
static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -399,6 +420,9 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
}
}
+ if (pasp_category(category))
+ update_phone_alerts(category, description);
+
DBG("NewAlert(\"%s\", %d, \"%s\")", category, count, description);
return dbus_message_new_method_return(msg);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 22/27] alert: Add support for ringer setting notification
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (20 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 21/27] alert: Update Alert Status and Ringer Setting characteristic values Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 23/27] alert: Add support for alert status notification Anderson Lizardo
` (5 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When the agent reports a ringer setting change, a ringer setting
notification is sent to the peer device (if notification is enabled).
---
profiles/alert/server.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 154 insertions(+), 2 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index bde9056..6fc6384 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -31,6 +31,7 @@
#include <gdbus.h>
#include <glib.h>
#include <bluetooth/uuid.h>
+#include <stdlib.h>
#include "dbus-common.h"
#include "att.h"
@@ -45,6 +46,8 @@
#include "server.h"
#include "profile.h"
#include "error.h"
+#include "textfile.h"
+#include "attio.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
#define ALERT_NOTIF_SVC_UUID 0x1811
@@ -89,6 +92,11 @@ enum {
RINGER_NORMAL,
};
+enum notify_type {
+ NOTIFY_RINGER_SETTING = 0,
+ NOTIFY_SIZE,
+};
+
struct alert_data {
const char *category;
char *srv;
@@ -102,6 +110,21 @@ struct alert_adapter {
uint16_t supp_unread_alert_cat_handle;
uint16_t new_alert_handle;
uint16_t unread_alert_handle;
+ uint16_t hnd_ccc[NOTIFY_SIZE];
+ uint16_t hnd_value[NOTIFY_SIZE];
+};
+
+struct notify_data {
+ struct alert_adapter *al_adapter;
+ enum notify_type type;
+ uint8_t *value;
+ size_t len;
+};
+
+struct notify_callback {
+ struct notify_data *notify_data;
+ struct btd_device *device;
+ guint id;
};
static GSList *registered_alerts = NULL;
@@ -282,6 +305,125 @@ static void watcher_disconnect(DBusConnection *conn, void *user_data)
g_slist_foreach(alert_adapters, update_supported_categories, NULL);
}
+static struct btd_device *get_notifiable_device(struct btd_adapter *adapter,
+ char *key, char *value,
+ uint16_t ccc)
+{
+ struct btd_device *device;
+ char addr[18];
+ uint16_t hnd, val;
+ uint8_t bdaddr_type;
+
+ sscanf(key, "%17s#%hhu#%04hX", addr, &bdaddr_type, &hnd);
+
+ if (hnd != ccc)
+ return NULL;
+
+ val = strtol(value, NULL, 16);
+ if (!(val & 0x0001))
+ return NULL;
+
+ device = adapter_find_device(adapter, addr);
+ if (device == NULL)
+ return NULL;
+
+ return btd_device_ref(device);
+}
+
+static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
+{
+ struct notify_callback *cb = user_data;
+ struct notify_data *nd = cb->notify_data;
+ enum notify_type type = nd->type;
+ struct alert_adapter *al_adapter = nd->al_adapter;
+ uint8_t pdu[ATT_MAX_MTU];
+ size_t len = 0;
+
+ switch (type) {
+ case NOTIFY_RINGER_SETTING:
+ len = enc_notification(al_adapter->hnd_value[type],
+ &ringer_setting, sizeof(ringer_setting),
+ pdu, sizeof(pdu));
+ break;
+ default:
+ DBG("Unknown type, could not send notification");
+ goto end;
+ }
+
+ DBG("Send notification for handle: 0x%04x, ccc: 0x%04x",
+ al_adapter->hnd_value[type],
+ al_adapter->hnd_ccc[type]);
+
+ g_attrib_send(attrib, 0, ATT_OP_HANDLE_NOTIFY, pdu, len,
+ NULL, NULL, NULL);
+
+end:
+ btd_device_remove_attio_callback(cb->device, cb->id);
+ btd_device_unref(cb->device);
+ g_free(cb->notify_data->value);
+ g_free(cb->notify_data);
+ g_free(cb);
+}
+
+static void filter_devices_notify(char *key, char *value, void *user_data)
+{
+ struct notify_data *notify_data = user_data;
+ struct alert_adapter *al_adapter = notify_data->al_adapter;
+ enum notify_type type = notify_data->type;
+ struct btd_device *device;
+ struct notify_callback *cb;
+
+ device = get_notifiable_device(al_adapter->adapter, key, value,
+ al_adapter->hnd_ccc[type]);
+ if (device == NULL)
+ return;
+
+ cb = g_new0(struct notify_callback, 1);
+ cb->notify_data = notify_data;
+ cb->device = device;
+ cb->id = btd_device_add_attio_callback(device,
+ attio_connected_cb, NULL, cb);
+}
+
+static void create_filename(char *filename, struct btd_adapter *adapter)
+{
+ char srcaddr[18];
+ bdaddr_t src;
+
+ adapter_get_address(adapter, &src);
+ ba2str(&src, srcaddr);
+
+ create_name(filename, PATH_MAX, STORAGEDIR, srcaddr, "ccc");
+}
+
+static void notify_devices(struct alert_adapter *al_adapter,
+ enum notify_type type, uint8_t *value, size_t len)
+{
+ struct notify_data *notify_data;
+ char filename[PATH_MAX + 1];
+
+ notify_data = g_new0(struct notify_data, 1);
+ notify_data->al_adapter = al_adapter;
+ notify_data->type = type;
+ notify_data->value = g_memdup(value, len);
+ notify_data->len = len;
+
+ create_filename(filename, al_adapter->adapter);
+ textfile_foreach(filename, filter_devices_notify, notify_data);
+}
+
+static void pasp_notification(enum notify_type type)
+{
+ GSList *it;
+ struct alert_adapter *al_adapter;
+
+ for (it = alert_adapters; it; it = g_slist_next(it)) {
+ al_adapter = it->data;
+
+ notify_devices(al_adapter, type, NULL, 0);
+ }
+}
+
static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -344,10 +486,15 @@ static void update_phone_alerts(const char *category, const char *description)
unsigned int i;
if (g_str_equal(category, "ringer")) {
- if (g_str_equal(description, "enabled"))
+ if (g_str_equal(description, "enabled")) {
ringer_setting = RINGER_NORMAL;
- else if (g_str_equal(description, "disabled"))
+ pasp_notification(NOTIFY_RINGER_SETTING);
+ return;
+ } else if (g_str_equal(description, "disabled")) {
ringer_setting = RINGER_SILENT;
+ pasp_notification(NOTIFY_RINGER_SETTING);
+ return;
+ }
}
for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
@@ -619,6 +766,10 @@ static void register_phone_alert_service(struct alert_adapter *al_adapter)
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
ringer_setting_read, al_adapter->adapter,
+ GATT_OPT_CCC_GET_HANDLE,
+ &al_adapter->hnd_ccc[NOTIFY_RINGER_SETTING],
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->hnd_value[NOTIFY_RINGER_SETTING],
GATT_OPT_INVALID);
}
@@ -753,6 +904,7 @@ static void alert_server_remove(struct btd_profile *p,
alert_adapters = g_slist_remove(alert_adapters, al_adapter);
btd_adapter_unref(al_adapter->adapter);
+
g_free(al_adapter);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 23/27] alert: Add support for alert status notification
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (21 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 22/27] alert: Add support for ringer setting notification Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 24/27] alert: Add support for new alert notification Anderson Lizardo
` (4 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
The notification is sent (to peer devices that have it enabled on the
CCC descriptor) every time the alert status characteristic value
changes.
---
profiles/alert/server.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 6fc6384..e4ad7e2 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -94,6 +94,7 @@ enum {
enum notify_type {
NOTIFY_RINGER_SETTING = 0,
+ NOTIFY_ALERT_STATUS,
NOTIFY_SIZE,
};
@@ -345,6 +346,11 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
&ringer_setting, sizeof(ringer_setting),
pdu, sizeof(pdu));
break;
+ case NOTIFY_ALERT_STATUS:
+ len = enc_notification(al_adapter->hnd_value[type],
+ &alert_status, sizeof(alert_status),
+ pdu, sizeof(pdu));
+ break;
default:
DBG("Unknown type, could not send notification");
goto end;
@@ -499,10 +505,14 @@ static void update_phone_alerts(const char *category, const char *description)
for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
if (g_str_equal(pasp_categories[i], category)) {
- if (g_str_equal(description, "active"))
+ if (g_str_equal(description, "active")) {
alert_status |= (1 << i);
- else if (g_str_equal(description, "not active"))
+ pasp_notification(NOTIFY_ALERT_STATUS);
+ } else if (g_str_equal(description, "not active")) {
alert_status &= ~(1 << i);
+ pasp_notification(NOTIFY_ALERT_STATUS);
+ }
+ break;
}
}
}
@@ -755,6 +765,10 @@ static void register_phone_alert_service(struct alert_adapter *al_adapter)
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
alert_status_read, al_adapter->adapter,
+ GATT_OPT_CCC_GET_HANDLE,
+ &al_adapter->hnd_ccc[NOTIFY_ALERT_STATUS],
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->hnd_value[NOTIFY_ALERT_STATUS],
/* Ringer Control Point characteristic */
GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 24/27] alert: Add support for new alert notification
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (22 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 23/27] alert: Add support for alert status notification Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 25/27] alert: Add support for unread " Anderson Lizardo
` (3 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When NewAlert D-Bus method is called for one category from Alert
Notification Profile, the new alert characteristic value is notified.
---
profiles/alert/server.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index e4ad7e2..560765b 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -95,6 +95,7 @@ enum {
enum notify_type {
NOTIFY_RINGER_SETTING = 0,
NOTIFY_ALERT_STATUS,
+ NOTIFY_NEW_ALERT,
NOTIFY_SIZE,
};
@@ -109,7 +110,6 @@ struct alert_adapter {
struct btd_adapter *adapter;
uint16_t supp_new_alert_cat_handle;
uint16_t supp_unread_alert_cat_handle;
- uint16_t new_alert_handle;
uint16_t unread_alert_handle;
uint16_t hnd_ccc[NOTIFY_SIZE];
uint16_t hnd_value[NOTIFY_SIZE];
@@ -351,6 +351,10 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
&alert_status, sizeof(alert_status),
pdu, sizeof(pdu));
break;
+ case NOTIFY_NEW_ALERT:
+ len = enc_notification(al_adapter->hnd_value[type],
+ nd->value, nd->len, pdu, sizeof(pdu));
+ break;
default:
DBG("Unknown type, could not send notification");
goto end;
@@ -483,8 +487,11 @@ static void update_new_alert(gpointer data, gpointer user_data)
struct btd_adapter *adapter = al_adapter->adapter;
uint8_t *value = user_data;
- attrib_db_update(adapter, al_adapter->new_alert_handle, NULL, &value[1],
- value[0], NULL);
+ attrib_db_update(adapter,
+ al_adapter->hnd_value[NOTIFY_NEW_ALERT],
+ NULL, &value[1], value[0], NULL);
+
+ notify_devices(al_adapter, NOTIFY_NEW_ALERT, &value[1], value[0]);
}
static void update_phone_alerts(const char *category, const char *description)
@@ -869,8 +876,10 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
/* New Alert */
GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CCC_GET_HANDLE,
+ &al_adapter->hnd_ccc[NOTIFY_NEW_ALERT],
GATT_OPT_CHR_VALUE_GET_HANDLE,
- &al_adapter->new_alert_handle,
+ &al_adapter->hnd_value[NOTIFY_NEW_ALERT],
/* Supported Unread Alert Category */
GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 25/27] alert: Add support for unread alert notification
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (23 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 24/27] alert: Add support for new alert notification Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 26/27] alert: Implement Release() agent method Anderson Lizardo
` (2 subsequent siblings)
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When UnreadAlert D-Bus method is called for a registered category
from Alert Notification Profile, The unread alert characteristic value
is notified.
---
profiles/alert/server.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 560765b..c631e0d 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -96,6 +96,7 @@ enum notify_type {
NOTIFY_RINGER_SETTING = 0,
NOTIFY_ALERT_STATUS,
NOTIFY_NEW_ALERT,
+ NOTIFY_UNREAD_ALERT,
NOTIFY_SIZE,
};
@@ -110,7 +111,6 @@ struct alert_adapter {
struct btd_adapter *adapter;
uint16_t supp_new_alert_cat_handle;
uint16_t supp_unread_alert_cat_handle;
- uint16_t unread_alert_handle;
uint16_t hnd_ccc[NOTIFY_SIZE];
uint16_t hnd_value[NOTIFY_SIZE];
};
@@ -352,6 +352,7 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
pdu, sizeof(pdu));
break;
case NOTIFY_NEW_ALERT:
+ case NOTIFY_UNREAD_ALERT:
len = enc_notification(al_adapter->hnd_value[type],
nd->value, nd->len, pdu, sizeof(pdu));
break;
@@ -645,8 +646,11 @@ static void update_unread_alert(gpointer data, gpointer user_data)
struct btd_adapter *adapter = al_adapter->adapter;
uint8_t *value = user_data;
- attrib_db_update(adapter, al_adapter->unread_alert_handle, NULL, value,
- 2, NULL);
+ attrib_db_update(adapter,
+ al_adapter->hnd_value[NOTIFY_UNREAD_ALERT], NULL, value,
+ 2, NULL);
+
+ notify_devices(al_adapter, NOTIFY_UNREAD_ALERT, value, 2);
}
static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
@@ -890,8 +894,10 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
/* Unread Alert Status */
GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CCC_GET_HANDLE,
+ &al_adapter->hnd_ccc[NOTIFY_UNREAD_ALERT],
GATT_OPT_CHR_VALUE_GET_HANDLE,
- &al_adapter->unread_alert_handle,
+ &al_adapter->hnd_value[NOTIFY_UNREAD_ALERT],
/* Alert Notification Control Point */
GATT_OPT_CHR_UUID, ALERT_NOTIF_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 26/27] alert: Implement Release() agent method
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (24 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 25/27] alert: Add support for unread " Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 27/27] alert: Add org.bluez.AlertAgent to D-Bus policy file Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This method allows BlueZ to notify the agent that it will not be used
anymore, and can thus cleanup itself (e.g. deallocate D-Bus object, or
exit).
---
profiles/alert/server.c | 18 +++++++++++++++++-
test/test-alert | 11 +++++++++--
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index c631e0d..4b00ae3 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -179,9 +179,25 @@ static void alert_data_destroy(gpointer user_data)
g_free(alert);
}
+static void alert_release(gpointer user_data)
+{
+ struct alert_data *alert = user_data;
+ DBusMessage *msg;
+
+ msg = dbus_message_new_method_call(alert->srv, alert->path,
+ ALERT_AGENT_INTERFACE,
+ "Release");
+ if (msg)
+ g_dbus_send_message(btd_get_dbus_connection(), msg);
+
+ alert_data_destroy(alert);
+}
+
static void alert_destroy(gpointer user_data)
{
- g_slist_free_full(registered_alerts, alert_data_destroy);
+ DBG("");
+
+ g_slist_free_full(registered_alerts, alert_release);
registered_alerts = NULL;
}
diff --git a/test/test-alert b/test/test-alert
index c92a719..1e241a3 100755
--- a/test/test-alert
+++ b/test/test-alert
@@ -15,9 +15,10 @@ BLUEZ_OBJECT_PATH = '/org/bluez'
TEST_OBJECT_PATH = '/org/bluez/test'
class AlertAgent(dbus.service.Object):
- def __init__(self, bus, object_path, alert):
+ def __init__(self, bus, object_path, alert, mainloop):
dbus.service.Object.__init__(self, bus, object_path)
self.alert = alert
+ self.mainloop = mainloop
@dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='',
out_signature='')
@@ -31,6 +32,12 @@ class AlertAgent(dbus.service.Object):
print('method SetRinger(%s) was called' % mode)
self.alert.NewAlert('ringer', 1, mode)
+ @dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='',
+ out_signature='')
+ def Release(self):
+ print('method Release() was called')
+ self.mainloop.quit()
+
def print_command_line(options):
if not options.verbose:
return False
@@ -145,7 +152,7 @@ bus = dbus.SystemBus()
mainloop = gobject.MainLoop()
alert = dbus.Interface(bus.get_object(BUS_NAME, BLUEZ_OBJECT_PATH),
ALERT_INTERFACE)
-alert_agent = AlertAgent(bus, TEST_OBJECT_PATH, alert)
+alert_agent = AlertAgent(bus, TEST_OBJECT_PATH, alert, mainloop)
print_command_line(options)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v2 BlueZ 27/27] alert: Add org.bluez.AlertAgent to D-Bus policy file
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (25 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 26/27] alert: Implement Release() agent method Anderson Lizardo
@ 2012-09-27 18:36 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
27 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-09-27 18:36 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This allows BlueZ to call the methods on the org.bluez.AlertAgent
interface.
---
src/bluetooth.conf | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/bluetooth.conf b/src/bluetooth.conf
index 26fde34..8b656f3 100644
--- a/src/bluetooth.conf
+++ b/src/bluetooth.conf
@@ -16,6 +16,7 @@
<allow send_interface="org.bluez.MediaPlayer"/>
<allow send_interface="org.bluez.Watcher"/>
<allow send_interface="org.bluez.ThermometerWatcher"/>
+ <allow send_interface="org.bluez.AlertAgent"/>
<allow send_interface="org.bluez.Profile"/>
</policy>
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (26 preceding siblings ...)
2012-09-27 18:36 ` [PATCH v2 BlueZ 27/27] alert: Add org.bluez.AlertAgent to D-Bus policy file Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 01/27] doc: Introduce Alert API Anderson Lizardo
` (26 more replies)
27 siblings, 27 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Hi,
This series implement most of mandatory features for Phone Alert Status (PASP)
and Alert Notification (ANP) profiles. The only major mandatory feature
currently missing is support for ANP control point (which will be added on a
future series).
Note: for those planning to use ANP/PASP in BlueZ using these patches, it is
necessary to implement an "agent" that forwards platform events (SMS, calls,
e-mail, and ringer/display/vibra status) to BlueZ. See doc/alert-api.txt and
test/test-alert for more details. Alternatively, the components that generate
these events can register themselves and report alerts directly to BlueZ.
This implementation was tested against PTS and all tests passed (except for the
features not yet implemented). The D-Bus API was implemented accordingly to the
previously proposed Alert API (documented on the first patch).
Comments/suggestions are welcome.
Changes since v2:
* Rebase and fix a minor conflict in Makefile.tools
* Fix issues detected by checkpatch.pl
Changes since v1:
* Rebase against latest btd_profile changes
* Add test-alert to Makefile.tools and alert-api.txt to Makefile.am
* Add org.bluez.AlertAgent to D-Bus policy file (patch 27/27)
* Implement Release() agent method (patch 26/27)
* Remove Suspend()/Resume() from documentation (they are not implemented, and
they are optimizations that can be added later if necessary).
Anderson Lizardo (13):
doc: Introduce Alert API
alert: Introduce manager abstraction layer
alert: Initial profile registration
alert: Initial Alert Notification
alert: Add initial support for UnreadAlert D-Bus method
alert: Add per adapter attribute handle information
alert: Update Supported New/Unread Category characteristic values
alert: Update new alert characteristic value
alert: Update unread alert characteristic value
alert: Implement MuteOnce command
alert: Update Alert Status and Ringer Setting characteristic values
alert: Implement Release() agent method
alert: Add org.bluez.AlertAgent to D-Bus policy file
Bruna Moreira (4):
alert: Add Phone Alert Status Service
alert: Add Ringer Control Point characteristic
alert: Add Ringer Setting characteristic
alert: Add Alert Status characteristic
Eder Ruiz Maria (10):
alert: Implement category registration in RegisterAlert()
alert: Add initial support for NewAlert D-Bus method
alert: Automatically unregister alert when agent leaves D-Bus
alert: Add support for calling MuteOnce()
alert: Add support for calling SetRinger()
alert: Add test-alert script
alert: Add support for ringer setting notification
alert: Add support for alert status notification
alert: Add support for new alert notification
alert: Add support for unread alert notification
Makefile.am | 5 +-
Makefile.tools | 2 +-
doc/alert-api.txt | 109 ++++++
profiles/alert/main.c | 6 +-
profiles/alert/manager.c | 40 ++
profiles/alert/manager.h | 26 ++
profiles/alert/server.c | 961 ++++++++++++++++++++++++++++++++++++++++++++++
src/bluetooth.conf | 1 +
test/test-alert | 180 +++++++++
9 files changed, 1324 insertions(+), 6 deletions(-)
create mode 100644 doc/alert-api.txt
create mode 100644 profiles/alert/manager.c
create mode 100644 profiles/alert/manager.h
create mode 100755 test/test-alert
--
1.7.9.5
^ permalink raw reply [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 01/27] doc: Introduce Alert API
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-03 8:21 ` Johan Hedberg
2012-10-03 12:46 ` [PATCH v4 " Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 02/27] alert: Introduce manager abstraction layer Anderson Lizardo
` (25 subsequent siblings)
26 siblings, 2 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This API will be implemented and initially used by Phone Alert Status
and Alert Notification GATT profiles (server role).
---
Makefile.am | 2 +-
doc/alert-api.txt | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+), 1 deletion(-)
create mode 100644 doc/alert-api.txt
diff --git a/Makefile.am b/Makefile.am
index c27eb01..470dbad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -396,7 +396,7 @@ EXTRA_DIST += doc/manager-api.txt \
doc/network-api.txt doc/input-api.txt doc/audio-api.txt \
doc/control-api.txt doc/hfp-api.txt doc/health-api.txt \
doc/sap-api.txt doc/media-api.txt doc/assigned-numbers.txt \
- doc/supported-features.txt
+ doc/supported-features.txt doc/alert-api.txt
AM_YFLAGS = -d
diff --git a/doc/alert-api.txt b/doc/alert-api.txt
new file mode 100644
index 0000000..e58430c
--- /dev/null
+++ b/doc/alert-api.txt
@@ -0,0 +1,109 @@
+BlueZ D-Bus Alert API description
+*********************************
+
+Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT
+
+Introduction
+------------
+
+Currently, there are two different GATT server profiles that depend on
+receiving alerts or notifications from the platform: Phone Alert Status (PASP)
+and Alert Notification (ANP). PASP is very specific to mobile phones, and also
+allows limited control to alerts (i.e. mute once or switch to a silent mode).
+
+This document presents a unified API that allows to register and notify alerts,
+and to control some alerts (using the provided agent object).
+
+
+Alert hierarchy
+===============
+
+Service org.bluez
+Interface org.bluez.Alert
+Object path /org/bluez
+
+Methods void RegisterAlert(string category, object agent)
+
+ Register a new alert category and an agent for it. This
+ means the application will be responsible for notifying
+ BlueZ of any alerts of that category, using the
+ NewAlert() method.
+
+ Supported ANP categories: simple, email, news, call,
+ missed_call, sms_mms, voice_mail, schedule,
+ high_priority, instant_message
+ Supported PASP categories: ringer, vibrate, display
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void NewAlert(string category, uint16 count, string description)
+
+ Notify BlueZ of new alert(s) for the given category. The
+ description is relative to the last received alert and
+ can be sender name, caller ID, title, or other
+ information specific to the category.
+
+ For ringer, vibrate and display categories, valid
+ descriptions are "active" and "not active". Alerts from
+ ringer category also accept "enabled" and "disabled",
+ depending on whether ringer is in silent mode or not.
+
+ Description must not exceed 18 bytes when encoded in
+ UTF-8 format, otherwise an error is returned. If there
+ is no description, an empty string should be used.
+
+ The count argument contains the number of alerts not
+ yet acknowledged by the user on the UI. To save D-Bus
+ traffic, events that may generate multiple alerts at
+ the same time (like email, sms, news) should trigger a
+ single NewAlert().
+
+ If there are more than 254 new alerts, count must be
+ set to 255. PASP alerts should always set count to 1.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void UnreadAlert(string category, uint16 count)
+
+ Some services (like SMS and e-mail) keep track of
+ number of unread items. This method allows to update
+ this counter, so peer devices can be notified using
+ Alert Notification Profile.
+
+ If there are more than 254 unread alerts, count must be
+ set to 255.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+Alert Agent hierarchy
+=====================
+
+Service org.bluez
+Interface org.bluez.AlertAgent
+Object path freely definable
+
+Methods void MuteOnce()
+
+ This method is only called if "ringer" alert category
+ is specified when registering the agent.
+
+ Mute the ringer once (e.g. during a incoming call). If
+ ringer is not active, does nothing.
+
+ void SetRinger(string mode)
+
+ This method is only called if "ringer" alert category
+ is specified when registering the agent.
+
+ Set ringer to the specified mode. If mode is "enabled",
+ ringer is set to the default mode, as defined by the
+ current active profile. If mode is "disabled", ringer
+ will not activate on incoming calls, until it is set
+ back to "enabled" mode.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void Release()
+
+ Release this agent. At this point, it will not be used
+ by BlueZ anymore and can be destroyed by the owner.
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 02/27] alert: Introduce manager abstraction layer
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 01/27] doc: Introduce Alert API Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 03/27] alert: Initial profile registration Anderson Lizardo
` (24 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This abstraction layer makes the GATT Phone Alert Status and Alert
Notification implementation consistent with other GATT profiles.
---
Makefile.am | 3 ++-
profiles/alert/main.c | 6 +++---
profiles/alert/manager.c | 40 ++++++++++++++++++++++++++++++++++++++++
profiles/alert/manager.h | 26 ++++++++++++++++++++++++++
4 files changed, 71 insertions(+), 4 deletions(-)
create mode 100644 profiles/alert/manager.c
create mode 100644 profiles/alert/manager.h
diff --git a/Makefile.am b/Makefile.am
index 470dbad..daa78d5 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -219,7 +219,8 @@ builtin_sources += profiles/thermometer/main.c \
profiles/thermometer/thermometer.h \
profiles/thermometer/thermometer.c \
profiles/alert/main.c profiles/alert/server.h \
- profiles/alert/server.c \
+ profiles/alert/server.c profiles/alert/manager.h \
+ profiles/alert/manager.c \
profiles/time/main.c profiles/time/server.h \
profiles/time/server.c profiles/time/manager.c \
profiles/time/manager.h \
diff --git a/profiles/alert/main.c b/profiles/alert/main.c
index ec4ab6d..5e6910a 100644
--- a/profiles/alert/main.c
+++ b/profiles/alert/main.c
@@ -33,7 +33,7 @@
#include "plugin.h"
#include "hcid.h"
#include "log.h"
-#include "server.h"
+#include "manager.h"
static int alert_init(void)
{
@@ -42,7 +42,7 @@ static int alert_init(void)
return -ENOTSUP;
}
- return alert_server_init();
+ return alert_manager_init();
}
static void alert_exit(void)
@@ -50,7 +50,7 @@ static void alert_exit(void)
if (!main_opts.gatt_enabled)
return;
- alert_server_exit();
+ alert_manager_exit();
}
BLUETOOTH_PLUGIN_DEFINE(alert, VERSION,
diff --git a/profiles/alert/manager.c b/profiles/alert/manager.c
new file mode 100644
index 0000000..eb2d627
--- /dev/null
+++ b/profiles/alert/manager.c
@@ -0,0 +1,40 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Nokia Corporation
+ * Copyright (C) 2012 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * 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 "manager.h"
+#include "server.h"
+
+int alert_manager_init(void)
+{
+ return alert_server_init();
+}
+
+void alert_manager_exit(void)
+{
+ alert_server_exit();
+}
diff --git a/profiles/alert/manager.h b/profiles/alert/manager.h
new file mode 100644
index 0000000..e4c6bd0
--- /dev/null
+++ b/profiles/alert/manager.h
@@ -0,0 +1,26 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2012 Nokia Corporation
+ * Copyright (C) 2012 Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ * 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 alert_manager_init(void);
+void alert_manager_exit(void);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 03/27] alert: Initial profile registration
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 01/27] doc: Introduce Alert API Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 02/27] alert: Introduce manager abstraction layer Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 04/27] alert: Add Phone Alert Status Service Anderson Lizardo
` (23 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
---
profiles/alert/server.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index d91b156..dc844d3 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -26,13 +26,37 @@
#include <config.h>
#endif
+#include <stdbool.h>
+
+#include "adapter.h"
#include "server.h"
+#include "profile.h"
+
+static int alert_server_probe(struct btd_profile *p,
+ struct btd_adapter *adapter)
+{
+ return 0;
+}
+
+static void alert_server_remove(struct btd_profile *p,
+ struct btd_adapter *adapter)
+{
+}
+
+static struct btd_profile alert_profile = {
+ .name = "gatt-alert-server",
+ .adapter_probe = alert_server_probe,
+ .adapter_remove = alert_server_remove,
+};
int alert_server_init(void)
{
+ btd_profile_register(&alert_profile);
+
return 0;
}
void alert_server_exit(void)
{
+ btd_profile_unregister(&alert_profile);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 04/27] alert: Add Phone Alert Status Service
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (2 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 03/27] alert: Initial profile registration Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 05/27] alert: Add Ringer Control Point characteristic Anderson Lizardo
` (22 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
From: Bruna Moreira <bruna.moreira@openbossa.org>
Add Phone Alert Status service for PASP.
---
profiles/alert/server.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index dc844d3..b39ef8a 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -27,14 +27,35 @@
#endif
#include <stdbool.h>
+#include <glib.h>
+#include <bluetooth/uuid.h>
+#include "att.h"
#include "adapter.h"
+#include "gatt-service.h"
+#include "gattrib.h"
+#include "gatt.h"
#include "server.h"
#include "profile.h"
+#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
+
+static void register_phone_alert_service(struct btd_adapter *adapter)
+{
+ bt_uuid_t uuid;
+
+ bt_uuid16_create(&uuid, PHONE_ALERT_STATUS_SVC_UUID);
+
+ /* Phone Alert Status Service */
+ gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ GATT_OPT_INVALID);
+}
+
static int alert_server_probe(struct btd_profile *p,
struct btd_adapter *adapter)
{
+ register_phone_alert_service(adapter);
+
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 05/27] alert: Add Ringer Control Point characteristic
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (3 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 04/27] alert: Add Phone Alert Status Service Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 06/27] alert: Add Ringer Setting characteristic Anderson Lizardo
` (21 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
From: Bruna Moreira <bruna.moreira@openbossa.org>
Ringer CP characteristic is used for configuring "silent mode" or muting
the ringer once.
---
profiles/alert/server.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index b39ef8a..8337c38 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -32,6 +32,9 @@
#include "att.h"
#include "adapter.h"
+#include "device.h"
+#include "att-database.h"
+#include "log.h"
#include "gatt-service.h"
#include "gattrib.h"
#include "gatt.h"
@@ -39,6 +42,16 @@
#include "profile.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
+#define RINGER_CP_CHR_UUID 0x2A40
+
+static uint8_t ringer_cp_write(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ DBG("a = %p", a);
+
+ return 0;
+}
static void register_phone_alert_service(struct btd_adapter *adapter)
{
@@ -48,6 +61,11 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
/* Phone Alert Status Service */
gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ /* Ringer Control Point characteristic */
+ GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
+ ringer_cp_write, NULL,
GATT_OPT_INVALID);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 06/27] alert: Add Ringer Setting characteristic
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (4 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 05/27] alert: Add Ringer Control Point characteristic Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 07/27] alert: Add Alert Status characteristic Anderson Lizardo
` (20 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
From: Bruna Moreira <bruna.moreira@openbossa.org>
This characteristic allows to read or notify the ringer mode (silent or
normal).
---
profiles/alert/server.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 8337c38..59e6fdc 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -37,12 +37,22 @@
#include "log.h"
#include "gatt-service.h"
#include "gattrib.h"
+#include "attrib-server.h"
#include "gatt.h"
#include "server.h"
#include "profile.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
#define RINGER_CP_CHR_UUID 0x2A40
+#define RINGER_SETTING_CHR_UUID 0x2A41
+
+/* Ringer Setting characteristic values */
+enum {
+ RINGER_SILENT,
+ RINGER_NORMAL,
+};
+
+static uint8_t ringer_setting = RINGER_NORMAL;
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
@@ -53,6 +63,21 @@ static uint8_t ringer_cp_write(struct attribute *a,
return 0;
}
+static uint8_t ringer_setting_read(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ struct btd_adapter *adapter = user_data;
+
+ DBG("a = %p", a);
+
+ if (a->data == NULL || a->data[0] != ringer_setting)
+ attrib_db_update(adapter, a->handle, NULL, &ringer_setting,
+ sizeof(ringer_setting), NULL);
+
+ return 0;
+}
+
static void register_phone_alert_service(struct btd_adapter *adapter)
{
bt_uuid_t uuid;
@@ -66,6 +91,12 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
ringer_cp_write, NULL,
+ /* Ringer Setting characteristic */
+ GATT_OPT_CHR_UUID, RINGER_SETTING_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
+ ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+ ringer_setting_read, adapter,
GATT_OPT_INVALID);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 07/27] alert: Add Alert Status characteristic
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (5 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 06/27] alert: Add Ringer Setting characteristic Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 08/27] alert: Initial Alert Notification Anderson Lizardo
` (19 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Bruna Moreira
From: Bruna Moreira <bruna.moreira@openbossa.org>
This characteristic allows to read/notify the status of the ringer,
display and vibration motor.
---
profiles/alert/server.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 59e6fdc..90536d5 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -43,6 +43,8 @@
#include "profile.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
+
+#define ALERT_STATUS_CHR_UUID 0x2A3F
#define RINGER_CP_CHR_UUID 0x2A40
#define RINGER_SETTING_CHR_UUID 0x2A41
@@ -53,6 +55,7 @@ enum {
};
static uint8_t ringer_setting = RINGER_NORMAL;
+static uint8_t alert_status = 0;
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
@@ -63,6 +66,21 @@ static uint8_t ringer_cp_write(struct attribute *a,
return 0;
}
+static uint8_t alert_status_read(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ struct btd_adapter *adapter = user_data;
+
+ DBG("a = %p", a);
+
+ if (a->data == NULL || a->data[0] != alert_status)
+ attrib_db_update(adapter, a->handle, NULL, &alert_status,
+ sizeof(alert_status), NULL);
+
+ return 0;
+}
+
static uint8_t ringer_setting_read(struct attribute *a,
struct btd_device *device,
gpointer user_data)
@@ -86,6 +104,12 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
/* Phone Alert Status Service */
gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ /* Alert Status characteristic */
+ GATT_OPT_CHR_UUID, ALERT_STATUS_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
+ ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+ alert_status_read, adapter,
/* Ringer Control Point characteristic */
GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 08/27] alert: Initial Alert Notification
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (6 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 07/27] alert: Add Alert Status characteristic Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 09/27] alert: Implement category registration in RegisterAlert() Anderson Lizardo
` (18 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Initial implementation for Alert Notification Profile (ANP).
---
profiles/alert/server.c | 154 +++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 154 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 90536d5..c0434a4 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -27,9 +27,12 @@
#endif
#include <stdbool.h>
+#include <errno.h>
+#include <gdbus.h>
#include <glib.h>
#include <bluetooth/uuid.h>
+#include "dbus-common.h"
#include "att.h"
#include "adapter.h"
#include "device.h"
@@ -41,13 +44,33 @@
#include "gatt.h"
#include "server.h"
#include "profile.h"
+#include "error.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
+#define ALERT_NOTIF_SVC_UUID 0x1811
#define ALERT_STATUS_CHR_UUID 0x2A3F
#define RINGER_CP_CHR_UUID 0x2A40
#define RINGER_SETTING_CHR_UUID 0x2A41
+#define ALERT_NOTIF_CP_CHR_UUID 0x2A44
+#define UNREAD_ALERT_CHR_UUID 0x2A45
+#define NEW_ALERT_CHR_UUID 0x2A46
+#define SUPP_NEW_ALERT_CAT_CHR_UUID 0x2A47
+#define SUPP_UNREAD_ALERT_CAT_CHR_UUID 0x2A48
+
+#define ALERT_OBJECT_PATH "/org/bluez"
+#define ALERT_INTERFACE "org.bluez.Alert"
+
+enum {
+ ENABLE_NEW_INCOMING,
+ ENABLE_UNREAD_CAT,
+ DISABLE_NEW_INCOMING,
+ DISABLE_UNREAD_CAT,
+ NOTIFY_NEW_INCOMING,
+ NOTIFY_UNREAD_CAT,
+};
+
/* Ringer Setting characteristic values */
enum {
RINGER_SILENT,
@@ -57,6 +80,20 @@ enum {
static uint8_t ringer_setting = RINGER_NORMAL;
static uint8_t alert_status = 0;
+static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ const char *category;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
+ DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+
+ DBG("RegisterAlert: %s", category);
+
+ return dbus_message_new_method_return(msg);
+}
+
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
gpointer user_data)
@@ -124,10 +161,107 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
GATT_OPT_INVALID);
}
+static uint8_t supp_new_alert_cat_read(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ struct btd_adapter *adapter = user_data;
+ uint8_t value[] = {0x00, 0x00};
+
+ DBG("a = %p", a);
+
+ if (a->data == NULL)
+ attrib_db_update(adapter, a->handle, NULL, value, sizeof(value),
+ NULL);
+
+ return 0;
+}
+
+static uint8_t supp_unread_alert_cat_read(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ struct btd_adapter *adapter = user_data;
+ uint8_t value[] = {0x00, 0x00};
+
+ DBG("a = %p", a);
+
+ if (a->data == NULL)
+ attrib_db_update(adapter, a->handle, NULL, value, sizeof(value),
+ NULL);
+
+ return 0;
+}
+
+static uint8_t alert_notif_cp_write(struct attribute *a,
+ struct btd_device *device,
+ gpointer user_data)
+{
+ DBG("a = %p", a);
+
+ switch (a->data[0]) {
+ case ENABLE_NEW_INCOMING:
+ DBG("ENABLE_NEW_INCOMING: 0x%02x", a->data[1]);
+ break;
+ case ENABLE_UNREAD_CAT:
+ DBG("ENABLE_UNREAD_CAT: 0x%02x", a->data[1]);
+ break;
+ case DISABLE_NEW_INCOMING:
+ DBG("DISABLE_NEW_INCOMING: 0x%02x", a->data[1]);
+ break;
+ case DISABLE_UNREAD_CAT:
+ DBG("DISABLE_UNREAD_CAT: 0x%02x", a->data[1]);
+ break;
+ case NOTIFY_NEW_INCOMING:
+ DBG("NOTIFY_NEW_INCOMING: 0x%02x", a->data[1]);
+ break;
+ case NOTIFY_UNREAD_CAT:
+ DBG("NOTIFY_UNREAD_CAT: 0x%02x", a->data[1]);
+ break;
+ default:
+ DBG("0x%02x 0x%02x", a->data[0], a->data[1]);
+ }
+
+ return 0;
+}
+
+static void register_alert_notif_service(struct btd_adapter *adapter)
+{
+ bt_uuid_t uuid;
+
+ bt_uuid16_create(&uuid, ALERT_NOTIF_SVC_UUID);
+
+ /* Alert Notification Service */
+ gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ /* Supported New Alert Category */
+ GATT_OPT_CHR_UUID, SUPP_NEW_ALERT_CAT_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+ supp_new_alert_cat_read, adapter,
+ /* New Alert */
+ GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ /* Supported Unread Alert Category */
+ GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+ supp_unread_alert_cat_read, adapter,
+ /* Unread Alert Status */
+ GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ /* Alert Notification Control Point */
+ GATT_OPT_CHR_UUID, ALERT_NOTIF_CP_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_WRITE,
+ alert_notif_cp_write, NULL,
+ GATT_OPT_INVALID);
+}
+
static int alert_server_probe(struct btd_profile *p,
struct btd_adapter *adapter)
{
register_phone_alert_service(adapter);
+ register_alert_notif_service(adapter);
return 0;
}
@@ -143,8 +277,25 @@ static struct btd_profile alert_profile = {
.adapter_remove = alert_server_remove,
};
+static const GDBusMethodTable alert_methods[] = {
+ { GDBUS_METHOD("RegisterAlert",
+ GDBUS_ARGS({ "category", "s" },
+ { "agent", "o" }), NULL,
+ register_alert) },
+ { }
+};
+
int alert_server_init(void)
{
+ if (!g_dbus_register_interface(btd_get_dbus_connection(),
+ ALERT_OBJECT_PATH, ALERT_INTERFACE,
+ alert_methods, NULL, NULL, NULL,
+ NULL)) {
+ error("D-Bus failed to register %s interface",
+ ALERT_INTERFACE);
+ return -EIO;
+ }
+
btd_profile_register(&alert_profile);
return 0;
@@ -153,4 +304,7 @@ int alert_server_init(void)
void alert_server_exit(void)
{
btd_profile_unregister(&alert_profile);
+
+ g_dbus_unregister_interface(btd_get_dbus_connection(),
+ ALERT_OBJECT_PATH, ALERT_INTERFACE);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 09/27] alert: Implement category registration in RegisterAlert()
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (7 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 08/27] alert: Initial Alert Notification Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-03 12:49 ` [PATCH v4 " Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 10/27] alert: Add initial support for NewAlert D-Bus method Anderson Lizardo
` (17 subsequent siblings)
26 siblings, 1 reply; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
The given alert category is now validated and registered.
---
profiles/alert/server.c | 102 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 98 insertions(+), 4 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index c0434a4..77fd40b 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -77,19 +77,113 @@ enum {
RINGER_NORMAL,
};
+struct alert_data {
+ const char *category;
+ char *srv;
+ char *path;
+};
+
+static GSList *registered_alerts = NULL;
static uint8_t ringer_setting = RINGER_NORMAL;
static uint8_t alert_status = 0;
+static const char * const anp_categories[] = {
+ "simple",
+ "email",
+ "news",
+ "call",
+ "missed_call",
+ "sms_mms",
+ "voice_mail",
+ "schedule",
+ "high_priority",
+ "instant_message",
+};
+
+static const char * const pasp_categories[] = {
+ "ringer",
+ "vibrate",
+ "display",
+};
+
+static void alert_data_destroy(gpointer user_data)
+{
+ struct alert_data *alert = user_data;
+
+ g_free(alert->srv);
+ g_free(alert->path);
+ g_free(alert);
+}
+
+static void alert_destroy(gpointer user_data)
+{
+ g_slist_free_full(registered_alerts, alert_data_destroy);
+ registered_alerts = NULL;
+}
+
+static const char *valid_category(const char *category)
+{
+ unsigned i;
+
+ for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+ if (g_str_equal(anp_categories[i], category))
+ return anp_categories[i];
+ }
+
+ for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
+ if (g_str_equal(pasp_categories[i], category))
+ return pasp_categories[i];
+ }
+
+ return NULL;
+}
+
+static gboolean registered_category(const char *category)
+{
+ GSList *l;
+ struct alert_data *alert;
+
+ for (l = registered_alerts; l; l = g_slist_next(l)) {
+ alert = l->data;
+ if (g_str_equal(alert->category, category))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
+ const char *sender = dbus_message_get_sender(msg);
+ char *path;
const char *category;
+ const char *c;
+ struct alert_data *alert;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &c,
+ DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
- if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
- DBUS_TYPE_INVALID))
+ category = valid_category(c);
+ if (!category) {
+ DBG("Invalid category: %s", c);
return btd_error_invalid_args(msg);
+ }
+
+ if (registered_category(category)) {
+ DBG("Category %s already registered", category);
+ return dbus_message_new_method_return(msg);
+ }
+
+ alert = g_new0(struct alert_data, 1);
+ alert->srv = g_strdup(sender);
+ alert->path = g_strdup(path);
+ alert->category = category;
+
+ registered_alerts = g_slist_append(registered_alerts, alert);
- DBG("RegisterAlert: %s", category);
+ DBG("RegisterAlert(\"%s\", \"%s\")", alert->category, alert->path);
return dbus_message_new_method_return(msg);
}
@@ -290,7 +384,7 @@ int alert_server_init(void)
if (!g_dbus_register_interface(btd_get_dbus_connection(),
ALERT_OBJECT_PATH, ALERT_INTERFACE,
alert_methods, NULL, NULL, NULL,
- NULL)) {
+ alert_destroy)) {
error("D-Bus failed to register %s interface",
ALERT_INTERFACE);
return -EIO;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 10/27] alert: Add initial support for NewAlert D-Bus method
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (8 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 09/27] alert: Implement category registration in RegisterAlert() Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 11/27] alert: Add initial support for UnreadAlert " Anderson Lizardo
` (16 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
NewAlert() is used for notifying BlueZ of new alert(s) for the given
category.
---
profiles/alert/server.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 105 insertions(+), 1 deletion(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 77fd40b..06370e4 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -62,6 +62,9 @@
#define ALERT_OBJECT_PATH "/org/bluez"
#define ALERT_INTERFACE "org.bluez.Alert"
+/* Maximum length for "Text String Information" */
+#define NEW_ALERT_MAX_INFO_SIZE 18
+
enum {
ENABLE_NEW_INCOMING,
ENABLE_UNREAD_CAT,
@@ -138,7 +141,7 @@ static const char *valid_category(const char *category)
return NULL;
}
-static gboolean registered_category(const char *category)
+static struct alert_data *get_alert_data_by_category(const char *category)
{
GSList *l;
struct alert_data *alert;
@@ -146,9 +149,64 @@ static gboolean registered_category(const char *category)
for (l = registered_alerts; l; l = g_slist_next(l)) {
alert = l->data;
if (g_str_equal(alert->category, category))
+ return alert;
+ }
+
+ return NULL;
+}
+
+static gboolean registered_category(const char *category)
+{
+ struct alert_data *alert;
+
+ alert = get_alert_data_by_category(category);
+ if (alert)
+ return TRUE;
+
+ return FALSE;
+}
+
+static gboolean pasp_category(const char *category)
+{
+ unsigned i;
+
+ for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++)
+ if (g_str_equal(category, pasp_categories[i]))
return TRUE;
+
+ return FALSE;
+}
+
+static gboolean valid_description(const char *category,
+ const char *description)
+{
+ if (!pasp_category(category)) {
+ if (strlen(description) >= NEW_ALERT_MAX_INFO_SIZE)
+ return FALSE;
+
+ return TRUE;
}
+ if (g_str_equal(description, "active") ||
+ g_str_equal(description, "not active"))
+ return TRUE;
+
+ if (g_str_equal(category, "ringer"))
+ if (g_str_equal(description, "enabled") ||
+ g_str_equal(description, "disabled"))
+ return TRUE;
+
+ return FALSE;
+}
+
+static gboolean valid_count(const char *category, uint16_t count)
+{
+ if (!pasp_category(category) && count > 0 && count <= 255)
+ return TRUE;
+
+ if (pasp_category(category) && count == 1)
+ return TRUE;
+
return FALSE;
}
@@ -188,6 +246,47 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ const char *sender = dbus_message_get_sender(msg);
+ const char *category, *description;
+ struct alert_data *alert;
+ uint16_t count;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
+ DBUS_TYPE_UINT16, &count, DBUS_TYPE_STRING,
+ &description, DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+
+ alert = get_alert_data_by_category(category);
+ if (!alert) {
+ DBG("Category %s not registered", category);
+ return btd_error_invalid_args(msg);
+ }
+
+ if (!g_str_equal(alert->srv, sender)) {
+ DBG("Sender %s is not registered in category %s", sender,
+ category);
+ return btd_error_invalid_args(msg);
+ }
+
+ if (!valid_description(category, description)) {
+ DBG("Description %s is invalid for %s category",
+ description, category);
+ return btd_error_invalid_args(msg);
+ }
+
+ if (!valid_count(category, count)) {
+ DBG("Count %d is invalid for %s category", count, category);
+ return btd_error_invalid_args(msg);
+ }
+
+ DBG("NewAlert(\"%s\", %d, \"%s\")", category, count, description);
+
+ return dbus_message_new_method_return(msg);
+}
+
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
gpointer user_data)
@@ -376,6 +475,11 @@ static const GDBusMethodTable alert_methods[] = {
GDBUS_ARGS({ "category", "s" },
{ "agent", "o" }), NULL,
register_alert) },
+ { GDBUS_METHOD("NewAlert",
+ GDBUS_ARGS({ "category", "s" },
+ { "count", "q" },
+ { "description", "s" }), NULL,
+ new_alert) },
{ }
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 11/27] alert: Add initial support for UnreadAlert D-Bus method
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (9 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 10/27] alert: Add initial support for NewAlert D-Bus method Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 12/27] alert: Automatically unregister alert when agent leaves D-Bus Anderson Lizardo
` (15 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This method is used for updating the "unread" counter for categories
that support it.
---
profiles/alert/server.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 06370e4..2dbc3b7 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -287,6 +287,36 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
+ void *data)
+{
+ const char *sender = dbus_message_get_sender(msg);
+ struct alert_data *alert;
+ const char *category;
+ uint16_t count;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
+ DBUS_TYPE_UINT16, &count,
+ DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+
+ alert = get_alert_data_by_category(category);
+ if (!alert) {
+ DBG("Category %s not registered", category);
+ return btd_error_invalid_args(msg);
+ }
+
+ if (!g_str_equal(alert->srv, sender)) {
+ DBG("Sender %s is not registered in category %s", sender,
+ category);
+ return btd_error_invalid_args(msg);
+ }
+
+ DBG("category %s, count %d", category, count);
+
+ return dbus_message_new_method_return(msg);
+}
+
static uint8_t ringer_cp_write(struct attribute *a,
struct btd_device *device,
gpointer user_data)
@@ -480,6 +510,9 @@ static const GDBusMethodTable alert_methods[] = {
{ "count", "q" },
{ "description", "s" }), NULL,
new_alert) },
+ { GDBUS_METHOD("UnreadAlert",
+ GDBUS_ARGS({ "category", "s" }, { "count", "q" }), NULL,
+ unread_alert) },
{ }
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 12/27] alert: Automatically unregister alert when agent leaves D-Bus
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (10 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 11/27] alert: Add initial support for UnreadAlert " Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 13/27] alert: Add per adapter attribute handle information Anderson Lizardo
` (14 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
---
profiles/alert/server.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 2dbc3b7..7622da0 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -84,6 +84,7 @@ struct alert_data {
const char *category;
char *srv;
char *path;
+ guint watcher;
};
static GSList *registered_alerts = NULL;
@@ -113,6 +114,9 @@ static void alert_data_destroy(gpointer user_data)
{
struct alert_data *alert = user_data;
+ if (alert->watcher)
+ g_dbus_remove_watch(btd_get_dbus_connection(), alert->watcher);
+
g_free(alert->srv);
g_free(alert->path);
g_free(alert);
@@ -210,6 +214,16 @@ static gboolean valid_count(const char *category, uint16_t count)
return FALSE;
}
+static void watcher_disconnect(DBusConnection *conn, void *user_data)
+{
+ struct alert_data *alert = user_data;
+
+ DBG("Category %s was disconnected", alert->category);
+
+ registered_alerts = g_slist_remove(registered_alerts, alert);
+ alert_data_destroy(alert);
+}
+
static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -238,6 +252,15 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
alert->srv = g_strdup(sender);
alert->path = g_strdup(path);
alert->category = category;
+ alert->watcher = g_dbus_add_disconnect_watch(conn, alert->srv,
+ watcher_disconnect, alert, NULL);
+
+ if (alert->watcher == 0) {
+ alert_data_destroy(alert);
+ DBG("Could not register disconnect watcher");
+ return btd_error_failed(msg,
+ "Could not register disconnect watcher");
+ }
registered_alerts = g_slist_append(registered_alerts, alert);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 13/27] alert: Add per adapter attribute handle information
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (11 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 12/27] alert: Automatically unregister alert when agent leaves D-Bus Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 14/27] alert: Update Supported New/Unread Category characteristic values Anderson Lizardo
` (13 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Each adapter may have different GATT services running, therefore any
attribute handles (e.g. for updating characteristic values) need to be
saved per adapter.
---
profiles/alert/server.c | 57 ++++++++++++++++++++++++++++++++++++++---------
1 file changed, 47 insertions(+), 10 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 7622da0..6f59f59 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -87,7 +87,13 @@ struct alert_data {
guint watcher;
};
+struct alert_adapter {
+ struct btd_adapter *adapter;
+ /* TODO: store characteristic value handles */
+};
+
static GSList *registered_alerts = NULL;
+static GSList *alert_adapters = NULL;
static uint8_t ringer_setting = RINGER_NORMAL;
static uint8_t alert_status = 0;
@@ -110,6 +116,21 @@ static const char * const pasp_categories[] = {
"display",
};
+static int adapter_cmp(gconstpointer a, gconstpointer b)
+{
+ const struct alert_adapter *al_adapter = a;
+ const struct btd_adapter *adapter = b;
+
+ return al_adapter->adapter == adapter ? 0 : -1;
+}
+
+static struct alert_adapter *find_alert_adapter(struct btd_adapter *adapter)
+{
+ GSList *l = g_slist_find_custom(alert_adapters, adapter, adapter_cmp);
+
+ return l ? l->data : NULL;
+}
+
static void alert_data_destroy(gpointer user_data)
{
struct alert_data *alert = user_data;
@@ -379,20 +400,20 @@ static uint8_t ringer_setting_read(struct attribute *a,
return 0;
}
-static void register_phone_alert_service(struct btd_adapter *adapter)
+static void register_phone_alert_service(struct alert_adapter *al_adapter)
{
bt_uuid_t uuid;
bt_uuid16_create(&uuid, PHONE_ALERT_STATUS_SVC_UUID);
/* Phone Alert Status Service */
- gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ gatt_service_add(al_adapter->adapter, GATT_PRIM_SVC_UUID, &uuid,
/* Alert Status characteristic */
GATT_OPT_CHR_UUID, ALERT_STATUS_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
- alert_status_read, adapter,
+ alert_status_read, al_adapter->adapter,
/* Ringer Control Point characteristic */
GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
@@ -403,7 +424,7 @@ static void register_phone_alert_service(struct btd_adapter *adapter)
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
- ringer_setting_read, adapter,
+ ringer_setting_read, al_adapter->adapter,
GATT_OPT_INVALID);
}
@@ -471,19 +492,19 @@ static uint8_t alert_notif_cp_write(struct attribute *a,
return 0;
}
-static void register_alert_notif_service(struct btd_adapter *adapter)
+static void register_alert_notif_service(struct alert_adapter *al_adapter)
{
bt_uuid_t uuid;
bt_uuid16_create(&uuid, ALERT_NOTIF_SVC_UUID);
/* Alert Notification Service */
- gatt_service_add(adapter, GATT_PRIM_SVC_UUID, &uuid,
+ gatt_service_add(al_adapter->adapter, GATT_PRIM_SVC_UUID, &uuid,
/* Supported New Alert Category */
GATT_OPT_CHR_UUID, SUPP_NEW_ALERT_CAT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
- supp_new_alert_cat_read, adapter,
+ supp_new_alert_cat_read, al_adapter->adapter,
/* New Alert */
GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
@@ -491,7 +512,7 @@ static void register_alert_notif_service(struct btd_adapter *adapter)
GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
- supp_unread_alert_cat_read, adapter,
+ supp_unread_alert_cat_read, al_adapter->adapter,
/* Unread Alert Status */
GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
@@ -506,8 +527,15 @@ static void register_alert_notif_service(struct btd_adapter *adapter)
static int alert_server_probe(struct btd_profile *p,
struct btd_adapter *adapter)
{
- register_phone_alert_service(adapter);
- register_alert_notif_service(adapter);
+ struct alert_adapter *al_adapter;
+
+ al_adapter = g_new0(struct alert_adapter, 1);
+ al_adapter->adapter = btd_adapter_ref(adapter);
+
+ alert_adapters = g_slist_append(alert_adapters, al_adapter);
+
+ register_phone_alert_service(al_adapter);
+ register_alert_notif_service(al_adapter);
return 0;
}
@@ -515,6 +543,15 @@ static int alert_server_probe(struct btd_profile *p,
static void alert_server_remove(struct btd_profile *p,
struct btd_adapter *adapter)
{
+ struct alert_adapter *al_adapter;
+
+ al_adapter = find_alert_adapter(adapter);
+ if (!al_adapter)
+ return;
+
+ alert_adapters = g_slist_remove(alert_adapters, al_adapter);
+ btd_adapter_unref(al_adapter->adapter);
+ g_free(al_adapter);
}
static struct btd_profile alert_profile = {
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 14/27] alert: Update Supported New/Unread Category characteristic values
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (12 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 13/27] alert: Add per adapter attribute handle information Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 15/27] alert: Update new alert characteristic value Anderson Lizardo
` (12 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
The value is now kept up-to-date when new/unread alerts arrive. This
value is not notified yet.
---
profiles/alert/server.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 6f59f59..8d0635a 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -89,7 +89,8 @@ struct alert_data {
struct alert_adapter {
struct btd_adapter *adapter;
- /* TODO: store characteristic value handles */
+ uint16_t supp_new_alert_cat_handle;
+ uint16_t supp_unread_alert_cat_handle;
};
static GSList *registered_alerts = NULL;
@@ -235,6 +236,29 @@ static gboolean valid_count(const char *category, uint16_t count)
return FALSE;
}
+static void update_supported_categories(gpointer data, gpointer user_data)
+{
+ struct alert_adapter *al_adapter = data;
+ struct btd_adapter *adapter = al_adapter->adapter;
+ uint8_t value[2];
+ unsigned int i;
+
+ memset(value, 0, sizeof(value));
+
+ for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+ if (registered_category(anp_categories[i]))
+ hci_set_bit(i, value);
+ }
+
+ attrib_db_update(adapter, al_adapter->supp_new_alert_cat_handle, NULL,
+ value, sizeof(value), NULL);
+
+ /* FIXME: For now report all registered categories as supporting unread
+ * status, until it is known which ones should be supported */
+ attrib_db_update(adapter, al_adapter->supp_unread_alert_cat_handle,
+ NULL, value, sizeof(value), NULL);
+}
+
static void watcher_disconnect(DBusConnection *conn, void *user_data)
{
struct alert_data *alert = user_data;
@@ -243,6 +267,8 @@ static void watcher_disconnect(DBusConnection *conn, void *user_data)
registered_alerts = g_slist_remove(registered_alerts, alert);
alert_data_destroy(alert);
+
+ g_slist_foreach(alert_adapters, update_supported_categories, NULL);
}
static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
@@ -285,6 +311,8 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
registered_alerts = g_slist_append(registered_alerts, alert);
+ g_slist_foreach(alert_adapters, update_supported_categories, NULL);
+
DBG("RegisterAlert(\"%s\", \"%s\")", alert->category, alert->path);
return dbus_message_new_method_return(msg);
@@ -505,6 +533,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
supp_new_alert_cat_read, al_adapter->adapter,
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->supp_new_alert_cat_handle,
/* New Alert */
GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
@@ -513,6 +543,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
supp_unread_alert_cat_read, al_adapter->adapter,
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->supp_unread_alert_cat_handle,
/* Unread Alert Status */
GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 15/27] alert: Update new alert characteristic value
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (13 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 14/27] alert: Update Supported New/Unread Category characteristic values Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 16/27] alert: Update unread " Anderson Lizardo
` (11 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Update the attribute value when a new alert is reported to BlueZ.
---
profiles/alert/server.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 8d0635a..73da8b8 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -64,6 +64,8 @@
/* Maximum length for "Text String Information" */
#define NEW_ALERT_MAX_INFO_SIZE 18
+/* Maximum length for New Alert Characteristic Value */
+#define NEW_ALERT_CHR_MAX_VALUE_SIZE (NEW_ALERT_MAX_INFO_SIZE + 2)
enum {
ENABLE_NEW_INCOMING,
@@ -91,6 +93,7 @@ struct alert_adapter {
struct btd_adapter *adapter;
uint16_t supp_new_alert_cat_handle;
uint16_t supp_unread_alert_cat_handle;
+ uint16_t new_alert_handle;
};
static GSList *registered_alerts = NULL;
@@ -318,6 +321,16 @@ static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static void update_new_alert(gpointer data, gpointer user_data)
+{
+ struct alert_adapter *al_adapter = data;
+ struct btd_adapter *adapter = al_adapter->adapter;
+ uint8_t *value = user_data;
+
+ attrib_db_update(adapter, al_adapter->new_alert_handle, NULL, &value[1],
+ value[0], NULL);
+}
+
static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -325,6 +338,7 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
const char *category, *description;
struct alert_data *alert;
uint16_t count;
+ unsigned int i;
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
DBUS_TYPE_UINT16, &count, DBUS_TYPE_STRING,
@@ -354,6 +368,29 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
return btd_error_invalid_args(msg);
}
+ for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+ if (g_str_equal(anp_categories[i], category)) {
+ uint8_t value[NEW_ALERT_CHR_MAX_VALUE_SIZE + 1];
+ size_t dlen = strlen(description);
+ uint8_t *ptr = value;
+
+ memset(value, 0, sizeof(value));
+
+ *ptr++ = 2; /* Attribute value size */
+ *ptr++ = i; /* Category ID (mandatory) */
+ *ptr++ = count; /* Number of New Alert (mandatory) */
+ /* Text String Information (optional) */
+ strncpy((char *) ptr, description,
+ NEW_ALERT_MAX_INFO_SIZE - 1);
+
+ if (dlen > 0)
+ *value += dlen + 1;
+
+ g_slist_foreach(alert_adapters, update_new_alert,
+ value);
+ }
+ }
+
DBG("NewAlert(\"%s\", %d, \"%s\")", category, count, description);
return dbus_message_new_method_return(msg);
@@ -538,6 +575,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
/* New Alert */
GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->new_alert_handle,
/* Supported Unread Alert Category */
GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 16/27] alert: Update unread alert characteristic value
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (14 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 15/27] alert: Update new alert characteristic value Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 17/27] alert: Implement MuteOnce command Anderson Lizardo
` (10 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Update the attribute value when the unread alert count is changed.
---
profiles/alert/server.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 73da8b8..e289dfc 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -94,6 +94,7 @@ struct alert_adapter {
uint16_t supp_new_alert_cat_handle;
uint16_t supp_unread_alert_cat_handle;
uint16_t new_alert_handle;
+ uint16_t unread_alert_handle;
};
static GSList *registered_alerts = NULL;
@@ -396,12 +397,23 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static void update_unread_alert(gpointer data, gpointer user_data)
+{
+ struct alert_adapter *al_adapter = data;
+ struct btd_adapter *adapter = al_adapter->adapter;
+ uint8_t *value = user_data;
+
+ attrib_db_update(adapter, al_adapter->unread_alert_handle, NULL, value,
+ 2, NULL);
+}
+
static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
const char *sender = dbus_message_get_sender(msg);
struct alert_data *alert;
const char *category;
+ unsigned int i;
uint16_t count;
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
@@ -415,12 +427,29 @@ static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
return btd_error_invalid_args(msg);
}
+ if (!valid_count(category, count)) {
+ DBG("Count %d is invalid for %s category", count, category);
+ return btd_error_invalid_args(msg);
+ }
+
if (!g_str_equal(alert->srv, sender)) {
DBG("Sender %s is not registered in category %s", sender,
category);
return btd_error_invalid_args(msg);
}
+ for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+ if (g_str_equal(anp_categories[i], category)) {
+ uint8_t value[2];
+
+ value[0] = i; /* Category ID */
+ value[1] = count; /* Unread count */
+
+ g_slist_foreach(alert_adapters, update_unread_alert,
+ value);
+ }
+ }
+
DBG("category %s, count %d", category, count);
return dbus_message_new_method_return(msg);
@@ -587,6 +616,8 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
/* Unread Alert Status */
GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->unread_alert_handle,
/* Alert Notification Control Point */
GATT_OPT_CHR_UUID, ALERT_NOTIF_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 17/27] alert: Implement MuteOnce command
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (15 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 16/27] alert: Update unread " Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 18/27] alert: Add support for calling MuteOnce() Anderson Lizardo
` (9 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
MuteOnce() is called by BlueZ to instruct the agent to mute the ringer
during a incoming call.
---
profiles/alert/server.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index e289dfc..f021c07 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -76,6 +76,12 @@ enum {
NOTIFY_UNREAD_CAT,
};
+enum {
+ RINGER_SILENT_MODE = 1,
+ RINGER_MUTE_ONCE,
+ RINGER_CANCEL_SILENT_MODE,
+};
+
/* Ringer Setting characteristic values */
enum {
RINGER_SILENT,
@@ -461,6 +467,25 @@ static uint8_t ringer_cp_write(struct attribute *a,
{
DBG("a = %p", a);
+ if (a->len > 1) {
+ DBG("Invalid command size (%zu)", a->len);
+ return 0;
+ }
+
+ switch (a->data[0]) {
+ case RINGER_SILENT_MODE:
+ DBG("Silent Mode");
+ break;
+ case RINGER_MUTE_ONCE:
+ DBG("Mute Once");
+ break;
+ case RINGER_CANCEL_SILENT_MODE:
+ DBG("Cancel Silent Mode");
+ break;
+ default:
+ DBG("Invalid command (0x%02x)", a->data[0]);
+ }
+
return 0;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 18/27] alert: Add support for calling MuteOnce()
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (16 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 17/27] alert: Implement MuteOnce command Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 19/27] alert: Add support for calling SetRinger() Anderson Lizardo
` (8 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When BlueZ wants to call MuteOnce() method from org.bluez.AlertAgent
interface for a registered agent, the function agent_ringer_mute_once()
must be called.
---
profiles/alert/server.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index f021c07..d18140f 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -61,6 +61,7 @@
#define ALERT_OBJECT_PATH "/org/bluez"
#define ALERT_INTERFACE "org.bluez.Alert"
+#define ALERT_AGENT_INTERFACE "org.bluez.AlertAgent"
/* Maximum length for "Text String Information" */
#define NEW_ALERT_MAX_INFO_SIZE 18
@@ -403,6 +404,28 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
return dbus_message_new_method_return(msg);
}
+static int agent_ringer_mute_once(void)
+{
+ struct alert_data *alert;
+ DBusMessage *msg;
+
+ alert = get_alert_data_by_category("ringer");
+ if (!alert) {
+ DBG("Category ringer is not registered");
+ return -EINVAL;
+ }
+
+ msg = dbus_message_new_method_call(alert->srv, alert->path,
+ ALERT_AGENT_INTERFACE, "MuteOnce");
+ if (!msg)
+ return -ENOMEM;
+
+ dbus_message_set_no_reply(msg, TRUE);
+ g_dbus_send_message(btd_get_dbus_connection(), msg);
+
+ return 0;
+}
+
static void update_unread_alert(gpointer data, gpointer user_data)
{
struct alert_adapter *al_adapter = data;
@@ -478,6 +501,7 @@ static uint8_t ringer_cp_write(struct attribute *a,
break;
case RINGER_MUTE_ONCE:
DBG("Mute Once");
+ agent_ringer_mute_once();
break;
case RINGER_CANCEL_SILENT_MODE:
DBG("Cancel Silent Mode");
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 19/27] alert: Add support for calling SetRinger()
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (17 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 18/27] alert: Add support for calling MuteOnce() Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 20/27] alert: Add test-alert script Anderson Lizardo
` (7 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When BlueZ wants to call SetRinger() method from org.bluez.AlertAgent
interface for a registered agent, the function agent_ringer_set_ringer()
must be called.
---
profiles/alert/server.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index d18140f..6592913 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -426,6 +426,31 @@ static int agent_ringer_mute_once(void)
return 0;
}
+static int agent_ringer_set_ringer(const char *mode)
+{
+ struct alert_data *alert;
+ DBusMessage *msg;
+
+ alert = get_alert_data_by_category("ringer");
+ if (!alert) {
+ DBG("Category ringer is not registered");
+ return -EINVAL;
+ }
+
+ msg = dbus_message_new_method_call(alert->srv, alert->path,
+ ALERT_AGENT_INTERFACE, "SetRinger");
+ if (!msg)
+ return -ENOMEM;
+
+ dbus_message_append_args(msg, DBUS_TYPE_STRING, &mode,
+ DBUS_TYPE_INVALID);
+
+ dbus_message_set_no_reply(msg, TRUE);
+ g_dbus_send_message(btd_get_dbus_connection(), msg);
+
+ return 0;
+}
+
static void update_unread_alert(gpointer data, gpointer user_data)
{
struct alert_adapter *al_adapter = data;
@@ -498,6 +523,7 @@ static uint8_t ringer_cp_write(struct attribute *a,
switch (a->data[0]) {
case RINGER_SILENT_MODE:
DBG("Silent Mode");
+ agent_ringer_set_ringer("disabled");
break;
case RINGER_MUTE_ONCE:
DBG("Mute Once");
@@ -505,6 +531,7 @@ static uint8_t ringer_cp_write(struct attribute *a,
break;
case RINGER_CANCEL_SILENT_MODE:
DBG("Cancel Silent Mode");
+ agent_ringer_set_ringer("enabled");
break;
default:
DBG("Invalid command (0x%02x)", a->data[0]);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 20/27] alert: Add test-alert script
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (18 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 19/27] alert: Add support for calling SetRinger() Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 21/27] alert: Update Alert Status and Ringer Setting characteristic values Anderson Lizardo
` (6 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
This script is useful for testing the Alert API and testing the
implementation with PTS.
---
Makefile.tools | 2 +-
test/test-alert | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 174 insertions(+), 1 deletion(-)
create mode 100755 test/test-alert
diff --git a/Makefile.tools b/Makefile.tools
index 9637a9f..a83ed3f 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -213,4 +213,4 @@ EXTRA_DIST += test/sap_client.py test/hsplay test/hsmicro \
test/test-health test/test-health-sink test/service-record.dtd \
test/service-did.xml test/service-spp.xml test/service-opp.xml \
test/service-ftp.xml test/simple-player test/test-nap \
- test/test-heartrate
+ test/test-heartrate test/test-alert
diff --git a/test/test-alert b/test/test-alert
new file mode 100755
index 0000000..c92a719
--- /dev/null
+++ b/test/test-alert
@@ -0,0 +1,173 @@
+#!/usr/bin/python
+from __future__ import absolute_import, print_function, unicode_literals
+import dbus
+import dbus.service
+import dbus.mainloop.glib
+import gobject
+import optparse
+import sys
+import os
+
+BUS_NAME = 'org.bluez'
+ALERT_INTERFACE = 'org.bluez.Alert'
+ALERT_AGENT_INTERFACE = 'org.bluez.AlertAgent'
+BLUEZ_OBJECT_PATH = '/org/bluez'
+TEST_OBJECT_PATH = '/org/bluez/test'
+
+class AlertAgent(dbus.service.Object):
+ def __init__(self, bus, object_path, alert):
+ dbus.service.Object.__init__(self, bus, object_path)
+ self.alert = alert
+
+ @dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='',
+ out_signature='')
+ def MuteOnce(self):
+ print('method MuteOnce() was called')
+ self.alert.NewAlert('ringer', 1, 'not active')
+
+ @dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='s',
+ out_signature='')
+ def SetRinger(self, mode):
+ print('method SetRinger(%s) was called' % mode)
+ self.alert.NewAlert('ringer', 1, mode)
+
+def print_command_line(options):
+ if not options.verbose:
+ return False
+
+ print('-w: ' + str(options.wait))
+
+ if options.times:
+ print('-t: ' + str(options.times))
+
+ if options.register:
+ print('-r: ' + options.register)
+ else:
+ print('-r: ' + str(None))
+
+ if options.new_alert:
+ print('-n:')
+ for i in options.new_alert:
+ print(' ' + i[0] + ', ' + i[1] + ', ' + i[2])
+ else:
+ print('-n: ' + str(None))
+
+ if options.unread_alert:
+ print('-u:')
+ for i in options.unread_alert:
+ print(' ' + i[0] + ', ' + i[1])
+ else:
+ print('-u: ' + str(None))
+
+ print()
+
+ return True
+
+def read_count(param):
+ try:
+ return int(param)
+ except ValueError:
+ print('<count> must be integer, not \"%s\"' % param)
+ sys.exit(1)
+
+def new_alert(alert, params):
+ if not params:
+ return False
+
+ for param in params:
+ category = param[0]
+ count = read_count(param[1])
+ description = param[2]
+
+ alert.NewAlert(category, count, description)
+
+def unread_alert(alert, params):
+ if not params:
+ return False
+
+ for param in params:
+ category = param[0]
+ count = read_count(param[1])
+
+ alert.UnreadAlert(category, count)
+
+option_list = [
+ optparse.make_option('-v', None,
+ action = 'store_true',
+ default = False,
+ dest = 'verbose',
+ help = 'verbose'),
+
+ optparse.make_option('-w', None,
+ action = 'store_true',
+ default = False,
+ dest = 'wait',
+ help = 'wait for dbus events'),
+
+ optparse.make_option('-t', None,
+ action = 'store',
+ default = 1,
+ type = "int",
+ dest = 'times',
+ help = 'repeat UnreadAlert/NewAlert <times> times',
+ metavar = '<times>'),
+
+ optparse.make_option('-r', None,
+ action = 'store',
+ dest = 'register',
+ type = 'string',
+ metavar = '<category>',
+ help = 'register alert'),
+
+ optparse.make_option('-n', None,
+ action = 'append',
+ dest = 'new_alert',
+ type = 'string',
+ nargs = 3,
+ metavar = '<category> <count> <description>',
+ help = 'send new alert'),
+
+ optparse.make_option('-u', None,
+ action = 'append',
+ dest = 'unread_alert',
+ type = 'string',
+ nargs = 2,
+ metavar = '<category> <count>',
+ help = 'send unread alert'),
+]
+
+parser = optparse.OptionParser(option_list=option_list)
+parser.disable_interspersed_args()
+(options, args) = parser.parse_args()
+
+dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+bus = dbus.SystemBus()
+mainloop = gobject.MainLoop()
+alert = dbus.Interface(bus.get_object(BUS_NAME, BLUEZ_OBJECT_PATH),
+ ALERT_INTERFACE)
+alert_agent = AlertAgent(bus, TEST_OBJECT_PATH, alert)
+
+print_command_line(options)
+
+if not (options.register or options.new_alert or options.unread_alert or
+ options.wait):
+ parser.print_usage()
+ sys.exit(1)
+
+if options.register:
+ alert.RegisterAlert(options.register, TEST_OBJECT_PATH)
+
+times = 0
+while times < options.times:
+ times += 1
+
+ new_alert(alert, options.new_alert)
+ unread_alert(alert, options.unread_alert)
+
+if not options.wait:
+ sys.exit(0)
+
+try:
+ mainloop.run()
+except:
+ pass
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 21/27] alert: Update Alert Status and Ringer Setting characteristic values
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (19 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 20/27] alert: Add test-alert script Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 22/27] alert: Add support for ringer setting notification Anderson Lizardo
` (5 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
Now these characteristic values are updated when the agent changes any
PASP alert state or setting.
---
profiles/alert/server.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 6592913..95dee04 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -339,6 +339,27 @@ static void update_new_alert(gpointer data, gpointer user_data)
value[0], NULL);
}
+static void update_phone_alerts(const char *category, const char *description)
+{
+ unsigned int i;
+
+ if (g_str_equal(category, "ringer")) {
+ if (g_str_equal(description, "enabled"))
+ ringer_setting = RINGER_NORMAL;
+ else if (g_str_equal(description, "disabled"))
+ ringer_setting = RINGER_SILENT;
+ }
+
+ for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
+ if (g_str_equal(pasp_categories[i], category)) {
+ if (g_str_equal(description, "active"))
+ alert_status |= (1 << i);
+ else if (g_str_equal(description, "not active"))
+ alert_status &= ~(1 << i);
+ }
+ }
+}
+
static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -399,6 +420,9 @@ static DBusMessage *new_alert(DBusConnection *conn, DBusMessage *msg,
}
}
+ if (pasp_category(category))
+ update_phone_alerts(category, description);
+
DBG("NewAlert(\"%s\", %d, \"%s\")", category, count, description);
return dbus_message_new_method_return(msg);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 22/27] alert: Add support for ringer setting notification
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (20 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 21/27] alert: Update Alert Status and Ringer Setting characteristic values Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 23/27] alert: Add support for alert status notification Anderson Lizardo
` (4 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When the agent reports a ringer setting change, a ringer setting
notification is sent to the peer device (if notification is enabled).
---
profiles/alert/server.c | 156 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 154 insertions(+), 2 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 95dee04..10c4160 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -31,6 +31,7 @@
#include <gdbus.h>
#include <glib.h>
#include <bluetooth/uuid.h>
+#include <stdlib.h>
#include "dbus-common.h"
#include "att.h"
@@ -45,6 +46,8 @@
#include "server.h"
#include "profile.h"
#include "error.h"
+#include "textfile.h"
+#include "attio.h"
#define PHONE_ALERT_STATUS_SVC_UUID 0x180E
#define ALERT_NOTIF_SVC_UUID 0x1811
@@ -89,6 +92,11 @@ enum {
RINGER_NORMAL,
};
+enum notify_type {
+ NOTIFY_RINGER_SETTING = 0,
+ NOTIFY_SIZE,
+};
+
struct alert_data {
const char *category;
char *srv;
@@ -102,6 +110,21 @@ struct alert_adapter {
uint16_t supp_unread_alert_cat_handle;
uint16_t new_alert_handle;
uint16_t unread_alert_handle;
+ uint16_t hnd_ccc[NOTIFY_SIZE];
+ uint16_t hnd_value[NOTIFY_SIZE];
+};
+
+struct notify_data {
+ struct alert_adapter *al_adapter;
+ enum notify_type type;
+ uint8_t *value;
+ size_t len;
+};
+
+struct notify_callback {
+ struct notify_data *notify_data;
+ struct btd_device *device;
+ guint id;
};
static GSList *registered_alerts = NULL;
@@ -282,6 +305,125 @@ static void watcher_disconnect(DBusConnection *conn, void *user_data)
g_slist_foreach(alert_adapters, update_supported_categories, NULL);
}
+static struct btd_device *get_notifiable_device(struct btd_adapter *adapter,
+ char *key, char *value,
+ uint16_t ccc)
+{
+ struct btd_device *device;
+ char addr[18];
+ uint16_t hnd, val;
+ uint8_t bdaddr_type;
+
+ sscanf(key, "%17s#%hhu#%04hX", addr, &bdaddr_type, &hnd);
+
+ if (hnd != ccc)
+ return NULL;
+
+ val = strtol(value, NULL, 16);
+ if (!(val & 0x0001))
+ return NULL;
+
+ device = adapter_find_device(adapter, addr);
+ if (device == NULL)
+ return NULL;
+
+ return btd_device_ref(device);
+}
+
+static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
+{
+ struct notify_callback *cb = user_data;
+ struct notify_data *nd = cb->notify_data;
+ enum notify_type type = nd->type;
+ struct alert_adapter *al_adapter = nd->al_adapter;
+ uint8_t pdu[ATT_MAX_MTU];
+ size_t len = 0;
+
+ switch (type) {
+ case NOTIFY_RINGER_SETTING:
+ len = enc_notification(al_adapter->hnd_value[type],
+ &ringer_setting, sizeof(ringer_setting),
+ pdu, sizeof(pdu));
+ break;
+ default:
+ DBG("Unknown type, could not send notification");
+ goto end;
+ }
+
+ DBG("Send notification for handle: 0x%04x, ccc: 0x%04x",
+ al_adapter->hnd_value[type],
+ al_adapter->hnd_ccc[type]);
+
+ g_attrib_send(attrib, 0, ATT_OP_HANDLE_NOTIFY, pdu, len,
+ NULL, NULL, NULL);
+
+end:
+ btd_device_remove_attio_callback(cb->device, cb->id);
+ btd_device_unref(cb->device);
+ g_free(cb->notify_data->value);
+ g_free(cb->notify_data);
+ g_free(cb);
+}
+
+static void filter_devices_notify(char *key, char *value, void *user_data)
+{
+ struct notify_data *notify_data = user_data;
+ struct alert_adapter *al_adapter = notify_data->al_adapter;
+ enum notify_type type = notify_data->type;
+ struct btd_device *device;
+ struct notify_callback *cb;
+
+ device = get_notifiable_device(al_adapter->adapter, key, value,
+ al_adapter->hnd_ccc[type]);
+ if (device == NULL)
+ return;
+
+ cb = g_new0(struct notify_callback, 1);
+ cb->notify_data = notify_data;
+ cb->device = device;
+ cb->id = btd_device_add_attio_callback(device,
+ attio_connected_cb, NULL, cb);
+}
+
+static void create_filename(char *filename, struct btd_adapter *adapter)
+{
+ char srcaddr[18];
+ bdaddr_t src;
+
+ adapter_get_address(adapter, &src);
+ ba2str(&src, srcaddr);
+
+ create_name(filename, PATH_MAX, STORAGEDIR, srcaddr, "ccc");
+}
+
+static void notify_devices(struct alert_adapter *al_adapter,
+ enum notify_type type, uint8_t *value, size_t len)
+{
+ struct notify_data *notify_data;
+ char filename[PATH_MAX + 1];
+
+ notify_data = g_new0(struct notify_data, 1);
+ notify_data->al_adapter = al_adapter;
+ notify_data->type = type;
+ notify_data->value = g_memdup(value, len);
+ notify_data->len = len;
+
+ create_filename(filename, al_adapter->adapter);
+ textfile_foreach(filename, filter_devices_notify, notify_data);
+}
+
+static void pasp_notification(enum notify_type type)
+{
+ GSList *it;
+ struct alert_adapter *al_adapter;
+
+ for (it = alert_adapters; it; it = g_slist_next(it)) {
+ al_adapter = it->data;
+
+ notify_devices(al_adapter, type, NULL, 0);
+ }
+}
+
static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
@@ -344,10 +486,15 @@ static void update_phone_alerts(const char *category, const char *description)
unsigned int i;
if (g_str_equal(category, "ringer")) {
- if (g_str_equal(description, "enabled"))
+ if (g_str_equal(description, "enabled")) {
ringer_setting = RINGER_NORMAL;
- else if (g_str_equal(description, "disabled"))
+ pasp_notification(NOTIFY_RINGER_SETTING);
+ return;
+ } else if (g_str_equal(description, "disabled")) {
ringer_setting = RINGER_SILENT;
+ pasp_notification(NOTIFY_RINGER_SETTING);
+ return;
+ }
}
for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
@@ -619,6 +766,10 @@ static void register_phone_alert_service(struct alert_adapter *al_adapter)
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
ringer_setting_read, al_adapter->adapter,
+ GATT_OPT_CCC_GET_HANDLE,
+ &al_adapter->hnd_ccc[NOTIFY_RINGER_SETTING],
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->hnd_value[NOTIFY_RINGER_SETTING],
GATT_OPT_INVALID);
}
@@ -753,6 +904,7 @@ static void alert_server_remove(struct btd_profile *p,
alert_adapters = g_slist_remove(alert_adapters, al_adapter);
btd_adapter_unref(al_adapter->adapter);
+
g_free(al_adapter);
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 23/27] alert: Add support for alert status notification
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (21 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 22/27] alert: Add support for ringer setting notification Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 24/27] alert: Add support for new alert notification Anderson Lizardo
` (3 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
The notification is sent (to peer devices that have it enabled on the
CCC descriptor) every time the alert status characteristic value
changes.
---
profiles/alert/server.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 10c4160..5414d74 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -94,6 +94,7 @@ enum {
enum notify_type {
NOTIFY_RINGER_SETTING = 0,
+ NOTIFY_ALERT_STATUS,
NOTIFY_SIZE,
};
@@ -345,6 +346,11 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
&ringer_setting, sizeof(ringer_setting),
pdu, sizeof(pdu));
break;
+ case NOTIFY_ALERT_STATUS:
+ len = enc_notification(al_adapter->hnd_value[type],
+ &alert_status, sizeof(alert_status),
+ pdu, sizeof(pdu));
+ break;
default:
DBG("Unknown type, could not send notification");
goto end;
@@ -499,10 +505,14 @@ static void update_phone_alerts(const char *category, const char *description)
for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
if (g_str_equal(pasp_categories[i], category)) {
- if (g_str_equal(description, "active"))
+ if (g_str_equal(description, "active")) {
alert_status |= (1 << i);
- else if (g_str_equal(description, "not active"))
+ pasp_notification(NOTIFY_ALERT_STATUS);
+ } else if (g_str_equal(description, "not active")) {
alert_status &= ~(1 << i);
+ pasp_notification(NOTIFY_ALERT_STATUS);
+ }
+ break;
}
}
}
@@ -755,6 +765,10 @@ static void register_phone_alert_service(struct alert_adapter *al_adapter)
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
alert_status_read, al_adapter->adapter,
+ GATT_OPT_CCC_GET_HANDLE,
+ &al_adapter->hnd_ccc[NOTIFY_ALERT_STATUS],
+ GATT_OPT_CHR_VALUE_GET_HANDLE,
+ &al_adapter->hnd_value[NOTIFY_ALERT_STATUS],
/* Ringer Control Point characteristic */
GATT_OPT_CHR_UUID, RINGER_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE_WITHOUT_RESP,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 24/27] alert: Add support for new alert notification
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (22 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 23/27] alert: Add support for alert status notification Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 25/27] alert: Add support for unread " Anderson Lizardo
` (2 subsequent siblings)
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When NewAlert D-Bus method is called for one category from Alert
Notification Profile, the new alert characteristic value is notified.
---
profiles/alert/server.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 5414d74..166f905 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -95,6 +95,7 @@ enum {
enum notify_type {
NOTIFY_RINGER_SETTING = 0,
NOTIFY_ALERT_STATUS,
+ NOTIFY_NEW_ALERT,
NOTIFY_SIZE,
};
@@ -109,7 +110,6 @@ struct alert_adapter {
struct btd_adapter *adapter;
uint16_t supp_new_alert_cat_handle;
uint16_t supp_unread_alert_cat_handle;
- uint16_t new_alert_handle;
uint16_t unread_alert_handle;
uint16_t hnd_ccc[NOTIFY_SIZE];
uint16_t hnd_value[NOTIFY_SIZE];
@@ -351,6 +351,10 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
&alert_status, sizeof(alert_status),
pdu, sizeof(pdu));
break;
+ case NOTIFY_NEW_ALERT:
+ len = enc_notification(al_adapter->hnd_value[type],
+ nd->value, nd->len, pdu, sizeof(pdu));
+ break;
default:
DBG("Unknown type, could not send notification");
goto end;
@@ -483,8 +487,10 @@ static void update_new_alert(gpointer data, gpointer user_data)
struct btd_adapter *adapter = al_adapter->adapter;
uint8_t *value = user_data;
- attrib_db_update(adapter, al_adapter->new_alert_handle, NULL, &value[1],
- value[0], NULL);
+ attrib_db_update(adapter, al_adapter->hnd_value[NOTIFY_NEW_ALERT], NULL,
+ &value[1], value[0], NULL);
+
+ notify_devices(al_adapter, NOTIFY_NEW_ALERT, &value[1], value[0]);
}
static void update_phone_alerts(const char *category, const char *description)
@@ -869,8 +875,10 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
/* New Alert */
GATT_OPT_CHR_UUID, NEW_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CCC_GET_HANDLE,
+ &al_adapter->hnd_ccc[NOTIFY_NEW_ALERT],
GATT_OPT_CHR_VALUE_GET_HANDLE,
- &al_adapter->new_alert_handle,
+ &al_adapter->hnd_value[NOTIFY_NEW_ALERT],
/* Supported Unread Alert Category */
GATT_OPT_CHR_UUID, SUPP_UNREAD_ALERT_CAT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 25/27] alert: Add support for unread alert notification
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (23 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 24/27] alert: Add support for new alert notification Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 26/27] alert: Implement Release() agent method Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 27/27] alert: Add org.bluez.AlertAgent to D-Bus policy file Anderson Lizardo
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
When UnreadAlert D-Bus method is called for a registered category
from Alert Notification Profile, The unread alert characteristic value
is notified.
---
profiles/alert/server.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 166f905..0ed8bb1 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -96,6 +96,7 @@ enum notify_type {
NOTIFY_RINGER_SETTING = 0,
NOTIFY_ALERT_STATUS,
NOTIFY_NEW_ALERT,
+ NOTIFY_UNREAD_ALERT,
NOTIFY_SIZE,
};
@@ -110,7 +111,6 @@ struct alert_adapter {
struct btd_adapter *adapter;
uint16_t supp_new_alert_cat_handle;
uint16_t supp_unread_alert_cat_handle;
- uint16_t unread_alert_handle;
uint16_t hnd_ccc[NOTIFY_SIZE];
uint16_t hnd_value[NOTIFY_SIZE];
};
@@ -352,6 +352,7 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
pdu, sizeof(pdu));
break;
case NOTIFY_NEW_ALERT:
+ case NOTIFY_UNREAD_ALERT:
len = enc_notification(al_adapter->hnd_value[type],
nd->value, nd->len, pdu, sizeof(pdu));
break;
@@ -644,8 +645,11 @@ static void update_unread_alert(gpointer data, gpointer user_data)
struct btd_adapter *adapter = al_adapter->adapter;
uint8_t *value = user_data;
- attrib_db_update(adapter, al_adapter->unread_alert_handle, NULL, value,
- 2, NULL);
+ attrib_db_update(adapter,
+ al_adapter->hnd_value[NOTIFY_UNREAD_ALERT], NULL, value,
+ 2, NULL);
+
+ notify_devices(al_adapter, NOTIFY_UNREAD_ALERT, value, 2);
}
static DBusMessage *unread_alert(DBusConnection *conn, DBusMessage *msg,
@@ -889,8 +893,10 @@ static void register_alert_notif_service(struct alert_adapter *al_adapter)
/* Unread Alert Status */
GATT_OPT_CHR_UUID, UNREAD_ALERT_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_NOTIFY,
+ GATT_OPT_CCC_GET_HANDLE,
+ &al_adapter->hnd_ccc[NOTIFY_UNREAD_ALERT],
GATT_OPT_CHR_VALUE_GET_HANDLE,
- &al_adapter->unread_alert_handle,
+ &al_adapter->hnd_value[NOTIFY_UNREAD_ALERT],
/* Alert Notification Control Point */
GATT_OPT_CHR_UUID, ALERT_NOTIF_CP_CHR_UUID,
GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_WRITE,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 26/27] alert: Implement Release() agent method
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (24 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 25/27] alert: Add support for unread " Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 27/27] alert: Add org.bluez.AlertAgent to D-Bus policy file Anderson Lizardo
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This method allows BlueZ to notify the agent that it will not be used
anymore, and can thus cleanup itself (e.g. deallocate D-Bus object, or
exit).
---
profiles/alert/server.c | 18 +++++++++++++++++-
test/test-alert | 11 +++++++++--
2 files changed, 26 insertions(+), 3 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 0ed8bb1..37fd125 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -179,9 +179,25 @@ static void alert_data_destroy(gpointer user_data)
g_free(alert);
}
+static void alert_release(gpointer user_data)
+{
+ struct alert_data *alert = user_data;
+ DBusMessage *msg;
+
+ msg = dbus_message_new_method_call(alert->srv, alert->path,
+ ALERT_AGENT_INTERFACE,
+ "Release");
+ if (msg)
+ g_dbus_send_message(btd_get_dbus_connection(), msg);
+
+ alert_data_destroy(alert);
+}
+
static void alert_destroy(gpointer user_data)
{
- g_slist_free_full(registered_alerts, alert_data_destroy);
+ DBG("");
+
+ g_slist_free_full(registered_alerts, alert_release);
registered_alerts = NULL;
}
diff --git a/test/test-alert b/test/test-alert
index c92a719..1e241a3 100755
--- a/test/test-alert
+++ b/test/test-alert
@@ -15,9 +15,10 @@ BLUEZ_OBJECT_PATH = '/org/bluez'
TEST_OBJECT_PATH = '/org/bluez/test'
class AlertAgent(dbus.service.Object):
- def __init__(self, bus, object_path, alert):
+ def __init__(self, bus, object_path, alert, mainloop):
dbus.service.Object.__init__(self, bus, object_path)
self.alert = alert
+ self.mainloop = mainloop
@dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='',
out_signature='')
@@ -31,6 +32,12 @@ class AlertAgent(dbus.service.Object):
print('method SetRinger(%s) was called' % mode)
self.alert.NewAlert('ringer', 1, mode)
+ @dbus.service.method(ALERT_AGENT_INTERFACE, in_signature='',
+ out_signature='')
+ def Release(self):
+ print('method Release() was called')
+ self.mainloop.quit()
+
def print_command_line(options):
if not options.verbose:
return False
@@ -145,7 +152,7 @@ bus = dbus.SystemBus()
mainloop = gobject.MainLoop()
alert = dbus.Interface(bus.get_object(BUS_NAME, BLUEZ_OBJECT_PATH),
ALERT_INTERFACE)
-alert_agent = AlertAgent(bus, TEST_OBJECT_PATH, alert)
+alert_agent = AlertAgent(bus, TEST_OBJECT_PATH, alert, mainloop)
print_command_line(options)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v3 BlueZ 27/27] alert: Add org.bluez.AlertAgent to D-Bus policy file
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
` (25 preceding siblings ...)
2012-10-02 20:24 ` [PATCH v3 BlueZ 26/27] alert: Implement Release() agent method Anderson Lizardo
@ 2012-10-02 20:24 ` Anderson Lizardo
26 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-02 20:24 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This allows BlueZ to call the methods on the org.bluez.AlertAgent
interface.
---
src/bluetooth.conf | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/bluetooth.conf b/src/bluetooth.conf
index 602c8af..2db43d9 100644
--- a/src/bluetooth.conf
+++ b/src/bluetooth.conf
@@ -16,6 +16,7 @@
<allow send_interface="org.bluez.MediaPlayer"/>
<allow send_interface="org.bluez.Watcher"/>
<allow send_interface="org.bluez.ThermometerWatcher"/>
+ <allow send_interface="org.bluez.AlertAgent"/>
<allow send_interface="org.bluez.Profile"/>
<allow send_interface="org.bluez.HeartRateWatcher"/>
</policy>
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* Re: [PATCH v3 BlueZ 01/27] doc: Introduce Alert API
2012-10-02 20:24 ` [PATCH v3 BlueZ 01/27] doc: Introduce Alert API Anderson Lizardo
@ 2012-10-03 8:21 ` Johan Hedberg
2012-10-03 10:56 ` Anderson Lizardo
2012-10-03 12:46 ` [PATCH v4 " Anderson Lizardo
1 sibling, 1 reply; 88+ messages in thread
From: Johan Hedberg @ 2012-10-03 8:21 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
Hi Lizardo,
On Tue, Oct 02, 2012, Anderson Lizardo wrote:
> + void SetRinger(string mode)
> +
> + This method is only called if "ringer" alert category
> + is specified when registering the agent.
> +
> + Set ringer to the specified mode. If mode is "enabled",
> + ringer is set to the default mode, as defined by the
> + current active profile. If mode is "disabled", ringer
> + will not activate on incoming calls, until it is set
> + back to "enabled" mode.
> +
> + Possible Errors: org.bluez.Error.InvalidArguments
Since you've used a string here instead of a boolean is it correct to
assume that you want to maintain the capability of extending the
possible values to more than just "enabled" and "disabled"? Does the
current profile/service specification already proved more possibilities
than these two values?
Johan
^ permalink raw reply [flat|nested] 88+ messages in thread
* Re: [PATCH v3 BlueZ 01/27] doc: Introduce Alert API
2012-10-03 8:21 ` Johan Hedberg
@ 2012-10-03 10:56 ` Anderson Lizardo
0 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-03 10:56 UTC (permalink / raw)
To: Anderson Lizardo, linux-bluetooth
Hi Johan,
On Wed, Oct 3, 2012 at 4:21 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Lizardo,
>
> On Tue, Oct 02, 2012, Anderson Lizardo wrote:
>> + void SetRinger(string mode)
>> +
>> + This method is only called if "ringer" alert category
>> + is specified when registering the agent.
>> +
>> + Set ringer to the specified mode. If mode is "enabled",
>> + ringer is set to the default mode, as defined by the
>> + current active profile. If mode is "disabled", ringer
>> + will not activate on incoming calls, until it is set
>> + back to "enabled" mode.
>> +
>> + Possible Errors: org.bluez.Error.InvalidArguments
>
> Since you've used a string here instead of a boolean is it correct to
> assume that you want to maintain the capability of extending the
> possible values to more than just "enabled" and "disabled"?
Yes, the idea here was to be able to extend this in case any future
GATT profile intends to control the ringer (or phone profile) to other
values.
> Does the
> current profile/service specification already proved more possibilities
> than these two values?
The Phone Alert Status (PASP) spec defines only "normal" and "silent"
modes (the other modes are Reserved). We mapped them to
"enabled/disabled" so it is more consistent with the Alert
Notification Profile (which is sharing the same D-Bus API). As PASP
only controls the ringer, it seemed logical to simply map it into the
broader ANP (which has the concept of "alert categories"). So we
created this "ringer" category and use it for PASP functionality
(along "display" and "vibrate").
See the description for RegisterAlert() and NewAlert() for more
details on how these categories work. Besides the ringer, the PASP
profile notifies state changes for the vibration motor and display
(which are mapped to "active"/"not active" alerts on the NewAlert()
API).
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 88+ messages in thread
* [PATCH v4 BlueZ 01/27] doc: Introduce Alert API
2012-10-02 20:24 ` [PATCH v3 BlueZ 01/27] doc: Introduce Alert API Anderson Lizardo
2012-10-03 8:21 ` Johan Hedberg
@ 2012-10-03 12:46 ` Anderson Lizardo
2012-10-03 19:39 ` Johan Hedberg
1 sibling, 1 reply; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-03 12:46 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Anderson Lizardo
This API will be implemented and initially used by Phone Alert Status
and Alert Notification GATT profiles (server role).
---
v4: Modify enumeration strings to use "-" as word separator.
Makefile.am | 2 +-
doc/alert-api.txt | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 110 insertions(+), 1 deletion(-)
create mode 100644 doc/alert-api.txt
diff --git a/Makefile.am b/Makefile.am
index c27eb01..470dbad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -396,7 +396,7 @@ EXTRA_DIST += doc/manager-api.txt \
doc/network-api.txt doc/input-api.txt doc/audio-api.txt \
doc/control-api.txt doc/hfp-api.txt doc/health-api.txt \
doc/sap-api.txt doc/media-api.txt doc/assigned-numbers.txt \
- doc/supported-features.txt
+ doc/supported-features.txt doc/alert-api.txt
AM_YFLAGS = -d
diff --git a/doc/alert-api.txt b/doc/alert-api.txt
new file mode 100644
index 0000000..bcaaaf3
--- /dev/null
+++ b/doc/alert-api.txt
@@ -0,0 +1,109 @@
+BlueZ D-Bus Alert API description
+*********************************
+
+Copyright (C) 2012 Instituto Nokia de Tecnologia - INdT
+
+Introduction
+------------
+
+Currently, there are two different GATT server profiles that depend on
+receiving alerts or notifications from the platform: Phone Alert Status (PASP)
+and Alert Notification (ANP). PASP is very specific to mobile phones, and also
+allows limited control to alerts (i.e. mute once or switch to a silent mode).
+
+This document presents a unified API that allows to register and notify alerts,
+and to control some alerts (using the provided agent object).
+
+
+Alert hierarchy
+===============
+
+Service org.bluez
+Interface org.bluez.Alert
+Object path /org/bluez
+
+Methods void RegisterAlert(string category, object agent)
+
+ Register a new alert category and an agent for it. This
+ means the application will be responsible for notifying
+ BlueZ of any alerts of that category, using the
+ NewAlert() method.
+
+ Supported ANP categories: simple, email, news, call,
+ missed-call, sms-mms, voice-mail, schedule,
+ high-priority, instant-message
+ Supported PASP categories: ringer, vibrate, display
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void NewAlert(string category, uint16 count, string description)
+
+ Notify BlueZ of new alert(s) for the given category. The
+ description is relative to the last received alert and
+ can be sender name, caller ID, title, or other
+ information specific to the category.
+
+ For ringer, vibrate and display categories, valid
+ descriptions are "active" and "not active". Alerts from
+ ringer category also accept "enabled" and "disabled",
+ depending on whether ringer is in silent mode or not.
+
+ Description must not exceed 18 bytes when encoded in
+ UTF-8 format, otherwise an error is returned. If there
+ is no description, an empty string should be used.
+
+ The count argument contains the number of alerts not
+ yet acknowledged by the user on the UI. To save D-Bus
+ traffic, events that may generate multiple alerts at
+ the same time (like email, sms, news) should trigger a
+ single NewAlert().
+
+ If there are more than 254 new alerts, count must be
+ set to 255. PASP alerts should always set count to 1.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void UnreadAlert(string category, uint16 count)
+
+ Some services (like SMS and e-mail) keep track of
+ number of unread items. This method allows to update
+ this counter, so peer devices can be notified using
+ Alert Notification Profile.
+
+ If there are more than 254 unread alerts, count must be
+ set to 255.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+Alert Agent hierarchy
+=====================
+
+Service org.bluez
+Interface org.bluez.AlertAgent
+Object path freely definable
+
+Methods void MuteOnce()
+
+ This method is only called if "ringer" alert category
+ is specified when registering the agent.
+
+ Mute the ringer once (e.g. during a incoming call). If
+ ringer is not active, does nothing.
+
+ void SetRinger(string mode)
+
+ This method is only called if "ringer" alert category
+ is specified when registering the agent.
+
+ Set ringer to the specified mode. If mode is "enabled",
+ ringer is set to the default mode, as defined by the
+ current active profile. If mode is "disabled", ringer
+ will not activate on incoming calls, until it is set
+ back to "enabled" mode.
+
+ Possible Errors: org.bluez.Error.InvalidArguments
+
+ void Release()
+
+ Release this agent. At this point, it will not be used
+ by BlueZ anymore and can be destroyed by the owner.
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* [PATCH v4 BlueZ 09/27] alert: Implement category registration in RegisterAlert()
2012-10-02 20:24 ` [PATCH v3 BlueZ 09/27] alert: Implement category registration in RegisterAlert() Anderson Lizardo
@ 2012-10-03 12:49 ` Anderson Lizardo
0 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-03 12:49 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Eder Ruiz Maria
From: Eder Ruiz Maria <eder.ruiz@openbossa.org>
The given alert category is now validated and registered.
---
v4: Modify enumeration strings to use "-" as word separator.
profiles/alert/server.c | 102 +++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 98 insertions(+), 4 deletions(-)
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index c0434a4..feb7b77 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -77,19 +77,113 @@ enum {
RINGER_NORMAL,
};
+struct alert_data {
+ const char *category;
+ char *srv;
+ char *path;
+};
+
+static GSList *registered_alerts = NULL;
static uint8_t ringer_setting = RINGER_NORMAL;
static uint8_t alert_status = 0;
+static const char * const anp_categories[] = {
+ "simple",
+ "email",
+ "news",
+ "call",
+ "missed-call",
+ "sms-mms",
+ "voice-mail",
+ "schedule",
+ "high-priority",
+ "instant-message",
+};
+
+static const char * const pasp_categories[] = {
+ "ringer",
+ "vibrate",
+ "display",
+};
+
+static void alert_data_destroy(gpointer user_data)
+{
+ struct alert_data *alert = user_data;
+
+ g_free(alert->srv);
+ g_free(alert->path);
+ g_free(alert);
+}
+
+static void alert_destroy(gpointer user_data)
+{
+ g_slist_free_full(registered_alerts, alert_data_destroy);
+ registered_alerts = NULL;
+}
+
+static const char *valid_category(const char *category)
+{
+ unsigned i;
+
+ for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+ if (g_str_equal(anp_categories[i], category))
+ return anp_categories[i];
+ }
+
+ for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
+ if (g_str_equal(pasp_categories[i], category))
+ return pasp_categories[i];
+ }
+
+ return NULL;
+}
+
+static gboolean registered_category(const char *category)
+{
+ GSList *l;
+ struct alert_data *alert;
+
+ for (l = registered_alerts; l; l = g_slist_next(l)) {
+ alert = l->data;
+ if (g_str_equal(alert->category, category))
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
void *data)
{
+ const char *sender = dbus_message_get_sender(msg);
+ char *path;
const char *category;
+ const char *c;
+ struct alert_data *alert;
+
+ if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &c,
+ DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
- if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
- DBUS_TYPE_INVALID))
+ category = valid_category(c);
+ if (!category) {
+ DBG("Invalid category: %s", c);
return btd_error_invalid_args(msg);
+ }
+
+ if (registered_category(category)) {
+ DBG("Category %s already registered", category);
+ return dbus_message_new_method_return(msg);
+ }
+
+ alert = g_new0(struct alert_data, 1);
+ alert->srv = g_strdup(sender);
+ alert->path = g_strdup(path);
+ alert->category = category;
+
+ registered_alerts = g_slist_append(registered_alerts, alert);
- DBG("RegisterAlert: %s", category);
+ DBG("RegisterAlert(\"%s\", \"%s\")", alert->category, alert->path);
return dbus_message_new_method_return(msg);
}
@@ -290,7 +384,7 @@ int alert_server_init(void)
if (!g_dbus_register_interface(btd_get_dbus_connection(),
ALERT_OBJECT_PATH, ALERT_INTERFACE,
alert_methods, NULL, NULL, NULL,
- NULL)) {
+ alert_destroy)) {
error("D-Bus failed to register %s interface",
ALERT_INTERFACE);
return -EIO;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 88+ messages in thread
* Re: [PATCH v4 BlueZ 01/27] doc: Introduce Alert API
2012-10-03 12:46 ` [PATCH v4 " Anderson Lizardo
@ 2012-10-03 19:39 ` Johan Hedberg
2012-10-03 20:17 ` Anderson Lizardo
0 siblings, 1 reply; 88+ messages in thread
From: Johan Hedberg @ 2012-10-03 19:39 UTC (permalink / raw)
To: Anderson Lizardo; +Cc: linux-bluetooth
Hi Lizardo,
On Wed, Oct 03, 2012, Anderson Lizardo wrote:
> This API will be implemented and initially used by Phone Alert Status
> and Alert Notification GATT profiles (server role).
> ---
>
> v4: Modify enumeration strings to use "-" as word separator.
>
> Makefile.am | 2 +-
> doc/alert-api.txt | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 110 insertions(+), 1 deletion(-)
> create mode 100644 doc/alert-api.txt
Thanks. All patches from this set are now upstream. I also pushed one
additional coding style patch since I didn't want to bother with another
review round for such a large patch set (and please don't do these huge
sets in the future - keep them under 10 or so).
Johan
^ permalink raw reply [flat|nested] 88+ messages in thread
* Re: [PATCH v4 BlueZ 01/27] doc: Introduce Alert API
2012-10-03 19:39 ` Johan Hedberg
@ 2012-10-03 20:17 ` Anderson Lizardo
0 siblings, 0 replies; 88+ messages in thread
From: Anderson Lizardo @ 2012-10-03 20:17 UTC (permalink / raw)
To: Anderson Lizardo, linux-bluetooth
Hi Johan,
On Wed, Oct 3, 2012 at 3:39 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Lizardo,
>
> On Wed, Oct 03, 2012, Anderson Lizardo wrote:
>> This API will be implemented and initially used by Phone Alert Status
>> and Alert Notification GATT profiles (server role).
>> ---
>>
>> v4: Modify enumeration strings to use "-" as word separator.
>>
>> Makefile.am | 2 +-
>> doc/alert-api.txt | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 110 insertions(+), 1 deletion(-)
>> create mode 100644 doc/alert-api.txt
>
> Thanks. All patches from this set are now upstream. I also pushed one
> additional coding style patch since I didn't want to bother with another
> review round for such a large patch set (and please don't do these huge
> sets in the future - keep them under 10 or so).
Thanks! We'll try to keep future series under a reasonable size.
Unfortunately, this one aggregated features too fast while the API was
being defined, but we could have split at least the skeleton GATT
server stuff to send earlier.
Regards,
--
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil
^ permalink raw reply [flat|nested] 88+ messages in thread
end of thread, other threads:[~2012-10-03 20:17 UTC | newest]
Thread overview: 88+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-24 18:00 [PATCH BlueZ 00/25] Add support for PASP and ANP server profiles Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 01/25] doc: Introduce Alert API Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 02/25] alert: Introduce manager abstraction layer Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 03/25] alert: Initial profile registration Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 04/25] alert: Add Phone Alert Status Service Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 05/25] alert: Add Ringer Control Point characteristic Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 06/25] alert: Add Ringer Setting characteristic Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 07/25] alert: Add Alert Status characteristic Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 08/25] alert: Initial Alert Notification Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 09/25] alert: Implement category registration in RegisterAlert() Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 10/25] alert: Add initial support for NewAlert D-Bus method Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 11/25] alert: Add initial support for UnreadAlert " Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 12/25] alert: Automatically unregister alert when agent leaves D-Bus Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 13/25] alert: Add per adapter attribute handle information Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 14/25] alert: Update Supported New/Unread Category characteristic values Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 15/25] alert: Update new alert characteristic value Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 16/25] alert: Update unread " Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 17/25] alert: Implement MuteOnce command Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 18/25] alert: Add support for calling MuteOnce() Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 19/25] alert: Add support for calling SetRinger() Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 20/25] alert: Add test-alert script Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 21/25] alert: Update Alert Status and Ringer Setting characteristic values Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 22/25] alert: Add support for ringer setting notification Anderson Lizardo
2012-09-24 18:00 ` [PATCH BlueZ 23/25] alert: Add support for alert status notification Anderson Lizardo
2012-09-24 18:01 ` [PATCH BlueZ 24/25] alert: Add support for new alert notification Anderson Lizardo
2012-09-24 18:01 ` [PATCH BlueZ 25/25] alert: Add support for unread " Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 01/27] doc: Introduce Alert API Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 02/27] alert: Introduce manager abstraction layer Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 03/27] alert: Initial profile registration Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 04/27] alert: Add Phone Alert Status Service Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 05/27] alert: Add Ringer Control Point characteristic Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 06/27] alert: Add Ringer Setting characteristic Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 07/27] alert: Add Alert Status characteristic Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 08/27] alert: Initial Alert Notification Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 09/27] alert: Implement category registration in RegisterAlert() Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 10/27] alert: Add initial support for NewAlert D-Bus method Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 11/27] alert: Add initial support for UnreadAlert " Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 12/27] alert: Automatically unregister alert when agent leaves D-Bus Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 13/27] alert: Add per adapter attribute handle information Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 14/27] alert: Update Supported New/Unread Category characteristic values Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 15/27] alert: Update new alert characteristic value Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 16/27] alert: Update unread " Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 17/27] alert: Implement MuteOnce command Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 18/27] alert: Add support for calling MuteOnce() Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 19/27] alert: Add support for calling SetRinger() Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 20/27] alert: Add test-alert script Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 21/27] alert: Update Alert Status and Ringer Setting characteristic values Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 22/27] alert: Add support for ringer setting notification Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 23/27] alert: Add support for alert status notification Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 24/27] alert: Add support for new alert notification Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 25/27] alert: Add support for unread " Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 26/27] alert: Implement Release() agent method Anderson Lizardo
2012-09-27 18:36 ` [PATCH v2 BlueZ 27/27] alert: Add org.bluez.AlertAgent to D-Bus policy file Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 00/27] Add support for PASP and ANP server profiles Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 01/27] doc: Introduce Alert API Anderson Lizardo
2012-10-03 8:21 ` Johan Hedberg
2012-10-03 10:56 ` Anderson Lizardo
2012-10-03 12:46 ` [PATCH v4 " Anderson Lizardo
2012-10-03 19:39 ` Johan Hedberg
2012-10-03 20:17 ` Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 02/27] alert: Introduce manager abstraction layer Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 03/27] alert: Initial profile registration Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 04/27] alert: Add Phone Alert Status Service Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 05/27] alert: Add Ringer Control Point characteristic Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 06/27] alert: Add Ringer Setting characteristic Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 07/27] alert: Add Alert Status characteristic Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 08/27] alert: Initial Alert Notification Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 09/27] alert: Implement category registration in RegisterAlert() Anderson Lizardo
2012-10-03 12:49 ` [PATCH v4 " Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 10/27] alert: Add initial support for NewAlert D-Bus method Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 11/27] alert: Add initial support for UnreadAlert " Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 12/27] alert: Automatically unregister alert when agent leaves D-Bus Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 13/27] alert: Add per adapter attribute handle information Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 14/27] alert: Update Supported New/Unread Category characteristic values Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 15/27] alert: Update new alert characteristic value Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 16/27] alert: Update unread " Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 17/27] alert: Implement MuteOnce command Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 18/27] alert: Add support for calling MuteOnce() Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 19/27] alert: Add support for calling SetRinger() Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 20/27] alert: Add test-alert script Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 21/27] alert: Update Alert Status and Ringer Setting characteristic values Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 22/27] alert: Add support for ringer setting notification Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 23/27] alert: Add support for alert status notification Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 24/27] alert: Add support for new alert notification Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 25/27] alert: Add support for unread " Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 26/27] alert: Implement Release() agent method Anderson Lizardo
2012-10-02 20:24 ` [PATCH v3 BlueZ 27/27] alert: Add org.bluez.AlertAgent to D-Bus policy file Anderson Lizardo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox