summaryrefslogtreecommitdiff
path: root/profiles/alert
diff options
context:
space:
mode:
authorBruna Moreira <bruna.moreira@openbossa.org>2012-10-02 16:24:29 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2012-10-03 22:23:48 +0300
commit509a45c84ed27b2f38a6d0e08dd0a501906026ed (patch)
treedf8c9448b497f896a0ead3c5a5c231a5c5cbb509 /profiles/alert
parent58443a997000845c7fb62bb5b571b8226edce6bc (diff)
downloadbluez-509a45c84ed27b2f38a6d0e08dd0a501906026ed.tar.gz
alert: Add Ringer Setting characteristic
This characteristic allows to read or notify the ringer mode (silent or normal).
Diffstat (limited to 'profiles/alert')
-rw-r--r--profiles/alert/server.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index 8337c3818..59e6fdc7c 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);
}