fromradio all option

requesting fromradio will return one protobuf
4:56
requesting fromradio?all=true will give you all of them.
1.2-legacy
Jm Casler 2020-10-16 17:07:35 -07:00
rodzic f698231be7
commit b9df2c00fa
1 zmienionych plików z 18 dodań i 2 usunięć

Wyświetl plik

@ -330,15 +330,31 @@ void handleAPIv1FromRadio(HTTPRequest *req, HTTPResponse *res)
http://10.10.30.198/api/v1/fromradio
*/
// Get access to the parameters
ResourceParameters *params = req->getParams();
// std::string paramAll = "all";
std::string valueAll;
// Status code is 200 OK by default.
res->setHeader("Content-Type", "application/x-protobuf");
res->setHeader("Access-Control-Allow-Origin", "*");
res->setHeader("Access-Control-Allow-Methods", "PUT, GET");
uint8_t txBuf[MAX_STREAM_BUF_SIZE];
uint32_t len = 1;
while (len) {
if (params->getQueryParameter("all", valueAll)) {
if (valueAll == "true") {
while (len) {
len = webAPI.getFromRadio(txBuf);
res->write(txBuf, len);
}
} else {
len = webAPI.getFromRadio(txBuf);
res->write(txBuf, len);
}
} else {
len = webAPI.getFromRadio(txBuf);
res->write(txBuf, len);
}