diff options
author | Bruna Moreira <bruna.moreira@openbossa.org> | 2012-10-02 16:24:30 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-10-03 22:23:59 +0300 |
commit | 1854dc6d7646023563594a9199d9d34bc7b02f2c (patch) | |
tree | aa9a3d7a1a8f735fdfc26af06070db81cc94f333 /profiles/alert | |
parent | 509a45c84ed27b2f38a6d0e08dd0a501906026ed (diff) | |
download | bluez-1854dc6d7646023563594a9199d9d34bc7b02f2c.tar.gz |
alert: Add Alert Status characteristic
This characteristic allows to read/notify the status of the ringer,
display and vibration motor.
Diffstat (limited to 'profiles/alert')
-rw-r--r-- | profiles/alert/server.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/profiles/alert/server.c b/profiles/alert/server.c index 59e6fdc7c..90536d57b 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, |