hyperion.ng
LedDeviceNanoleaf.h
1 #pragma once
2 
3 // Leddevice includes
4 #include <leddevice/LedDevice.h>
5 #include "ProviderUdp.h"
6 
7 // ssdp discover
8 #include <ssdp/SSDPDiscover.h>
9 
10 // Qt includes
11 #include <QString>
12 #include <QNetworkAccessManager>
13 
19 {
20 public:
36  LedDeviceNanoleaf(const QJsonObject &deviceConfig);
37 
41  virtual ~LedDeviceNanoleaf();
42 
44  static LedDevice* construct(const QJsonObject &deviceConfig);
45 
47  virtual int switchOn();
48 
50  virtual int switchOff();
51 
52 protected:
53 
60  virtual int write(const std::vector<ColorRgb> & ledValues);
61 
71  bool init(const QJsonObject &deviceConfig);
72 
73 private:
74  // QNetworkAccessManager object for sending requests.
75  QNetworkAccessManager* _networkmanager;
76 
77  QString _hostname;
78  QString _api_port;
79  QString _auth_token;
80 
81  //Nanoleaf device details
82  QString _deviceModel;
83  QString _deviceFirmwareVersion;
84  ushort _extControlVersion;
86  int _panelLedCount;
88  std::vector<uint> _panelIds;
89 
95  bool discoverNanoleafDevice();
96 
102  QJsonDocument changeToExternalControlMode();
103 
110  QString getOnOffRequest (bool isOn ) const;
111 
121  QString getUrl(QString host, QString port, QString auth_token, QString endpoint) const;
122 
129  QJsonDocument getJson(QString url) const;
130 
138  QJsonDocument putJson(QString url, QString json) const;
139 
147  QJsonDocument handleReply(QNetworkReply* const &reply ) const;
148 };
The ProviderUdp implements an abstract base-class for LedDevices using UDP packets.
Definition: ProviderUdp.h:15
Interface (pure virtual base class) for LedDevices.
Definition: LedDevice.h:32
static LedDevice * construct(const QJsonObject &deviceConfig)
Constructs leddevice.
Definition: LedDeviceNanoleaf.cpp:75
virtual ~LedDeviceNanoleaf()
Destructor of the LedDevice; closes the tcp client.
Definition: LedDeviceNanoleaf.cpp:360
virtual int write(const std::vector< ColorRgb > &ledValues)
Writes the led color values to the led-device.
Definition: LedDeviceNanoleaf.cpp:365
bool init(const QJsonObject &deviceConfig)
Identifies a Nanoleaf device&#39;s panel configuration, sets device into External Control (UDP) mode...
Definition: LedDeviceNanoleaf.cpp:86
LedDeviceNanoleaf(const QJsonObject &deviceConfig)
Constructs the LedDevice for Nanoleaf LightPanels (aka Aurora) or Canvas.
Definition: LedDeviceNanoleaf.cpp:80
virtual int switchOff()
Switch the leds off.
Definition: LedDeviceNanoleaf.cpp:487
virtual int switchOn()
Switch the leds on.
Definition: LedDeviceNanoleaf.cpp:478
Implementation of the LedDevice interface for sending to Nanoleaf devices via network by using the &#39;e...
Definition: LedDeviceNanoleaf.h:18