v1.6.996
This commit is contained in:
1 parent
48cbcd40cd
commit
9574a194fd
13 files changed
+52
-34
No files matched your search
+2
-2
@@ -8,7 +8,7 @@ static const char TAG[] = "main";
|
||||
bmeStatus_t bme_status;
|
||||
TaskHandle_t BmeTask;
|
||||
|
||||
float bme_offset = (float) BME_TEMP_OFFSET;
|
||||
float bme_offset = (float)BME_TEMP_OFFSET;
|
||||
|
||||
// --- Bosch BSEC library configuration ---
|
||||
// 3,3V supply voltage; 3s max time between sensor_control calls; 4 days
|
||||
@@ -59,7 +59,7 @@ int bme_init(void) {
|
||||
return_values_init ret =
|
||||
bsec_iot_init(BSEC_SAMPLE_RATE_LP, bme_offset, i2c_write, i2c_read,
|
||||
user_delay_ms, state_load, config_load);
|
||||
|
||||
|
||||
if ((int)ret.bme680_status) {
|
||||
ESP_LOGE(TAG, "Could not initialize BME680, error %d",
|
||||
(int)ret.bme680_status);
|
||||
|
||||
+11
-5
@@ -26,8 +26,8 @@ void doHousekeeping() {
|
||||
// time sync once per TIME_SYNC_INTERVAL
|
||||
#ifdef TIME_SYNC_INTERVAL
|
||||
if (millis() >= nextTimeSync) {
|
||||
nextTimeSync = millis() + TIME_SYNC_INTERVAL *
|
||||
60000; // set up next time sync period
|
||||
nextTimeSync =
|
||||
millis() + TIME_SYNC_INTERVAL * 60000; // set up next time sync period
|
||||
do_timesync();
|
||||
}
|
||||
#endif
|
||||
@@ -62,8 +62,8 @@ void doHousekeeping() {
|
||||
"free heap = %d bytes)",
|
||||
esp_get_minimum_free_heap_size(), 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
|
||||
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
|
||||
do_reset(); // memory leak, reset device
|
||||
@@ -89,7 +89,8 @@ void reset_counters() {
|
||||
|
||||
void do_timesync() {
|
||||
#ifdef TIME_SYNC_INTERVAL
|
||||
// sync time & date if we have valid gps time
|
||||
|
||||
// sync time & date by GPS if we have valid gps time
|
||||
#ifdef HAS_GPS
|
||||
if (gps.time.isValid()) {
|
||||
setTime(gps.time.hour(), gps.time.minute(), gps.time.second(),
|
||||
@@ -101,9 +102,14 @@ void do_timesync() {
|
||||
ESP_LOGI(TAG, "No valid GPS time");
|
||||
}
|
||||
#endif // HAS_GPS
|
||||
|
||||
// sync time by LoRa Network if network supports DevTimeReq
|
||||
#ifdef LMIC_ENABLE_DeviceTimeReq
|
||||
// Schedule a network time request at the next possible time
|
||||
LMIC_requestNetworkTime(user_request_network_time_callback, &userUTCTime);
|
||||
ESP_LOGI(TAG, "Network time request scheduled");
|
||||
#endif
|
||||
|
||||
#endif // TIME_SYNC_INTERVAL
|
||||
} // do_timesync()
|
||||
|
||||
|
||||
+1
-2
@@ -121,8 +121,7 @@ void refreshtheDisplay() {
|
||||
// update Battery status (line 2)
|
||||
#ifdef HAS_BATTERY_PROBE
|
||||
u8x8.setCursor(0, 2);
|
||||
u8x8.printf(batt_voltage > 4000 ? "B:USB " : "B:%.1fV",
|
||||
batt_voltage / 1000.0);
|
||||
u8x8.printf("B:%.1fV", batt_voltage / 1000.0);
|
||||
#endif
|
||||
|
||||
// update GPS status (line 2)
|
||||
|
||||
@@ -13,13 +13,20 @@
|
||||
// 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 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
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ void IRAM_ATTR SendCycleIRQ() {
|
||||
|
||||
#ifdef HAS_DISPLAY
|
||||
void IRAM_ATTR DisplayIRQ() {
|
||||
xTaskNotifyFromISR(irqHandlerTask, DISPLAY_IRQ, eSetBits, NULL);
|
||||
xTaskNotifyFromISR(irqHandlerTask, DISPLAY_IRQ, eSetBits, NULL);
|
||||
portYIELD_FROM_ISR();
|
||||
}
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@
|
||||
//#define LMIC_USE_INTERRUPTS
|
||||
|
||||
//time sync via LoRaWAN network, is not yet supported by TTN (LoRaWAN spec v1.0.3)
|
||||
#define LMIC_ENABLE_DeviceTimeReq 1
|
||||
//#define LMIC_ENABLE_DeviceTimeReq 1
|
||||
|
||||
// 16 μs per tick
|
||||
// LMIC requires ticks to be 15.5μs - 100 μs long
|
||||
@@ -34,7 +34,7 @@
|
||||
// faster or slower. This causes the transceiver to be earlier switched on,
|
||||
// so consuming more power. You may sharpen (reduce) this value if you are
|
||||
// limited on battery.
|
||||
#define CLOCK_ERROR_PROCENTAGE 20
|
||||
#define CLOCK_ERROR_PROCENTAGE 3
|
||||
|
||||
// Set this to 1 to enable some basic debug output (using printf) about
|
||||
// RF settings used during transmission and reception. Set to 2 to
|
||||
|
||||
+9
-3
@@ -54,7 +54,7 @@ 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
|
||||
@@ -105,9 +105,15 @@ void setup() {
|
||||
chip_info.revision, spi_flash_get_chip_size() / (1024 * 1024),
|
||||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded"
|
||||
: "external");
|
||||
ESP_LOGI(TAG, "ESP32 SDK: %s", ESP.getSdkVersion());
|
||||
ESP_LOGI(TAG, "Internal Total heap %d, internal Free Heap %d",
|
||||
ESP.getHeapSize(), ESP.getFreeHeap());
|
||||
ESP_LOGI(TAG, "SPIRam Total heap %d, SPIRam Free Heap %d", ESP.getPsramSize(),
|
||||
ESP.getFreePsram());
|
||||
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(),
|
||||
ESP.getFlashChipSpeed());
|
||||
ESP_LOGI(TAG, "Wifi/BT software coexist version: %s", esp_coex_version_get());
|
||||
ESP_LOGI(TAG, "Free RAM: %d bytes", ESP.getFreeHeap());
|
||||
|
||||
#ifdef HAS_GPS
|
||||
ESP_LOGI(TAG, "TinyGPS+ v%s", TinyGPSPlus::libraryVersion());
|
||||
|
||||
+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
|
||||
@@ -54,8 +54,6 @@ void wifi_sniffer_init(void) {
|
||||
ESP_ERROR_CHECK(esp_coex_preference_set(
|
||||
ESP_COEX_PREFER_BALANCE)); // configure Wifi/BT coexist lib
|
||||
|
||||
coex_deinit();
|
||||
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg)); // configure Wifi with cfg
|
||||
ESP_ERROR_CHECK(
|
||||
esp_wifi_set_country(&wifi_country)); // set locales for RF and channels
|
||||
|
||||
Reference in new issue
Block a user