Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/controller #245

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ To install the library, simply clone this repository in the /libraries folder of

## API documentation

The API currently supports five type of commands: digital, analog, and mode, variables, and user-defined functions.
The API currently supports five type of commands: digital, analog, and mode, variables, and user-defined functions and api-extensions.

### Digital

Expand Down Expand Up @@ -189,6 +189,24 @@ You can also define your own functions in your sketch that can be called using t
* `rest.function("led",ledControl);` declares the function in the Arduino sketch
* `/led?params=0` executes the function

### API-Extensions

With api-extensions you have the possibility to extend the api by your own subcommands and customized responses.

You define your api extensions in your sketch that can be called using the REST API. To access an user-defined api-extension defined in your sketch, you have to declare it first, and then call it from with a REST call. Note that all api-extension functions need to have the following signature `void api_extension(aREST *arest, const String& name, const String& request_url)`. For example, if your aREST instance is called "rest" and the function "aquariumController":
* `rest.api_extension("aquarium",aquariumController);` declares the api extension in the Arduino sketch
* `/aquarium/water_limit/lower/set/65` executes the api-extension function and passes the value `"/aquarium/water_limit/lower/set/65"` as the third parameter (`request_url`) into the api-extension function
* You can then customize your JSON result and extend it to something like this:
```
{
"sensor-ids": ["100", "101", "102", "103", "104"],
"id": "008",
"name": "dapper_drake",
"hardware": "arduino",
"connected": true
}
```

### Log data to the cloud

You can also directly tell your board to log data on our cloud server, to be stored there & retrieved later or displayed on the [aREST cloud dashboard](https://dashboard.arest.io/). This is useful when you want for example to record the data coming from a sensor at regular intervals. The data is then stored along with the current date, the ID of the device sending the data, and also an event name that is used to identifiy the data. This can be done via the following commands:
Expand Down
Loading