| 157 | } |
| 158 | |
| 159 | void YeelightController::SetPower() |
| 160 | { |
| 161 | json command; |
| 162 | |
| 163 | /*-----------------------------------------------------------------*\ |
| 164 | | Fill in the set_rgb command with RGB information. | |
| 165 | | The bulb will not respond to 0, 0, 0, so if all channels are zero,| |
| 166 | | set the state to off. Otherwise, set it to on. | |
| 167 | \*-----------------------------------------------------------------*/ |
| 168 | command["id"] = 1; |
| 169 | command["method"] = "set_power"; |
| 170 | command["params"][0] = "on"; |
| 171 | command["params"][1] = "sudden"; |
| 172 | command["params"][2] = 0; |
| 173 | command["params"][3] = 2; |
| 174 | |
| 175 | /*-----------------------------------------------------------------*\ |
| 176 | | Convert the JSON object to a string and write it | |
| 177 | \*-----------------------------------------------------------------*/ |
| 178 | std::string command_str = command.dump().append("\r\n"); |
| 179 | |
| 180 | port.tcp_client_connect(); |
| 181 | port.tcp_client_write((char *)command_str.c_str(), command_str.length() + 1); |
| 182 | port.tcp_close(); |
| 183 | } |
| 184 | |
| 185 | void YeelightController::SetColor(unsigned char red, unsigned char green, unsigned char blue) |
| 186 | { |
nothing calls this directly
no test coverage detected