EmlaLockSafe
emlalock::EmlaLockApi Class Reference

Class interfacing Arduino to the EmlaLock API. More...

#include <EmlaLockApi.h>

Public Member Functions

void triggerRefresh ()
 Triggers the client to reload the current state from the EmlaLock server. More...
 

Static Public Member Functions

static EmlaLockApigetSingleton (bool offlineMode=false)
 Get the singleton instance of the API handler. More...
 

Protected Member Functions

 EmlaLockApi (bool offlineMode)
 Construct a new EmlaLock Api Object. Use the singleton EmlaLock or getInstance() instead of creating new objects. More...
 
void threadFunction ()
 The thread functions which is communicating asynchronously with the Emlalock API. More...
 
bool requestUrl (String &url)
 Loads the requested url and parses the json result. More...
 

Protected Attributes

const String host = "api.emlalock.com"
 The base address to the API. More...
 
StaticJsonDocument< 10000 > jsonDocument
 JSON parser. More...
 
std::mutex mtx
 Mutex used to ensure thread safety of the API. More...
 
std::condition_variable condVar
 Condition variable to which can be triggered to immediately request the status of the EmlaLock Session. More...
 
bool triggered
 Helper variable to detect spurious wakeups of thread. More...
 
bool offlineMode
 If true the thread requesting data from emlalock won't be started. More...
 

Detailed Description

Class interfacing Arduino to the EmlaLock API.

See also
https://www.emlalock.com/apidoc/

Constructor & Destructor Documentation

◆ EmlaLockApi()

emlalock::EmlaLockApi::EmlaLockApi ( bool  offlineMode)
inlineprotected

Construct a new EmlaLock Api Object. Use the singleton EmlaLock or getInstance() instead of creating new objects.

Parameters
offlineModeif true the thread requesting data from emlalock won't be started.

Member Function Documentation

◆ getSingleton()

static EmlaLockApi & emlalock::EmlaLockApi::getSingleton ( bool  offlineMode = false)
inlinestatic

Get the singleton instance of the API handler.

Parameters
offlineModeif true the thread requesting data from emlalock won't be started.

◆ requestUrl()

bool emlalock::EmlaLockApi::requestUrl ( String &  url)
inlineprotected

Loads the requested url and parses the json result.

Parameters
urlthe URL to be loaded
Returns
true if no error occurred.

◆ threadFunction()

void emlalock::EmlaLockApi::threadFunction ( )
inlineprotected

The thread functions which is communicating asynchronously with the Emlalock API.

◆ triggerRefresh()

void emlalock::EmlaLockApi::triggerRefresh ( )
inline

Triggers the client to reload the current state from the EmlaLock server.

Member Data Documentation

◆ condVar

std::condition_variable emlalock::EmlaLockApi::condVar
protected

Condition variable to which can be triggered to immediately request the status of the EmlaLock Session.

◆ host

const String emlalock::EmlaLockApi::host = "api.emlalock.com"
protected

The base address to the API.

◆ jsonDocument

StaticJsonDocument<10000> emlalock::EmlaLockApi::jsonDocument
protected

JSON parser.

◆ mtx

std::mutex emlalock::EmlaLockApi::mtx
protected

Mutex used to ensure thread safety of the API.

◆ offlineMode

bool emlalock::EmlaLockApi::offlineMode
protected

If true the thread requesting data from emlalock won't be started.

◆ triggered

bool emlalock::EmlaLockApi::triggered
protected

Helper variable to detect spurious wakeups of thread.


The documentation for this class was generated from the following file: