Merge pull request #509 from cyberman54/development

Bugfixes
This commit is contained in:
Verkehrsrot 2019-12-26 13:28:59 +01:00 committed by GitHub
commit 33e92d0464
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 43 additions and 25 deletions

View File

@ -43,10 +43,10 @@ void showLoraKeys(void);
void lora_send(void *pvParameters); void lora_send(void *pvParameters);
void lora_enqueuedata(MessageBuffer_t *message); void lora_enqueuedata(MessageBuffer_t *message);
void lora_queuereset(void); void lora_queuereset(void);
static void IRAM_ATTR myEventCallback(void *pUserData, ev_t ev); void IRAM_ATTR myEventCallback(void *pUserData, ev_t ev);
static void IRAM_ATTR myRxCallback(void *pUserData, uint8_t port, void IRAM_ATTR myRxCallback(void *pUserData, uint8_t port,
const uint8_t *pMsg, size_t nMsg); const uint8_t *pMsg, size_t nMsg);
static void IRAM_ATTR myTxCallback(void *pUserData, int fSuccess); void IRAM_ATTR myTxCallback(void *pUserData, int fSuccess);
void mac_decode(const uint8_t cmd[], const uint8_t cmdlen, const mac_t table[], void mac_decode(const uint8_t cmd[], const uint8_t cmdlen, const mac_t table[],
const uint8_t tablesize); const uint8_t tablesize);
uint8_t getBattLevel(void); uint8_t getBattLevel(void);

View File

@ -17,7 +17,7 @@ void start_ota_update();
int version_compare(const String v1, const String v2); int version_compare(const String v1, const String v2);
void ota_display(const uint8_t row, const std::string status, void ota_display(const uint8_t row, const std::string status,
const std::string msg); const std::string msg);
static void show_progress(unsigned long current, unsigned long size); void show_progress(unsigned long current, unsigned long size);
#endif // USE_OTA #endif // USE_OTA

View File

@ -9,7 +9,7 @@
void wifi_sniffer_init(void); void wifi_sniffer_init(void);
void switch_wifi_sniffer (uint8_t state); void switch_wifi_sniffer (uint8_t state);
static void IRAM_ATTR wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type); void IRAM_ATTR wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type);
void switchWifiChannel(TimerHandle_t xTimer); void switchWifiChannel(TimerHandle_t xTimer);
#endif #endif

View File

@ -22,11 +22,11 @@ void doHousekeeping() {
// check if update mode trigger switch was set // check if update mode trigger switch was set
if (RTC_runmode == RUNMODE_UPDATE) { if (RTC_runmode == RUNMODE_UPDATE) {
// check battery status if we can before doing ota // check battery status if we can before doing ota
if (batt_sufficient()) if (batt_sufficient()) {
do_reset(true); // warmstart to runmode update do_reset(true); // warmstart to runmode update
else { } else {
ESP_LOGE(TAG, "Battery voltage %dmV too low for OTA", batt_voltage); ESP_LOGE(TAG, "Battery voltage %dmV too low for OTA", batt_voltage);
RTC_runmode == RUNMODE_NORMAL; // keep running in normal mode RTC_runmode = RUNMODE_NORMAL; // keep running in normal mode
} }
} }
@ -82,8 +82,8 @@ void doHousekeeping() {
ESP_LOGI(TAG, "BME280 Temp: %.2f°C | Humidity: %.2f | Pressure: %.0f", ESP_LOGI(TAG, "BME280 Temp: %.2f°C | Humidity: %.2f | Pressure: %.0f",
bme_status.temperature, bme_status.humidity, bme_status.pressure); bme_status.temperature, bme_status.humidity, bme_status.pressure);
#elif defined HAS_BMP180 #elif defined HAS_BMP180
ESP_LOGI(TAG, "BMP180 Temp: %.2f°C | Pressure: %.0f", ESP_LOGI(TAG, "BMP180 Temp: %.2f°C | Pressure: %.0f", bme_status.temperature,
bme_status.temperature, bme_status.pressure); bme_status.pressure);
#endif #endif
#endif #endif

View File

@ -8,7 +8,7 @@ void irqHandler(void *pvParameters) {
configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check
uint32_t InterruptStatus; static uint32_t InterruptStatus = 0x00;
static bool mask_irq = false; static bool mask_irq = false;
// task remains in blocked state until it is notified by an irq // task remains in blocked state until it is notified by an irq
@ -37,49 +37,65 @@ void irqHandler(void *pvParameters) {
// button pressed? // button pressed?
#ifdef HAS_BUTTON #ifdef HAS_BUTTON
if (InterruptStatus & BUTTON_IRQ) if (InterruptStatus & BUTTON_IRQ) {
readButton(); readButton();
InterruptStatus &= ~BUTTON_IRQ;
}
#endif #endif
// display needs refresh? // display needs refresh?
#ifdef HAS_DISPLAY #ifdef HAS_DISPLAY
if (InterruptStatus & DISPLAY_IRQ) if (InterruptStatus & DISPLAY_IRQ) {
refreshTheDisplay(); refreshTheDisplay();
InterruptStatus &= ~DISPLAY_IRQ;
}
#endif #endif
// LED Matrix display needs refresh? // LED Matrix display needs refresh?
#ifdef HAS_MATRIX_DISPLAY #ifdef HAS_MATRIX_DISPLAY
if (InterruptStatus & MATRIX_DISPLAY_IRQ) if (InterruptStatus & MATRIX_DISPLAY_IRQ) {
refreshTheMatrixDisplay(); refreshTheMatrixDisplay();
InterruptStatus &= ~MATRIX_DISPLAY_IRQ;
}
#endif #endif
// BME sensor data to be read? // BME sensor data to be read?
#if (HAS_BME) #if (HAS_BME)
if (InterruptStatus & BME_IRQ) if (InterruptStatus & BME_IRQ) {
bme_storedata(&bme_status); bme_storedata(&bme_status);
InterruptStatus &= ~BME_IRQ;
}
#endif #endif
// are cyclic tasks due? // are cyclic tasks due?
if (InterruptStatus & CYCLIC_IRQ) if (InterruptStatus & CYCLIC_IRQ) {
doHousekeeping(); doHousekeeping();
InterruptStatus &= ~CYCLIC_IRQ;
}
#if (TIME_SYNC_INTERVAL) #if (TIME_SYNC_INTERVAL)
// is time to be synced? // is time to be synced?
if (InterruptStatus & TIMESYNC_IRQ) { if (InterruptStatus & TIMESYNC_IRQ) {
now(); // ensure sysTime is recent now(); // ensure sysTime is recent
calibrateTime(); calibrateTime();
InterruptStatus &= ~TIMESYNC_IRQ;
} }
#endif #endif
// do we have a power event? // do we have a power event?
#if (HAS_PMU) #if (HAS_PMU)
if (InterruptStatus & PMU_IRQ) if (InterruptStatus & PMU_IRQ) {
AXP192_powerevent_IRQ(); AXP192_powerevent_IRQ();
InterruptStatus &= ~PMU_IRQ;
}
#endif #endif
// is time to send the payload? // is time to send the payload?
if (InterruptStatus & SENDCYCLE_IRQ) if (InterruptStatus & SENDCYCLE_IRQ) {
sendData(); sendData();
InterruptStatus &= ~SENDCYCLE_IRQ;
}
} }
} }

