new _ASSERT function
This commit is contained in:
parent
7330419f5e
commit
5bbe4bee02
@ -1,5 +1,6 @@
|
||||
#ifndef _GLOBALS_H
|
||||
#define _GLOBALS_H
|
||||
#endif
|
||||
|
||||
// The mother of all embedded development...
|
||||
#include <Arduino.h>
|
||||
@ -49,6 +50,16 @@
|
||||
(xSemaphoreTake(I2Caccess, pdMS_TO_TICKS(DISPLAYREFRESH_MS)) == pdTRUE)
|
||||
#define I2C_MUTEX_UNLOCK() (xSemaphoreGive(I2Caccess))
|
||||
|
||||
// pseudo system halt function, useful to prevent writeloops to NVRAM
|
||||
#ifndef _ASSERT
|
||||
#define _ASSERT(cond) \
|
||||
if ((cond) == 0) { \
|
||||
ESP_LOGE(TAG, "FAILURE in %s:%d", __FILE__, __LINE__); \
|
||||
mask_user_IRQ(); \
|
||||
for (;;) \
|
||||
; \
|
||||
}
|
||||
|
||||
enum sendprio_t { prio_low, prio_normal, prio_high };
|
||||
enum timesource_t { _gps, _rtc, _lora, _unsynced };
|
||||
|
||||
|
@ -67,7 +67,7 @@ void dp_setup(int contrast) {
|
||||
MY_DISPLAY_INVERT, USE_HW_I2C, MY_DISPLAY_SDA,
|
||||
MY_DISPLAY_SCL, MY_DISPLAY_RST,
|
||||
OLED_FREQUENCY); // use standard I2C bus at 400Khz
|
||||
assert(rc != OLED_NOT_FOUND);
|
||||
_ASSERT (rc != OLED_NOT_FOUND);
|
||||
|
||||
// set display buffer
|
||||
obdSetBackBuffer(&ssoled, displaybuf);
|
||||
@ -281,8 +281,7 @@ void dp_drawPage(time_t t, bool nextpage) {
|
||||
dp_printf("BLTH:%-5d", macs_ble);
|
||||
if (cfg.enscount)
|
||||
dp_printf("(CWA:%d)", cwa_report());
|
||||
}
|
||||
else
|
||||
} else
|
||||
dp_printf("BLTH:off");
|
||||
#else
|
||||
dp_printf("Sniffer disabled");
|
||||
|
@ -150,7 +150,7 @@ time_t get_gpstime(void) {
|
||||
// GPS serial feed FreeRTos Task
|
||||
void gps_loop(void *pvParameters) {
|
||||
|
||||
configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check
|
||||
_ASSERT((uint32_t)pvParameters == 1); // FreeRTOS check
|
||||
|
||||
while (1) {
|
||||
|
||||
|
@ -6,7 +6,7 @@ static const char TAG[] = __FILE__;
|
||||
// irq handler task, handles all our application level interrupts
|
||||
void irqHandler(void *pvParameters) {
|
||||
|
||||
configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check
|
||||
_ASSERT((uint32_t)pvParameters == 1); // FreeRTOS check
|
||||
|
||||
uint32_t InterruptStatus;
|
||||
|
||||
|
@ -22,8 +22,7 @@
|
||||
#define LMIC_USE_INTERRUPTS 1
|
||||
#endif
|
||||
|
||||
// avoid lmic warning if we don't configure radio because we don't have one
|
||||
#define CFG_sx1276_radio 1
|
||||
// avoid lmic warning if we don't configure radio in case we haven't one
|
||||
#if !(defined(CFG_sx1272_radio) || defined(CFG_sx1276_radio))
|
||||
#define CFG_sx1276_radio 1
|
||||
#endif
|
||||
|
@ -227,7 +227,7 @@ void showLoraKeys(void) {
|
||||
|
||||
// LMIC send task
|
||||
void lora_send(void *pvParameters) {
|
||||
configASSERT(((uint32_t)pvParameters) == 1); // FreeRTOS check
|
||||
_ASSERT((uint32_t)pvParameters == 1); // FreeRTOS check
|
||||
|
||||
MessageBuffer_t SendBuffer;
|
||||
|
||||
@ -292,7 +292,7 @@ void lora_stack_reset() {
|
||||
}
|
||||
|
||||
esp_err_t lora_stack_init(bool do_join) {
|
||||
assert(SEND_QUEUE_SIZE);
|
||||
_ASSERT(SEND_QUEUE_SIZE > 0);
|
||||
LoraSendQueue = xQueueCreate(SEND_QUEUE_SIZE, sizeof(MessageBuffer_t));
|
||||
if (LoraSendQueue == 0) {
|
||||
ESP_LOGE(TAG, "Could not create LORA send queue. Aborting.");
|
||||
@ -382,7 +382,7 @@ void lora_queuereset(void) { xQueueReset(LoraSendQueue); }
|
||||
|
||||
// LMIC lorawan stack task
|
||||
void lmictask(void *pvParameters) {
|
||||
configASSERT(((uint32_t)pvParameters) == 1);
|
||||
_ASSERT((uint32_t)pvParameters == 1);
|
||||
|
||||
// setup LMIC stack
|
||||
os_init_ex(&myPinmap); // initialize lmic run-time environment
|
||||
|
22
src/main.cpp
22
src/main.cpp
@ -118,7 +118,7 @@ void setup() {
|
||||
|
||||
// create some semaphores for syncing / mutexing tasks
|
||||
I2Caccess = xSemaphoreCreateMutex(); // for access management of i2c bus
|
||||
assert(I2Caccess != NULL);
|
||||
_ASSERT(I2Caccess != NULL);
|
||||
I2C_MUTEX_UNLOCK();
|
||||
|
||||
// disable brownout detection
|
||||
@ -203,7 +203,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
// read (and initialize on first run) runtime settings from NVRAM
|
||||
assert(loadConfig()); // includes initialize if necessary
|
||||
_ASSERT(loadConfig()); // includes initialize if necessary
|
||||
|
||||
// now that we are powered, we scan i2c bus for devices
|
||||
i2c_scan();
|
||||
@ -217,7 +217,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_HAS_PSRAM
|
||||
assert(psramFound());
|
||||
_ASSERT(psramFound());
|
||||
ESP_LOGI(TAG, "PSRAM found and initialized");
|
||||
strcat_P(features, " PSRAM");
|
||||
#endif
|
||||
@ -343,20 +343,20 @@ void setup() {
|
||||
#if (HAS_LORA)
|
||||
strcat_P(features, " LORA");
|
||||
// kick off join, except we come from sleep
|
||||
assert(lora_stack_init(RTC_runmode == RUNMODE_WAKEUP ? false : true) ==
|
||||
_ASSERT(lora_stack_init(RTC_runmode == RUNMODE_WAKEUP ? false : true) ==
|
||||
ESP_OK);
|
||||
#endif
|
||||
|
||||
// initialize SPI
|
||||
#ifdef HAS_SPI
|
||||
strcat_P(features, " SPI");
|
||||
assert(spi_init() == ESP_OK);
|
||||
_ASSERT(spi_init() == ESP_OK);
|
||||
#endif
|
||||
|
||||
// initialize MQTT
|
||||
#ifdef HAS_MQTT
|
||||
strcat_P(features, " MQTT");
|
||||
assert(mqtt_init() == ESP_OK);
|
||||
_ASSERT(mqtt_init() == ESP_OK);
|
||||
#endif
|
||||
|
||||
#if (HAS_SDCARD)
|
||||
@ -395,7 +395,7 @@ void setup() {
|
||||
// initialize RTC
|
||||
#ifdef HAS_RTC
|
||||
strcat_P(features, " RTC");
|
||||
assert(rtc_init());
|
||||
_ASSERT(rtc_init());
|
||||
#endif
|
||||
|
||||
#if defined HAS_DCF77
|
||||
@ -446,11 +446,13 @@ void setup() {
|
||||
strcat_P(features, " BMP180");
|
||||
#endif
|
||||
if (bme_init())
|
||||
ESP_LOGI(TAG, "Starting BME sensor...");
|
||||
ESP_LOGI(TAG, "BME sensor initialized");
|
||||
else
|
||||
ESP_LOGE(TAG, "BME sensor could not be initialized");
|
||||
#endif
|
||||
|
||||
// starting timers and interrupts
|
||||
assert(irqHandlerTask != NULL); // has interrupt handler task started?
|
||||
_ASSERT(irqHandlerTask != NULL); // has interrupt handler task started?
|
||||
ESP_LOGI(TAG, "Starting Timers...");
|
||||
|
||||
// display interrupt
|
||||
@ -505,7 +507,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
ESP_LOGI(TAG, "Starting Timekeeper...");
|
||||
assert(timepulse_init()); // setup pps timepulse
|
||||
_ASSERT(timepulse_init()); // setup pps timepulse
|
||||
timepulse_start(); // starts pps and cyclic time sync
|
||||
|
||||
#endif // TIME_SYNC_INTERVAL
|
||||
|
@ -23,7 +23,7 @@ esp_err_t mqtt_init(void) {
|
||||
mqttClient.begin(MQTT_SERVER, MQTT_PORT, netClient);
|
||||
mqttClient.onMessageAdvanced(mqtt_callback);
|
||||
|
||||
assert(SEND_QUEUE_SIZE);
|
||||
_ASSERT(SEND_QUEUE_SIZE > 0);
|
||||
MQTTSendQueue = xQueueCreate(SEND_QUEUE_SIZE, sizeof(MessageBuffer_t));
|
||||
if (MQTTSendQueue == 0) {
|
||||
ESP_LOGE(TAG, "Could not create MQTT send queue. Aborting.");
|
||||
|
@ -104,7 +104,7 @@ void spi_slave_task(void *param) {
|
||||
}
|
||||
|
||||
esp_err_t spi_init() {
|
||||
assert(SEND_QUEUE_SIZE);
|
||||
_ASSERT(SEND_QUEUE_SIZE > 0);
|
||||
SPISendQueue = xQueueCreate(SEND_QUEUE_SIZE, sizeof(MessageBuffer_t));
|
||||
if (SPISendQueue == 0) {
|
||||
ESP_LOGE(TAG, "Could not create SPI send queue. Aborting.");
|
||||
|
@ -245,7 +245,7 @@ void clock_init(void) {
|
||||
&ClockTask, // task handle
|
||||
1); // CPU core
|
||||
|
||||
assert(ClockTask); // has clock task started?
|
||||
_ASSERT(ClockTask != NULL); // has clock task started?
|
||||
} // clock_init
|
||||
|
||||
void clock_loop(void *taskparameter) { // ClockTask
|
||||
|
@ -45,7 +45,7 @@ IRAM_ATTR void wifi_sniffer_packet_handler(void *buff,
|
||||
|
||||
// Software-timer driven Wifi channel rotation callback function
|
||||
void switchWifiChannel(TimerHandle_t xTimer) {
|
||||
configASSERT(xTimer);
|
||||
_ASSERT(xTimer != NULL);
|
||||
channel =
|
||||
(channel % WIFI_CHANNEL_MAX) + 1; // rotate channel 1..WIFI_CHANNEL_MAX
|
||||
esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
|
||||
@ -82,7 +82,7 @@ void wifi_sniffer_init(void) {
|
||||
}
|
||||
|
||||
void switch_wifi_sniffer(uint8_t state) {
|
||||
assert(WifiChanTimer);
|
||||
_ASSERT(WifiChanTimer != NULL);
|
||||
if (state) {
|
||||
// switch wifi sniffer on
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
|
Loading…
Reference in New Issue
Block a user