aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVinicius Costa Gomes <vinicius.gomes@openbossa.org>2010-07-29 19:11:06 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2010-08-09 18:06:47 -0400
commita04de9ef92d435b9773e2f5a15f4ab24038f6ffa (patch)
tree4e3ab2791aefd90fe31c4edfc497a15779356538 /src
parentfc367513b16229cfb3643c5e130f22ab989ef517 (diff)
downloadbluez-a04de9ef92d435b9773e2f5a15f4ab24038f6ffa.tar.gz
bluez-a04de9ef92d435b9773e2f5a15f4ab24038f6ffa.tar.xz
bluez-a04de9ef92d435b9773e2f5a15f4ab24038f6ffa.zip
Add a way to read a device's characteristics from storage
With this we can finally load the essential information to register a DBus interface for the characteristics of a device without connecting to it.
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 08778bcf..4fb5f9e8 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -1280,3 +1280,19 @@ int write_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
return textfile_put(filename, key, chars);
}
+
+char *read_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
+ uint16_t handle)
+{
+ char filename[PATH_MAX + 1], addr[18], key[23];
+
+ create_filename(filename, PATH_MAX, sba, "characteristic");
+
+ create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+
+ ba2str(dba, addr);
+
+ snprintf(key, sizeof(key), "%17s#%04X", addr, handle);
+
+ return textfile_caseget(filename, key);
+}
diff --git a/src/storage.h b/src/storage.h
index 37c6d54a..dbe2f412 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -83,6 +83,8 @@ int write_device_services(const bdaddr_t *sba, const bdaddr_t *dba,
char *read_device_services(const bdaddr_t *sba, const bdaddr_t *dba);
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);
#define PNP_UUID "00001200-0000-1000-8000-00805f9b34fb"