Skip to content

Commit f3d3317

Browse files
committed
Read SDS011 firmware date/uuid string only once
This string doesn't change during the uptime of a sensor, so we can read it only once. unfortunately we can't cache it in powerOnSensors() because the OTA update is launched before powering on sensors.
1 parent 3c77b49 commit f3d3317

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

airrohr-firmware/Versions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
NRZ-2019-126-B6
2+
* Read SDS011 version once on startup
3+
14
NRZ-2019-126-B5
25
* Rename Luftdaten.info to Sensors.Community everywhere
36
* Report the submitted wifi signal quality level in the web UI

airrohr-firmware/airrohr-firmware.ino

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
*
9191
************************************************************************/
9292
// increment on change
93-
#define SOFTWARE_VERSION_STR "NRZ-2019-126-B5"
93+
#define SOFTWARE_VERSION_STR "NRZ-2019-126-B6"
9494
const String SOFTWARE_VERSION(SOFTWARE_VERSION_STR);
9595

9696
/*****************************************************************
@@ -537,6 +537,7 @@ String last_data_string;
537537
int last_signal_strength;
538538

539539
String esp_chipid;
540+
String last_value_SDS_version;
540541

541542
unsigned long last_page_load = millis();
542543

@@ -817,10 +818,13 @@ static String SDS_version_date() {
817818
char buffer;
818819
int value;
819820
int len = 0;
820-
String s, version_date, device_id;
821+
String version_date, device_id;
822+
String s(last_value_SDS_version);
821823
int checksum_is = 0;
822824
bool checksum_ok = false;
823825

826+
if (!cfg::sds_read || s.length()) return s;
827+
824828
debug_outln_verbose(FPSTR(DBG_TXT_END_READING), FPSTR(DBG_TXT_SDS011_VERSION_DATE));
825829

826830
is_SDS_running = SDS_cmd(PmSensorCmd::Start);
@@ -895,7 +899,7 @@ static String SDS_version_date() {
895899
if (len > 2) { checksum_is += value; }
896900
len++;
897901
if (len == 10 && checksum_ok) {
898-
s = version_date + '(' + device_id + ')';
902+
s = last_value_SDS_version = version_date + '(' + device_id + ')';
899903
debug_outln_info(F("SDS version date : "), version_date);
900904
debug_outln_info(F("SDS device ID: "), device_id);
901905
len = 0;
@@ -3354,8 +3358,7 @@ static bool fwDownloadStream(WiFiClientSecure& client, const String& url, Stream
33543358
int bytes_written = -1;
33553359

33563360
http.setTimeout(20 * 1000);
3357-
const String SDS_version = cfg::sds_read ? SDS_version_date() : "";
3358-
http.setUserAgent(SOFTWARE_VERSION + ' ' + esp_chipid + ' ' + SDS_version + ' ' +
3361+
http.setUserAgent(SOFTWARE_VERSION + ' ' + esp_chipid + ' ' + SDS_version_date() + ' ' +
33593362
String(cfg::current_lang) + ' ' + String(CURRENT_LANG) + ' ' +
33603363
String(cfg::use_beta ? "BETA" : ""));
33613364

0 commit comments

Comments
 (0)