aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBruna Moreira <bruna.moreira@openbossa.org>2010-08-12 10:48:40 -0400
committerAnderson Lizardo <anderson.lizardo@openbossa.org>2010-08-26 09:29:56 -0400
commita5e5c9262a7fa20b03643c478f1620995a89ad79 (patch)
tree6236cda48fb5098c8e396ecfa4775d54c822546e /src
parent05a3ffaf6ed7c01d2b05b1edebfbf810f3eb8fe2 (diff)
downloadbluez-a5e5c9262a7fa20b03643c478f1620995a89ad79.tar.gz
bluez-a5e5c9262a7fa20b03643c478f1620995a89ad79.tar.xz
bluez-a5e5c9262a7fa20b03643c478f1620995a89ad79.zip
Support for storing attribute data
Create a new storage called "attributes" to save attribute data. Format description: <bt_addr>#<attr_handle> <attr_type>#<attr_value> - the key is composed of the device address and the attribute handle; - the value is composed of the attribute type UUID (converted to printable 128-bit format) and the attribute value (hex encoded). - the key/value components are joined with "#", and separated from each other by a space.
Diffstat (limited to 'src')
-rw-r--r--src/storage.c16
-rw-r--r--src/storage.h2
2 files changed, 18 insertions, 0 deletions
diff --git a/src/storage.c b/src/storage.c
index 4fb5f9e8..dcd6511d 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -1296,3 +1296,19 @@ char *read_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
return textfile_caseget(filename, key);
}
+
+int write_device_attribute(const bdaddr_t *sba, const bdaddr_t *dba,
+ uint16_t handle, const char *chars)
+{
+ char filename[PATH_MAX + 1], addr[18], key[23];
+
+ create_filename(filename, PATH_MAX, sba, "attributes");
+
+ create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
+ ba2str(dba, addr);
+
+ snprintf(key, sizeof(key), "%17s#%04X", addr, handle);
+
+ return textfile_put(filename, key, chars);
+}
diff --git a/src/storage.h b/src/storage.h
index dbe2f412..dcba2ce5 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -85,6 +85,8 @@ int write_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
uint16_t handle, const char *chars);
char *read_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
uint16_t handle);
+int write_device_attribute(const bdaddr_t *sba, const bdaddr_t *dba,
+ uint16_t handle, const char *chars);
#define PNP_UUID "00001200-0000-1000-8000-00805f9b34fb"