Skip to content

Commit

Permalink
Patch transparant
Browse files Browse the repository at this point in the history
  • Loading branch information
rvdbreemen committed Jan 18, 2023
1 parent 829235a commit 3a1011c
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
32 changes: 10 additions & 22 deletions OTGW-Core.ino
Expand Up @@ -1783,35 +1783,23 @@ void handleOTGW()
DebugT(F("Serial Rx Error\r\n"));
}
size_t bytes_available = OTGWSerial.available();
if(bytes_available > 0) {
OTGWSerial.setTimeout(1000);//never more then 1 second blocking
bytes_read = OTGWSerial.readBytesUntil('\n', sRead, sizeof(sRead));
if (bytes_read>0) {
sRead[strcspn(sRead, "\r\n")] = 0; // works for LF, CR, CRLF, LFCR, ...
bytes_read = strlen(sRead);
//OTGWDebugTf(PSTR("Read from OTGW: (%s) [%d]\r\n"), sRead, bytes_read);
while (OTGWSerial.available()) {
outByte = OTGWSerial.read();
OTGWstream.write(outByte);
if (outByte == '\r' || outByte == '\n') {
if (bytes_read == 0) continue;
blinkLEDnow(LED2);
//uint32_t tmr=micros(); //profiling code
sRead[bytes_read] = '\0';
processOT(sRead, bytes_read);
//tmr=micros()-tmr;
//DebugTf(PSTR("processOTGW: (MsdID, Type, time_us) = %3d, %-16s, %6d\r\n"), OTdata.id, messageTypeToString(static_cast<OpenThermMessageType>(OTdata.type)), tmr);
//make sure it ends with a newline
OTGWstream.write(sRead, bytes_read);
OTGWstream.write('\r');
OTGWstream.write('\n');
}
bytes_read = 0;
} else if (bytes_read < (MAX_BUFFER_READ-1))
sRead[bytes_read++] = outByte;
}

//handle incoming data from network (port 25238) sent to serial port OTGW (WRITE BUFFER)
while (OTGWstream.available()){
//OTGWSerial.write(OTGWstream.read()); //just forward it directly to Serial
outByte = OTGWstream.read(); // read from port 25238
// while (OTGWSerial.availableForWrite()==0) {
// //cannot write, buffer full, wait for some space in serial out buffer
// feedWatchDog(); //this yields for other processes
// }
OTGWSerial.write(outByte); // write to serial port
//OTGWSerial.flush(); // wait for write to serial
OTGWSerial.write(outByte); // write to serial port
if (outByte == '\r')
{ //on CR, do something...
sWrite[bytes_write] = 0;
Expand Down
14 changes: 14 additions & 0 deletions handleDebug.ino
Expand Up @@ -13,8 +13,22 @@ void handleDebug(){
Debugln(F("q) Force read settings"));
Debugln(F("m) Force MQTT discovery"));
Debugln(F("r) Reconnect wifi, telnet, otgwstream and mqtt"));
Debugln(F("p) Reset PIC manually"));
Debugln(F("a) Send PR=A command to ID PIC firmware version and type"));
Debugln();
break;
case 'p':
DebugTln(F("Manual reset PIC"));
resetOTGW();
break;
case 'a':
DebugTln(F("Send PR=A command, to ID the chip"));
getpicfwversion();
sPICfwversion = OTGWSerial.firmwareToString();
OTGWDebugTf(PSTR("Current firmware version: %s\r\n"), CSTR(sPICfwversion));
sPICdeviceid = OTGWSerial.processorToString();
OTGWDebugTf(PSTR("Current device id: %s\r\n"), CSTR(sPICdeviceid));
break;
case 'q':
DebugTln(F("Read settings"));
readSettings(true);
Expand Down
18 changes: 9 additions & 9 deletions version.h
Expand Up @@ -2,15 +2,15 @@
#define _VERSION_MAJOR 0
#define _VERSION_MINOR 9
#define _VERSION_PATCH 6
#define _VERSION_BUILD 1869
#define _VERSION_GITHASH "94d5cbf"
#define _VERSION_BUILD 1872
#define _VERSION_GITHASH "829235a"
#define _VERSION_PRERELEASE beta
#define _VERSION_DATE "16-01-2023"
#define _VERSION_TIME "23:40:09"
#define _VERSION_DATE "18-01-2023"
#define _VERSION_TIME "23:43:25"
#define _SEMVER_CORE "0.9.6"
#define _SEMVER_BUILD "0.9.6+1869"
#define _SEMVER_GITHASH "0.9.6+94d5cbf"
#define _SEMVER_FULL "0.9.6-beta+94d5cbf"
#define _SEMVER_NOBUILD "0.9.6-beta (16-01-2023)"
#define _VERSION "0.9.6-beta+94d5cbf (16-01-2023)"
#define _SEMVER_BUILD "0.9.6+1872"
#define _SEMVER_GITHASH "0.9.6+829235a"
#define _SEMVER_FULL "0.9.6-beta+829235a"
#define _SEMVER_NOBUILD "0.9.6-beta (18-01-2023)"
#define _VERSION "0.9.6-beta+829235a (18-01-2023)"
//The version information is created automatically, more information here: https://github.com/rvdbreemen/autoinc-semver

0 comments on commit 3a1011c

Please sign in to comment.