summaryrefslogtreecommitdiff
path: root/time
diff options
context:
space:
mode:
authorAnderson Lizardo <anderson.lizardo@openbossa.org>2011-11-04 11:59:28 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2011-11-14 21:14:21 +0200
commit474c85f7a6c4680364722861d8dafddcb78cc7f1 (patch)
tree0717849c8b579cedaed49e03006b4f5808c96171 /time
parentd1e8012cc65887cfc548677d52331ce749a5b2c9 (diff)
downloadbluez-474c85f7a6c4680364722861d8dafddcb78cc7f1.tar.gz
Time Profile: add Local Time Information characteristic
This is an optional characteristic from the Current Time Service. From the spec: "The Local Time Information characteristic returns the local time information that includes time zone and DST offset when read using the GATT Read Characteristic Value sub-procedure."
Diffstat (limited to 'time')
-rw-r--r--time/server.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/time/server.c b/time/server.c
index b15456be8..5c32dc2d6 100644
--- a/time/server.c
+++ b/time/server.c
@@ -40,6 +40,7 @@
#define CURRENT_TIME_SVC_UUID 0x1805
+#define LOCAL_TIME_INFO_CHR_UUID 0x2A0F
#define CT_TIME_CHR_UUID 0x2A2B
static int encode_current_time(uint8_t value[10])
@@ -88,6 +89,27 @@ static uint8_t current_time_read(struct attribute *a, gpointer user_data)
return 0;
}
+static uint8_t local_time_info_read(struct attribute *a, gpointer user_data)
+{
+ uint8_t value[2];
+
+ DBG("a=%p", a);
+
+ tzset();
+
+ /* FIXME: POSIX "daylight" variable only indicates whether there is DST
+ * for the local time or not. The offset is unknown. */
+ value[0] = daylight ? 0xff : 0x00;
+
+ /* Convert POSIX "timezone" (seconds West of GMT) to Time Profile
+ * format (offset from UTC in number of 15 minutes increments). */
+ value[1] = (uint8_t) (-1 * timezone / (60 * 15));
+
+ attrib_db_update(a->handle, NULL, value, sizeof(value), NULL);
+
+ return 0;
+}
+
static void register_current_time_service(void)
{
/* Current Time service */
@@ -98,6 +120,13 @@ static void register_current_time_service(void)
ATT_CHAR_PROPER_NOTIFY,
GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
current_time_read,
+
+ /* Local Time Information characteristic */
+ GATT_OPT_CHR_UUID, LOCAL_TIME_INFO_CHR_UUID,
+ GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ,
+ GATT_OPT_CHR_VALUE_CB, ATTRIB_READ,
+ local_time_info_read,
+
GATT_OPT_INVALID);
}