diff --git a/src/attrib-server.c b/src/attrib-server.c
index 21b1501..3291e2d 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
uint8_t status;
GList *l;
uint16_t cccval;
+ uint8_t bdaddr_type;
guint h = handle;
l = g_list_find_custom(channel->server->database,
a = l->data;
+ bdaddr_type = device_get_addr_type(channel->device);
+
if (bt_uuid_cmp(&ccc_uuid, &a->uuid) == 0 &&
- read_device_ccc(&channel->src, &channel->dst,
- handle, &cccval) == 0) {
+ read_device_ccc(&channel->src, &channel->dst, bdaddr_type,
+ handle, &cccval) == 0) {
uint8_t config[2];
att_put_u16(cccval, config);
uint8_t status;
GList *l;
uint16_t cccval;
+ uint8_t bdaddr_type;
guint h = handle;
l = g_list_find_custom(channel->server->database,
return enc_error_resp(ATT_OP_READ_BLOB_REQ, handle,
ATT_ECODE_INVALID_OFFSET, pdu, len);
+ bdaddr_type = device_get_addr_type(channel->device);
+
if (bt_uuid_cmp(&ccc_uuid, &a->uuid) == 0 &&
- read_device_ccc(&channel->src, &channel->dst,
- handle, &cccval) == 0) {
+ read_device_ccc(&channel->src, &channel->dst, bdaddr_type,
+ handle, &cccval) == 0) {
uint8_t config[2];
att_put_u16(cccval, config);
}
} else {
uint16_t cccval = att_get_u16(value);
- write_device_ccc(&channel->src, &channel->dst, handle, cccval);
+ uint8_t bdaddr_type = device_get_addr_type(channel->device);
+
+ write_device_ccc(&channel->src, &channel->dst, bdaddr_type,
+ handle, cccval);
}
return enc_write_resp(pdu, len);
diff --git a/src/device.c b/src/device.c
index eb015ec..a01a524 100644
--- a/src/device.c
+++ b/src/device.c
device->bdaddr_type = bdaddr_type;
}
+uint8_t device_get_addr_type(struct btd_device *device)
+{
+ return device->bdaddr_type;
+}
+
const gchar *device_get_path(struct btd_device *device)
{
if (!device)
diff --git a/src/device.h b/src/device.h
index 51140c7..26e17f7 100644
--- a/src/device.h
+++ b/src/device.h
void device_get_address(struct btd_device *device, bdaddr_t *bdaddr,
uint8_t *bdaddr_type);
void device_set_addr_type(struct btd_device *device, uint8_t bdaddr_type);
+uint8_t device_get_addr_type(struct btd_device *device);
const gchar *device_get_path(struct btd_device *device);
struct agent *device_get_agent(struct btd_device *device);
gboolean device_is_bredr(struct btd_device *device);
diff --git a/src/storage.c b/src/storage.c
index ab9b1ed..3cde9c1 100644
--- a/src/storage.c
+++ b/src/storage.c
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);
- sprintf(&key[17], "#%hhu", bdaddr_type);
-
create_filename(filename, PATH_MAX, sba, "primary");
return textfile_del(filename, key);
return textfile_foreach(filename, func, data);
}
-int read_device_ccc(bdaddr_t *local, bdaddr_t *peer, uint16_t handle,
- uint16_t *value)
+int read_device_ccc(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
+ uint16_t handle, uint16_t *value)
{
- char filename[PATH_MAX + 1], addr[18], key[23];
+ char filename[PATH_MAX + 1], addr[18], key[25];
char *str;
unsigned int config;
int err = 0;
create_filename(filename, PATH_MAX, local, "ccc");
ba2str(peer, addr);
- snprintf(key, sizeof(key), "%17s#%04X", addr, handle);
+ snprintf(key, sizeof(key), "%17s#%hhu#%04X", addr, bdaddr_type, handle);
str = textfile_caseget(filename, key);
if (str == NULL)
return err;
}
-int write_device_ccc(bdaddr_t *local, bdaddr_t *peer, uint16_t handle,
- uint16_t value)
+int write_device_ccc(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
+ uint16_t handle, uint16_t value)
{
- char filename[PATH_MAX + 1], addr[18], key[23], config[5];
+ char filename[PATH_MAX + 1], addr[18], key[25], config[5];
create_filename(filename, PATH_MAX, local, "ccc");
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
ba2str(peer, addr);
+ snprintf(key, sizeof(key), "%17s#%hhu#%04X", addr, bdaddr_type, handle);
- snprintf(key, sizeof(key), "%17s#%04X", addr, handle);
snprintf(config, sizeof(config), "%04X", value);
return textfile_put(filename, key, config);
diff --git a/src/storage.h b/src/storage.h
index db33b43..b6d24e9 100644
--- a/src/storage.h
+++ b/src/storage.h
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);
-int read_device_ccc(bdaddr_t *local, bdaddr_t *peer, uint16_t handle,
- uint16_t *value);
-int write_device_ccc(bdaddr_t *local, bdaddr_t *peer, uint16_t handle,
- uint16_t value);
+int read_device_ccc(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
+ uint16_t handle, uint16_t *value);
+int write_device_ccc(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
+ uint16_t handle, uint16_t value);
void delete_device_ccc(bdaddr_t *local, bdaddr_t *peer);
int write_longtermkeys(bdaddr_t *local, bdaddr_t *peer, const char *key);
gboolean has_longtermkeys(bdaddr_t *local, bdaddr_t *peer);