From 326c605122f909256d1aa6dbc0a5cc17aabc666e Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Sun, 2 Apr 2023 14:20:03 +0200 Subject: [PATCH] Prep support ESP32 enum SerialConfig --- .../src/esp8266toEsp32.h | 8 +++---- tasmota/tasmota_xsns_sensor/xsns_53_sml.ino | 22 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h index 23ed7f1b4..c544d5d30 100644 --- a/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h +++ b/lib/libesp32/ESP32-to-ESP8266-compat/src/esp8266toEsp32.h @@ -25,14 +25,14 @@ /*******************************************************************************************\ * ESP32/S2/S3/C3... PWM analog support - * + * * The following supersedes Arduino framework and provides more granular control: * - fine grained phase control (in addition to duty cycle) * - fine control of PWM frequency and resolution per GPIO - * + * * By default, all PWM are using the same timer called Timer 0. * Changes in frequency of resolution apply to all PWM using Timer 0. - * + * * You can specify a different a different resolution/frequency for * specific GPIOs, this will internally assign a new timer to the GPIO. * The limit is 3 specific values in addition to the global value. @@ -129,7 +129,7 @@ uint32_t analogGetTimerFrequency(uint8_t timer); #define os_delay_us ets_delay_us // Serial minimal type to hold the config typedef int SerConfu8; -typedef int SerialConfig; +//typedef int SerialConfig; // Will be replaced enum in esp32_hal-uart.h (#7926) // // UDP diff --git a/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino b/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino index c7629a52f..81f29351c 100755 --- a/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino +++ b/tasmota/tasmota_xsns_sensor/xsns_53_sml.ino @@ -1252,10 +1252,10 @@ void sml_shift_in(uint32_t meters, uint32_t shard) { mp->sbuff[count] = mp->sbuff[count + 1]; } } - + uint8_t iob; if (mp->srcpin != TCP_MODE_FLG) { - iob = (uint8_t)mp->meter_ss->read(); + iob = (uint8_t)mp->meter_ss->read(); } else { iob = (uint8_t)mp->client->read(); } @@ -1447,7 +1447,7 @@ uint32_t meters; sml_shift_in(meters, 0); } } else { -#ifdef USE_SML_TCP +#ifdef USE_SML_TCP while (mp->client->available()){ sml_shift_in(meters, 0); } @@ -2625,7 +2625,7 @@ struct METER_DESC *mp = &meter_desc[mnum]; break; case '7': cp += 2; -#ifdef ESP32 +#ifdef ESP32 mp->uart_index = strtol(cp, &cp, 10); #endif // ESP32 break; @@ -3096,7 +3096,7 @@ next_line: mp->client = new WiFiClientSecure; //client(new BearSSL::WiFiClientSecure_light(1024,1024)) { mp->client->setInsecure(); -#else +#else mp->client = new WiFiClient; #endif int32_t err = mp->client->connect(mp->ip_addr, mp->params); @@ -3142,7 +3142,7 @@ next_line: #endif // ESP32 - SerialConfig smode = SERIAL_8N1; + uint32_t smode = SERIAL_8N1; if (mp->sopt & 0xf0) { // new serial config @@ -3178,14 +3178,14 @@ next_line: mp->meter_ss->flush(); } if (mp->meter_ss->hardwareSerial()) { - Serial.begin(mp->params, smode); + Serial.begin(mp->params, (SerialConfig)smode); // void HardwareSerial::begin(unsigned long baud, SerialConfig config, SerialMode mode, uint8_t tx_pin, bool invert) ClaimSerial(); //Serial.setRxBufferSize(512); } #endif // ESP8266 #ifdef ESP32 - mp->meter_ss->begin(mp->params, smode, mp->srcpin, mp->trxpin); + mp->meter_ss->begin(mp->params, smode, mp->srcpin, mp->trxpin); // void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert, unsigned long timeout_ms, uint8_t rxfifo_full_thrhd) #ifdef USE_ESP32_SW_SERIAL mp->meter_ss->setRxBufferSize(mp->sibsiz); #endif @@ -3293,7 +3293,7 @@ uint32_t SML_Write(int32_t meter, char *hstr) { hstr++; // currently only 8 bits and ignore stopbits hstr++; - SerialConfig smode; + uint32_t smode; switch (*hstr) { case 'N': smode = SERIAL_8N1; @@ -3307,9 +3307,9 @@ uint32_t SML_Write(int32_t meter, char *hstr) { } #ifdef ESP8266 - Serial.begin(baud, smode); + Serial.begin(baud, (SerialConfig)smode); // void HardwareSerial::begin(unsigned long baud, SerialConfig config, SerialMode mode, uint8_t tx_pin, bool invert) #else - meter_desc[meter].meter_ss->begin(baud, smode, sml_globs.mp[meter].srcpin, sml_globs.mp[meter].trxpin); + meter_desc[meter].meter_ss->begin(baud, smode, sml_globs.mp[meter].srcpin, sml_globs.mp[meter].trxpin); // void HardwareSerial::begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert, unsigned long timeout_ms, uint8_t rxfifo_full_thrhd) #endif } return 1;