mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
remove dupe strings
This commit is contained in:
@@ -184,6 +184,23 @@ extern Adafruit_Sensor *bme_humidity;
|
|||||||
//#include <SoftwareSerial.h>
|
//#include <SoftwareSerial.h>
|
||||||
//SoftwareSerial mySerial(14, 12);
|
//SoftwareSerial mySerial(14, 12);
|
||||||
|
|
||||||
|
// StringUtils
|
||||||
|
extern uint8_t hexStringToUint8(String hex);
|
||||||
|
extern uint16_t hexStringToUint16(String hex);
|
||||||
|
extern String selectToMarkerLast(String str, String found);
|
||||||
|
extern String selectToMarker(String str, String found);
|
||||||
|
extern String deleteAfterDelimiter(String str, String found);
|
||||||
|
extern String deleteBeforeDelimiter(String str, String found);
|
||||||
|
extern String deleteBeforeDelimiterTo(String str, String found);
|
||||||
|
extern String selectFromMarkerToMarker(String str, String found, int number);
|
||||||
|
|
||||||
|
// JsonUtils
|
||||||
|
extern String jsonReadStr(String &json, String name);
|
||||||
|
extern int jsonReadInt(String &json, String name);
|
||||||
|
extern String jsonWriteInt(String &json, String name, int volume);
|
||||||
|
extern String jsonWriteStr(String &json, String name, String volume);
|
||||||
|
extern String jsonWriteFloat(String &json, String name, float volume);
|
||||||
|
|
||||||
// Cmd
|
// Cmd
|
||||||
extern void CMD_init();
|
extern void CMD_init();
|
||||||
extern void button();
|
extern void button();
|
||||||
@@ -240,33 +257,13 @@ extern void choose_log_date_and_send();
|
|||||||
|
|
||||||
// Main
|
// Main
|
||||||
void getMemoryLoad(String text);
|
void getMemoryLoad(String text);
|
||||||
|
|
||||||
extern String jsonReadStr(String &json, String name);
|
|
||||||
extern int jsonReadInt(String &json, String name);
|
|
||||||
extern String jsonWriteInt(String &json, String name, int volume);
|
|
||||||
extern String jsonWriteStr(String &json, String name, String volume);
|
|
||||||
extern void saveConfig();
|
extern void saveConfig();
|
||||||
extern String jsonWriteFloat(String &json, String name, float volume);
|
extern String getURL(const String &urls);
|
||||||
|
|
||||||
extern String getURL(String urls);
|
|
||||||
|
|
||||||
extern String writeFile(String fileName, String strings);
|
extern String writeFile(String fileName, String strings);
|
||||||
extern String readFile(String fileName, size_t len);
|
extern String readFile(String fileName, size_t len);
|
||||||
extern String addFile(String fileName, String strings);
|
extern String addFile(String fileName, String strings);
|
||||||
|
|
||||||
// Main Utils - явно
|
|
||||||
extern uint8_t hexStringToUint8(String hex);
|
|
||||||
extern uint16_t hexStringToUint16(String hex);
|
|
||||||
|
|
||||||
//STRING
|
|
||||||
extern String selectToMarkerLast(String str, String found);
|
|
||||||
extern String selectToMarker(String str, String found);
|
|
||||||
extern String deleteAfterDelimiter(String str, String found);
|
|
||||||
extern String deleteBeforeDelimiter(String str, String found);
|
|
||||||
extern String deleteBeforeDelimiterTo(String str, String found);
|
|
||||||
|
|
||||||
extern String selectFromMarkerToMarker(String str, String found, int number);
|
|
||||||
|
|
||||||
extern void servo_();
|
extern void servo_();
|
||||||
extern boolean isDigitStr(String str);
|
extern boolean isDigitStr(String str);
|
||||||
extern String jsonWriteStr(String &json, String name, String volume);
|
extern String jsonWriteStr(String &json, String name, String volume);
|
||||||
|
|||||||
@@ -1,20 +1,29 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
static const char* UPGRADE_URL PROGMEM = "http://91.204.228.124:1100/update/";
|
static const char* UPDATE_URL PROGMEM = "http://91.204.228.124:1100/update/%s/%s";
|
||||||
|
static const char* FIRMWARE_FILE = "esp32-esp8266_iot-manager_modules_firmware.spiffs.bin";
|
||||||
const String getUpgradeUrl() {
|
|
||||||
String url = FPSTR(UPGRADE_URL);
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
url += "esp32";
|
static const char* MCU = "esp32";
|
||||||
#else
|
#else
|
||||||
url += "esp8266";
|
static const char* MCU = "esp8266";
|
||||||
#endif
|
#endif
|
||||||
url += "/version.txt";
|
|
||||||
return url;
|
const String createUrl(const char* qry) {
|
||||||
|
char buf[128];
|
||||||
|
sprintf_P(buf, UPDATE_URL, MCU, qry);
|
||||||
|
return String(buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
const String getVersionUrl() {
|
||||||
|
return createUrl("version.txt");
|
||||||
|
}
|
||||||
|
|
||||||
|
const String getFirmwareUrl() {
|
||||||
|
return createUrl(FIRMWARE_FILE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initUpgrade() {
|
void initUpgrade() {
|
||||||
String last_version = WiFi.status() == WL_CONNECTED ? getURL(getUpgradeUrl()) : "";
|
String last_version = WiFi.status() == WL_CONNECTED ? getURL(getVersionUrl()) : "";
|
||||||
jsonWriteStr(configSetup, "last_version", last_version);
|
jsonWriteStr(configSetup, "last_version", last_version);
|
||||||
|
|
||||||
Serial.printf("[i] Last firmware version: %s\n", last_version.c_str());
|
Serial.printf("[i] Last firmware version: %s\n", last_version.c_str());
|
||||||
@@ -63,14 +72,8 @@ void initUpgrade() {
|
|||||||
void do_upgrade_url() {
|
void do_upgrade_url() {
|
||||||
if (upgrade_url) {
|
if (upgrade_url) {
|
||||||
upgrade_url = false;
|
upgrade_url = false;
|
||||||
#ifdef ESP32
|
last_version = getURL(getVersionUrl());
|
||||||
last_version = getURL("http://91.204.228.124:1100/update/esp32/version.txt");
|
|
||||||
jsonWriteStr(configSetup, "last_version", last_version);
|
jsonWriteStr(configSetup, "last_version", last_version);
|
||||||
#endif
|
|
||||||
#ifdef ESP8266
|
|
||||||
last_version = getURL("http://91.204.228.124:1100/update/esp8266/version.txt");
|
|
||||||
jsonWriteStr(configSetup, "last_version", last_version);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -86,14 +89,8 @@ void upgrade_firmware() {
|
|||||||
|
|
||||||
WiFiClient client_for_upgrade;
|
WiFiClient client_for_upgrade;
|
||||||
|
|
||||||
#ifdef ESP32
|
|
||||||
httpUpdate.rebootOnUpdate(false);
|
httpUpdate.rebootOnUpdate(false);
|
||||||
t_httpUpdate_return ret = httpUpdate.updateSpiffs(client_for_upgrade, "http://91.204.228.124:1100/update/esp32/esp32-esp8266_iot-manager_modules_firmware.spiffs.bin");
|
t_httpUpdate_return ret = httpUpdate.updateSpiffs(client_for_upgrade, getFirmwareUrl());
|
||||||
#endif
|
|
||||||
#ifdef ESP8266
|
|
||||||
ESPhttpUpdate.rebootOnUpdate(false);
|
|
||||||
t_httpUpdate_return ret = ESPhttpUpdate.updateSpiffs(client_for_upgrade, "http://91.204.228.124:1100/update/esp8266/esp32-esp8266_iot-manager_modules_firmware.spiffs.bin");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ret == HTTP_UPDATE_OK) {
|
if (ret == HTTP_UPDATE_OK) {
|
||||||
writeFile("firmware.s.txt", scenario_for_update);
|
writeFile("firmware.s.txt", scenario_for_update);
|
||||||
@@ -104,14 +101,7 @@ void upgrade_firmware() {
|
|||||||
Serial.println("SPIFFS upgrade done!");
|
Serial.println("SPIFFS upgrade done!");
|
||||||
Serial.println("Start upgrade BUILD, please wait...");
|
Serial.println("Start upgrade BUILD, please wait...");
|
||||||
|
|
||||||
#ifdef ESP32
|
t_httpUpdate_return ret = httpUpdate.update(client_for_upgrade, getFirmwareUrl());
|
||||||
//httpUpdate.rebootOnUpdate(true);
|
|
||||||
t_httpUpdate_return ret = httpUpdate.update(client_for_upgrade, "http://91.204.228.124:1100/update/esp32/esp32-esp8266_iot-manager_modules_firmware.ino.bin");
|
|
||||||
#endif
|
|
||||||
#ifdef ESP8266
|
|
||||||
//ESPhttpUpdate.rebootOnUpdate(true);
|
|
||||||
t_httpUpdate_return ret = ESPhttpUpdate.update(client_for_upgrade, "http://91.204.228.124:1100/update/esp8266/esp32-esp8266_iot-manager_modules_firmware.ino.bin");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ret == HTTP_UPDATE_OK) {
|
if (ret == HTTP_UPDATE_OK) {
|
||||||
Serial.println("BUILD upgrade done!");
|
Serial.println("BUILD upgrade done!");
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ boolean isDigitStr(String str) {
|
|||||||
return str.length();
|
return str.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
String getURL(String urls) {
|
String getURL(const String& urls) {
|
||||||
String res = "";
|
String res = "";
|
||||||
HTTPClient http;
|
HTTPClient http;
|
||||||
http.begin(urls);
|
http.begin(urls);
|
||||||
|
|||||||
Reference in New Issue
Block a user