Optimize Serial handling

This commit is contained in:
Robert van den Breemen 2020-11-19 16:47:10 +01:00
parent 752379e981
commit 12993f9a43
4 changed files with 36 additions and 16 deletions

View File

@ -146,26 +146,24 @@ void doTaskEvery5s(){
//===[ Do task every 30s ]===
void doTaskEvery30s(){
//== do tasks ==
DebugTf("Alive, Serial Available=[%d]\r\n", Serial.available());
}
//===[ Do task every 60s ]===
void doTaskEvery60s(){
//== do tasks ==
}
//===[ Do the background tasks ]===
void doBackgroundTasks()
{
delay(0);
delay(1);
feedWatchDog(); // Feed the dog before it bites!
blinkLEDms(1000); // 'blink' the status led every x ms
handleOTGW(); // OTGW handling
handleOTGW_2(); // OTGW handling
handleMQTT(); // MQTT transmissions
httpServer.handleClient();
MDNS.update();
events(); // trigger ezTime update etc.
blinkLEDms(1000); // 'blink' the status led every x ms
}
void loop()

View File

@ -601,15 +601,38 @@ void print_daytime(uint16_t _value, const char *_label, const char*_unit)
//=====================================[ Handle OTGW ]=====================================================
void handleOTGW_1(){
//let's try this, read all data from the serial device, and dump it to the telnet stream.
while(Serial.available() > 0)
{
feedWatchDog(); //let's make sure we don't get bit
char rIn = Serial.read();
TelnetStream.write((char)rIn);
//DebugTf("[%s] [%d]\r\n", strBuffer.c_str(), strBuffer.length());
}
}
void handleOTGW_2(){
//let's try this, read all data from the serial device, and dump it to the telnet stream.
while(Serial.available() > 0)
{
feedWatchDog(); //let's make sure we don't get bit
String strBuffer = Serial.readStringUntil('\n');
TelnetStream.write((char *)strBuffer.c_str(), strBuffer.length());
TelnetStream.write('\n');
//DebugTf("[%s] [%d]\r\n", strBuffer.c_str(), strBuffer.length());
}
}
void handleOTGW(){
//let's try this, read all data from the serial device, and dump it to the telnet stream.
while(Serial.available() > 0)
{
feedWatchDog(); //let's make sure we don't get bit
String strBuffer = Serial.readStringUntil('\n');
strBuffer.trim(); //remove LF and CR (and whitespaces)
// DebugTf("[%s] [%d]\r\n", strBuffer.c_str(), strBuffer.length());
DebugTf("[%s] [%d]\r\n", strBuffer.c_str(), strBuffer.length());
if (strBuffer.length()>=9) {
DebugTf("%s ", strBuffer.c_str());

View File

@ -75,7 +75,6 @@ homeassistant/sensor/OTGW/master_memberid_code/config , {"name": "Status", "stat
homeassistant/sensor/OTGW/slave_configuration/config , {"name": "Status", "state_topic": "OTGW/slave_configuration", "unit_of_measurement": "", "value_template": "{{ value }}" }
homeassistant/sensor/OTGW/slave_memberid_code/config , {"name": "Status", "state_topic": "OTGW/slave_configuration", "unit_of_measurement": "", "value_template": "{{ value }}" }
/master_configuration
// case MConfigMMemberIDcode: print_flag8u8(OTdata.MConfigMMemberIDcode, "Master Config / Member ID", ""); break; // flag8 / u8 Master Configuration Flags / Master MemberID Code
// case SConfigSMemberIDcode: print_flag8u8(OTdata.SConfigSMemberIDcode, "Slave Config / Member ID", ""); break; // flag8 / u8 Slave Configuration Flags / Slave MemberID Code
// case Command: print_u8u8(OTdata.Command, "Command",""); break; // u8 / u8 Remote Command

View File

@ -2,13 +2,13 @@
#define _VERSION_MAJOR 0
#define _VERSION_MINOR 2
#define _VERSION_PATCH 0
#define _VERSION_BUILD 141
#define _VERSION_BUILD 152
//#define _VERSION_PRERELEASE beta //uncomment to define prerelease labels: alpha - beta - rc
#define _VERSION_DATE "06-11-2020"
#define _VERSION_TIME "21:57:50"
#define _VERSION_DATE "19-11-2020"
#define _VERSION_TIME "16:36:57"
#define _SEMVER_CORE "0.2.0"
#define _SEMVER_BUILD "0.2.0+141"
#define _SEMVER_FULL "0.2.0+141"
#define _SEMVER_NOBUILD "0.2.0 (06-11-2020)"
#define _VERSION "0.2.0+141 (06-11-2020)"
#define _SEMVER_BUILD "0.2.0+152"
#define _SEMVER_FULL "0.2.0+152"
#define _SEMVER_NOBUILD "0.2.0 (19-11-2020)"
#define _VERSION "0.2.0+152 (19-11-2020)"
//The version information is created automatically, more information here: https://github.com/rvdbreemen/autoinc-semver