View File

@ -452,7 +452,7 @@ void lmictask(void *pvParameters) {
} // lmictask } // lmictask
// lmic event handler // lmic event handler
static void myEventCallback(void *pUserData, ev_t ev) { void myEventCallback(void *pUserData, ev_t ev) {
// using message descriptors from LMIC library // using message descriptors from LMIC library
static const char *const evNames[] = {LMIC_EVENT_NAME_TABLE__INIT}; static const char *const evNames[] = {LMIC_EVENT_NAME_TABLE__INIT};
@ -502,7 +502,7 @@ static void myEventCallback(void *pUserData, ev_t ev) {
} }
// receive message handler // receive message handler
static void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg, void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg,
size_t nMsg) { size_t nMsg) {
// display type of received data // display type of received data
@ -557,7 +557,7 @@ static void myRxCallback(void *pUserData, uint8_t port, const uint8_t *pMsg,
} }
// transmit complete message handler // transmit complete message handler
static void myTxCallback(void *pUserData, int fSuccess) { void myTxCallback(void *pUserData, int fSuccess) {
#if (TIME_SYNC_LORASERVER) #if (TIME_SYNC_LORASERVER)
// if last packet sent was a timesync request, store TX timestamp // if last packet sent was a timesync request, store TX timestamp

View File

@ -318,7 +318,7 @@ void ota_display(const uint8_t row, const std::string status,
} }
// callback function to show download progress while streaming data // callback function to show download progress while streaming data
static void show_progress(unsigned long current, unsigned long size) { void show_progress(unsigned long current, unsigned long size) {
#ifdef HAS_DISPLAY #ifdef HAS_DISPLAY
char buf[17]; char buf[17];
snprintf(buf, 17, "%-9lu (%3lu%%)", current, current * 100 / size); snprintf(buf, 17, "%-9lu (%3lu%%)", current, current * 100 / size);

View File

@ -58,7 +58,9 @@ void sendData() {
uint8_t bitmask = cfg.payloadmask; uint8_t bitmask = cfg.payloadmask;
uint8_t mask = 1; uint8_t mask = 1;
#if (HAS_GPS)
gpsStatus_t gps_status; gpsStatus_t gps_status;
#endif
while (bitmask) { while (bitmask) {
switch (bitmask & mask) { switch (bitmask & mask) {

View File

@ -29,8 +29,8 @@ typedef struct {
} wifi_ieee80211_packet_t; } wifi_ieee80211_packet_t;
// using IRAM_:ATTR here to speed up callback function // using IRAM_:ATTR here to speed up callback function
static IRAM_ATTR void IRAM_ATTR void wifi_sniffer_packet_handler(void *buff,
wifi_sniffer_packet_handler(void *buff, wifi_promiscuous_pkt_type_t type) { wifi_promiscuous_pkt_type_t type) {
const wifi_promiscuous_pkt_t *ppkt = (wifi_promiscuous_pkt_t *)buff; const wifi_promiscuous_pkt_t *ppkt = (wifi_promiscuous_pkt_t *)buff;
const wifi_ieee80211_packet_t *ipkt = const wifi_ieee80211_packet_t *ipkt =
@ -75,7 +75,7 @@ void wifi_sniffer_init(void) {
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE)); // no modem power saving ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE)); // no modem power saving
ESP_ERROR_CHECK(esp_wifi_set_promiscuous_filter(&filter)); // set frame filter ESP_ERROR_CHECK(esp_wifi_set_promiscuous_filter(&filter)); // set frame filter
ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler)); ESP_ERROR_CHECK(esp_wifi_set_promiscuous_rx_cb(&wifi_sniffer_packet_handler));
ESP_ERROR_CHECK(esp_wifi_start()); //for esp_wifi v3.3 ESP_ERROR_CHECK(esp_wifi_start()); // for esp_wifi v3.3
ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true)); // now switch on monitor mode ESP_ERROR_CHECK(esp_wifi_set_promiscuous(true)); // now switch on monitor mode
// setup wifi channel rotation timer // setup wifi channel rotation timer