@@ -337,7 +337,6 @@ enum class PmSensorCmd {
337
337
};
338
338
339
339
LoggerConfig loggerConfigs[LoggerCount];
340
- BearSSL::X509List x509_dst_root_ca (dst_root_ca_x3);
341
340
342
341
long int sample_count = 0 ;
343
342
bool htu21d_init_failed = false ;
@@ -717,7 +716,8 @@ static bool SDS_cmd(PmSensorCmd cmd) {
717
716
0xAA , 0xB4 , 0x06 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xFF , 0xFF , 0x05 , 0xAB
718
717
};
719
718
static constexpr uint8_t continuous_mode_cmd[] PROGMEM = {
720
- 0xAA , 0xB4 , 0x08 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xFF , 0xFF , 0x07 , 0xAB
719
+ 0xAA , 0xB4 , 0x08 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xFF , 0xFF , 0x07 , 0xAB ,
720
+ 0xAA , 0xB4 , 0x02 , 0x01 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xFF , 0xFF , 0x01 , 0xAB
721
721
};
722
722
static constexpr uint8_t version_cmd[] PROGMEM = {
723
723
0xAA , 0xB4 , 0x07 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0x00 , 0xFF , 0xFF , 0x05 , 0xAB
@@ -739,6 +739,7 @@ static bool SDS_cmd(PmSensorCmd cmd) {
739
739
memcpy_P (buf, version_cmd, cmd_len);
740
740
break ;
741
741
}
742
+ delay (100 );
742
743
serialSDS.write (buf, cmd_len);
743
744
return cmd != PmSensorCmd::Stop;
744
745
}
@@ -827,10 +828,10 @@ static String SDS_version_date() {
827
828
828
829
debug_outln_verbose (FPSTR (DBG_TXT_END_READING), FPSTR (DBG_TXT_SDS011_VERSION_DATE));
829
830
831
+ delay (100 );
830
832
is_SDS_running = SDS_cmd (PmSensorCmd::Start);
831
833
832
834
delay (100 );
833
-
834
835
is_SDS_running = SDS_cmd (PmSensorCmd::VersionDate);
835
836
836
837
delay (500 );
@@ -1090,30 +1091,35 @@ static void writeConfig() {
1090
1091
* Prepare information for data Loggers *
1091
1092
*****************************************************************/
1092
1093
static void createLoggerConfigs () {
1094
+ #if defined(ESP8266)
1095
+ auto new_session = []() { return new BearSSL::Session; };
1096
+ #else
1097
+ auto new_session = []() { return nullptr ; };
1098
+ #endif
1093
1099
if (cfg::send2dusti) {
1094
1100
loggerConfigs[LoggerSensorCommunity].destport = 80 ;
1095
1101
if (cfg::ssl_dusti) {
1096
1102
loggerConfigs[LoggerSensorCommunity].destport = 443 ;
1097
- loggerConfigs[LoggerSensorCommunity].session = new BearSSL::Session ;
1103
+ loggerConfigs[LoggerSensorCommunity].session = new_session () ;
1098
1104
}
1099
1105
}
1100
1106
loggerConfigs[LoggerMadavi].destport = PORT_MADAVI;
1101
1107
if (cfg::send2madavi && cfg::ssl_madavi) {
1102
1108
loggerConfigs[LoggerMadavi].destport = 443 ;
1103
- loggerConfigs[LoggerMadavi].session = new BearSSL::Session ;
1109
+ loggerConfigs[LoggerMadavi].session = new_session () ;
1104
1110
}
1105
1111
loggerConfigs[LoggerSensemap].destport = PORT_SENSEMAP;
1106
- loggerConfigs[LoggerSensemap].session = new BearSSL::Session ;
1112
+ loggerConfigs[LoggerSensemap].session = new_session () ;
1107
1113
loggerConfigs[LoggerFSapp].destport = PORT_FSAPP;
1108
- loggerConfigs[LoggerFSapp].session = new BearSSL::Session ;
1114
+ loggerConfigs[LoggerFSapp].session = new_session () ;
1109
1115
loggerConfigs[Loggeraircms].destport = PORT_AIRCMS;
1110
1116
loggerConfigs[LoggerInflux].destport = cfg::port_influx;
1111
1117
if (cfg::send2influx && cfg::ssl_influx) {
1112
- loggerConfigs[LoggerInflux].session = new BearSSL::Session ;
1118
+ loggerConfigs[LoggerInflux].session = new_session () ;
1113
1119
}
1114
1120
loggerConfigs[LoggerCustom].destport = cfg::port_custom;
1115
1121
if (cfg::send2custom && (cfg::ssl_custom || (cfg::port_custom == 443 ))) {
1116
- loggerConfigs[LoggerCustom].session = new BearSSL::Session ;
1122
+ loggerConfigs[LoggerCustom].session = new_session () ;
1117
1123
}
1118
1124
}
1119
1125
@@ -1882,6 +1888,7 @@ static void webserver_values() {
1882
1888
page_content += FPSTR (EMPTY_ROW);
1883
1889
add_table_row_from_value (page_content, FPSTR (SENSORS_SDS011), FPSTR (WEB_PM25), check_display_value (last_value_SDS_P2, -1 , 1 , 0 ), unit_PM);
1884
1890
add_table_row_from_value (page_content, FPSTR (SENSORS_SDS011), FPSTR (WEB_PM10), check_display_value (last_value_SDS_P1, -1 , 1 , 0 ), unit_PM);
1891
+ add_table_row_from_value (page_content, FPSTR (SENSORS_SDS011), F (" Version" ), SDS_version_date (), emptyString);
1885
1892
}
1886
1893
if (cfg::pms_read) {
1887
1894
page_content += FPSTR (EMPTY_ROW);
@@ -2337,6 +2344,9 @@ static void connectWifi() {
2337
2344
last_signal_strength = WiFi.RSSI ();
2338
2345
}
2339
2346
2347
+ #if defined(ESP8266)
2348
+ BearSSL::X509List x509_dst_root_ca (dst_root_ca_x3);
2349
+
2340
2350
static void configureCACertTrustAnchor (WiFiClientSecure* client) {
2341
2351
constexpr time_t fw_built_year = (__DATE__[ 7 ] - ' 0' ) * 1000 + \
2342
2352
(__DATE__[ 8 ] - ' 0' ) * 100 + \
@@ -2350,12 +2360,14 @@ static void configureCACertTrustAnchor(WiFiClientSecure* client) {
2350
2360
client->setTrustAnchors (&x509_dst_root_ca);
2351
2361
}
2352
2362
}
2363
+ #endif
2353
2364
2354
2365
static WiFiClient* getNewLoggerWiFiClient (const LoggerEntry logger) {
2355
2366
2356
2367
WiFiClient* _client;
2357
2368
if (loggerConfigs[logger].session ) {
2358
2369
_client = new WiFiClientSecure;
2370
+ #if defined(ESP8266)
2359
2371
static_cast <WiFiClientSecure*>(_client)->setSession (loggerConfigs[logger].session );
2360
2372
static_cast <WiFiClientSecure*>(_client)->setBufferSizes (1024 , TCP_MSS > 1024 ? 2048 : 1024 );
2361
2373
switch (logger) {
@@ -2368,6 +2380,7 @@ static WiFiClient* getNewLoggerWiFiClient(const LoggerEntry logger) {
2368
2380
default :
2369
2381
configureCACertTrustAnchor (static_cast <WiFiClientSecure*>(_client));
2370
2382
}
2383
+ #endif
2371
2384
} else {
2372
2385
_client = new WiFiClient;
2373
2386
}
@@ -2415,15 +2428,16 @@ static unsigned long sendData(const LoggerEntry logger, const String& data, cons
2415
2428
if (pin) {
2416
2429
http.addHeader (F (" X-PIN" ), String (pin));
2417
2430
}
2431
+
2418
2432
int result = http.POST (data);
2419
- http.end ();
2420
2433
2421
2434
if (result >= HTTP_CODE_OK && result <= HTTP_CODE_ALREADY_REPORTED) {
2422
2435
debug_outln_info (F (" Succeeded - " ), s_Host);
2423
2436
} else if (result >= HTTP_CODE_BAD_REQUEST) {
2424
2437
debug_outln_info (F (" Request failed with error: " ), String (result));
2425
2438
debug_outln_info (F (" Details:" ), http.getString ());
2426
2439
}
2440
+ http.end ();
2427
2441
} else {
2428
2442
debug_outln_info (F (" Failed connecting to " ), s_Host);
2429
2443
}
@@ -2775,9 +2789,8 @@ static void fetchSensorSDS(String& s) {
2775
2789
pm25_serial = 0 ;
2776
2790
checksum_is = 0 ;
2777
2791
}
2778
- yield ();
2779
2792
}
2780
-
2793
+ yield ();
2781
2794
}
2782
2795
if (send_now) {
2783
2796
last_value_SDS_P1 = -1 ;
@@ -2937,10 +2950,10 @@ static void fetchSensorPMS(String& s) {
2937
2950
checksum_is = 0 ;
2938
2951
}
2939
2952
}
2940
- yield ();
2941
2953
}
2942
-
2954
+ yield ();
2943
2955
}
2956
+
2944
2957
if (send_now) {
2945
2958
last_value_PMS_P0 = -1 ;
2946
2959
last_value_PMS_P1 = -1 ;
@@ -3076,8 +3089,8 @@ static void fetchSensorHPM(String& s) {
3076
3089
checksum_is = 0 ;
3077
3090
}
3078
3091
}
3079
- yield ();
3080
3092
}
3093
+ yield ();
3081
3094
3082
3095
}
3083
3096
if (send_now) {
@@ -3958,6 +3971,8 @@ static void powerOnTestSensors() {
3958
3971
delay (100 );
3959
3972
debug_outln_info (F (" Stopping SDS011..." ));
3960
3973
is_SDS_running = SDS_cmd (PmSensorCmd::Stop);
3974
+ delay (100 );
3975
+ serialSDS.flush ();
3961
3976
}
3962
3977
3963
3978
if (cfg::pms_read) {
@@ -3968,6 +3983,8 @@ static void powerOnTestSensors() {
3968
3983
delay (100 );
3969
3984
debug_outln_info (F (" Stopping PMS..." ));
3970
3985
is_PMS_running = PMS_cmd (PmSensorCmd::Stop);
3986
+ delay (100 );
3987
+ serialSDS.flush ();
3971
3988
}
3972
3989
3973
3990
if (cfg::hpm_read) {
@@ -3978,6 +3995,8 @@ static void powerOnTestSensors() {
3978
3995
delay (100 );
3979
3996
debug_outln_info (F (" Stopping HPM..." ));
3980
3997
is_HPM_running = HPM_cmd (PmSensorCmd::Stop);
3998
+ delay (100 );
3999
+ serialSDS.flush ();
3981
4000
}
3982
4001
3983
4002
if (cfg::sps30_read) {
@@ -4201,6 +4220,8 @@ void setup(void) {
4201
4220
esp_chipid += String ((uint32_t )chipid_num, HEX);
4202
4221
#endif
4203
4222
cfg::initNonTrivials (esp_chipid.c_str ());
4223
+ WiFi.persistent (false );
4224
+
4204
4225
debug_outln_info (F (" Airrohr: " ), SOFTWARE_VERSION);
4205
4226
4206
4227
init_config ();
0 commit comments