V5MiLightUdpServer.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_ALL_ON = 0x35,
  11. UDP_CCT_ALL_OFF = 0x39,
  12. UDP_CCT_GROUP_1_ON = 0x38,
  13. UDP_CCT_GROUP_1_OFF = 0x3B,
  14. UDP_CCT_GROUP_2_ON = 0x3D,
  15. UDP_CCT_GROUP_2_OFF = 0x33,
  16. UDP_CCT_GROUP_3_ON = 0x37,
  17. UDP_CCT_GROUP_3_OFF = 0x3A,
  18. UDP_CCT_GROUP_4_ON = 0x32,
  19. UDP_CCT_GROUP_4_OFF = 0x36,
  20. UDP_CCT_TEMPERATURE_DOWN = 0x3F,
  21. UDP_CCT_TEMPERATURE_UP = 0x3E,
  22. UDP_CCT_BRIGHTNESS_DOWN = 0x34,
  23. UDP_CCT_BRIGHTNESS_UP = 0x3C,
  24. UDP_CCT_NIGHT_MODE = 0xB9,
  25. UDP_RGBW_ALL_OFF = 0x41,
  26. UDP_RGBW_ALL_ON = 0x42,
  27. UDP_RGBW_SPEED_UP = 0x43,
  28. UDP_RGBW_SPEED_DOWN = 0x44,
  29. UDP_RGBW_GROUP_1_ON = 0x45,
  30. UDP_RGBW_GROUP_1_OFF = 0x46,
  31. UDP_RGBW_GROUP_2_ON = 0x47,
  32. UDP_RGBW_GROUP_2_OFF = 0x48,
  33. UDP_RGBW_GROUP_3_ON = 0x49,
  34. UDP_RGBW_GROUP_3_OFF = 0x4A,
  35. UDP_RGBW_GROUP_4_ON = 0x4B,
  36. UDP_RGBW_GROUP_4_OFF = 0x4C,
  37. UDP_RGBW_DISCO_MODE = 0x4D,
  38. UDP_RGBW_GROUP_ALL_WHITE = 0xC2,
  39. UDP_RGBW_GROUP_1_WHITE = 0xC5,
  40. UDP_RGBW_GROUP_2_WHITE = 0xC7,
  41. UDP_RGBW_GROUP_3_WHITE = 0xC9,
  42. UDP_RGBW_GROUP_4_WHITE = 0xCB,
  43. UDP_RGBW_BRIGHTNESS = 0x4E,
  44. UDP_RGBW_COLOR = 0x40
  45. };
  46. class V5MiLightUdpServer : public MiLightUdpServer {
  47. public:
  48. V5MiLightUdpServer(MiLightClient*& client, uint16_t port, uint16_t deviceId)
  49. : MiLightUdpServer(client, port, deviceId)
  50. { }
  51. // Should return size of the response packet
  52. virtual void handlePacket(uint8_t* packet, size_t packetSize);
  53. protected:
  54. void handleCommand(uint8_t command, uint8_t commandArg);
  55. void pressButton(uint8_t button);
  56. uint8_t cctCommandIdToGroup(uint8_t command);
  57. MiLightStatus cctCommandToStatus(uint8_t command);
  58. };
  59. #endif