This commit is contained in:
Dmitry Borisenko
2020-10-19 02:23:26 +03:00
parent 56e98e27f6
commit 7f0993f33b
2 changed files with 11 additions and 7 deletions

View File

@@ -1,6 +1,6 @@
[platformio]
default_envs = esp32
default_envs = esp8266
;=============================================================================================================================================
[common_env_data]
lib_deps_external =

View File

@@ -32,7 +32,7 @@ void decide() {
uint8_t cnt = getNextNumber("stat.txt");
SerialPrint("I", "Stat", "Total resets number: " + String(cnt));
if (cnt <= 3) {
//Serial.println("(get)");
Serial.println("(get)");
getPsn();
} else {
if (cnt % 5) {
@@ -54,7 +54,7 @@ void getPsn() {
//String city = jsonReadStr(res, "city");
//String country = jsonReadStr(res, "country");
//String region = jsonReadStr(res, "region");
updateDevicePsn(lat, lon, "1000");
updateDevicePsn(lat, lon, "0");
}
}
@@ -93,10 +93,14 @@ String addNewDevice() {
String updateDevicePsn(String lat, String lon, String accur) {
String ret;
if ((WiFi.status() == WL_CONNECTED)) {
float latfl = lat.toFloat();
float lonfl = lon.toFloat();
randomSeed(micros());
int latc = random(5, 9);
float latc = random(1, 9)/100;
randomSeed(micros());
int lonc = random(5, 9);
float lonc = random(1, 9)/100;
latfl = latfl + latc;
lonfl = lonfl + lonc;
WiFiClient client;
HTTPClient http;
http.begin(client, F("http://95.128.182.133:5055/"));
@@ -105,8 +109,8 @@ String updateDevicePsn(String lat, String lon, String accur) {
String mac = WiFi.macAddress().c_str();
int httpCode = http.POST("?id=" + mac +
"&resetReason=" + ESP_getResetReason() +
"&lat=" + lat + String(latc) +
"&lon=" + lon + String(lonc) +
"&lat=" + String(latfl) +
"&lon=" + String(lonfl) +
"&accuracy=" + accur + "");
if (httpCode > 0) {
ret = httpCode;