* [PATCH v2 1/5] device : Add EndGroupHandle key in attributes storage
@ 2012-12-15 8:59 Frédéric Danis
2012-12-15 8:59 ` [PATCH v2 2/5] device: Store services in device's attributes file Frédéric Danis
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Frédéric Danis @ 2012-12-15 8:59 UTC (permalink / raw)
To: linux-bluetooth
End group handle should also be converted/saved for each
group in device's attributes file.
---
doc/settings-storage.txt | 8 +++++---
src/adapter.c | 8 +++++---
src/device.c | 10 ++++++++++
3 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/doc/settings-storage.txt b/doc/settings-storage.txt
index 351b17e..11b127f 100644
--- a/doc/settings-storage.txt
+++ b/doc/settings-storage.txt
@@ -94,10 +94,12 @@ Attributes are stored using their handle as group name (decimal format).
Each group contains:
- UUID String 128-bit UUID of the attribute
+ UUID String 128-bit UUID of the attribute
- Value String Value of the attribute as hexadecimal encoded
- string
+ Value String Value of the attribute as hexadecimal encoded
+ string
+
+ EndGroupHandle Integer End group handle in decimal format
Sample:
[1]
diff --git a/src/adapter.c b/src/adapter.c
index b962bc1..37e85ed 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2419,7 +2419,8 @@ static gboolean record_has_uuid(const sdp_record_t *rec,
}
static void store_attribute_uuid(GKeyFile *key_file, uint16_t start,
- char *att_uuid, uuid_t uuid)
+ uint16_t end, char *att_uuid,
+ uuid_t uuid)
{
char handle[6], uuid_str[33];
int i;
@@ -2443,6 +2444,7 @@ static void store_attribute_uuid(GKeyFile *key_file, uint16_t start,
sprintf(handle, "%hu", start);
g_key_file_set_string(key_file, handle, "UUID", att_uuid);
g_key_file_set_string(key_file, handle, "Value", uuid_str);
+ g_key_file_set_integer(key_file, handle, "EndGroupHandle", end);
}
static void store_sdp_record(char *local, char *peer, int handle, char *value)
@@ -2535,7 +2537,7 @@ static void convert_sdp_entry(char *key, char *value, void *user_data)
key_file = g_key_file_new();
g_key_file_load_from_file(key_file, filename, 0, NULL);
- store_attribute_uuid(key_file, start, prim_uuid, uuid);
+ store_attribute_uuid(key_file, start, end, prim_uuid, uuid);
data = g_key_file_to_data(key_file, &length, NULL);
if (length > 0) {
@@ -2597,7 +2599,7 @@ static void convert_primaries_entry(char *key, char *value, void *user_data)
bt_string2uuid(&uuid, uuid_str);
sdp_uuid128_to_uuid(&uuid);
- store_attribute_uuid(key_file, start, prim_uuid, uuid);
+ store_attribute_uuid(key_file, start, end, prim_uuid, uuid);
}
g_strfreev(services);
diff --git a/src/device.c b/src/device.c
index 77466ff..780a496 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1907,6 +1907,7 @@ static void load_att_info(struct btd_device *device, const gchar *local,
for (handle = groups; *handle; handle++) {
gboolean uuid_ok;
+ gint end;
str = g_key_file_get_string(key_file, *handle, "UUID", NULL);
if (!str)
@@ -1922,8 +1923,16 @@ static void load_att_info(struct btd_device *device, const gchar *local,
if (!str)
continue;
+ end = g_key_file_get_integer(key_file, *handle,
+ "EndGroupHandle", NULL);
+ if (end == 0) {
+ g_free(str);
+ continue;
+ }
+
prim = g_new0(struct gatt_primary, 1);
prim->range.start = atoi(*handle);
+ prim->range.end = end;
switch (strlen(str)) {
case 4:
@@ -2524,6 +2533,7 @@ static void store_primaries_from_sdp_record(GKeyFile *key_file,
g_key_file_set_string(key_file, handle, "UUID", prim_uuid);
g_key_file_set_string(key_file, handle, "Value", uuid_str);
+ g_key_file_set_integer(key_file, handle, "EndGroupHandle", end);
done:
g_free(prim_uuid);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/5] device: Store services in device's attributes file
2012-12-15 8:59 [PATCH v2 1/5] device : Add EndGroupHandle key in attributes storage Frédéric Danis
@ 2012-12-15 8:59 ` Frédéric Danis
2012-12-15 8:59 ` [PATCH v2 3/5] adapter: Convert ccc file Frédéric Danis
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Frédéric Danis @ 2012-12-15 8:59 UTC (permalink / raw)
To: linux-bluetooth
Remove no more used write_device_primaries() from storage.[ch].
---
src/device.c | 73 +++++++++++++++++++++++++++++++++++++++++----------------
src/storage.c | 15 ------------
src/storage.h | 2 --
3 files changed, 53 insertions(+), 37 deletions(-)
diff --git a/src/device.c b/src/device.c
index 780a496..d6a6f04 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2872,37 +2872,70 @@ static void init_browse(struct browse_req *req, gboolean reverse)
l->data);
}
-static char *primary_list_to_string(GSList *primary_list)
+static void store_services(struct btd_device *device)
{
- GString *services;
+ struct btd_adapter *adapter = device->adapter;
+ char filename[PATH_MAX + 1];
+ char src_addr[18], dst_addr[18];
+ uuid_t uuid;
+ char *prim_uuid;
+ GKeyFile *key_file;
GSList *l;
+ char *data;
+ gsize length = 0;
- services = g_string_new(NULL);
+ sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
+ prim_uuid = bt_uuid2string(&uuid);
- for (l = primary_list; l; l = l->next) {
- struct gatt_primary *primary = l->data;
- char service[64];
+ ba2str(adapter_get_address(adapter), src_addr);
+ ba2str(&device->bdaddr, dst_addr);
- memset(service, 0, sizeof(service));
+ snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/attributes", src_addr,
+ dst_addr);
+ filename[PATH_MAX] = '\0';
- snprintf(service, sizeof(service), "%04X#%04X#%s ",
- primary->range.start, primary->range.end, primary->uuid);
+ key_file = g_key_file_new();
- services = g_string_append(services, service);
- }
+ for (l = device->primaries; l; l = l->next) {
+ struct gatt_primary *primary = l->data;
+ char handle[6], uuid_str[33];
+ int i;
- return g_string_free(services, FALSE);
-}
+ sprintf(handle, "%hu", primary->range.start);
-static void store_services(struct btd_device *device)
-{
- struct btd_adapter *adapter = device->adapter;
- char *str = primary_list_to_string(device->primaries);
+ bt_string2uuid(&uuid, primary->uuid);
+ sdp_uuid128_to_uuid(&uuid);
- write_device_primaries(adapter_get_address(adapter), &device->bdaddr,
- device->bdaddr_type, str);
+ switch (uuid.type) {
+ case SDP_UUID16:
+ sprintf(uuid_str, "%4.4X", uuid.value.uuid16);
+ break;
+ case SDP_UUID32:
+ sprintf(uuid_str, "%8.8X", uuid.value.uuid32);
+ break;
+ case SDP_UUID128:
+ for (i = 0; i < 16; i++)
+ sprintf(uuid_str + (i * 2), "%2.2X",
+ uuid.value.uuid128.data[i]);
+ break;
+ default:
+ uuid_str[0] = '\0';
+ }
- g_free(str);
+ g_key_file_set_string(key_file, handle, "UUID", prim_uuid);
+ g_key_file_set_string(key_file, handle, "Value", uuid_str);
+ g_key_file_set_integer(key_file, handle, "EndGroupHandle",
+ primary->range.end);
+ }
+
+ data = g_key_file_to_data(key_file, &length, NULL);
+ if (length > 0) {
+ create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ g_file_set_contents(filename, data, length, NULL);
+ }
+
+ g_free(data);
+ g_key_file_free(key_file);
}
static void attio_connected(gpointer data, gpointer user_data)
diff --git a/src/storage.c b/src/storage.c
index 713a421..02ac1f3 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -273,21 +273,6 @@ int read_device_pairable(const bdaddr_t *bdaddr, gboolean *mode)
return 0;
}
-int write_device_primaries(const bdaddr_t *sba, const bdaddr_t *dba,
- uint8_t bdaddr_type, const char *services)
-{
- char filename[PATH_MAX + 1], key[20];
-
- create_filename(filename, PATH_MAX, sba, "primaries");
-
- create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-
- ba2str(dba, key);
- sprintf(&key[17], "#%hhu", bdaddr_type);
-
- return textfile_put(filename, key, services);
-}
-
static void filter_keys(char *key, char *value, void *data)
{
struct match *match = data;
diff --git a/src/storage.h b/src/storage.h
index d150f15..682523a 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -35,8 +35,6 @@ ssize_t read_pin_code(const bdaddr_t *local, const bdaddr_t *peer, char *pin);
sdp_record_t *record_from_string(const gchar *str);
sdp_record_t *find_record_in_list(sdp_list_t *recs, const char *uuid);
int read_device_pairable(const bdaddr_t *local, gboolean *mode);
-int write_device_primaries(const bdaddr_t *sba, const bdaddr_t *dba,
- uint8_t bdaddr_type, const char *services);
int read_device_ccc(const bdaddr_t *local, const bdaddr_t *peer,
uint8_t bdaddr_type, uint16_t handle, uint16_t *value);
int write_device_ccc(const bdaddr_t *local, const bdaddr_t *peer,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 3/5] adapter: Convert ccc file
2012-12-15 8:59 [PATCH v2 1/5] device : Add EndGroupHandle key in attributes storage Frédéric Danis
2012-12-15 8:59 ` [PATCH v2 2/5] device: Store services in device's attributes file Frédéric Danis
@ 2012-12-15 8:59 ` Frédéric Danis
2012-12-15 8:59 ` [PATCH v2 4/5] device: Add btd_device_get_storage_path() Frédéric Danis
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Frédéric Danis @ 2012-12-15 8:59 UTC (permalink / raw)
To: linux-bluetooth
Update settings-storage.txt documentation to add ccc file.
---
doc/settings-storage.txt | 17 +++++++++++++
src/adapter.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 80 insertions(+)
diff --git a/doc/settings-storage.txt b/doc/settings-storage.txt
index 11b127f..d1c3f4f 100644
--- a/doc/settings-storage.txt
+++ b/doc/settings-storage.txt
@@ -31,6 +31,8 @@ contains:
contains:
- an info file
- an attributes file containing attributes of remote LE services
+ - a ccc file containing persistent Client Characteristic Configuration
+ (CCC) descriptor information for GATT characteristics
So the directory structure is:
/var/lib/bluetooth/<adapter address>/
@@ -43,6 +45,7 @@ So the directory structure is:
./<remote device address>/
./info
./attributes
+ ./ccc
./<remote device address>/
./info
./attributes
@@ -114,6 +117,20 @@ Sample:
UUID=00002a00-0000-1000-8000-00805f9b34fb
Value=4578616D706C6520446576696365
+CCC file format
+======================
+
+The ccc file stores the current CCC descriptor values for GATT characteristics
+which have notification/indication enabled by the remote device.
+
+Information is stored using CCC attribute handle as group name (in decimal
+format).
+
+Each group contains:
+
+ Value String CCC descriptor value encoded in
+ hexadecimal
+
Cache directory file format
============================
diff --git a/src/adapter.c b/src/adapter.c
index 37e85ed..0dda57d 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2636,6 +2636,56 @@ end:
g_key_file_free(key_file);
}
+static void convert_ccc_entry(char *key, char *value, void *user_data)
+{
+ char *src_addr = user_data;
+ char dst_addr[18];
+ char type = BDADDR_BREDR;
+ int handle, ret;
+ char filename[PATH_MAX + 1];
+ GKeyFile *key_file;
+ struct stat st;
+ int err;
+ char group[6];
+ char *data;
+ gsize length = 0;
+
+ ret = sscanf(key, "%17s#%hhu#%04X", dst_addr, &type, &handle);
+ if (ret < 3)
+ return;
+
+ if (bachk(dst_addr) != 0)
+ return;
+
+ /* Check if the device directory has been created as records should
+ * only be converted for known devices */
+ snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s", src_addr, dst_addr);
+ filename[PATH_MAX] = '\0';
+
+ err = stat(filename, &st);
+ if (err || !S_ISDIR(st.st_mode))
+ return;
+
+ snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/ccc", src_addr,
+ dst_addr);
+ filename[PATH_MAX] = '\0';
+
+ key_file = g_key_file_new();
+ g_key_file_load_from_file(key_file, filename, 0, NULL);
+
+ sprintf(group, "%hu", handle);
+ g_key_file_set_string(key_file, group, "Value", value);
+
+ data = g_key_file_to_data(key_file, &length, NULL);
+ if (length > 0) {
+ create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ g_file_set_contents(filename, data, length, NULL);
+ }
+
+ g_free(data);
+ g_key_file_free(key_file);
+}
+
static void convert_device_storage(struct btd_adapter *adapter)
{
char filename[PATH_MAX + 1];
@@ -2706,6 +2756,19 @@ static void convert_device_storage(struct btd_adapter *adapter)
textfile_put(filename, "converted", "yes");
}
free(str);
+
+ /* Convert ccc */
+ snprintf(filename, PATH_MAX, STORAGEDIR "/%s/ccc", address);
+ filename[PATH_MAX] = '\0';
+
+ str = textfile_get(filename, "converted");
+ if (str && strcmp(str, "yes") == 0) {
+ DBG("Legacy %s file already converted", filename);
+ } else {
+ textfile_foreach(filename, convert_ccc_entry, address);
+ textfile_put(filename, "converted", "yes");
+ }
+ free(str);
}
static void convert_config(struct btd_adapter *adapter, const char *filename,
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 4/5] device: Add btd_device_get_storage_path()
2012-12-15 8:59 [PATCH v2 1/5] device : Add EndGroupHandle key in attributes storage Frédéric Danis
2012-12-15 8:59 ` [PATCH v2 2/5] device: Store services in device's attributes file Frédéric Danis
2012-12-15 8:59 ` [PATCH v2 3/5] adapter: Convert ccc file Frédéric Danis
@ 2012-12-15 8:59 ` Frédéric Danis
2012-12-15 8:59 ` [PATCH v2 5/5] attrib-server: Read/write CCC info from new storage Frédéric Danis
2012-12-16 11:33 ` [PATCH v2 1/5] device : Add EndGroupHandle key in attributes storage Johan Hedberg
4 siblings, 0 replies; 6+ messages in thread
From: Frédéric Danis @ 2012-12-15 8:59 UTC (permalink / raw)
To: linux-bluetooth
---
src/device.c | 15 +++++++++++++++
src/device.h | 2 ++
2 files changed, 17 insertions(+)
diff --git a/src/device.c b/src/device.c
index d6a6f04..0bc8a09 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2049,6 +2049,21 @@ struct btd_device *device_create(struct btd_adapter *adapter,
return btd_device_ref(device);
}
+char *btd_device_get_storage_path(struct btd_device *device,
+ const char *filename)
+{
+ char srcaddr[18], dstaddr[18];
+
+ ba2str(adapter_get_address(device->adapter), srcaddr);
+ ba2str(&device->bdaddr, dstaddr);
+
+ if (!filename)
+ return g_strdup_printf(STORAGEDIR "/%s/%s", srcaddr, dstaddr);
+
+ return g_strdup_printf(STORAGEDIR "/%s/%s/%s", srcaddr, dstaddr,
+ filename);
+}
+
void device_set_name(struct btd_device *device, const char *name)
{
if (strncmp(name, device->name, MAX_NAME_LENGTH) == 0)
diff --git a/src/device.h b/src/device.h
index 8534117..7707bce 100644
--- a/src/device.h
+++ b/src/device.h
@@ -30,6 +30,8 @@ struct btd_device *device_create(struct btd_adapter *adapter,
const char *address, uint8_t bdaddr_type);
struct btd_device *device_create_from_storage(struct btd_adapter *adapter,
const char *address, GKeyFile *key_file);
+char *btd_device_get_storage_path(struct btd_device *device,
+ const char *filename);
void device_set_name(struct btd_device *device, const char *name);
void device_get_name(struct btd_device *device, char *name, size_t len);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 5/5] attrib-server: Read/write CCC info from new storage
2012-12-15 8:59 [PATCH v2 1/5] device : Add EndGroupHandle key in attributes storage Frédéric Danis
` (2 preceding siblings ...)
2012-12-15 8:59 ` [PATCH v2 4/5] device: Add btd_device_get_storage_path() Frédéric Danis
@ 2012-12-15 8:59 ` Frédéric Danis
2012-12-16 11:33 ` [PATCH v2 1/5] device : Add EndGroupHandle key in attributes storage Johan Hedberg
4 siblings, 0 replies; 6+ messages in thread
From: Frédéric Danis @ 2012-12-15 8:59 UTC (permalink / raw)
To: linux-bluetooth
Remove no more used storage functions.
---
src/attrib-server.c | 79 +++++++++++++++++++++++++++++++++++++---------
src/storage.c | 87 ---------------------------------------------------
src/storage.h | 6 ----
3 files changed, 64 insertions(+), 108 deletions(-)
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 8dc0d6a..e3715e8 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -32,6 +32,7 @@
#include <string.h>
#include <unistd.h>
#include <glib.h>
+#include <sys/file.h>
#include <bluetooth/bluetooth.h>
#include <bluetooth/uuid.h>
@@ -746,6 +747,36 @@ static uint16_t find_by_type(struct gatt_channel *channel, uint16_t start,
return len;
}
+static int read_device_ccc(struct btd_device *device, uint16_t handle,
+ uint16_t *value)
+{
+ char *filename;
+ GKeyFile *key_file;
+ char group[6];
+ char *str;
+ unsigned int config;
+ int err = 0;
+
+ filename = btd_device_get_storage_path(device, "ccc");
+
+ key_file = g_key_file_new();
+ g_key_file_load_from_file(key_file, filename, 0, NULL);
+
+ sprintf(group, "%hu", handle);
+
+ str = g_key_file_get_string(key_file, group, "Value", NULL);
+ if (!str || sscanf(str, "%04X", &config) != 1)
+ err = -ENOENT;
+ else
+ *value = config;
+
+ g_free(str);
+ g_free(filename);
+ g_key_file_free(key_file);
+
+ return err;
+}
+
static uint16_t read_value(struct gatt_channel *channel, uint16_t handle,
uint8_t *pdu, size_t len)
{
@@ -753,7 +784,6 @@ static uint16_t read_value(struct gatt_channel *channel, uint16_t handle,
uint8_t status;
GList *l;
uint16_t cccval;
- uint8_t bdaddr_type;
guint h = handle;
l = g_list_find_custom(channel->server->database,
@@ -764,11 +794,8 @@ static uint16_t read_value(struct gatt_channel *channel, uint16_t handle,
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, bdaddr_type,
- handle, &cccval) == 0) {
+ read_device_ccc(channel->device, handle, &cccval) == 0) {
uint8_t config[2];
att_put_u16(cccval, config);
@@ -794,7 +821,6 @@ static uint16_t read_blob(struct gatt_channel *channel, uint16_t handle,
uint8_t status;
GList *l;
uint16_t cccval;
- uint8_t bdaddr_type;
guint h = handle;
l = g_list_find_custom(channel->server->database,
@@ -809,11 +835,8 @@ static uint16_t read_blob(struct gatt_channel *channel, uint16_t handle,
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, bdaddr_type,
- handle, &cccval) == 0) {
+ read_device_ccc(channel->device, handle, &cccval) == 0) {
uint8_t config[2];
att_put_u16(cccval, config);
@@ -869,10 +892,31 @@ static uint16_t write_value(struct gatt_channel *channel, uint16_t handle,
}
} else {
uint16_t cccval = att_get_u16(value);
- uint8_t bdaddr_type = device_get_addr_type(channel->device);
+ char *filename;
+ GKeyFile *key_file;
+ char group[6], value[5];
+ char *data;
+ gsize length = 0;
+
+ filename = btd_device_get_storage_path(channel->device, "ccc");
+
+ key_file = g_key_file_new();
+ g_key_file_load_from_file(key_file, filename, 0, NULL);
+
+ sprintf(group, "%hu", handle);
+ sprintf(value, "%hhX", cccval);
+ g_key_file_set_string(key_file, group, "Value", value);
+
+ data = g_key_file_to_data(key_file, &length, NULL);
+ if (length > 0) {
+ create_file(filename,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ g_file_set_contents(filename, data, length, NULL);
+ }
- write_device_ccc(&channel->src, &channel->dst, bdaddr_type,
- handle, cccval);
+ g_free(data);
+ g_free(filename);
+ g_key_file_free(key_file);
}
return enc_write_resp(pdu, len);
@@ -1089,8 +1133,13 @@ guint attrib_channel_attach(GAttrib *attrib)
ba2str(&channel->dst, addr);
device = adapter_find_device(server->adapter, addr);
- if (device == NULL || device_is_bonded(device) == FALSE)
- delete_device_ccc(&channel->src, &channel->dst);
+ if (device == NULL || device_is_bonded(device) == FALSE) {
+ char *filename;
+
+ filename = btd_device_get_storage_path(channel->device, "ccc");
+ unlink(filename);
+ g_free(filename);
+ }
if (cid != ATT_CID) {
channel->le = FALSE;
diff --git a/src/storage.c b/src/storage.c
index 02ac1f3..38e5897 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -272,90 +272,3 @@ int read_device_pairable(const bdaddr_t *bdaddr, gboolean *mode)
return 0;
}
-
-static void filter_keys(char *key, char *value, void *data)
-{
- struct match *match = data;
-
- if (strncasecmp(key, match->pattern, strlen(match->pattern)) == 0)
- match->keys = g_slist_append(match->keys, g_strdup(key));
-}
-
-static void delete_by_pattern(const char *filename, char *pattern)
-{
- struct match match;
- GSList *l;
- int err;
-
- memset(&match, 0, sizeof(match));
- match.pattern = pattern;
-
- err = textfile_foreach(filename, filter_keys, &match);
- if (err < 0)
- goto done;
-
- for (l = match.keys; l; l = l->next) {
- const char *key = l->data;
- textfile_del(filename, key);
- }
-
-done:
- g_slist_free_full(match.keys, g_free);
-}
-
-int read_device_ccc(const bdaddr_t *local, const bdaddr_t *peer,
- uint8_t bdaddr_type, uint16_t handle,
- uint16_t *value)
-{
- 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#%hhu#%04X", addr, bdaddr_type, handle);
-
- str = textfile_caseget(filename, key);
- if (str == NULL)
- return -ENOENT;
-
- if (sscanf(str, "%04X", &config) != 1)
- err = -ENOENT;
- else
- *value = config;
-
- free(str);
-
- return err;
-}
-
-int write_device_ccc(const bdaddr_t *local, const bdaddr_t *peer,
- uint8_t bdaddr_type, uint16_t handle,
- uint16_t value)
-{
- 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(config, sizeof(config), "%04X", value);
-
- return textfile_put(filename, key, config);
-}
-
-void delete_device_ccc(const bdaddr_t *local, const bdaddr_t *peer)
-{
- char filename[PATH_MAX + 1], addr[18];
-
- ba2str(peer, addr);
-
- /* Deleting all CCC values of a given address */
- create_filename(filename, PATH_MAX, local, "ccc");
- delete_by_pattern(filename, addr);
-}
diff --git a/src/storage.h b/src/storage.h
index 682523a..cc7f930 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -35,9 +35,3 @@ ssize_t read_pin_code(const bdaddr_t *local, const bdaddr_t *peer, char *pin);
sdp_record_t *record_from_string(const gchar *str);
sdp_record_t *find_record_in_list(sdp_list_t *recs, const char *uuid);
int read_device_pairable(const bdaddr_t *local, gboolean *mode);
-int read_device_ccc(const bdaddr_t *local, const bdaddr_t *peer,
- uint8_t bdaddr_type, uint16_t handle, uint16_t *value);
-int write_device_ccc(const bdaddr_t *local, const bdaddr_t *peer,
- uint8_t bdaddr_type, uint16_t handle,
- uint16_t value);
-void delete_device_ccc(const bdaddr_t *local, const bdaddr_t *peer);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/5] device : Add EndGroupHandle key in attributes storage
2012-12-15 8:59 [PATCH v2 1/5] device : Add EndGroupHandle key in attributes storage Frédéric Danis
` (3 preceding siblings ...)
2012-12-15 8:59 ` [PATCH v2 5/5] attrib-server: Read/write CCC info from new storage Frédéric Danis
@ 2012-12-16 11:33 ` Johan Hedberg
4 siblings, 0 replies; 6+ messages in thread
From: Johan Hedberg @ 2012-12-16 11:33 UTC (permalink / raw)
To: Frédéric Danis; +Cc: linux-bluetooth
Hi Frédéric,
On Sat, Dec 15, 2012, Frédéric Danis wrote:
> End group handle should also be converted/saved for each
> group in device's attributes file.
> ---
> doc/settings-storage.txt | 8 +++++---
> src/adapter.c | 8 +++++---
> src/device.c | 10 ++++++++++
> 3 files changed, 20 insertions(+), 6 deletions(-)
All patches in this set have been applied. Thanks.
Johan
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-12-16 11:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-15 8:59 [PATCH v2 1/5] device : Add EndGroupHandle key in attributes storage Frédéric Danis
2012-12-15 8:59 ` [PATCH v2 2/5] device: Store services in device's attributes file Frédéric Danis
2012-12-15 8:59 ` [PATCH v2 3/5] adapter: Convert ccc file Frédéric Danis
2012-12-15 8:59 ` [PATCH v2 4/5] device: Add btd_device_get_storage_path() Frédéric Danis
2012-12-15 8:59 ` [PATCH v2 5/5] attrib-server: Read/write CCC info from new storage Frédéric Danis
2012-12-16 11:33 ` [PATCH v2 1/5] device : Add EndGroupHandle key in attributes storage Johan Hedberg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.