V5MiLightUdpServer.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // This protocol is documented here:
  2. // http://www.limitlessled.com/dev/
  3. #include <Arduino.h>
  4. #include <MiLightClient.h>
  5. #include <WiFiUdp.h>
  6. #include <MiLightUdpServer.h>
  7. #ifndef _V5_MILIGHT_UDP_SERVER
  8. #define _V5_MILIGHT_UDP_SERVER
  9. enum MiLightUdpCommands {
  10. UDP_CCT_GROUP_1_ON = 0x38,
  11. UDP_CCT_GROUP_1_OFF = 0x3B,
  12. UDP_CCT_GROUP_2_ON = 0x3D,
  13. UDP_CCT_GROUP_2_OFF = 0x33,
  14. UDP_CCT_GROUP_3_ON = 0x37,
  15. UDP_CCT_GROUP_3_OFF = 0x3A,
  16. UDP_CCT_GROUP_4_ON = 0x32,
  17. UDP_CCT_GROUP_4_OFF = 0x36,
  18. UDP_CCT_TEMPERATURE_DOWN = 0x3F,
  19. UDP_CCT_TEMPERATURE_UP = 0x3E,
  20. UDP_CCT_BRIGHTNESS_DOWN = 0x34,
  21. UDP_CCT_BRIGHTNESS_UP = 0x3C,
  22. UDP_RGBW_ALL_ON = 0x41,
  23. UDP_RGBW_ALL_OFF = 0x42,
  24. UDP_RGBW_SPEED_UP = 0x43,
  25. UDP_RGBW_SPEED_DOWN = 0x44,
  26. UDP_RGBW_GROUP_1_ON = 0x45,
  27. UDP_RGBW_GROUP_1_OFF = 0x46,
  28. UDP_RGBW_GROUP_2_ON = 0x47,
  29. UDP_RGBW_GROUP_2_OFF = 0x48,
  30. UDP_RGBW_GROUP_3_ON = 0x49,
  31. UDP_RGBW_GROUP_3_OFF = 0x4A,
  32. UDP_RGBW_GROUP_4_ON = 0x4B,
  33. UDP_RGBW_GROUP_4_OFF = 0x4C,
  34. UDP_RGBW_DISCO_MODE = 0x4D,
  35. UDP_RGBW_GROUP_ALL_WHITE = 0xC2,
  36. UDP_RGBW_GROUP_1_WHITE = 0xC5,
  37. UDP_RGBW_GROUP_2_WHITE = 0xC7,
  38. UDP_RGBW_GROUP_3_WHITE = 0xC9,
  39. UDP_RGBW_GROUP_4_WHITE = 0xCB,
  40. UDP_RGBW_BRIGHTNESS = 0x4E,
  41. UDP_RGBW_COLOR = 0x40
  42. };
  43. class V5MiLightUdpServer : public MiLightUdpServer {
  44. public:
  45. V5MiLightUdpServer(MiLightClient*& client, uint16_t port, uint16_t deviceId)
  46. : MiLightUdpServer(client, port, deviceId)
  47. { }
  48. // Should return size of the response packet
  49. virtual void handlePacket(uint8_t* packet, size_t packetSize);
  50. protected:
  51. void handleCommand(uint8_t command, uint8_t commandArg);
  52. void pressButton(uint8_t button);
  53. uint8_t cctCommandIdToGroup(uint8_t command);
  54. MiLightStatus cctCommandToStatus(uint8_t command);
  55. };
  56. #endif