aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaulo Alcantara <paulo.alcantara@openbossa.org>2012-05-08 17:32:41 -0300
committerPaulo Alcantara <paulo.alcantara@openbossa.org>2012-05-21 23:45:09 -0300
commit19075b4691fbf6c0307148bf9a7fc6a6b8b3a16a (patch)
treecbb0b078ff94ff3da47b2a1fc17c4cdb2a61f839 /src
parent1a5abd77c6a482d947b92bb17d30e187182bd69a (diff)
downloadbluez-19075b4691fbf6c0307148bf9a7fc6a6b8b3a16a.tar.gz
bluez-19075b4691fbf6c0307148bf9a7fc6a6b8b3a16a.tar.xz
bluez-19075b4691fbf6c0307148bf9a7fc6a6b8b3a16a.zip
storage: Store address type in "characteristics"
GATT can use BR/EDR or BLE as transport. Addressing types can be either BR/EDR, BLE public or BLE random so the entries in the "characteristics" file did not contain enough information to distinguish which addressing type it's supposed to be. Entries will now contain both address number and address type as a single key in every entry in the file.
Diffstat (limited to 'src')
-rw-r--r--src/storage.c20
-rw-r--r--src/storage.h5
2 files changed, 17 insertions, 8 deletions
diff --git a/src/storage.c b/src/storage.c
index 5603cb8d..2c16a79f 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -1256,30 +1256,38 @@ 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)
+ uint8_t bdaddr_type, uint16_t handle,
+ const char *chars)
{
- char filename[PATH_MAX + 1], addr[18], key[23];
+ char filename[PATH_MAX + 1], addr[18], key[25];
create_filename(filename, PATH_MAX, sba, "characteristic");
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ /* New format: address#type */
ba2str(dba, addr);
-
- snprintf(key, sizeof(key), "%17s#%04X", addr, handle);
+ snprintf(key, sizeof(key), "%17s#%hhu#%04X", addr, bdaddr_type, handle);
return textfile_put(filename, key, chars);
}
char *read_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
- uint16_t handle)
+ uint8_t bdaddr_type, uint16_t handle)
{
- char filename[PATH_MAX + 1], addr[18], key[23];
+ char filename[PATH_MAX + 1], *str, addr[18], key[25];
create_filename(filename, PATH_MAX, sba, "characteristic");
+ /* New format: address#type */
ba2str(dba, addr);
+ snprintf(key, sizeof(key), "%17s#%hhu#%04X", addr, bdaddr_type, handle);
+
+ str = textfile_caseget(filename, key);
+ if (str != NULL)
+ return str;
+ /* Old format: address only */
snprintf(key, sizeof(key), "%17s#%04X", addr, handle);
return textfile_caseget(filename, key);
diff --git a/src/storage.h b/src/storage.h
index 745aff8e..05f4fdb6 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -81,9 +81,10 @@ int delete_device_service(const bdaddr_t *sba, const bdaddr_t *dba);
char *read_device_services(const bdaddr_t *sba, const bdaddr_t *dba,
uint8_t bdaddr_type);
int write_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
- uint16_t handle, const char *chars);
+ uint8_t bdaddr_type, uint16_t handle,
+ const char *chars);
char *read_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
- uint16_t handle);
+ uint8_t bdaddr_type, uint16_t handle);
int write_device_attribute(const bdaddr_t *sba, const bdaddr_t *dba,
uint16_t handle, const char *chars);
int read_device_attributes(const bdaddr_t *sba, textfile_cb func, void *data);