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] [platformio]
default_envs = esp32 default_envs = esp8266
;============================================================================================================================================= ;=============================================================================================================================================
[common_env_data] [common_env_data]
lib_deps_external = lib_deps_external =

View File

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