aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulo Alcantara <paulo.alcantara@openbossa.org>2012-05-12 02:44:07 -0300
committerPaulo Alcantara <paulo.alcantara@openbossa.org>2012-05-22 01:18:01 -0300
commit225d0cf7458a4453ea1e7d3308ca9fd657c98f5d (patch)
treeac5594a3459eec436e812f80afd2ccae7b1ce533
parent0b17ce57481014d292f3c070f612c1a3731929a1 (diff)
downloadbluez-hog_test3.tar.gz
bluez-hog_test3.tar.xz
bluez-hog_test3.zip
storage: Store address type in "eir" filehog_test3
-rw-r--r--src/event.c2
-rw-r--r--src/storage.c38
-rw-r--r--src/storage.h7
3 files changed, 33 insertions, 14 deletions
diff --git a/src/event.c b/src/event.c
index e453e134..d4e766c5 100644
--- a/src/event.c
+++ b/src/event.c
@@ -270,7 +270,7 @@ void btd_event_device_found(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type
update_lastseen(local, peer);
if (data)
- write_remote_eir(local, peer, data, data_len);
+ write_remote_eir(local, peer, bdaddr_type, data, data_len);
adapter_update_found_devices(adapter, peer, bdaddr_type, rssi,
confirm_name, data, data_len);
diff --git a/src/storage.c b/src/storage.c
index 461e7991..33edfa06 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -449,10 +449,10 @@ done:
return 0;
}
-int write_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t *data,
- uint8_t data_len)
+int write_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
+ uint8_t *data, uint8_t data_len)
{
- char filename[PATH_MAX + 1], addr[18], str[481];
+ char filename[PATH_MAX + 1], key[20], str[481];
int i;
memset(str, 0, sizeof(str));
@@ -463,23 +463,41 @@ int write_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t *data,
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- ba2str(peer, addr);
- return textfile_put(filename, addr, str);
+ memset(key, 0, sizeof(key));
+
+ /* New format: address#type */
+ ba2str(peer, key);
+ sprintf(&key[17], "#%hhu", bdaddr_type);
+
+ return textfile_put(filename, key, str);
}
-int read_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t *data)
+int read_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
+ uint8_t *data)
{
- char filename[PATH_MAX + 1], addr[18], *str;
+ char filename[PATH_MAX + 1], key[20], *str;
int i;
create_filename(filename, PATH_MAX, local, "eir");
- ba2str(peer, addr);
+ memset(key, 0, sizeof(key));
- str = textfile_get(filename, addr);
- if (!str)
+ /* New format: address#type */
+ ba2str(peer, key);
+ sprintf(&key[17], "#%hhu", bdaddr_type);
+
+ str = textfile_get(filename, key);
+ if (str != NULL)
+ goto done;
+
+ /* Old format: address only */
+ key[17] = '\0';
+
+ str = textfile_get(filename, key);
+ if (str == NULL)
return -ENOENT;
+done:
if (!data) {
free(str);
return 0;
diff --git a/src/storage.h b/src/storage.h
index 53491d9c..9e5eff18 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -48,9 +48,10 @@ int write_device_name(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
char *name);
int read_device_name(const char *src, const char *dst, uint8_t bdaddr_type,
char *name);
-int write_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t *data,
- uint8_t data_len);
-int read_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t *data);
+int write_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
+ uint8_t *data, uint8_t data_len);
+int read_remote_eir(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
+ uint8_t *data);
int write_version_info(bdaddr_t *local, bdaddr_t *peer, uint16_t manufacturer, uint8_t lmp_ver, uint16_t lmp_subver);
int write_features_info(bdaddr_t *local, bdaddr_t *peer, unsigned char *page1, unsigned char *page2);
int read_remote_features(bdaddr_t *local, bdaddr_t *peer, unsigned char *page1, unsigned char *page2);