esp32 support

This commit is contained in:
Paul
2020-05-19 17:03:00 +02:00
parent be4f075663
commit 1ceef8afd5
4 changed files with 15 additions and 9 deletions

View File

@@ -173,7 +173,7 @@ void EMSESP::show_emsbus(uuid::console::Shell & shell) {
// and for each associated EMS device go and request data values // and for each associated EMS device go and request data values
void EMSESP::show_values(uuid::console::Shell & shell) { void EMSESP::show_values(uuid::console::Shell & shell) {
if (sensor_devices().empty() && emsdevices.empty()) { if (sensor_devices().empty() && emsdevices.empty()) {
shell.printfln(F("No information from devices to show")); shell.printfln(F("No data available from devices to show"));
return; return;
} }

View File

@@ -524,14 +524,19 @@ void System::console_commands() {
if (shell.has_flags(CommandFlags::ADMIN | CommandFlags::LOCAL)) { if (shell.has_flags(CommandFlags::ADMIN | CommandFlags::LOCAL)) {
shell.printfln("Wifi:"); shell.printfln("Wifi:");
shell.print(" ");
shell.printfln(F_(wifi_ssid_fmt), shell.printfln(F_(wifi_ssid_fmt),
settings.wifi_ssid().empty() ? uuid::read_flash_string(F_(unset)).c_str() settings.wifi_ssid().empty() ? uuid::read_flash_string(F_(unset)).c_str()
: settings.wifi_ssid().c_str()); : settings.wifi_ssid().c_str());
shell.print(" ");
shell.printfln(F_(wifi_password_fmt), settings.wifi_password().empty() ? F_(unset) : F_(asterisks)); shell.printfln(F_(wifi_password_fmt), settings.wifi_password().empty() ? F_(unset) : F_(asterisks));
shell.printfln(F("Syslog:")); shell.printfln(F("Syslog:"));
auto host = settings.syslog_host(); auto host = settings.syslog_host();
shell.print(" ");
shell.printfln(F_(host_fmt), !host.empty() ? host.c_str() : uuid::read_flash_string(F_(unset)).c_str()); shell.printfln(F_(host_fmt), !host.empty() ? host.c_str() : uuid::read_flash_string(F_(unset)).c_str());
shell.print(" ");
shell.printfln(F_(log_level_fmt), uuid::log::format_level_uppercase(settings.syslog_level())); shell.printfln(F_(log_level_fmt), uuid::log::format_level_uppercase(settings.syslog_level()));
shell.print(" ");
shell.printfln(F_(mark_interval_fmt), settings.syslog_mark_interval()); shell.printfln(F_(mark_interval_fmt), settings.syslog_mark_interval());
} }
}); });

View File

@@ -73,16 +73,16 @@ class System {
#endif #endif
static constexpr uint32_t SYSTEM_CHECK_FREQUENCY = 5000; // check every 5 seconds static constexpr uint32_t SYSTEM_CHECK_FREQUENCY = 5000; // check every 5 seconds
static constexpr uint32_t LED_WARNING_BLINK = 1000; // flash static constexpr uint32_t LED_WARNING_BLINK = 1000; // pulse to show no connection
static constexpr uint32_t LED_WARNING_BLINK_FAST = 100; // flash quick static constexpr uint32_t LED_WARNING_BLINK_FAST = 100; // flash quickly for boot up sequence or safe-mode
// internal LED // internal LED
#if defined(ESP8266) #if defined(ESP8266)
static constexpr uint8_t LED_GPIO = 2; static constexpr uint8_t LED_GPIO = 2;
static constexpr uint8_t LED_ON = LOW; static constexpr uint8_t LED_ON = LOW;
#elif defined(ESP32) #elif defined(ESP32)
static constexpr uint8_t LED_GPIO = 5; static constexpr uint8_t LED_GPIO = 5; // on Wemos D32
static constexpr uint8_t LED_ON = HIGH; static constexpr uint8_t LED_ON = LOW;
#else #else
static constexpr uint8_t LED_GPIO = 0; static constexpr uint8_t LED_GPIO = 0;
static constexpr uint8_t LED_ON = 0; static constexpr uint8_t LED_ON = 0;

View File

@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* ESP32 UART port by Arwed Richert @ArwedL */
#if defined(ESP32) #if defined(ESP32)
#include "uart/emsuart_esp32.h" #include "uart/emsuart_esp32.h"
@@ -85,7 +87,6 @@ void EMSuart::emsuart_recvTask(void * param) {
* init UART0 driver * init UART0 driver
*/ */
void EMSuart::start(uint8_t tx_mode) { void EMSuart::start(uint8_t tx_mode) {
return; // TODO commented out because it causes crash. @ArwedL could you take a look?
tx_mode_ = tx_mode; tx_mode_ = tx_mode;
@@ -117,15 +118,15 @@ void EMSuart::start(uint8_t tx_mode) {
// 1 should be enough - also 10 should be fine // 1 should be enough - also 10 should be fine
ESP_ERROR_CHECK(uart_driver_install(EMSUART_UART, EMSUART_RXBUFSIZE, 0, 10, &uart_queue, 0)); ESP_ERROR_CHECK(uart_driver_install(EMSUART_UART, EMSUART_RXBUFSIZE, 0, 10, &uart_queue, 0));
// Create a ringbuffer for communication between recvTask and parseTask (as max message size is ~32 bytes) 512 bytes has capacity to hold more than 16 telegrams
buf_handle = xRingbufferCreate(512, RINGBUF_TYPE_NOSPLIT);
// start recvTaskQueue stacksize choosen any value 4069 bytes, Priority choosen 2 above normal to be able to fastly react on received signals // start recvTaskQueue stacksize choosen any value 4069 bytes, Priority choosen 2 above normal to be able to fastly react on received signals
// xTaskCreate parameters taken from https://github.com/espressif/esp-idf/blob/ce2a99dc23533f40369e4ab0d17ffd40f4b0dd72/examples/peripherals/uart/uart_events/main/uart_events_example_main.c // xTaskCreate parameters taken from https://github.com/espressif/esp-idf/blob/ce2a99dc23533f40369e4ab0d17ffd40f4b0dd72/examples/peripherals/uart/uart_events/main/uart_events_example_main.c
xTaskCreate(emsuart_recvTask, "EMS_recv", 2048, NULL, 12, NULL); xTaskCreate(emsuart_recvTask, "EMS_recv", 2048, NULL, 12, NULL);
// create 2 tasks because assumption is that parseTelegram needs some time (even on ESP32) which would block receiving task // create 2 tasks because assumption is that parseTelegram needs some time (even on ESP32) which would block receiving task
xTaskCreate(emsuart_parseTask, "EMS_parse", 8000, NULL, 2, NULL); xTaskCreate(emsuart_parseTask, "EMS_parse", 8000, NULL, 2, NULL);
// Create a ringbuffer for communication between recvTask and parseTask (as max message size is ~32 bytes) 512 bytes has capacity to hold more than 16 telegrams
buf_handle = xRingbufferCreate(512, RINGBUF_TYPE_NOSPLIT);
} }
/* /*