| 60 | } |
| 61 | |
| 62 | bool load(const std::string& addr_hex, PairedDevice& device) { |
| 63 | std::map<std::string, std::string> map; |
| 64 | if (!file::loadPropertiesFile(getFilePath(addr_hex), map)) return false; |
| 65 | if (!map.contains(KEY_ADDR)) return false; |
| 66 | if (!hexToAddr(map[KEY_ADDR], device.addr)) return false; |
| 67 | |
| 68 | device.name = map.contains(KEY_NAME) ? map[KEY_NAME] : ""; |
| 69 | |
| 70 | device.autoConnect = !map.contains(KEY_AUTO_CONNECT) || (map[KEY_AUTO_CONNECT] == "true"); |
| 71 | |
| 72 | if (map.contains(KEY_PROFILE_ID)) { |
| 73 | // TODO: Handle incorrect parsing input |
| 74 | device.profileId = std::stoi(map[KEY_PROFILE_ID]); |
| 75 | } |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | bool save(const PairedDevice& device) { |
| 80 | const auto addr_hex = addrToHex(device.addr); |
no test coverage detected