Skip to content

Commit

Permalink
add valve moves
Browse files Browse the repository at this point in the history
  • Loading branch information
SurfGargano committed Aug 1, 2023
1 parent 79d3fe8 commit c224cd1
Show file tree
Hide file tree
Showing 10 changed files with 1,804 additions and 1,778 deletions.
3 changes: 3 additions & 0 deletions software_esp32/include/stmApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ typedef struct {
int temp2; // temperature of 2nd assigned sensor
uint8_t lastState;
bool worked;
uint32_t movements;
} ACTUATOR_STRUC;

typedef struct {
Expand Down Expand Up @@ -221,13 +222,15 @@ class CStmApp
char arg3[30];
char arg4[30];
char arg5[30];
char arg6[30];

char* arg0ptr;
char* arg1ptr;
char* arg2ptr;
char* arg3ptr;
char* arg4ptr;
char* arg5ptr;
char* arg6ptr;

uint8_t argcnt;

Expand Down
4 changes: 2 additions & 2 deletions software_esp32/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
; https://docs.platformio.org/page/projectconf.html

[common]
firmware_version = '"1.2.1"'
firmware_version_dev = '"1.2.1_Dev"'
firmware_version = '"1.2.2"'
firmware_version_dev = '"1.2.2_Dev"'

[env]
platform = espressif32
Expand Down
28 changes: 16 additions & 12 deletions software_esp32/src/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,20 +484,24 @@ void CMqtt::publish_valves () {
lastValveValues[x].meanCurrent=StmApp.actuators[x].meancurrent;
}
// temperature 1st sensor
if ((lastValveValues[x].temp1!=StmApp.actuators[x].temp1) || forcePublish || lastValveValues[x].publishTimeOut) {
topicstr[len] = '\0';
strncat(topicstr, "/temp1",sizeof(topicstr) - strlen (topicstr) - 1);
String s = String(((float)StmApp.actuators[x].temp1)/10,1);
mqtt_client.publish(topicstr, (const char*) &s);
lastValveValues[x].temp1=StmApp.actuators[x].temp1;
if (StmApp.actuators[x].temp1>-50) {
if ((lastValveValues[x].temp1!=StmApp.actuators[x].temp1) || forcePublish || lastValveValues[x].publishTimeOut) {
topicstr[len] = '\0';
strncat(topicstr, "/temp1",sizeof(topicstr) - strlen (topicstr) - 1);
String s = String(((float)StmApp.actuators[x].temp1)/10,1);
mqtt_client.publish(topicstr, (const char*) &s);
lastValveValues[x].temp1=StmApp.actuators[x].temp1;
}
}
// temperature 2nd sensor
if ((lastValveValues[x].temp2!=StmApp.actuators[x].temp2) || forcePublish || lastValveValues[x].publishTimeOut) {
topicstr[len] = '\0';
strncat(topicstr, "/temp2",sizeof(topicstr) - strlen (topicstr) - 1);
String s = String(((float)StmApp.actuators[x].temp2)/10,1);
mqtt_client.publish(topicstr, (const char*) &s);
lastValveValues[x].temp2=StmApp.actuators[x].temp2;
if (StmApp.actuators[x].temp2>-50) {
if ((lastValveValues[x].temp2!=StmApp.actuators[x].temp2) || forcePublish || lastValveValues[x].publishTimeOut) {
topicstr[len] = '\0';
strncat(topicstr, "/temp2",sizeof(topicstr) - strlen (topicstr) - 1);
String s = String(((float)StmApp.actuators[x].temp2)/10,1);
mqtt_client.publish(topicstr, (const char*) &s);
lastValveValues[x].temp2=StmApp.actuators[x].temp2;
}
}
lastValveValues[x].publishNow=false;
lastValveValues[x].publishTimeOut=false;
Expand Down
13 changes: 11 additions & 2 deletions software_esp32/src/stmApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ CStmApp::CStmApp()
arg3ptr = arg3;
arg4ptr = arg4;
arg5ptr = arg5;
arg6ptr = arg6;
argcnt = 0;
tempsPrivCount=0;
tempsCount=0;
Expand Down Expand Up @@ -433,7 +434,7 @@ void CStmApp::app_check_data()
// ****************************************
cmdptr = buffer;

for(int x=0;x<7;x++) {
for(int x=0;x<8;x++) {
cmdptrend = strchr(cmdptr,' ');
if (cmdptrend!=NULL) {
*cmdptrend = '\0';
Expand Down Expand Up @@ -469,6 +470,11 @@ void CStmApp::app_check_data()
strncpy(arg5,cmdptr,sizeof(arg5)-1);
argcnt=6;
} // 6th argument
else if(x==7) {
memset (arg6,0x0,sizeof(arg6));
strncpy(arg6,cmdptr,sizeof(arg6)-1);
argcnt=7;
} // 7th argument
cmdptr = cmdptrend + 1;
}
}
Expand Down Expand Up @@ -540,14 +546,17 @@ void CStmApp::app_check_data()
// get data values
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
else if(memcmp(APP_PRE_GETVLVDATA,cmd,5) == 0) {
if(argcnt == 6) {
if(argcnt >= 6) {
uint8_t idx=atoi(arg0ptr);
if(idx < ACTUATOR_COUNT) {
actuators[idx].actual_position = atoi(arg1ptr);
actuators[idx].meancurrent = atoi(arg2ptr);
actuators[idx].state = atoi(arg3ptr);
actuators[idx].temp1 = ConvertCF(atoi(arg4ptr))+getTOffset(actuators[idx].tIdx1);
actuators[idx].temp2 = ConvertCF(atoi(arg5ptr))+getTOffset(actuators[idx].tIdx2);
if (argcnt == 7) {
actuators[idx].movements = atoi(arg6ptr);
}

if (VdmConfig.configFlash.netConfig.syslogLevel>=VISMODE_DETAIL) {
syslog.log(LOG_DEBUG, "STMApp:got valve data #"+String(arg0ptr)+" pos:"+String(arg1ptr)+
Expand Down
Loading

0 comments on commit c224cd1

Please sign in to comment.