MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / main

Function main

dependencies/hueplusplus-1.0.0/examples/UsernameConfig.cpp:123–149  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

121//
122// Also prints out the IP and username.
123int 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}

Callers

nothing calls this directly

Calls 8

readConfigFileFunction · 0.85
saveConfigFileFunction · 0.85
getUsernameMethod · 0.80
getMACAddressMethod · 0.80
getBridgeIPMethod · 0.80
connectToBridgeFunction · 0.70
valueMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected