#include #include #define PLAYER_UPDATE_INTERVAL_MS (500) static unsigned long playerLastUpdateTime = 0; String httpURL(String path) { return String(OWNTONE_SERVER_ADDRESS) + "/api/" + path; } String httpGET(String path) { HTTPClient http; Serial.println(httpURL(path)); http.begin(httpURL(path)); http.GET(); String out = http.getString(); http.end(); return out; } void apiDebug(AppState *state) { } void apiLoop(AppState *state) { bool playerNeedsUpdate = (state->sinceBoot - playerLastUpdateTime) > PLAYER_UPDATE_INTERVAL_MS; playerNeedsUpdate = playerNeedsUpdate || (playerLastUpdateTime > state->sinceBoot); if (playerNeedsUpdate) { String playerText = httpGET(String("player")); FirebaseJson json; json.setJsonData(playerText); FirebaseJsonData result; json.get(result, "volume"); Serial.println(result.type); Serial.println(result.to()); state->volume = result.to(); playerLastUpdateTime = state->sinceBoot; } } void apiSetup(AppState *state) { }