From 05df11e0d982bcc04f44cbc5dfb2b8c80ec0e6c5 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Tue, 12 May 2020 00:01:48 +0300 Subject: [PATCH] some compile fixes --- cores/esp32/esp32-hal-gpio.c | 1 + cores/esp32/esp32-hal-uart.c | 5 +++++ libraries/WiFi/src/WiFiGeneric.cpp | 15 +++++++++++---- libraries/WiFi/src/WiFiGeneric.h | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/cores/esp32/esp32-hal-gpio.c b/cores/esp32/esp32-hal-gpio.c index 68ab29e8..39d044a5 100644 --- a/cores/esp32/esp32-hal-gpio.c +++ b/cores/esp32/esp32-hal-gpio.c @@ -13,6 +13,7 @@ // limitations under the License. #include "esp32-hal-gpio.h" +#include "pins_arduino.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_attr.h" diff --git a/cores/esp32/esp32-hal-uart.c b/cores/esp32/esp32-hal-uart.c index 5def9b20..2b09255a 100644 --- a/cores/esp32/esp32-hal-uart.c +++ b/cores/esp32/esp32-hal-uart.c @@ -327,8 +327,13 @@ void uartRxFifoToQueue(uart_t* uart) //disable interrupts uart->dev->int_ena.val = 0; uart->dev->int_clr.val = 0xffffffff; +#if CONFIG_IDF_TARGET_ESP32 while (uart->dev->status.rxfifo_cnt || (uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr)) { c = uart->dev->fifo.rw_byte; +#else + while (uart->dev->status.rxfifo_cnt) { + c = uart->dev->ahb_fifo.rw_byte; +#endif xQueueSend(uart->queue, &c, 0); } //enable interrupts diff --git a/libraries/WiFi/src/WiFiGeneric.cpp b/libraries/WiFi/src/WiFiGeneric.cpp index a77bb11d..f7c4461b 100644 --- a/libraries/WiFi/src/WiFiGeneric.cpp +++ b/libraries/WiFi/src/WiFiGeneric.cpp @@ -79,17 +79,24 @@ static void _network_event_task(void * arg){ _network_event_task_handle = NULL; } -static void _network_event_cb(void* arg, esp_event_base_t base, int32_t id, void* data) { - system_event_t *event = (system_event_t *)data; +static esp_err_t _network_event_cb(void* arg, system_event_t *event) { system_prov_event_t *sys_prov_data = (system_prov_event_t *)malloc(sizeof(system_prov_event_t)); if(sys_prov_data == NULL) { - return; + return ESP_FAIL; } sys_prov_data->sys_event = event; sys_prov_data->prov_event = NULL; if (postToSysQueue(sys_prov_data) != ESP_OK){ free(sys_prov_data); - return; + return ESP_FAIL; + } + return ESP_OK; +} + +static void _network_event_cb(void* arg, esp_event_base_t base, int32_t id, void* data) { + system_event_t *event = (system_event_t *)data; + if(_network_event_cb(arg, event) != ESP_OK){ + log_e("event dispatch failed"); } } diff --git a/libraries/WiFi/src/WiFiGeneric.h b/libraries/WiFi/src/WiFiGeneric.h index 152c0351..4fbb05d0 100644 --- a/libraries/WiFi/src/WiFiGeneric.h +++ b/libraries/WiFi/src/WiFiGeneric.h @@ -113,7 +113,7 @@ class WiFiGenericClass bool setTxPower(wifi_power_t power); wifi_power_t getTxPower(); - static esp_err_t _eventCallback(void *arg, system_event_t *event, wifi_prov_event_t *prov_event); + static esp_err_t _eventCallback(void *arg, system_event_t *event, wifi_prov_event_t *prov_event=NULL); protected: static bool _persistent;