-
Notifications
You must be signed in to change notification settings - Fork 5
Json rest api
Json rest api documentation
As soon as ESP is running that will provide access to internal end points
<your_esp_host_name>/get_info
returns JSON with generic data about sketch, as example
{
"version":"0.9",
"async":"true",
"hostname":"HomeController"
}
Additionally each service configured provide each own methods
- HTTP GET get_state returns current state
- HTTP POST set_state set new state
Full URL is defined by following rules
<your_esp_host_name>//get_state <your_esp_host_name>//set_state
Both of this methods returns/accepted JSON, contains state of the service.
That allows to implement any website or mobile communication manage Controller. All of the services are cross domain, by supporting
-
Preflight request
-
Headers
"Access-Control-Allow-Origin", "*" "Access-Control-Allow-Methods", "POST, GET, PUT, DELETE, OPTIONS"
therefore is not so important to manage ESP from internal web site , and web site can be installed separatelly
RelayController state
{"isOn":false}
TimeController state
{"time":1548411912}
where 1548411912 it time_t value from your ESP, it's number of sec since 1970
LDRController state
{"ldrValue":1}
where "1" is result of read Analog GPIO !**set_state **is not supported, however is not fails, just nothing happens
RGBStripController state
{"isOn":true,"brightness":0,"color":0,"wxmode":0,"wxspeed":0}
get/set full information about rgb state
Additionally this controller has
<your_esp_host_name>//get_modes
which return the list of available modes see library WS2812FX, the result is like this
[{"mode":0,"name":"Static"},{"mode":1,"name":"Blink"},........]
this allows for externals properly setup wxmode on the state