Two things...

1. Optional change delay before sending command, now can be set to 0ms for sendtime
2. Skip on parity in a different location in the code, logic fix.
This commit is contained in:
Robert van den Breemen 2023-01-28 11:09:16 +01:00
parent 89bb5ee8af
commit 36ae4b2807
4 changed files with 25 additions and 22 deletions

View File

@ -1201,7 +1201,9 @@ void print_daytime(uint16_t& value)
First it checks the queue, if the command is in the queue, it's updated.
Otherwise it's simply added to the queue, unless there are no free queue slots.
*/
void addOTWGcmdtoqueue(const char* buf, const int len, const bool force = false){
//void addOTWGcmdtoqueue(const char* buf, const int len, const bool forceQueue = false, const int16_t delay = OTGW_DELAY_SEND_MS);
void addOTWGcmdtoqueue(const char* buf, const int len, const bool forceQueue, const int16_t delay){
if ((len < 3) || (buf[2] != '=')){
//no valid command of less then 2 bytes
OTGWDebugT("CmdQueue: Error:Not a valid command=[");
@ -1214,7 +1216,7 @@ void addOTWGcmdtoqueue(const char* buf, const int len, const bool force = false)
//check to see if the cmd is in queue
bool foundcmd = false;
int8_t insertptr = cmdptr; //set insertprt to next empty slot
if (!force){
if (!forceQueue){
char cmd[2]; memset( cmd, 0, sizeof(cmd));
memcpy(cmd, buf, 2);
for (int i=0; i<cmdptr; i++){
@ -1243,7 +1245,7 @@ void addOTWGcmdtoqueue(const char* buf, const int len, const bool force = false)
memcpy(cmdqueue[insertptr].cmd, buf, cmdlen);
cmdqueue[insertptr].cmdlen = cmdlen;
cmdqueue[insertptr].retrycnt = 0;
cmdqueue[insertptr].due = millis() + OTGW_DELAY_SEND_MS; //due right away
cmdqueue[insertptr].due = millis() + delay; //due right away
//if not found
if (!foundcmd) {
@ -1488,15 +1490,16 @@ void processOT(const char *buf, int len){
bool skipthis = (delayedOTdata.id == OTdata.id) && (OTdata.time - delayedOTdata.time < 500) &&
(((OTdata.rsptype == OTGW_ANSWER_THERMOSTAT) && (delayedOTdata.rsptype == OTGW_BOILER)) ||
((OTdata.rsptype == OTGW_REQUEST_BOILER) && (delayedOTdata.rsptype == OTGW_THERMOSTAT)));
//when parity error in OTGW then skip data to MQTT nor store it local in data object
skipthis = skipthis || (OTdata.rsptype == OTGW_PARITY_ERROR);
//delay message processing by 1 message, to make sure detection of value decoding is done correctly with R and A message.
tmpOTdata = delayedOTdata; //fetch delayed msg
delayedOTdata = OTdata; //store current msg
OTdata = tmpOTdata; //then process delayed msg
OTdata.skipthis = skipthis; //skip if needed
//when parity error in OTGW then skip data to MQTT nor store it local in data object
OTdata.skipthis |= (OTdata.rsptype == OTGW_PARITY_ERROR);
//keep track of last update time of each message id
msglastupdated[OTdata.id] = now;
@ -1552,10 +1555,10 @@ void processOT(const char *buf, int len){
//OTGWDebugf("[M=%d]",OTdata.master);
if (OTdata.skipthis){
if ((OTdata.rsptype == OTGW_PARITY_ERROR)) {
if (OTdata.rsptype == OTGW_PARITY_ERROR) {
AddLog("P"); //skipped due to parity error
} else {
AddLog("-"); //skipped
AddLog("-"); //skipped due to R or A message
}
} else {

View File

@ -61,7 +61,7 @@ void setLed(int8_t, uint8_t);
//prototype
void sendMQTTData(const String, const String, const bool);
void sendMQTTData(const char*, const char*, const bool);
void addOTWGcmdtoqueue(const char* , int , const bool);
void addOTWGcmdtoqueue(const char* , int , const bool = false, const int16_t = 1000);
//Global variables
WiFiClient wifiClient;

View File

@ -178,20 +178,20 @@ void sendtimecommand(){
//Send msg id xx: hour:minute/day of week
int day_of_week = (myTime.dayOfWeek()+6)%7+1;
sprintf(msg,"SC=%d:%02d/%d", myTime.hour(), myTime.minute(), day_of_week);
addOTWGcmdtoqueue(msg, strlen(msg), true);
addOTWGcmdtoqueue(msg, strlen(msg), true, 0);
handleOTGWqueue(); //send command right away
if (dayChanged()){
//Send msg id 21: month, day
sprintf(msg,"SR=21:%d,%d", myTime.month(), myTime.day());
addOTWGcmdtoqueue(msg, strlen(msg), true);
addOTWGcmdtoqueue(msg, strlen(msg), true, 0);
handleOTGWqueue(); //send command right away
}
if (yearChanged()){
//Send msg id 22: HB of Year, LB of Year
sprintf(msg,"SR=22:%d,%d", (myTime.year() >> 8) & 0xFF, myTime.year() & 0xFF);
addOTWGcmdtoqueue(msg, strlen(msg), true);
addOTWGcmdtoqueue(msg, strlen(msg), true, 0);
handleOTGWqueue(); //send command right away
}
}

View File

@ -2,15 +2,15 @@
#define _VERSION_MAJOR 0
#define _VERSION_MINOR 10
#define _VERSION_PATCH 0
#define _VERSION_BUILD 1981
#define _VERSION_GITHASH "828ebb3"
#define _VERSION_PRERELEASE rc1
#define _VERSION_DATE "26-01-2023"
#define _VERSION_TIME "21:18:11"
#define _VERSION_BUILD 1998
#define _VERSION_GITHASH "89bb5ee"
#define _VERSION_PRERELEASE rc3
#define _VERSION_DATE "28-01-2023"
#define _VERSION_TIME "11:07:51"
#define _SEMVER_CORE "0.10.0"
#define _SEMVER_BUILD "0.10.0+1981"
#define _SEMVER_GITHASH "0.10.0+828ebb3"
#define _SEMVER_FULL "0.10.0-rc1+828ebb3"
#define _SEMVER_NOBUILD "0.10.0-rc1 (26-01-2023)"
#define _VERSION "0.10.0-rc1+828ebb3 (26-01-2023)"
#define _SEMVER_BUILD "0.10.0+1998"
#define _SEMVER_GITHASH "0.10.0+89bb5ee"
#define _SEMVER_FULL "0.10.0-rc3+89bb5ee"
#define _SEMVER_NOBUILD "0.10.0-rc3 (28-01-2023)"
#define _VERSION "0.10.0-rc3+89bb5ee (28-01-2023)"
//The version information is created automatically, more information here: https://github.com/rvdbreemen/autoinc-semver