[ESPEasy Serial] Fix build issues for core 2.4.0

This commit is contained in:
TD-er
2019-01-05 03:06:20 +01:00
parent 0caa805452
commit b8aa681421
5 changed files with 55 additions and 18 deletions
+41 -11
View File
@@ -1,10 +1,11 @@
#include <ESPeasySerial.h>
#define DETECT_BAUDATE_TIMEOUT 250
// ****************************************
// ESP8266 implementation wrapper
// ****************************************
#ifdef ESP8266
bool ESPeasySerial::_serial0_swap_active = false;
#endif
@@ -47,7 +48,7 @@ void ESPeasySerial::begin(unsigned long baud, SerialConfig config, SerialMode mo
if (isSWserial()) {
_swserial->begin(baud);
} else {
getHW()->begin(baud, config, mode, tx_pin);
doHWbegin(baud, config, mode, tx_pin);
}
}
@@ -216,7 +217,7 @@ bool ESPeasySerial::hasOverrun(void) {
if (!isValid()) {
return false;
}
#ifdef ARDUINO_ESP8266_RELEASE_2_4_1
#if defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1)
return false;
#else
if (isSWserial()) {
@@ -294,7 +295,9 @@ void ESPeasySerial::startDetectBaudrate() {
if (!isValid() || isSWserial()) {
return;
}
#ifndef ARDUINO_ESP8266_RELEASE_2_4_1
#if defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1)
return;
#else
getHW()->startDetectBaudrate();
#endif
}
@@ -303,10 +306,10 @@ unsigned long ESPeasySerial::testBaudrate() {
if (!isValid() || isSWserial()) {
return 0;
}
#ifndef ARDUINO_ESP8266_RELEASE_2_4_1
return getHW()->testBaudrate();
#else
#if defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1)
return 0;
#else
return getHW()->testBaudrate();
#endif
}
@@ -314,10 +317,10 @@ unsigned long ESPeasySerial::detectBaudrate(time_t timeoutMillis) {
if (!isValid() || isSWserial()) {
return 0;
}
#ifndef ARDUINO_ESP8266_RELEASE_2_4_1
return getHW()->detectBaudrate(timeoutMillis);
#else
#if defined(ARDUINO_ESP8266_RELEASE_2_4_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_1)
return 0;
#else
return getHW()->detectBaudrate(timeoutMillis);
#endif
}
@@ -356,6 +359,33 @@ bool ESPeasySerial::stopListening() {
#endif // ESP8266
#ifdef ESP8266
// ****************************************
// ESP8266 implementation wrapper
// Shared functions for HW serial
// ****************************************
bool ESPeasySerial::doHWbegin(unsigned long baud, SerialConfig config, SerialMode mode, uint8_t tx_pin) {
if (!isValid()) {
return false;
}
if (baud > 0) {
getHW()->begin(baud ? baud : 9600, config, mode, tx_pin);
return true;
}
startDetectBaudrate();
unsigned long detectedBaudRate = detectBaudrate(DETECT_BAUDATE_TIMEOUT);
if(detectedBaudRate > 0) {
delay(100); // Give some time...
getHW()->begin(detectedBaudRate, config, mode, tx_pin);
_baud = detectedBaudRate;
return true;
} else {
return false;
}
}
#endif
#if defined(DISABLE_SOFTWARE_SERIAL) && defined(ESP8266)
// ****************************************
@@ -391,7 +421,7 @@ void ESPeasySerial::begin(unsigned long baud, SerialConfig config, SerialMode mo
_baud = 0;
return;
}
getHW()->begin(baud, config, mode, tx_pin);
doHWbegin(baud, config, mode, tx_pin);
}
void ESPeasySerial::end() {
+8
View File
@@ -130,6 +130,8 @@ public:
// Serial1: RX: -- TX: 2 (TX only)
ESPeasySerial(int receivePin, int transmitPin, bool inverse_logic = false, unsigned int buffSize = 64);
virtual ~ESPeasySerial();
// If baud rate is set to 0, it will perform an auto-detect on the baudrate
void begin(unsigned long baud, SerialConfig config=SERIAL_8N1, SerialMode mode=SERIAL_FULL, uint8_t tx_pin=1);
#endif
@@ -145,6 +147,8 @@ public:
// @param serialPort can be a helper to suggest the set serial port. (is needed to define Serial1)
ESPeasySerial(int receivePin, int transmitPin, bool inverse_logic = false, int serialPort = -1);
virtual ~ESPeasySerial();
// If baud rate is set to 0, it will perform an auto-detect on the baudrate
void begin(unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1, bool invert=false, unsigned long timeout_ms = 20000UL);
#endif
@@ -216,6 +220,10 @@ private:
bool isValid() const;
#ifdef ESP8266
bool doHWbegin(unsigned long baud, SerialConfig config, SerialMode mode, uint8_t tx_pin);
#endif
#if !defined(DISABLE_SOFTWARE_SERIAL) && defined(ESP8266)
bool isSWserial() const { return _serialtype == ESPeasySerialType::serialtype::software; }
+3 -3
View File
@@ -1,14 +1,14 @@
{
"name": "ESPeasySerial",
"version": "1.0.0",
"version": "1.0.1",
"keywords": [
"serial", "io", "softwareserial", "hardwareserial"
],
"description": "Wrapper for SoftwareSerial and HardwareSerial fo ESP8266 and ESP32",
"description": "Wrapper for SoftwareSerial and HardwareSerial for ESP8266 and ESP32",
"repository":
{
"type": "git",
"url": "https://github.com/letscontrolit/espeasy"
"url": "https://github.com/TD-er/ESPEasySerial/"
},
"frameworks": "arduino",
"platforms": "espressif8266"
+1 -1
View File
@@ -1,5 +1,5 @@
name=ESPeasySerial
version=1.0
version=1.0.1
author=Gijs Noorlander
maintainer=Gijs Noorlander <gijs.noorlander@gmail.com>
sentence=Wrapper for SoftwareSerial and HardwareSerial for ESP8266 and ESP32.
+2 -3
View File
@@ -699,11 +699,10 @@ bool connectClient(WiFiClient& client, IPAddress ip, uint16_t port)
START_TIMER;
bool connected = (client.connect(ip, port) == 1);
STOP_TIMER(CONNECT_CLIENT_STATS);
#ifndef ESP32
#ifndef ARDUINO_ESP8266_RELEASE_2_3_0
#if defined(ESP32) || defined(ARDUINO_ESP8266_RELEASE_2_3_0) || defined(ARDUINO_ESP8266_RELEASE_2_4_0)
#else
if (connected)
client.keepAlive(); // Use default keep alive values
#endif
#endif
return connected;
}