SinricPro Library
|
The main class of this library, handling communication between SinricPro Server and your devices. More...
#include <SinricPro.h>
Inherits SinricProInterface.
Public Member Functions | |
void | begin (String appKey, String appSecret, String serverURL="ws.sinric.pro") |
Initializing SinricProClass to be able to connect to SinricPro Server. | |
void | handle () |
Handles communication between device and SinricPro Server. | |
void | onConnected (ConnectedCallbackHandler cb) |
Set callback function for websocket connected event. | |
void | onDisconnected (DisconnectedCallbackHandler cb) |
Set callback function for websocket disconnected event. | |
void | restoreDeviceStates (bool flag) |
Enable / disable restore device states function. | |
unsigned long | getTimestamp () override |
Get the current timestamp. | |
Proxy | operator[] (const String deviceId) |
operator[] is used tor create a new device instance or get an existing device instance | |
The main class of this library, handling communication between SinricPro Server and your devices.
void begin | ( | String | appKey, |
String | appSecret, | ||
String | serverURL = "ws.sinric.pro" |
||
) |
Initializing SinricProClass to be able to connect to SinricPro Server.
appKey | String containing APP_KEY (see credentials from https://sinric.pro ) |
appSecret | String containing APP_SECRET (see credentials from https:://sinric.pro) |
serverURL | String containing SinricPro Server URL (default="ws.sinric.pro") |
Get the current timestamp.
void handle | ( | ) |
Handles communication between device and SinricPro Server.
This is the absolute main function which handles communication between your device and SinricPro Server.
It is responsible for connect, disconnect to SinricPro Server, handling requests, responses and events.
This function has to be called as often as possible. So it must be called in your main loop() function!
For proper function, begin() must be called with valid values for 'APP_KEY' and 'APP_SECRET'
void onConnected | ( | ConnectedCallbackHandler | cb | ) |
Set callback function for websocket connected event.
cb | Function pointer to a ConnectedCallbackHandler function |
void onDisconnected | ( | DisconnectedCallbackHandler | cb | ) |
Set callback function for websocket disconnected event.
cb | Function pointer to a DisconnectedCallbackHandler function |
operator[] is used tor create a new device instance or get an existing device instance
If the device is unknown to SinricProClass it will create a new device instance
deviceId | a String containing deviceId for device that have to been created or retreived |
<DeviceType> &reference = SinricPro[<DEVICE_ID>];
void restoreDeviceStates | ( | bool | flag | ) |
Enable / disable restore device states function.
If this flag is enabled (true
), SinricProServer will send last known device states to your device directly after connection to SinricPro server has been established.
For every state the corresponding callback (like onPowerState
) will be called
This is useful after a power failure / reboot of your device.
flag | true = enabled false = disabled |