summaryrefslogtreecommitdiff
path: root/src/storage.c
diff options
context:
space:
mode:
authorPaulo Alcantara <paulo.alcantara@openbossa.org>2012-05-26 21:40:47 -0300
committerJohan Hedberg <johan.hedberg@intel.com>2012-05-27 22:22:03 +0300
commit24fb2b3a8754d2169cba497023a61ad5f5b2b1cf (patch)
tree52a4772c4dcd2e25c84fcbaab5a867597ae7020b /src/storage.c
parent0185e5d4d69da7b6d7ca195274703296ff5ca735 (diff)
storage: Store address type in "appearance" file
BLE addressing types can be either public or random so the entries in the "appearance" file did not contain enough information to distinguish which addressing type it's supposed to be (LE public or LE random). Appearance is an information related to BLE device only. Entries will now contain both BLE address number and BLE address type as a single key in every entry in the file.
Diffstat (limited to 'src/storage.c')
-rw-r--r--src/storage.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/storage.c b/src/storage.c
index b783be09..ab9b1ed1 100644
--- a/src/storage.c
+++ b/src/storage.c
@@ -281,16 +281,17 @@ int read_local_class(bdaddr_t *bdaddr, uint8_t *class)
return 0;
}
-int read_remote_appearance(bdaddr_t *local, bdaddr_t *peer,
+int read_remote_appearance(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
uint16_t *appearance)
{
- char filename[PATH_MAX + 1], addr[18], *str;
+ char filename[PATH_MAX + 1], key[20], *str;
create_filename(filename, PATH_MAX, local, "appearance");
- ba2str(peer, addr);
+ ba2str(peer, key);
+ sprintf(&key[17], "#%hhu", bdaddr_type);
- str = textfile_get(filename, addr);
+ str = textfile_get(filename, key);
if (!str)
return -ENOENT;
@@ -305,18 +306,20 @@ int read_remote_appearance(bdaddr_t *local, bdaddr_t *peer,
}
int write_remote_appearance(bdaddr_t *local, bdaddr_t *peer,
- uint16_t appearance)
+ uint8_t bdaddr_type, uint16_t appearance)
{
- char filename[PATH_MAX + 1], addr[18], str[7];
+ char filename[PATH_MAX + 1], key[20], str[7];
create_filename(filename, PATH_MAX, local, "appearance");
create_file(filename, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- ba2str(peer, addr);
+ ba2str(peer, key);
+ sprintf(&key[17], "#%hhu", bdaddr_type);
+
sprintf(str, "0x%4.4x", appearance);
- return textfile_put(filename, addr, str);
+ return textfile_put(filename, key, str);
}
int write_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class)