v1.7.01 (PSRAM support, timesync off)
This commit is contained in:
1 parent
9574a194fd
commit
3140ab9214
15 files changed
+126
-25
No files matched your search
+26
-4
@@ -55,19 +55,33 @@ void doHousekeeping() {
|
||||
ESP_LOGI(TAG, "Measured Voltage: %dmV", batt_voltage);
|
||||
#endif
|
||||
|
||||
// check free memory
|
||||
if (esp_get_minimum_free_heap_size() <= MEM_LOW) {
|
||||
// check free heap memory
|
||||
if (ESP.getMinFreeHeap() <= MEM_LOW) {
|
||||
ESP_LOGI(TAG,
|
||||
"Memory full, counter cleared (heap low water mark = %d Bytes / "
|
||||
"free heap = %d bytes)",
|
||||
esp_get_minimum_free_heap_size(), ESP.getFreeHeap());
|
||||
ESP.getMinFreeHeap() , ESP.getFreeHeap());
|
||||
SendPayload(COUNTERPORT); // send data before clearing counters
|
||||
reset_counters(); // clear macs container and reset all counters
|
||||
get_salt(); // get new salt for salting hashes
|
||||
|
||||
if (esp_get_minimum_free_heap_size() <= MEM_LOW) // check again
|
||||
if (ESP.getMinFreeHeap() <= MEM_LOW) // check again
|
||||
do_reset(); // memory leak, reset device
|
||||
}
|
||||
|
||||
// check free PSRAM memory
|
||||
#ifdef BOARD_HAS_PSRAM
|
||||
if (ESP.getMinFreePsram() <= MEM_LOW) {
|
||||
ESP_LOGI(TAG, "PSRAM full, counter cleared");
|
||||
SendPayload(COUNTERPORT); // send data before clearing counters
|
||||
reset_counters(); // clear macs container and reset all counters
|
||||
get_salt(); // get new salt for salting hashes
|
||||
|
||||
if (ESP.getMinFreePsram() <= MEM_LOW) // check again
|
||||
do_reset(); // memory leak, reset device
|
||||
}
|
||||
#endif
|
||||
|
||||
} // doHousekeeping()
|
||||
|
||||
// uptime counter 64bit to prevent millis() rollover after 49 days
|
||||
@@ -80,6 +94,14 @@ uint64_t uptime() {
|
||||
return (uint64_t)high32 << 32 | low32;
|
||||
}
|
||||
|
||||
uint32_t getFreeRAM() {
|
||||
#ifndef BOARD_HAS_PSRAM
|
||||
return ESP.getFreeHeap();
|
||||
#else
|
||||
return ESP.getFreePsram();
|
||||
#endif
|
||||
}
|
||||
|
||||
void reset_counters() {
|
||||
macs.clear(); // clear all macs container
|
||||
macs_total = 0; // reset all counters
|
||||
|
||||
+1
-1
@@ -166,7 +166,7 @@ void refreshtheDisplay() {
|
||||
u8x8.setCursor(0, 5);
|
||||
u8x8.printf(!cfg.rssilimit ? "RLIM:off " : "RLIM:%-4d", cfg.rssilimit);
|
||||
u8x8.setCursor(10, 5);
|
||||
u8x8.printf("%4dKB", ESP.getFreeHeap() / 1024);
|
||||
u8x8.printf("%4dKB", getFreeRAM() / 1024);
|
||||
|
||||
#ifdef HAS_LORA
|
||||
// update LoRa status display (line 6)
|
||||
|
||||
@@ -13,18 +13,17 @@
|
||||
// BME680 sensor on I2C bus
|
||||
// don't forget to connect SDIO of BME680 to GND for selecting i2c addr 0x76
|
||||
//
|
||||
#define HAS_BME GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL
|
||||
//#define HAS_BME GPIO_NUM_21, GPIO_NUM_22 // SDA, SCL
|
||||
|
||||
#define HAS_LED GPIO_NUM_14 // on board green LED
|
||||
|
||||
// user defined sensors
|
||||
//#define HAS_SENSORS 1 // comment out if device has user defined sensors
|
||||
|
||||
#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
|
||||
// Pins for I2C interface of OLED Display
|
||||
#define MY_OLED_SDA (21)
|
||||
#define MY_OLED_SCL (22)
|
||||
#define MY_OLED_RST (NOT_A_PIN)
|
||||
//#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
|
||||
//#define MY_OLED_SDA (21)
|
||||
//#define MY_OLED_SCL (22)
|
||||
//#define MY_OLED_RST (NOT_A_PIN)
|
||||
//#define DISPLAY_FLIP 1 // use if display is rotated
|
||||
|
||||
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
// user defined sensors
|
||||
//#define HAS_SENSORS 1 // comment out if device has user defined sensors
|
||||
|
||||
//#define HAS_DISPLAY U8X8_SSD1306_128X64_NONAME_HW_I2C
|
||||
//#define MY_OLED_SDA (21)
|
||||
//#define MY_OLED_SCL (22)
|
||||
//#define MY_OLED_RST (NOT_A_PIN)
|
||||
//#define DISPLAY_FLIP 1 // use if display is rotated
|
||||
|
||||
#define HAS_LORA 1 // comment out if device shall not send data via LoRa
|
||||
#define CFG_sx1276_radio 1 // HPD13A LoRa SoC
|
||||
#define BOARD_HAS_PSRAM // use extra 4MB external RAM
|
||||
|
||||
+2
-1
@@ -119,7 +119,8 @@ bool mac_add(uint8_t *paddr, int8_t rssi, bool sniff_type) {
|
||||
"%d Bytes left",
|
||||
added ? "new " : "known",
|
||||
sniff_type == MAC_SNIFF_WIFI ? "WiFi" : "BLTH", rssi, buff,
|
||||
hashedmac, macs_wifi, macs_ble, ESP.getFreeHeap());
|
||||
hashedmac, macs_wifi, macs_ble, getFreeRAM());
|
||||
|
||||
#ifdef VENDORFILTER
|
||||
} else {
|
||||
// Very noisy
|
||||
|
||||
+16
-4
@@ -54,13 +54,14 @@ configData_t cfg; // struct holds current device configuration
|
||||
char display_line6[16], display_line7[16]; // display buffers
|
||||
uint8_t volatile channel = 0; // channel rotation counter
|
||||
uint16_t volatile macs_total = 0, macs_wifi = 0, macs_ble = 0,
|
||||
batt_voltage = 0; // globals for display
|
||||
|
||||
batt_voltage = 0; // globals for display
|
||||
hw_timer_t *channelSwitch = NULL, *sendCycle = NULL, *homeCycle = NULL,
|
||||
*displaytimer = NULL; // irq tasks
|
||||
TaskHandle_t irqHandlerTask, wifiSwitchTask;
|
||||
|
||||
std::set<uint16_t> macs; // container holding unique MAC adress hashes
|
||||
// container holding unique MAC address hashes with Memory Alloctor using PSRAM,
|
||||
// if present
|
||||
std::set<uint16_t, std::less<uint16_t>, Mallocator<uint16_t>> macs;
|
||||
|
||||
// initialize payload encoder
|
||||
PayloadConvert payload(PAYLOAD_BUFFER_SIZE);
|
||||
@@ -107,8 +108,10 @@ void setup() {
|
||||
: "external");
|
||||
ESP_LOGI(TAG, "Internal Total heap %d, internal Free Heap %d",
|
||||
ESP.getHeapSize(), ESP.getFreeHeap());
|
||||
#ifdef BOARD_HAS_PSRAM
|
||||
ESP_LOGI(TAG, "SPIRam Total heap %d, SPIRam Free Heap %d", ESP.getPsramSize(),
|
||||
ESP.getFreePsram());
|
||||
#endif
|
||||
ESP_LOGI(TAG, "ChipRevision %d, Cpu Freq %d, SDK Version %s",
|
||||
ESP.getChipRevision(), ESP.getCpuFreqMHz(), ESP.getSdkVersion());
|
||||
ESP_LOGI(TAG, "Flash Size %d, Flash Speed %d", ESP.getFlashChipSize(),
|
||||
@@ -124,7 +127,16 @@ void setup() {
|
||||
// read (and initialize on first run) runtime settings from NVRAM
|
||||
loadConfig(); // includes initialize if necessary
|
||||
|
||||
// initialize leds
|
||||
#ifdef BOARD_HAS_PSRAM
|
||||
if (psramFound()) {
|
||||
ESP_LOGI(TAG, "PSRAM found and initialized");
|
||||
strcat_P(features, " PSRAM");
|
||||
} else
|
||||
ESP_LOGI(TAG, "No PSRAM found");
|
||||
#else
|
||||
#endif
|
||||
|
||||
// initialize leds
|
||||
#if (HAS_LED != NOT_A_PIN)
|
||||
pinMode(HAS_LED, OUTPUT);
|
||||
strcat_P(features, " LED");
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@
|
||||
#define RESPONSE_TIMEOUT_MS 60000 // firmware binary server connection timeout [milliseconds]
|
||||
|
||||
// setting for syncing time of node
|
||||
#define TIME_SYNC_INTERVAL 60 // sync time each ... minutes [default = 60], comment out means off
|
||||
//#define TIME_SYNC_INTERVAL 60 // sync time each ... minutes [default = 60], comment out means off
|
||||
|
||||
// LMIC settings
|
||||
// moved to src/lmic_config.h
|
||||
+1
-1
@@ -245,7 +245,7 @@ void get_status(uint8_t val[]) {
|
||||
#endif
|
||||
payload.reset();
|
||||
payload.addStatus(voltage, uptime() / 1000, temperatureRead(),
|
||||
ESP.getFreeHeap(), rtc_get_reset_reason(0),
|
||||
getFreeRAM(), rtc_get_reset_reason(0),
|
||||
rtc_get_reset_reason(1));
|
||||
SendPayload(STATUSPORT);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user