-
-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Beta #462
Beta #462
Changes from 10 commits
6afb681
826555e
e9516bc
1339700
945ce7e
bfb2a96
d88f98c
9fb6f87
7276094
87d430e
94a20af
97d45ff
063615a
8ecb0af
d4d2988
13c14a3
ad3031e
8a4c56d
d3a8672
05f2cc2
3b9a827
44bedf2
485d6f7
b24bc00
2cab340
2d165c9
6b51740
3e3f202
1ec6f80
131068a
ed3b909
bc03758
cfc8b01
e9053db
e1c680b
c6105f0
d6daad7
6a11df8
133c0f4
ba85a83
9ac3145
3d04417
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -410,8 +410,8 @@ SoftwareSerial serialSDS(PM_SERIAL_RX, PM_SERIAL_TX, false, 128); | |
SoftwareSerial serialGPS(GPS_SERIAL_RX, GPS_SERIAL_TX, false, 512); | ||
#endif | ||
#if defined(ESP32) | ||
HardwareSerial serialSDS(2); | ||
HardwareSerial serialGPS(3); | ||
#define serialSDS (Serial1) | ||
#define serialGPS (Serial2) | ||
#endif | ||
|
||
/***************************************************************** | ||
|
@@ -731,15 +731,25 @@ String Var2Json(const String& name, const String& value) { | |
/***************************************************************** | ||
* convert boolean value to json string * | ||
*****************************************************************/ | ||
String Var2Json(const String& name, const bool value) { | ||
return Var2Json(name, String(value ? "true" : "false")); | ||
String Var2JsonBool(const String& name, const bool value) { | ||
String s = "\""; | ||
s += name; | ||
s += "\":"; | ||
s += value ? "true" : "false"; | ||
s += ","; | ||
return s; | ||
} | ||
|
||
/***************************************************************** | ||
* convert boolean value to json string * | ||
* convert int value to json string * | ||
*****************************************************************/ | ||
String Var2Json(const String& name, const int value) { | ||
return Var2Json(name, String(value)); | ||
String Var2JsonLong(const String& name, const long value) { | ||
String s = "\""; | ||
s += name; | ||
s += "\":"; | ||
s += Float2String(value, 0); | ||
s += ","; | ||
return s; | ||
} | ||
|
||
/***************************************************************** | ||
|
@@ -995,8 +1005,8 @@ void readConfig() { | |
strcpy(version_from_local_config, json["SOFTWARE_VERSION"]); | ||
} | ||
|
||
#define setFromJSON(key) if (json.containsKey(#key)) key = json[#key]; | ||
#define strcpyFromJSON(key) if (json.containsKey(#key)) strcpy(key, json[#key]); | ||
#define setFromJSON(key) if (json.containsKey(#key)) {key = json[#key]; } | ||
#define strcpyFromJSON(key) if (json.containsKey(#key)) {strcpy(key, json[#key]); } | ||
strcpyFromJSON(current_lang); | ||
strcpyFromJSON(wlanssid); | ||
strcpyFromJSON(wlanpwd); | ||
|
@@ -1098,8 +1108,8 @@ void writeConfig() { | |
String json_string = "{"; | ||
debug_outln(F("saving config..."), DEBUG_MIN_INFO); | ||
|
||
#define copyToJSON_Bool(varname) json_string += Var2Json(#varname, varname); | ||
#define copyToJSON_Int(varname) json_string += Var2Json(#varname, varname); | ||
#define copyToJSON_Bool(varname) json_string += Var2JsonBool(#varname, varname); | ||
#define copyToJSON_Int(varname) json_string += Var2JsonLong(#varname, varname); | ||
#define copyToJSON_String(varname) json_string += Var2Json(#varname, String(varname)); | ||
copyToJSON_String(current_lang); | ||
copyToJSON_String(SOFTWARE_VERSION); | ||
|
@@ -1143,9 +1153,9 @@ void writeConfig() { | |
copyToJSON_Bool(has_lcd2004_27); | ||
copyToJSON_Bool(display_wifi_info); | ||
copyToJSON_Bool(display_device_info); | ||
copyToJSON_String(debug); | ||
copyToJSON_String(sending_intervall_ms); | ||
copyToJSON_String(time_for_wifi_config); | ||
copyToJSON_Int(debug); | ||
copyToJSON_Int(sending_intervall_ms); | ||
copyToJSON_Int(time_for_wifi_config); | ||
copyToJSON_String(senseboxid); | ||
copyToJSON_Bool(send2custom); | ||
copyToJSON_String(host_custom); | ||
|
@@ -4225,11 +4235,15 @@ static bool acquireNetworkTime() { | |
#if defined(ESP8266) | ||
settimeofday_cb(time_is_set); | ||
#endif | ||
configTime(8 * 3600, 0, "pool.ntp.org"); | ||
configTime(0, 0, "pool.ntp.org"); // using UTC as timezone | ||
while (retryCount++ < 20) { | ||
// later than 2000/01/01:00:00:00 | ||
now = time(nullptr); | ||
#if defined(ESP8266) | ||
if (sntp_time_is_set) { | ||
now = time(nullptr); | ||
#endif | ||
#if defined(ESP32) | ||
if (now > 17897*24*60*60) { // later than 2019/01/01:00:00:00 | ||
#endif | ||
debug_outln(ctime(&now), DEBUG_MIN_INFO); | ||
return true; | ||
} | ||
|
@@ -4240,9 +4254,13 @@ static bool acquireNetworkTime() { | |
retryCount = 0; | ||
configTime(0, 0, WiFi.gatewayIP().toString().c_str()); | ||
while (retryCount++ < 20) { | ||
// later than 2000/01/01:00:00:00 | ||
now = time(nullptr); | ||
#if defined(ESP8266) | ||
if (sntp_time_is_set) { | ||
now = time(nullptr); | ||
#endif | ||
#if defined(ESP32) | ||
if (now > 17897*24*60*60) { // later than 2019/01/01:00:00:00 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. doesn't that mean that sntp_time_is_set should not be true? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if I understood your questions correctly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right, I agree with your assessment, sorry, didn't read the code closely. I wonder if we can remove all of the ESP conditionals in the code and use both code paths the same way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, in this specific case the ESP32 path will work for both. The error checking of the ESP8266 is more strict. The fallback in the ESP32 case to use the local router will not be triggered if the RTC has a date after 2019-01-01 and this will happen on a reboot. That means:
To solve that, I would remove the fallback and replace it by the following solution:
roughly the code would be the following, but I need to check how to mix dhcp and fixed servers:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would try local first before going to the internet.. I implemented router/pool in my pr that I just opened. Searching for ntp information in dhcp does sound like a good idea though. |
||
#endif | ||
debug_outln(ctime(&now), DEBUG_MIN_INFO); | ||
return true; | ||
} | ||
|
@@ -4317,7 +4335,7 @@ static unsigned long sendDataToOptionalApis(const String &data) { | |
/***************************************************************** | ||
* The Setup * | ||
*****************************************************************/ | ||
void setup() { | ||
void setup(void) { | ||
Serial.begin(9600); // Output to Serial at 9600 baud | ||
|
||
#if defined(ESP32) | ||
|
@@ -4390,7 +4408,7 @@ void setup() { | |
/***************************************************************** | ||
* And action * | ||
*****************************************************************/ | ||
void loop() { | ||
void loop(void) { | ||
String result_PPD, result_SDS, result_PMS, result_HPM, result_SPS30; | ||
String result_DHT, result_HTU21D, result_BMP, result_BMP280; | ||
String result_BME280, result_DS18B20, result_GPS, result_DNMS; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,42 +13,90 @@ src_dir = . | |
|
||
[common] | ||
build_flags = | ||
-DESP8266 ; as hint for ldf | ||
-DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY | ||
-DVTABLES_IN_FLASH | ||
-DNDEBUG | ||
-Wl,-Teagle.flash.4m.ld | ||
-Wl,-Teagle.flash.4m.ld ; required for platform == [email protected] | ||
; -Wl,-Teagle.flash.4m3m.ld ; required for platform >= [email protected] to make SPIFFS work | ||
|
||
build_flags_esp32 = | ||
-DESP32 ; as hint for ldf | ||
-DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY | ||
-DVTABLES_IN_FLASH | ||
build_flags_esp32_release = ${common.build_flags_esp32} -DNDEBUG | ||
build_flags_esp32_debug = ${common.build_flags_esp32} -g -Og -fno-inline -DJTAG_DEBUGGER=1 -DDEBUG_ESP_PORT=Serial | ||
|
||
board_build.f_cpu = 160000000L | ||
; Always depend on specific library versions (wherever possible) | ||
; Keep Library names in alphabetical order | ||
; Always depend on specific library versions (wherever possible and only for external libraries) | ||
; Keep Library names in the order of their dependencies (leaves at the top) | ||
; ESP8266WiFi in both cases is necessary to solve a case sensitivity issue with WiFiUdp.h | ||
; TinyGPSPlus is not yet in platformio - https://github.com/platformio/platformio-libmirror/issues/99 | ||
lib_deps_external = | ||
; Use library ID numbers instead of names for libraries whose names are not unique | ||
; (like OneWire, LiquidCrystal_I2C and TinyGPSPlus) | ||
|
||
lib_deps_generic_external = | ||
[email protected] ; OneWire | ||
[email protected] ; LiquidCrystal_I2C | ||
;136 ; LiquidCrystal, alternative to 576 LiquidCrystal_I2C? | ||
Adafruit Unified [email protected] | ||
Adafruit BMP085 [email protected] | ||
Adafruit BMP280 [email protected] | ||
Adafruit BME280 [email protected] | ||
Adafruit HTU21DF [email protected] | ||
ArduinoJson@6.11.5 | ||
ArduinoJson@6.12.0 | ||
[email protected] | ||
[email protected] | ||
[email protected] ; TinyGPSPlus, formerly this was referenced as mikalhart/TinyGPSPlus#v0.95 | ||
|
||
lib_deps_esp8266_external = | ||
;[email protected] ; the latest version available in platformio | ||
;plerup/espsoftwareserial#5.2.9 ; this version needs unpublished 8266 plaform, see https://github.com/plerup/espsoftwareserial/issues/103 | ||
;plerup/espsoftwareserial#5.0.3 ; this version compiles with esp8266 platform version 2.2.3 | ||
plerup/espsoftwareserial#4.0.0 ; this version compiles with esp8266 platform version 1.8.0 | ||
|
||
lib_deps_esp32_external = | ||
|
||
; system libraries from platform -> no version number | ||
lib_deps_esp8266_platform = | ||
Hash | ||
Wire | ||
SPI | ||
ESP8266WiFi | ||
DNSServer | ||
ESP8266HTTPClient | ||
ESP8266WebServer | ||
ESP8266WiFi | ||
[email protected] | ||
ESP8266httpUpdate | ||
ESP8266mDNS | ||
[email protected] | ||
SPI | ||
mikalhart/TinyGPSPlus#v0.95 | ||
|
||
; system libraries from platform -> no version number | ||
lib_deps_esp32_platform = | ||
Wire | ||
[email protected] | ||
[email protected] | ||
SPI | ||
WiFi | ||
DNSServer | ||
WiFiClientSecure | ||
HTTPClient | ||
FS | ||
SPIFFS | ||
WebServer | ||
Update | ||
HTTPUpdate | ||
ESPmDNS | ||
|
||
lib_deps_esp8266 = ${common.lib_deps_esp8266_platform} ${common.lib_deps_esp8266_external} ${common.lib_deps_generic_external} | ||
lib_deps_esp32 = ${common.lib_deps_esp32_platform} ${common.lib_deps_esp32_external} ${common.lib_deps_generic_external} | ||
|
||
extra_scripts = platformio_script.py | ||
# This release is reflecting the Arduino Core 2.4.2 release | ||
# When the requirement for Arduino Core is raised, this | ||
# needs to be adjusted to the matching version from | ||
# https://github.com/platformio/platform-espressif8266/releases | ||
platform_version = [email protected] | ||
;platform_version = [email protected] ; using Arduino core 2.5.2 | ||
[env] | ||
;lib_ldf_mode = chain+ | ||
lib_ldf_mode = off | ||
;lib_compat_mode = strict | ||
|
||
[env:nodemcuv2] | ||
lang = DE | ||
|
@@ -57,7 +105,7 @@ framework = arduino | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_DE' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:nodemcuv2_bg] | ||
|
@@ -67,7 +115,7 @@ framework = arduino | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_BG' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:nodemcuv2_cz] | ||
|
@@ -77,7 +125,7 @@ platform = ${common.platform_version} | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_CZ' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:nodemcuv2_dk] | ||
|
@@ -87,7 +135,7 @@ framework = arduino | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_DK' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:nodemcuv2_en] | ||
|
@@ -97,7 +145,7 @@ framework = arduino | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_EN' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:nodemcuv2_es] | ||
|
@@ -107,7 +155,7 @@ framework = arduino | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_ES' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:nodemcuv2_fr] | ||
|
@@ -117,7 +165,7 @@ framework = arduino | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_FR' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:nodemcuv2_it] | ||
|
@@ -127,7 +175,7 @@ framework = arduino | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_IT' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:nodemcuv2_lu] | ||
|
@@ -137,7 +185,7 @@ framework = arduino | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_LU' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:nodemcuv2_nl] | ||
|
@@ -147,7 +195,7 @@ framework = arduino | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_NL' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:nodemcuv2_pl] | ||
|
@@ -157,7 +205,7 @@ framework = arduino | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_PL' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:nodemcuv2_pt] | ||
|
@@ -167,7 +215,7 @@ framework = arduino | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_PT' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:nodemcuv2_ru] | ||
|
@@ -177,7 +225,7 @@ framework = arduino | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_RU' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:nodemcuv2_se] | ||
|
@@ -187,5 +235,20 @@ framework = arduino | |
board = nodemcuv2 | ||
board_build.f_cpu = ${common.board_build.f_cpu} | ||
build_flags = ${common.build_flags} '-DINTL_SE' | ||
lib_deps = ${common.lib_deps_external} | ||
lib_deps = ${common.lib_deps_esp8266} | ||
extra_scripts = ${common.extra_scripts} | ||
|
||
[env:lolin_d32_pro_debug] | ||
lang = DE | ||
platform = espressif32 | ||
framework = arduino | ||
board = lolin_d32_pro | ||
build_flags = ${common.build_flags_esp32_debug} '-DINTL_DE' | ||
lib_deps = ${common.lib_deps_esp32} | ||
extra_scripts = ${common.extra_scripts} | ||
debug_tool = custom | ||
monitor_speed = 9600 | ||
upload_port = /dev/cu.wchusbserial40 | ||
monitor_port = /dev/cu.wchusbserial40 | ||
targets = debug | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is sntp_time_is_set now only used for ESP8266?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because settimeofday_cb() is not available for ESP32. The examples are using sntp_set_time_sync_notification_cb() but this is not yet available in the newest esp32platform delivered with platformio.
/edit: see also https://github.com/espressif/esp-idf/tree/master/examples/protocols/sntp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, thanks