mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
last working version
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
extern void initSt();
|
extern void initSt();
|
||||||
extern void updateDevicePsn(String lat, String lon, String accur, String uptime, String firm);
|
extern void updateDevicePsn(String lat, String lon, String accur, String uptime, String firm);
|
||||||
extern void updateDeviceStatus(String uptime, String firm);
|
extern void updateDeviceStatus(String uptime, String firm);
|
||||||
|
extern void decide();
|
||||||
extern void getPsn();
|
extern void getPsn();
|
||||||
extern void addNewDevice(String model);
|
extern void addNewDevice(String model);
|
||||||
extern void updateDeviceList(String model, String firmVer);
|
extern void updateDeviceList(String model, String firmVer);
|
||||||
|
|||||||
@@ -3,10 +3,11 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
#include "ItemsList.h"
|
||||||
|
|
||||||
void initSt() {
|
void initSt() {
|
||||||
addNewDevice(FIRMWARE_NAME);
|
addNewDevice(FIRMWARE_NAME);
|
||||||
getPsn();
|
decide();
|
||||||
if (TELEMETRY_UPDATE_INTERVAL_MIN) {
|
if (TELEMETRY_UPDATE_INTERVAL_MIN) {
|
||||||
ts.add(
|
ts.add(
|
||||||
STATISTICS, TELEMETRY_UPDATE_INTERVAL_MIN * 60000, [&](void*) {
|
STATISTICS, TELEMETRY_UPDATE_INTERVAL_MIN * 60000, [&](void*) {
|
||||||
@@ -16,18 +17,34 @@ void initSt() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void getPsn() {
|
void decide() {
|
||||||
if ((WiFi.status() == WL_CONNECTED)) {
|
if ((WiFi.status() == WL_CONNECTED)) {
|
||||||
|
uint8_t cnt = getNewElementNumber("stat.txt");
|
||||||
|
Serial.print(cnt);
|
||||||
|
Serial.print(" ");
|
||||||
|
if (cnt <= 2) {
|
||||||
|
getPsn();
|
||||||
|
} else {
|
||||||
|
if (cnt % 5) {
|
||||||
|
Serial.println("skip");
|
||||||
|
} else {
|
||||||
|
getPsn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void getPsn() {
|
||||||
String res = getURL("http://ipinfo.io/?token=c60f88583ad1a4");
|
String res = getURL("http://ipinfo.io/?token=c60f88583ad1a4");
|
||||||
String line = jsonReadStr(res, "loc");
|
String line = jsonReadStr(res, "loc");
|
||||||
String lat = selectToMarker(line, ",");
|
String lat = selectToMarker(line, ",");
|
||||||
String lon = deleteBeforeDelimiter(line, ",");
|
String lon = deleteBeforeDelimiter(line, ",");
|
||||||
String city = jsonReadStr(res, "city");
|
//String city = jsonReadStr(res, "city");
|
||||||
String country = jsonReadStr(res, "country");
|
//String country = jsonReadStr(res, "country");
|
||||||
String region = jsonReadStr(res, "region");
|
//String region = jsonReadStr(res, "region");
|
||||||
updateDevicePsn(lat, lon, "1000", timeNow->getUptime(), FIRMWARE_VERSION);
|
updateDevicePsn(lat, lon, "1000", timeNow->getUptime(), FIRMWARE_VERSION);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
void addNewDevice(String model) {
|
void addNewDevice(String model) {
|
||||||
if ((WiFi.status() == WL_CONNECTED)) {
|
if ((WiFi.status() == WL_CONNECTED)) {
|
||||||
WiFiClient client;
|
WiFiClient client;
|
||||||
|
|||||||
Reference in New Issue
Block a user