Connects to a bridge. The steps are: - read "config.json" for an existing config - connect to the bridge - save the username to the config file for the next run Also prints out the IP and username.
| 121 | // |
| 122 | // Also prints out the IP and username. |
| 123 | int main(int argc, char** argv) |
| 124 | { |
| 125 | |
| 126 | const std::string filename = "config.json"; |
| 127 | try |
| 128 | { |
| 129 | |
| 130 | nlohmann::json config = readConfigFile(filename); |
| 131 | const std::string username = config.value("username", ""); |
| 132 | const std::string macAddress = config.value("mac", ""); |
| 133 | hue::Bridge hue = connectToBridge(username, macAddress); |
| 134 | |
| 135 | // Store updated information into file |
| 136 | config["username"] = hue.getUsername(); |
| 137 | config["mac"] = hue.config().getMACAddress(); |
| 138 | saveConfigFile(filename, config); |
| 139 | |
| 140 | std::cout << "Connected to bridge. IP: " << hue.getBridgeIP() << ", username: " << hue.getUsername() << '\n'; |
| 141 | } |
| 142 | catch (...) |
| 143 | { } |
| 144 | |
| 145 | std::cout << "Press enter to exit\n"; |
| 146 | std::cin.get(); |
| 147 | |
| 148 | return 0; |
| 149 | } |
nothing calls this directly
no test coverage detected