Browse Source

better error messages

main
Hendrik Langer 5 years ago
parent
commit
f3fae1b5c0
  1. 28
      src/main.cpp

28
src/main.cpp

@ -149,7 +149,7 @@ void inline lightsleep() {
Serial.flush();
wifi_fpm_do_sleep(0xFFFFFFF); // Sleep for longest possible time // this does not work: (uint32_t)postingInterval*1000
delay(1); // go to sleep now
DEBUG_MSG("woken\n");
DEBUG_MSG("[DEBUG] woken\n");
//wifi_fpm_do_wakeup();
wifi_fpm_close();
}
@ -288,7 +288,7 @@ void ICACHE_FLASH_ATTR sendValues() {
&& (rtcMillis() - last_dhcp < dhcp_interval)
) {
DEBUG_MSG("static ip\n");
DEBUG_MSG("[WiFi] STATIC IP\n");
WiFi.config(ip, dns, gateway, subnet);
WiFi.begin(ssid, password);
int tries = 0;
@ -298,7 +298,7 @@ void ICACHE_FLASH_ATTR sendValues() {
tries++;
DEBUG_MSG(".");
if (tries*retry_delay >= max_retry_delay) {
DEBUG_MSG(" [ERROR]\n");
DEBUG_MSG(" [ERROR] could not connect to WiFi\n");
DEBUG_MSG("Rebooting..\n");
ESP.restart();
}
@ -309,7 +309,7 @@ void ICACHE_FLASH_ATTR sendValues() {
DEBUG_MSG("%s\n", WiFi.localIP().toString().c_str());
} else {
DEBUG_MSG("dhcp\n");
DEBUG_MSG("[WiFi] DHCP\n");
WiFi.disconnect();
int tries = 0;
constexpr unsigned int retry_delay = 500;
@ -318,7 +318,7 @@ void ICACHE_FLASH_ATTR sendValues() {
tries++;
DEBUG_MSG(".");
if (tries*retry_delay >= max_retry_delay) {
DEBUG_MSG(" [ERROR]\n");
DEBUG_MSG(" [ERROR] could not connect to WiFi\n");
DEBUG_MSG("Rebooting..\n");
ESP.restart();
}
@ -366,7 +366,7 @@ void ICACHE_FLASH_ATTR sendValues() {
DEBUG_MSG("\n");
#endif
} else {
DEBUG_MSG("[HTTP] POST... failed, error: %s\n", httpclient.errorToString(httpCode).c_str());
DEBUG_MSG("[ERROR] HTTP POST... failed, error: %s\n", httpclient.errorToString(httpCode).c_str());
}
}
@ -386,9 +386,9 @@ void ICACHE_FLASH_ATTR sendValues() {
getValuesJSON(buffer, MQTT_MAX_PACKET_SIZE, 2);
if (mqttclient.publish("sensor/esp-weatherstation/01/json", buffer, strlen(buffer))) {
lastSuccess = currentMillis;
DEBUG_MSG("mqtt done\n");
DEBUG_MSG("[DEBUG] MQTT done\n");
} else {
DEBUG_MSG("mqtt failed\n");
DEBUG_MSG("[ERROR] MQTT failed\n");
}
mqttclient.loop();
mqttclient.disconnect();
@ -433,7 +433,7 @@ void setup() {
Wire.begin(BMP_SDA, BMP_SCL);
if (!bmp.begin(BMP085_MODE_STANDARD)) {
DEBUG_MSG("No valid BMP085 sensor!\n");
DEBUG_MSG("[ERROR] No valid BMP085 sensor!\n");
}
dht.begin();
@ -450,7 +450,7 @@ void setup() {
wifiMulti.addAP("Freifunk", "");
previousMillis = rtcMillis();
DEBUG_MSG("ready.\n"); //Serial.flush();
DEBUG_MSG("[DEBUG] ready.\n"); //Serial.flush();
}
void loop() {
@ -458,14 +458,14 @@ void loop() {
unsigned long currentMillis = rtcMillis();
if ((currentMillis - previousMillis) >= postingInterval) {
previousMillis = currentMillis;
DEBUG_MSG("sending values... previousMillis:%u, millis():%u, difference:%d\n", previousMillis, currentMillis, currentMillis-previousMillis);
DEBUG_MSG("[DEBUG] sending values... previousMillis:%u, millis():%u, difference:%d\n", previousMillis, currentMillis, currentMillis-previousMillis);
sendValues();
DEBUG_MSG("resetting geiger counts. was: %d\n", geiger_counts);
DEBUG_MSG("[DEBUG] resetting geiger counts. was: %d\n", geiger_counts);
geiger_previousMillis = rtcMillis();
geiger_counts = 0;
}
DEBUG_MSG("heap: %d\n", ESP.getFreeHeap());
DEBUG_MSG("sleeping now... (%u)\n", currentMillis);
DEBUG_MSG("[DEBUG] heap: %d\n", ESP.getFreeHeap());
DEBUG_MSG("[DEBUG] sleeping now... (%u)\n", currentMillis);
delay(10);
detachInterrupt(digitalPinToInterrupt(GEIGER_PIN));

Loading…
Cancel
Save