diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2006-02-24 18:52:07 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2006-02-24 18:52:07 +0000 |
commit | 8d49d5f190c9e7ff03e2c8a596881fbbb59454aa (patch) | |
tree | 7c54df19a7a7c6c1d982e672bad9135de6f91574 /hcid/storage.c | |
parent | 12100721445e1651a5b8d58f4b5c8190de8d517e (diff) | |
download | bluez-8d49d5f190c9e7ff03e2c8a596881fbbb59454aa.tar.gz |
Read class of device value from config storage
Diffstat (limited to 'hcid/storage.c')
-rw-r--r-- | hcid/storage.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/hcid/storage.c b/hcid/storage.c index 0fae94475..17f0744aa 100644 --- a/hcid/storage.c +++ b/hcid/storage.c @@ -101,7 +101,8 @@ int write_local_class(bdaddr_t *bdaddr, uint8_t *class) int read_local_class(bdaddr_t *bdaddr, uint8_t *class) { - char filename[PATH_MAX + 1], addr[18], *str; + char filename[PATH_MAX + 1], addr[18], tmp[3], *str; + int i; ba2str(bdaddr, addr); snprintf(filename, PATH_MAX, "%s/%s/config", STORAGEDIR, addr); @@ -110,6 +111,12 @@ int read_local_class(bdaddr_t *bdaddr, uint8_t *class) if (!str) return -ENOENT; + memset(tmp, 0, sizeof(tmp)); + for (i = 0; i < 3; i++) { + memcpy(tmp, str + (i * 2) + 2, 2); + class[2 - i] = (uint8_t) strtol(tmp, NULL, 16); + } + free(str); return 0; |