|
|
@@ -1,4 +1,5 @@
|
|
|
#include <V5MiLightUdpServer.h>
|
|
|
+#include <CctPacketFormatter.h>
|
|
|
|
|
|
void V5MiLightUdpServer::handlePacket(uint8_t* packet, size_t packetSize) {
|
|
|
if (packetSize == 2 || packetSize == 3) {
|
|
|
@@ -25,9 +26,9 @@ void V5MiLightUdpServer::handleCommand(uint8_t command, uint8_t commandArg) {
|
|
|
client->prepare(MilightRgbwConfig, deviceId, groupId);
|
|
|
client->updateColorWhite();
|
|
|
this->lastGroup = groupId;
|
|
|
- // On/off for CCT
|
|
|
- } else if (cctCommandIdToGroup(command) != 255) {
|
|
|
- uint8_t cctGroup = cctCommandIdToGroup(command);
|
|
|
+ // On/off for CCT
|
|
|
+ } else if (CctPacketFormatter::cctCommandIdToGroup(command) != 255) {
|
|
|
+ uint8_t cctGroup = CctPacketFormatter::cctCommandIdToGroup(command);
|
|
|
client->prepare(MilightCctConfig, deviceId, cctGroup);
|
|
|
this->lastGroup = cctGroup;
|
|
|
|
|
|
@@ -35,7 +36,7 @@ void V5MiLightUdpServer::handleCommand(uint8_t command, uint8_t commandArg) {
|
|
|
if ((command & 0x80) == 0x80) {
|
|
|
client->enableNightMode();
|
|
|
} else {
|
|
|
- client->updateStatus(cctCommandToStatus(command));
|
|
|
+ client->updateStatus(CctPacketFormatter::cctCommandToStatus(command));
|
|
|
}
|
|
|
} else {
|
|
|
client->prepare(MilightRgbwConfig, deviceId, lastGroup);
|
|
|
@@ -118,42 +119,3 @@ void V5MiLightUdpServer::handleCommand(uint8_t command, uint8_t commandArg) {
|
|
|
void V5MiLightUdpServer::pressButton(uint8_t button) {
|
|
|
client->command(button, 0);
|
|
|
}
|
|
|
-
|
|
|
-uint8_t V5MiLightUdpServer::cctCommandIdToGroup(uint8_t command) {
|
|
|
- switch (command & 0x7F) {
|
|
|
- case UDP_CCT_GROUP_1_ON:
|
|
|
- case UDP_CCT_GROUP_1_OFF:
|
|
|
- return 1;
|
|
|
- case UDP_CCT_GROUP_2_ON:
|
|
|
- case UDP_CCT_GROUP_2_OFF:
|
|
|
- return 2;
|
|
|
- case UDP_CCT_GROUP_3_ON:
|
|
|
- case UDP_CCT_GROUP_3_OFF:
|
|
|
- return 3;
|
|
|
- case UDP_CCT_GROUP_4_ON:
|
|
|
- case UDP_CCT_GROUP_4_OFF:
|
|
|
- return 4;
|
|
|
- case UDP_CCT_ALL_ON:
|
|
|
- case UDP_CCT_ALL_OFF:
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- return 255;
|
|
|
-}
|
|
|
-
|
|
|
-MiLightStatus V5MiLightUdpServer::cctCommandToStatus(uint8_t command) {
|
|
|
- switch (command & 0x7F) {
|
|
|
- case UDP_CCT_GROUP_1_ON:
|
|
|
- case UDP_CCT_GROUP_2_ON:
|
|
|
- case UDP_CCT_GROUP_3_ON:
|
|
|
- case UDP_CCT_GROUP_4_ON:
|
|
|
- case UDP_CCT_ALL_ON:
|
|
|
- return ON;
|
|
|
- case UDP_CCT_GROUP_1_OFF:
|
|
|
- case UDP_CCT_GROUP_2_OFF:
|
|
|
- case UDP_CCT_GROUP_3_OFF:
|
|
|
- case UDP_CCT_GROUP_4_OFF:
|
|
|
- case UDP_CCT_ALL_OFF:
|
|
|
- return OFF;
|
|
|
- }
|
|
|
-}
|