This program is controlled with a config file `config.toml` in which the user can configure each thermocouple channel independently, enable a web view, configure database logging, etc.
The TH7 software uses sane default values where possible.
The TH7 implements a simple REST API along with a websocket endpoint that periodically dumps data probably relevant to user logging applications.
#### REST API
```
--- fetch latest measurement for a given channel id ---
GET v1/data/channel/:id -> {
"channel": {
id,
value in °C
},
"time": current system time
}
--- fetch latest measurements for all configured channels ---
GET v1/data/channels
--- fetch latest "ratio table" used during signal conversion ---
GET v1/data/ratio -> {
"ratio": {
vref,
vadj,
pivdd
},
"time": current system time
}
--- short for all measurement data that may be wanted by a user ---
GET v1/data -> {
"channels": { ... },
"ratio": { ... },
"time": "..."
}
--- fetch configuration options for a given channel id ---
GET v1/config/channel/:id -> {
"id": ...,
"thermocouple": ...,
"gain": ...,
"offset": ...,
"log" ...,
"filter": {
"sample_size": ...,
"type": ...,
},
"time": "..."
}
--- Fetch config options for all configured channels ---
GET v1/config/channels
--- Fetch device config options ---
GET v1/config/device -> {
"device": {
"led": ...,
"debug": ...,
"nolog": ...,
"noweb": ...
},
"time": "..."
}
--- Fetch the DB config options ---
--- This can leak sensitive information so this endpoint must be ---
--- explicitly enabled in the API section of the config file. ---
GET v1/config/db
--
-- All POST requests are in the form:
-- $ curl -d "key=$KEY&value=$VALUE" -X POST "$URL"
-- If a request is succesful, "OK" is returned.
--
--- Modify a field in the device config ---
POST v1/config/device
--- Modify a config field for a given channel ---
POST v1/config/channel/:id
--- Modify or add a field in the database config map object ---
POST v1/config/db
```
#### WebSocket
The WebSocket endpoint requires no configuration, and will dump data at a regular interval to any active client connection. The data is functionally identical to `GET v1/data`. Example: