FauxmoESP v2.0.0
Loading...
Searching...
No Matches
FauxmoESP Class Reference

Detailed Description

Main class for FauxmoESP.

Definition at line 32 of file FauxmoESP.h.

#include <FauxmoESP.h>

Public Member Functions

 FauxmoESP (bool enableWebServer=true)
 Construct a new FauxmoESP object.
 
 ~FauxmoESP ()
 Destroy the FauxmoESP object.
 
void setup (OnStateChangeCallback onStateChangeCallback, OnGetStateCallback onGetStateCallback)
 Setup the FauxmoESP object.
 
void teardown ()
 Teardown the FauxmoESP object.
 
LightaddLight (const String &name, const LightCapabilities &capabilities=LightCapabilities(), const LightState &initialState=LightState())
 Add a light to the FauxmoESP object.
 
void removeLight (const String &deviceId)
 Remove a light from the FauxmoESP object.
 
void update ()
 Handles the SSDP and web server.
 
void setWebServerEnabled (bool enabled)
 Set whether the web server is enabled or not.
 
void setCheckUsername (bool checkUsername)
 Set whether the username should be checked or not If a request is made with a username that does not match the known one, the request will be denied.
 
bool checkUsername (const String &username)
 Check if the username is correct.
 
void processRequest (const String &url, const String &body, const String &method, String &response, uint16_t *resultCode)
 Process a request, only used when the web server is disabled.
 
void setUsername (const String &username)
 Set the username.
 
void setWebServerPort (uint16_t port)
 Set the web server port.
 
LightgetLightByDeviceId (ushort deviceId)
 Get a light by its device id.
 
LightgetLightByName (const String &name)
 Get a light by its name.
 

Constructor & Destructor Documentation

◆ FauxmoESP()

FauxmoESP::FauxmoESP ( bool  enableWebServer = true)
explicit

Construct a new FauxmoESP object.

Parameters
enableWebServerWhether to enable the web server or not

Definition at line 11 of file FauxmoESP.cpp.

◆ ~FauxmoESP()

FauxmoESP::~FauxmoESP ( )

Destroy the FauxmoESP object.

Definition at line 16 of file FauxmoESP.cpp.

Member Function Documentation

◆ addLight()

Light * FauxmoESP::addLight ( const String &  name,
const LightCapabilities capabilities = LightCapabilities(),
const LightState initialState = LightState() 
)

Add a light to the FauxmoESP object.

Parameters
nameThe name of the light
capabilitiesThe capabilities of the light, defaults to LightCapabilities()
initialStateThe initial state of the light, defaults to LightState()
Returns
Light* The light object or nullptr if the light could not be added

Definition at line 370 of file FauxmoESP.cpp.

◆ checkUsername()

bool FauxmoESP::checkUsername ( const String &  username)

Check if the username is correct.

Parameters
usernameThe username to check
Returns
true If the username is correct, false otherwise

Definition at line 242 of file FauxmoESP.cpp.

◆ getLightByDeviceId()

Light * FauxmoESP::getLightByDeviceId ( ushort  deviceId)

Get a light by its device id.

Parameters
deviceIdThe device id of the light
Returns
Light* The light object or nullptr if the light could not be found

Definition at line 424 of file FauxmoESP.cpp.

◆ getLightByName()

Light * FauxmoESP::getLightByName ( const String &  name)

Get a light by its name.

Parameters
nameThe name of the light
Returns
Light* The light object or nullptr if the light could not be found

Definition at line 409 of file FauxmoESP.cpp.

◆ processRequest()

void FauxmoESP::processRequest ( const String &  url,
const String &  body,
const String &  method,
String &  response,
uint16_t *  resultCode 
)

Process a request, only used when the web server is disabled.

Parameters
urlThe full URL of the request
bodyThe body of the request
methodThe method of the request
responseReturns the response
resultCodeReturns the result code

Definition at line 34 of file FauxmoESP.cpp.

◆ removeLight()

void FauxmoESP::removeLight ( const String &  deviceId)

Remove a light from the FauxmoESP object.

Parameters
deviceIdThe device id of the light

Definition at line 392 of file FauxmoESP.cpp.

◆ setCheckUsername()

void FauxmoESP::setCheckUsername ( bool  checkUsername)
inline

Set whether the username should be checked or not If a request is made with a username that does not match the known one, the request will be denied.

Parameters
checkUsernameWhether the username should be checked or not

Definition at line 120 of file FauxmoESP.h.

◆ setup()

void FauxmoESP::setup ( OnStateChangeCallback  onStateChangeCallback,
OnGetStateCallback  onGetStateCallback 
)

Setup the FauxmoESP object.

Parameters
onStateChangeCallbackCallback to be called when a device state changes
onGetStateCallbackCallback to be called when a device state is requested

Definition at line 21 of file FauxmoESP.cpp.

◆ setUsername()

void FauxmoESP::setUsername ( const String &  username)
inline

Set the username.

Parameters
usernameThe username

Definition at line 146 of file FauxmoESP.h.

◆ setWebServerEnabled()

void FauxmoESP::setWebServerEnabled ( bool  enabled)
inline

Set whether the web server is enabled or not.

Parameters
enabledWhether the web server is enabled or not

Definition at line 109 of file FauxmoESP.h.

◆ setWebServerPort()

void FauxmoESP::setWebServerPort ( uint16_t  port)
inline

Set the web server port.

Parameters
portThe web server port

Definition at line 155 of file FauxmoESP.h.

◆ teardown()

void FauxmoESP::teardown ( )

Teardown the FauxmoESP object.

Definition at line 113 of file FauxmoESP.cpp.

◆ update()

void FauxmoESP::update ( )

Handles the SSDP and web server.

Definition at line 232 of file FauxmoESP.cpp.


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