NanoLux (Device) 3.0
Codebase for the open-source AudioLux device.
Loading...
Searching...
No Matches
api.h File Reference
#include <iterator>
#include <algorithm>

Go to the source code of this file.

Functions

void initialize_pattern_list ()
 Creates a JSON file with the list of patterns.
 
void handle_patterns_list_request (AsyncWebServerRequest *request)
 Handles sending the JSON of patterns to other devices.
 
void handle_pattern_get_request (AsyncWebServerRequest *request)
 Handler function for getting pattern data.
 
void handle_strip_get_request (AsyncWebServerRequest *request)
 Handler function for getting pattern data.
 
void handle_strip_put_request (AsyncWebServerRequest *request, JsonVariant &json)
 Handler function for updating strip data.
 
void handle_pattern_put_request (AsyncWebServerRequest *request, JsonVariant &json)
 Handler function for updating pattern data.
 
void handle_load_save_slot_put_request (AsyncWebServerRequest *request, JsonVariant &json)
 Handler function for loading a saved pattern.
 
void handle_save_to_slot_put_request (AsyncWebServerRequest *request, JsonVariant &json)
 Handler function for saving the currently-running pattern.
 
void handle_system_settings_put_request (AsyncWebServerRequest *request, JsonVariant &json)
 Handler function for updating system settings.
 
void handle_system_settings_get_request (AsyncWebServerRequest *request)
 Handler function for getting system settings.
 
void handle_new_password_put_request (AsyncWebServerRequest *request, JsonVariant &json)
 

Variables

constexpr int PATTERN_BUFFER_SIZE = 4096
 
APIGetHook apiGetHooks []
 The currently active get requests.
 
constexpr int API_GET_HOOK_COUNT = 4
 
APIPutHook apiPutHooks []
 The currently active put requests.
 
constexpr int API_PUT_HOOK_COUNT = 6
 

Detailed Description

This file contains most of the web request API, in particular pertaining to pattern and pattern settings.

For the remaining parts of the API, see webServer.h

Function Documentation

◆ handle_load_save_slot_put_request()

void handle_load_save_slot_put_request ( AsyncWebServerRequest * request,
JsonVariant & json )
inline

Handler function for loading a saved pattern.

Parameters
requestThe incoming put request
jsonThe incoming JSON file holding the slot to load.

If the save slot to load is less than 0 or above NUM_SAVES, send a failure response and don't load anything.

◆ handle_pattern_get_request()

void handle_pattern_get_request ( AsyncWebServerRequest * request)
inline

Handler function for getting pattern data.

Parameters
requestThe incoming request for data.

This handler is responsible for sending data from a particular pattern. The web request contains the particular pattern to get through a string query. Once that pattern has been requested, the device sends back information like the currently selected pattern id, the pattern brightness, and the smoothing.

◆ handle_pattern_put_request()

void handle_pattern_put_request ( AsyncWebServerRequest * request,
JsonVariant & json )
inline

Handler function for updating pattern data.

Parameters
requestThe incoming put request
jsonThe incoming JSON file holding new data.

This handler is responsible for updating pattern-level data from a web request. The specific pattern to update is obtained from a string query.

◆ handle_patterns_list_request()

void handle_patterns_list_request ( AsyncWebServerRequest * request)
inline

Handles sending the JSON of patterns to other devices.

Parameters
requestThe incoming request for data.

◆ handle_save_to_slot_put_request()

void handle_save_to_slot_put_request ( AsyncWebServerRequest * request,
JsonVariant & json )
inline

Handler function for saving the currently-running pattern.

Parameters
requestThe incoming put request
jsonThe incoming JSON file holding the slot to save to.

If the save slot to load is less than 0 or above NUM_SAVES, send a failure response and don't load anything.

◆ handle_strip_get_request()

void handle_strip_get_request ( AsyncWebServerRequest * request)
inline

Handler function for getting pattern data.

Parameters
requestThe incoming request for data.

This handler is responsible for sending strip configuration data. The device device sends back information like the pattern count, pattern transparancy, and the current mode (Z-layering or Strip Splitting)

◆ handle_strip_put_request()

void handle_strip_put_request ( AsyncWebServerRequest * request,
JsonVariant & json )
inline

Handler function for updating strip data.

Parameters
requestThe incoming put request
jsonThe incoming JSON file holding new data.

This handler is responsible for updating strip-level data from a web request.

◆ handle_system_settings_get_request()

void handle_system_settings_get_request ( AsyncWebServerRequest * request)
inline

Handler function for getting system settings.

Parameters
requestThe incoming get request

Includes data such as strip length, loop times, and debug mode.

◆ handle_system_settings_put_request()

void handle_system_settings_put_request ( AsyncWebServerRequest * request,
JsonVariant & json )
inline

Handler function for updating system settings.

Parameters
requestThe incoming put request
jsonThe incoming JSON file holding the new system settings to save

Includes data such as strip length, loop times, and debug mode.

◆ initialize_pattern_list()

void initialize_pattern_list ( )
inline

Creates a JSON file with the list of patterns.

This file is intended to be sent to connecting devices in order to present a list of patterns to the user.

Variable Documentation

◆ apiGetHooks

APIGetHook apiGetHooks[]
Initial value:
= {
{ "/api/patterns", handle_patterns_list_request },
{ "/api/getPattern", handle_pattern_get_request },
{ "/api/getStrip", handle_strip_get_request },
{ "/api/getSettings", handle_system_settings_get_request },
}
void handle_pattern_get_request(AsyncWebServerRequest *request)
Handler function for getting pattern data.
Definition api.h:81
void handle_system_settings_get_request(AsyncWebServerRequest *request)
Handler function for getting system settings.
Definition api.h:359
void handle_patterns_list_request(AsyncWebServerRequest *request)
Handles sending the JSON of patterns to other devices.
Definition api.h:56
void handle_strip_get_request(AsyncWebServerRequest *request)
Handler function for getting pattern data.
Definition api.h:108

The currently active get requests.

◆ apiPutHooks

APIPutHook apiPutHooks[]
Initial value:
= {
{ "/api/putPattern", handle_pattern_put_request },
{ "/api/putStrip", handle_strip_put_request },
{ "/api/putSettings", handle_system_settings_put_request },
{ "/api/updatePassword", handle_new_password_put_request },
}
void handle_system_settings_put_request(AsyncWebServerRequest *request, JsonVariant &json)
Handler function for updating system settings.
Definition api.h:320
void handle_pattern_put_request(AsyncWebServerRequest *request, JsonVariant &json)
Handler function for updating pattern data.
Definition api.h:175
void handle_load_save_slot_put_request(AsyncWebServerRequest *request, JsonVariant &json)
Handler function for loading a saved pattern.
Definition api.h:222
void handle_strip_put_request(AsyncWebServerRequest *request, JsonVariant &json)
Handler function for updating strip data.
Definition api.h:127
void handle_save_to_slot_put_request(AsyncWebServerRequest *request, JsonVariant &json)
Handler function for saving the currently-running pattern.
Definition api.h:272

The currently active put requests.