sd syslogging integration in flow control
This commit is contained in:
parent
fc0bc9b5ea
commit
ecc3c4976e
25
src/main.cpp
25
src/main.cpp
@ -79,7 +79,6 @@ BME_IRQ <- setBMEIRQ() <- Ticker.h
|
|||||||
// Basic Config
|
// Basic Config
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
|
||||||
char clientId[20] = {0}; // unique ClientID
|
char clientId[20] = {0}; // unique ClientID
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
@ -91,6 +90,13 @@ void setup() {
|
|||||||
(*((uint32_t volatile *)ETS_UNCACHED_ADDR((DR_REG_RTCCNTL_BASE + 0xd4)))) = 0;
|
(*((uint32_t volatile *)ETS_UNCACHED_ADDR((DR_REG_RTCCNTL_BASE + 0xd4)))) = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// hash 6 byte device MAC to 4 byte clientID
|
||||||
|
uint8_t mac[6];
|
||||||
|
esp_read_mac(mac, ESP_MAC_WIFI_STA);
|
||||||
|
|
||||||
|
const uint32_t hashedmac = myhash((const char *)mac, 6);
|
||||||
|
snprintf(clientId, 20, "paxcounter_%08x", hashedmac);
|
||||||
|
|
||||||
// setup debug output or silence device
|
// setup debug output or silence device
|
||||||
#if (VERBOSE)
|
#if (VERBOSE)
|
||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
@ -100,15 +106,15 @@ void setup() {
|
|||||||
esp_log_level_set("*", ESP_LOG_NONE);
|
esp_log_level_set("*", ESP_LOG_NONE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// initialize SD interface and mount SD card, if present
|
||||||
|
#if (HAS_SDCARD)
|
||||||
|
if (sdcard_init())
|
||||||
|
strcat_P(features, " SD");
|
||||||
|
#endif
|
||||||
|
|
||||||
// load device configuration from NVRAM and set runmode
|
// load device configuration from NVRAM and set runmode
|
||||||
do_after_reset();
|
do_after_reset();
|
||||||
|
|
||||||
// hash 6 byte device MAC to 4 byte clientID
|
|
||||||
uint8_t mac[6];
|
|
||||||
esp_read_mac(mac, ESP_MAC_WIFI_STA);
|
|
||||||
|
|
||||||
const uint32_t hashedmac = myhash((const char *)mac, 6);
|
|
||||||
snprintf(clientId, 20, "paxcounter_%08x", hashedmac);
|
|
||||||
ESP_LOGI(TAG, "Starting %s v%s (runmode=%d / restarts=%d)", clientId,
|
ESP_LOGI(TAG, "Starting %s v%s (runmode=%d / restarts=%d)", clientId,
|
||||||
PROGVERSION, RTC_runmode, RTC_restarts);
|
PROGVERSION, RTC_runmode, RTC_restarts);
|
||||||
ESP_LOGI(TAG, "code build date: %d", compileTime());
|
ESP_LOGI(TAG, "code build date: %d", compileTime());
|
||||||
@ -347,11 +353,6 @@ void setup() {
|
|||||||
_ASSERT(mqtt_init() == ESP_OK);
|
_ASSERT(mqtt_init() == ESP_OK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (HAS_SDCARD)
|
|
||||||
if (sdcard_init())
|
|
||||||
strcat_P(features, " SD");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if (HAS_SDS011)
|
#if (HAS_SDS011)
|
||||||
ESP_LOGI(TAG, "init fine-dust-sensor");
|
ESP_LOGI(TAG, "init fine-dust-sensor");
|
||||||
if (sds011_init())
|
if (sds011_init())
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "reset.h"
|
#include "reset.h"
|
||||||
|
|
||||||
|
|
||||||
// Conversion factor for micro seconds to seconds
|
// Conversion factor for micro seconds to seconds
|
||||||
#define uS_TO_S_FACTOR 1000000ULL
|
#define uS_TO_S_FACTOR 1000000ULL
|
||||||
|
|
||||||
@ -99,10 +98,12 @@ void enter_deepsleep(const uint32_t wakeup_sec, gpio_num_t wakeup_gpio) {
|
|||||||
sds011_sleep();
|
sds011_sleep();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// flush & close sd card, if we have
|
/*
|
||||||
#if (HAS_SDCARD)
|
// flush & close sd card, if we have
|
||||||
|
#if (HAS_SDCARD)
|
||||||
sdcard_close();
|
sdcard_close();
|
||||||
#endif
|
#endif
|
||||||
|
*/
|
||||||
|
|
||||||
// wait a while (max 100 sec) to clear send queues
|
// wait a while (max 100 sec) to clear send queues
|
||||||
ESP_LOGI(TAG, "Waiting until send queues are empty...");
|
ESP_LOGI(TAG, "Waiting until send queues are empty...");
|
||||||
@ -175,6 +176,12 @@ void enter_deepsleep(const uint32_t wakeup_sec, gpio_num_t wakeup_gpio) {
|
|||||||
gettimeofday(&RTC_sleep_start_time, NULL);
|
gettimeofday(&RTC_sleep_start_time, NULL);
|
||||||
RTC_millis += esp_timer_get_time() / 1000;
|
RTC_millis += esp_timer_get_time() / 1000;
|
||||||
ESP_LOGI(TAG, "Going to sleep, good bye.");
|
ESP_LOGI(TAG, "Going to sleep, good bye.");
|
||||||
|
|
||||||
|
// flush & close sd card, if we have
|
||||||
|
#if (HAS_SDCARD)
|
||||||
|
sdcard_close();
|
||||||
|
#endif
|
||||||
|
|
||||||
esp_deep_sleep_start();
|
esp_deep_sleep_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user