-
Notifications
You must be signed in to change notification settings - Fork 4
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"
}
<your_esp_host_name>/browse
switch to file browser mode, returns filebrowse.html, which must be present in the root
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>/ServiceName/get_state
<your_esp_host_name>/ServiceName/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>/ServiceName/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
RelayDimController state
{"isOn":true,"brightness":150,"isLdr":false,"ldrValue":0}
RFController state
{"isReceive":false,"isSend":false,"rftoken":0,"rfprotocol":0,"rfdatalen":0,"rfdelay":0,"timetick":0}
Additionally this controller has <your_esp_host_name>/ServiceName/get_data
[{"name":"gate_2","token":0,"len":0,"protocol":0,"pulse":0}]
which returns database of saved RF signals and their parameters