diff --git a/attrib/client.c b/attrib/client.c
index 8aa2800..7aefd96 100644
--- a/attrib/client.c
+++ b/attrib/client.c
static void store_attribute(struct gatt_service *gatt, uint16_t handle,
uint16_t type, uint8_t *value, gsize len)
{
+ struct btd_device *device = gatt->dev;
bdaddr_t sba, dba;
+ uint8_t bdaddr_type;
bt_uuid_t uuid;
char *str, *tmp;
guint i;
gatt_get_address(gatt, &sba, &dba, NULL);
- write_device_attribute(&sba, &dba, handle, str);
+ bdaddr_type = device_get_addr_type(device);
+
+ write_device_attribute(&sba, &dba, bdaddr_type, handle, str);
g_free(str);
}
diff --git a/src/storage.c b/src/storage.c
index f8e9679..cbbf8f6 100644
--- a/src/storage.c
+++ b/src/storage.c
create_filename(filename, PATH_MAX, sba, "characteristic");
delete_by_pattern(filename, key);
- key[17] = '\0';
-
/* Deleting all attributes values of a given key */
create_filename(filename, PATH_MAX, sba, "attributes");
delete_by_pattern(filename, key);
- sprintf(&key[17], "#%hhu", bdaddr_type);
-
/* Deleting all CCC values of a given key */
create_filename(filename, PATH_MAX, sba, "ccc");
delete_by_pattern(filename, key);
}
int write_device_attribute(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, "attributes");
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
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);
}
diff --git a/src/storage.h b/src/storage.h
index 69ade35..c541807 100644
--- a/src/storage.h
+++ b/src/storage.h
char *read_device_characteristics(const bdaddr_t *sba, const bdaddr_t *dba,
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);
+ uint8_t bdaddr_type, uint16_t handle,
+ const char *chars);
int read_device_attributes(const bdaddr_t *sba, textfile_cb func, void *data);
int read_device_ccc(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
uint16_t handle, uint16_t *value);