fix flash_64kb error. debugSerial in Item.cpp

This commit is contained in:
livello
2018-11-07 13:49:30 +03:00
parent 9ea9ad8698
commit 23f2e60079
3 changed files with 15 additions and 31 deletions

View File

@@ -81,20 +81,10 @@ void Item::Parse() {
for (int i = aJson.getArraySize(itemArr); i < 4; i++)
aJson.addItemToArray(itemArr, aJson.createItem(
int(defval[i]))); //Enlarge item to 4 elements. VAL=int if no other definition in conf
itemType = aJson.getArrayItem(itemArr, I_TYPE)->valueint;
itemArg = aJson.getArrayItem(itemArr, I_ARG);
itemVal = aJson.getArrayItem(itemArr, I_VAL);
/*
Serial.print(F(" Item:"));
Serial.print(itemArr->name);
Serial.print(F(" T:"));
Serial.print(itemType);
Serial.print(F(" ="));
Serial.println(getArg());
*/
debugSerial << (F(" Item:") << itemArr->name << F(" T:") << itemType << F(" =") << getArg() << eol;
}
}
@@ -117,13 +107,12 @@ uint8_t Item::getCmd(bool ext) {
}
void Item::setCmd(uint8_t cmd) {
aJsonObject *t = aJson.getArrayItem(itemArr, I_CMD);
if (t)
void Item::setCmd(uint8_t cmdValue) {
aJsonObject *itemCmd = aJson.getArrayItem(itemArr, I_CMD);
if (itemCmd)
{
t->valueint = cmd;
Serial.print(F("SetCmd:"));
Serial.println(cmd);
itemCmd->valueint = cmdValue;
debugSerial<<F("SetCmd:")<<cmdValue<<eol;
}
}
@@ -176,9 +165,7 @@ void Item::setVal(short n, int par) // Only store if VAL is array defined in c
void Item::setVal(long int par) // Only store if VAL is int (autogenerated or config-defined)
{
if (!itemVal || itemVal->type != aJson_Int) return;
// Serial.print(F(" Store "));
// Serial.print(F(" Val="));
// Serial.println(par);
debugSerial<<F(" Store ")<<F(" Val=")<<par<<eol;
itemVal->valueint = par;
}
@@ -262,7 +249,7 @@ int Item::Ctrl(char * payload, boolean send){
int Item::Ctrl(short cmd, short n, int *Parameters, boolean send) {
Serial.print(F("Cmd="));Serial.print(cmd);Serial.print(F(" MEM="));Serial.println(freeRam());
debugSerial<<F("Cmd=")<<cmd<<F(" MEM=")<<freeRam()<<eol;
int Par[MAXCTRLPAR] = {0, 0, 0};
if (Parameters)
@@ -1238,7 +1225,7 @@ int Item::SendStatus(short cmd, short n, int *Par, boolean deffered) {
int chancmd=getCmd(true);
if (deffered) {
setCmd(chancmd | CMD_REPORT);
Serial.println(F("Status deffered"));
debugSerial<<F("Status deffered\n");
// mqttClient.publish("/push", "1");
return 0;
// Todo: Parameters? Now expected that parameters already stored by setVal()
@@ -1267,10 +1254,11 @@ int Item::SendStatus(short cmd, short n, int *Par, boolean deffered) {
if (Par)
for (short i = 0; i < n; i++) {
char num[4];
#ifndef FLASH_64KB
#ifndef FLASH_64KB
snprintf(num, sizeof(num), "%d", Par[i]);
#endif
#else
itoa(Par[i],num,10);
#endif
strncat(valstr, num, sizeof(valstr));
if (i != n - 1) {
strcpy(num, ",");
@@ -1279,13 +1267,10 @@ int Item::SendStatus(short cmd, short n, int *Par, boolean deffered) {
}
break;
default:
Serial.println(F("Unknown cmd "));
debugSerial<<F("Unknown cmd \n");
return -1;
}
Serial.print(F("Pub: "));
Serial.print(addrstr);
Serial.print(F("->"));
Serial.println(valstr);
debugSerial<<F("Pub: ")<<addrstr<<F("->")<<valstr<<eol;
mqttClient.publish(addrstr, valstr,true);
return 0;
}

View File

@@ -112,7 +112,7 @@ class Item
//int getVal(short n); //From VAL array. Negative if no array
long int getVal(); //From int val OR array
uint8_t getCmd(bool ext = false);
void setCmd(uint8_t cmd);
void setCmd(uint8_t cmdValue);
//void setVal(uint8_t n, int par);
void setVal(long int par);
//void copyPar (aJsonObject *itemV);

View File

@@ -246,7 +246,6 @@ lib_deps =
Streaming
https://github.com/livello/PrintEx#is-select-redecl
;TODO:STM32 compilation problems
[env:stm32]
platform = ststm32
framework = arduino