Skip to content

Commit e48eae4

Browse files
authored
Merge pull request opendata-stuttgart#547 from dirkmueller/beta
Read SDS011 firmware date/uuid string only once
2 parents 3c77b49 + 3876637 commit e48eae4

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

airrohr-firmware/Versions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
NRZ-2019-126-B6
2+
* Read SDS011 version once on startup
3+
* Put software serial edge detection work within loop
4+
15
NRZ-2019-126-B5
26
* Rename Luftdaten.info to Sensors.Community everywhere
37
* Report the submitted wifi signal quality level in the web UI

airrohr-firmware/airrohr-firmware.ino

Lines changed: 9 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

@@ -4483,6 +4486,7 @@ void loop(void) {
44834486
yield();
44844487
#if defined(ESP8266)
44854488
MDNS.update();
4489+
serialSDS.perform_work();
44864490
#endif
44874491

44884492
if (sample_count % 500 == 0) {

0 commit comments

Comments
 (0)