mirror of
https://github.com/rvdbreemen/OTGW-firmware
synced 2024-10-02 23:47:18 +02:00
Fix few remaining warnings.
restAPI.ino the move of the readAnything needs to be checked.
This commit is contained in:
parent
05da9a17f1
commit
b232cbe1e2
@ -143,7 +143,7 @@ String executeCommand(const String sCmd){
|
||||
OTGWDebugTf("OTGW Send Cmd [%s]\r\n", CSTR(sCmd));
|
||||
OTGWSerial.setTimeout(1000);
|
||||
DECLARE_TIMER_MS(tmrWaitForIt, 1000);
|
||||
while((OTGWSerial.availableForWrite() < sCmd.length()+2) && !DUE(tmrWaitForIt)){
|
||||
while((OTGWSerial.availableForWrite() < (int)(sCmd.length()+2)) && !DUE(tmrWaitForIt)){
|
||||
feedWatchDog();
|
||||
}
|
||||
OTGWSerial.write(CSTR(sCmd));
|
||||
@ -1231,10 +1231,10 @@ void handleOTGWqueue(){
|
||||
Then checks if incoming response matches what was to be set.
|
||||
Only then it's deleted from the queue.
|
||||
*/
|
||||
void checkOTGWcmdqueue(const char *buf, int len){
|
||||
void checkOTGWcmdqueue(const char *buf, unsigned int len){
|
||||
if ((len<3) || (buf[2]!=':')) {
|
||||
OTGWDebugT("CmdQueue: Error: Not a command response [");
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (unsigned int i = 0; i < len; i++) {
|
||||
OTGWDebug((char)buf[i]);
|
||||
}
|
||||
OTGWDebugf("] (%d)\r\n", len);
|
||||
@ -1242,7 +1242,7 @@ void checkOTGWcmdqueue(const char *buf, int len){
|
||||
}
|
||||
|
||||
OTGWDebugT("CmdQueue: Checking if command is in in queue [");
|
||||
for (int i = 0; i < len; i++) {
|
||||
for (unsigned int i = 0; i < len; i++) {
|
||||
OTGWDebug((char)buf[i]);
|
||||
}
|
||||
OTGWDebugf("] (%d)\r\n", len);
|
||||
@ -1250,7 +1250,7 @@ void checkOTGWcmdqueue(const char *buf, int len){
|
||||
char cmd[3]; memset( cmd, 0, sizeof(cmd));
|
||||
char value[11]; memset( value, 0, sizeof(value));
|
||||
memcpy(cmd, buf, 2);
|
||||
memcpy(value, buf+3, (len-3<sizeof(value)-1)?(len-3):(sizeof(value)-1));
|
||||
memcpy(value, buf+3, ((len-3)<(sizeof(value)-1))?(len-3):(sizeof(value)-1));
|
||||
for (int i=0; i<cmdptr; i++){
|
||||
OTGWDebugTf("CmdQueue: Checking [%2s]==>[%d]:[%s] from queue\r\n", cmd, i, cmdqueue[i].cmd);
|
||||
if (strstr(cmdqueue[i].cmd, cmd)){
|
||||
@ -1326,8 +1326,8 @@ bool isvalidotmsg(const char *buf, int len){
|
||||
- ...
|
||||
*/
|
||||
void processOT(const char *buf, int len){
|
||||
static unsigned long epochBoilerlastseen = 0;
|
||||
static unsigned long epochThermostatlastseen = 0;
|
||||
static time_t epochBoilerlastseen = 0;
|
||||
static time_t epochThermostatlastseen = 0;
|
||||
static bool bOTGWboilerpreviousstate = false;
|
||||
static bool bOTGWthermostatpreviousstate = false;
|
||||
static bool bOTGWpreviousstate = false;
|
||||
|
@ -34,7 +34,7 @@
|
||||
|
||||
#define PICFIRMWARE "/gateway.hex"
|
||||
|
||||
extern OTGWSerial OTGWSerial(PICRST, LED2);
|
||||
OTGWSerial OTGWSerial(PICRST, LED2);
|
||||
void fwupgradestart(const char *hexfile);
|
||||
|
||||
void blinkLEDnow();
|
||||
|
@ -35,7 +35,7 @@ void setOutputState(uint8_t status = ON){
|
||||
|
||||
void setOutputState(bool set_HIGH = true){
|
||||
if(!settingGPIOOUTPUTSenabled) return;
|
||||
digitalWrite(settingGPIOOUTPUTSpin,ON);
|
||||
digitalWrite(settingGPIOOUTPUTSpin,set_HIGH?HIGH:LOW);
|
||||
DebugTf("Output GPIO%d set to %d", settingGPIOOUTPUTSpin, digitalRead(settingGPIOOUTPUTSpin));
|
||||
}
|
||||
|
||||
|
20
restAPI.ino
20
restAPI.ino
@ -42,12 +42,12 @@ void processAPI()
|
||||
return;
|
||||
}
|
||||
|
||||
int8_t wc = splitString(URI, '/', words, 10);
|
||||
uint8_t wc = splitString(URI, '/', words, 10);
|
||||
|
||||
if (bDebugRestAPI)
|
||||
{
|
||||
DebugT(">>");
|
||||
for (int w=0; w<wc; w++)
|
||||
for (uint_fast8_t w=0; w<wc; w++)
|
||||
{
|
||||
Debugf("word[%d] => [%s], ", w, words[w].c_str());
|
||||
}
|
||||
@ -178,9 +178,9 @@ void sendOTGWvalue(int msgid){
|
||||
void sendOTGWlabel(const char *msglabel){
|
||||
StaticJsonDocument<256> doc;
|
||||
JsonObject root = doc.to<JsonObject>();
|
||||
int msgid;
|
||||
PROGMEM_readAnything (&OTmap[msgid], OTlookupitem);
|
||||
uint_fast8_t msgid;
|
||||
for (msgid = 0; msgid<= OT_MSGID_MAX; msgid++){
|
||||
PROGMEM_readAnything (&OTmap[msgid], OTlookupitem);
|
||||
if (stricmp(OTlookupitem.label, msglabel)==0) break;
|
||||
}
|
||||
if (msgid > OT_MSGID_MAX){
|
||||
@ -449,14 +449,16 @@ void postSettings()
|
||||
jsonIn.replace("{", "");
|
||||
jsonIn.replace("}", "");
|
||||
jsonIn.replace("\"", "");
|
||||
int8_t wp = splitString(jsonIn.c_str(), ',', wPair, 5) ;
|
||||
for (int i=0; i<wp; i++)
|
||||
uint_fast8_t wp = splitString(jsonIn.c_str(), ',', wPair, 5) ;
|
||||
for (uint_fast8_t i=0; i<wp; i++)
|
||||
{
|
||||
//RESTDebugTf("[%d] -> pair[%s]\r\n", i, wPair[i].c_str());
|
||||
int8_t wc = splitString(wPair[i].c_str(), ':', wOut, 5) ;
|
||||
uint8_t wc = splitString(wPair[i].c_str(), ':', wOut, 5) ;
|
||||
//RESTDebugTf("==> [%s] -> field[%s]->val[%s]\r\n", wPair[i].c_str(), wOut[0].c_str(), wOut[1].c_str());
|
||||
if (wOut[0].equalsIgnoreCase("name")) strCopy(field, sizeof(field), wOut[1].c_str());
|
||||
if (wOut[0].equalsIgnoreCase("value")) strCopy(newValue, sizeof(newValue), wOut[1].c_str());
|
||||
if (wc>1) {
|
||||
if (wOut[0].equalsIgnoreCase("name")) strCopy(field, sizeof(field), wOut[1].c_str());
|
||||
if (wOut[0].equalsIgnoreCase("value")) strCopy(newValue, sizeof(newValue), wOut[1].c_str());
|
||||
}
|
||||
}
|
||||
RESTDebugTf("--> field[%s] => newValue[%s]\r\n", field, newValue);
|
||||
updateSetting(field, newValue);
|
||||
|
Loading…
Reference in New Issue
Block a user