aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
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);