Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String getBeaconsReport() {
- StaticJsonDocument<1024> doc;
- JsonArray tagsArr = doc.createNestedArray("tags");
- for (x = 0; x < noOfBeacons; x++) {
- JsonObject tagsObj = tagsArr.createNestedObject();
- tagsObj["mac"] = getMacAsString(x);
- tagsObj["rssi"] = beaconsRSSI[x];
- tagsObj["time"] = saved_beacons.beacons[x].time;
- }
- doc["mac"] = String(eth_mac);
- doc["msg"] = "REPORT";
- doc["bcnt"] = bootCount;
- String json;
- serializeJson(doc, json);
- return json;
- }
- void reportStatusOverWifi() {
- String content = getBeaconsReport();
- String result = myGAS.gasClient(content, false);
- if (!result.equals("error")) {
- reportTimerRTC = timestampUnix;
- } else {
- if (debug) Serial.println("Error reportStatusOverWifi: " + String(result));
- }
- }
- void reportStatus() {
- if (!readBridgeConfig()) {
- if (debug) Serial.println("Error readBridgeConfig");
- } else {
- if (internetservices_internet) {
- if ( (timestampUnix - reportTimerRTC > reportTimer) || (smsAlert == true) ) {
- genericDurationStart = millis();
- if (debug) Serial.println("Reporting over wifi..");
- reportStatusOverWifi();
- genericDurationTotal = millis() - genericDurationStart;
- if (debugDuration) Serial.println("Duration ReportStatusOverWifi: " + String(genericDurationTotal));
- } else {
- if (debug) Serial.println("Next report: " + String(reportTimer - (timestampUnix - reportTimerRTC)) + " seconds");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement