mirror of
https://github.com/anklimov/lighthub
synced 2026-09-13 05:34:17 +00:00
core fixes, modbus, ac, pre-mapping, bins
This commit is contained in:
Generated
-8
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="MarkdownExportedFiles">
|
|
||||||
<htmlFiles />
|
|
||||||
<imageFiles />
|
|
||||||
<otherFiles />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
-67
@@ -1,67 +0,0 @@
|
|||||||
# Continuous Integration (CI) is the practice, in software
|
|
||||||
# engineering, of merging all developer working copies with a shared mainline
|
|
||||||
# several times a day < http://docs.platformio.org/page/ci/index.html >
|
|
||||||
#
|
|
||||||
# Documentation:
|
|
||||||
#
|
|
||||||
# * Travis CI Embedded Builds with PlatformIO
|
|
||||||
# < https://docs.travis-ci.com/user/integration/platformio/ >
|
|
||||||
#
|
|
||||||
# * PlatformIO integration with Travis CI
|
|
||||||
# < http://docs.platformio.org/page/ci/travis.html >
|
|
||||||
#
|
|
||||||
# * User Guide for `platformio ci` command
|
|
||||||
# < http://docs.platformio.org/page/userguide/cmd_ci.html >
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Please choice one of the following templates (proposed below) and uncomment
|
|
||||||
# it (remove "# " before each line) or use own configuration according to the
|
|
||||||
# Travis CI documentation (see above).
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #1: General project. Test it using existing `platformio.ini`.
|
|
||||||
#
|
|
||||||
|
|
||||||
# language: python
|
|
||||||
# python:
|
|
||||||
# - "2.7"
|
|
||||||
#
|
|
||||||
# sudo: false
|
|
||||||
# cache:
|
|
||||||
# directories:
|
|
||||||
# - "~/.platformio"
|
|
||||||
#
|
|
||||||
# install:
|
|
||||||
# - pip install -U platformio
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio run
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Template #2: The project is intended to by used as a library with examples
|
|
||||||
#
|
|
||||||
|
|
||||||
# language: python
|
|
||||||
# python:
|
|
||||||
# - "2.7"
|
|
||||||
#
|
|
||||||
# sudo: false
|
|
||||||
# cache:
|
|
||||||
# directories:
|
|
||||||
# - "~/.platformio"
|
|
||||||
#
|
|
||||||
# env:
|
|
||||||
# - PLATFORMIO_CI_SRC=path/to/test/file.c
|
|
||||||
# - PLATFORMIO_CI_SRC=examples/file.ino
|
|
||||||
# - PLATFORMIO_CI_SRC=path/to/test/directory
|
|
||||||
#
|
|
||||||
# install:
|
|
||||||
# - pip install -U platformio
|
|
||||||
# - platformio update
|
|
||||||
#
|
|
||||||
# script:
|
|
||||||
# - platformio ci --lib="." --board=ID_1 --board=ID_2 --board=ID_N
|
|
||||||
Binary file not shown.
+7094
-6945
File diff suppressed because it is too large
Load Diff
+8865
-8468
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
+8436
-8115
File diff suppressed because it is too large
Load Diff
+8208
-7869
File diff suppressed because it is too large
Load Diff
Binary file not shown.
+6568
-6425
File diff suppressed because it is too large
Load Diff
+6356
-5989
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
+16
-12
@@ -280,7 +280,7 @@ Item::Item(char *name) //Constructor
|
|||||||
buf[i]=0;
|
buf[i]=0;
|
||||||
itemArr = aJson.getObjectItem(items, buf);
|
itemArr = aJson.getObjectItem(items, buf);
|
||||||
sub++;
|
sub++;
|
||||||
strncpy(defaultSubItem,sub,sizeof(defaultSubItem));
|
strncpy(defaultSubItem,sub,sizeof(defaultSubItem)-1);
|
||||||
defaultSuffixCode = retrieveCode (&pDefaultSubItem);
|
defaultSuffixCode = retrieveCode (&pDefaultSubItem);
|
||||||
if (!pDefaultSubItem) defaultSubItem[0] =0; //Zero string
|
if (!pDefaultSubItem) defaultSubItem[0] =0; //Zero string
|
||||||
//debugSerial<<F("defaultSubItem: ")<<defaultSubItem<<F(" defaultSuffixCode:")<<defaultSuffixCode<<endl;
|
//debugSerial<<F("defaultSubItem: ")<<defaultSubItem<<F(" defaultSuffixCode:")<<defaultSuffixCode<<endl;
|
||||||
@@ -761,7 +761,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion)
|
|||||||
|
|
||||||
int fr = freeRam();
|
int fr = freeRam();
|
||||||
|
|
||||||
debugSerial<<F("RAM=")<<fr<<F(" Item=")<<itemArr->name<<F(" Sub=")<<subItem<<F(" Cmd:");
|
debugSerial<<F("RAM=")<<fr<<F(" Item=")<<itemArr->name<<F(" Sub=")<<subItem<<F(" ");
|
||||||
if (fr < 200)
|
if (fr < 200)
|
||||||
{
|
{
|
||||||
errorSerial<<F("OutOfMemory!\n")<<endl;
|
errorSerial<<F("OutOfMemory!\n")<<endl;
|
||||||
@@ -1281,6 +1281,15 @@ int Item::isActive() {
|
|||||||
}
|
}
|
||||||
int cmd = getCmd();
|
int cmd = getCmd();
|
||||||
|
|
||||||
|
if (driver) {
|
||||||
|
short active = driver->isActive();
|
||||||
|
if (active >= 0)
|
||||||
|
{
|
||||||
|
printActiveStatus(active);
|
||||||
|
return active;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// No driver - check command
|
||||||
|
|
||||||
if (itemType != CH_GROUP)
|
if (itemType != CH_GROUP)
|
||||||
// Simple check last command first
|
// Simple check last command first
|
||||||
@@ -1300,12 +1309,7 @@ int Item::isActive() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Last time was not a command but parameters set. Looking inside
|
// Last time was not a command but parameters set. Looking inside
|
||||||
if (driver) {
|
|
||||||
bool active = driver->isActive();
|
|
||||||
printActiveStatus(active);
|
|
||||||
return active;
|
|
||||||
}
|
|
||||||
// No driver - check value
|
|
||||||
st.loadItem(this);
|
st.loadItem(this);
|
||||||
|
|
||||||
switch (itemType) {
|
switch (itemType) {
|
||||||
@@ -1431,7 +1435,7 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
{
|
{
|
||||||
char addrstr[48];
|
char addrstr[48];
|
||||||
char valstr[20] = "";
|
char valstr[20] = "";
|
||||||
char cmdstr[8] = "";
|
char cmdstr[9] = "";
|
||||||
st.debugOut();
|
st.debugOut();
|
||||||
if (sendFlags & SEND_COMMAND)
|
if (sendFlags & SEND_COMMAND)
|
||||||
{
|
{
|
||||||
@@ -1571,11 +1575,11 @@ int Item::SendStatus(int sendFlags) {
|
|||||||
strncat(addrstr, itemArr->name, sizeof(addrstr)-1);
|
strncat(addrstr, itemArr->name, sizeof(addrstr)-1);
|
||||||
if (subItem)
|
if (subItem)
|
||||||
{
|
{
|
||||||
strncat(addrstr, "/", sizeof(addrstr));
|
strncat(addrstr, "/", sizeof(addrstr)-1);
|
||||||
strncat(addrstr, subItem, sizeof(addrstr)-1);
|
strncat(addrstr, subItem, sizeof(addrstr)-1);
|
||||||
}
|
}
|
||||||
strncat(addrstr, "/", sizeof(addrstr));
|
strncat(addrstr, "/", sizeof(addrstr)-1);
|
||||||
strncat_P(addrstr, CMD_P, sizeof(addrstr));
|
strncat_P(addrstr, CMD_P, sizeof(addrstr)-1);
|
||||||
|
|
||||||
debugSerial<<F("Pub: ")<<addrstr<<F("->")<<cmdstr<<endl;
|
debugSerial<<F("Pub: ")<<addrstr<<F("->")<<cmdstr<<endl;
|
||||||
if (mqttClient.connected() && !ethernetIdleCount)
|
if (mqttClient.connected() && !ethernetIdleCount)
|
||||||
|
|||||||
+1
-1
@@ -168,7 +168,7 @@ class Item
|
|||||||
|
|
||||||
|
|
||||||
int checkFM();
|
int checkFM();
|
||||||
char defaultSubItem[10];
|
char defaultSubItem[16];
|
||||||
int defaultSuffixCode;
|
int defaultSuffixCode;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
+28
-4
@@ -1129,15 +1129,39 @@ return false;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int itemCmd::doMapping(aJsonObject *mappingData)
|
itemCmd itemCmd::doMapping(aJsonObject *mappingData)
|
||||||
{
|
{
|
||||||
|
if (isCommand())
|
||||||
|
{
|
||||||
|
switch (getCmd())
|
||||||
|
{
|
||||||
|
case CMD_AUTO:
|
||||||
|
case CMD_ON:
|
||||||
|
return itemCmd().Int((uint32_t)3);
|
||||||
|
case CMD_OFF:
|
||||||
|
return itemCmd().Int((uint32_t)0);
|
||||||
|
case CMD_FAN:
|
||||||
|
return itemCmd().Int((uint32_t)1);
|
||||||
|
case CMD_HEAT:
|
||||||
|
return itemCmd().Int((uint32_t)2);
|
||||||
|
|
||||||
return 0;
|
case CMD_LOW:
|
||||||
|
return itemCmd().Int((uint32_t)10);
|
||||||
|
case CMD_MED:
|
||||||
|
return itemCmd().Int((uint32_t)128);
|
||||||
|
case CMD_HIGH:
|
||||||
|
return itemCmd().Int((uint32_t)255);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return itemCmd().Int((uint32_t)0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
}
|
}
|
||||||
int itemCmd::doReverseMapping (aJsonObject *mappingData)
|
itemCmd itemCmd::doReverseMapping (aJsonObject *mappingData)
|
||||||
|
|
||||||
{
|
{
|
||||||
return 0;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
int itemCmd::doMappingCmd(aJsonObject *mappingData)
|
int itemCmd::doMappingCmd(aJsonObject *mappingData)
|
||||||
|
|||||||
+2
-2
@@ -220,8 +220,8 @@ public:
|
|||||||
itemCmd setChanType(short chanType);
|
itemCmd setChanType(short chanType);
|
||||||
void debugOut();
|
void debugOut();
|
||||||
|
|
||||||
int doMapping(aJsonObject *mappingData);
|
itemCmd doMapping(aJsonObject *mappingData);
|
||||||
int doReverseMapping (aJsonObject *mappingData);
|
itemCmd doReverseMapping (aJsonObject *mappingData);
|
||||||
int doMappingCmd(aJsonObject *mappingData);
|
int doMappingCmd(aJsonObject *mappingData);
|
||||||
int doReverseMappingCmd (aJsonObject *mappingData);
|
int doReverseMappingCmd (aJsonObject *mappingData);
|
||||||
bool scale100();
|
bool scale100();
|
||||||
|
|||||||
@@ -186,11 +186,11 @@ byte getCRC(byte req[], size_t size){
|
|||||||
return crc;
|
return crc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendData(byte req[], size_t size){
|
void out_AC::SendData(byte req[], size_t size){
|
||||||
AC_Serial.write(req, size - 1);
|
AC_Serial.write(req, size - 1);
|
||||||
AC_Serial.write(getCRC(req, size-1));
|
AC_Serial.write(getCRC(req, size-1));
|
||||||
//AC_Serial.flush();
|
//AC_Serial.flush();
|
||||||
|
item->setExt(millisNZ());
|
||||||
debugSerial.print("AirCon<<");
|
debugSerial.print("AirCon<<");
|
||||||
for (int i=0; i < size-1; i++)
|
for (int i=0; i < size-1; i++)
|
||||||
{
|
{
|
||||||
@@ -485,9 +485,12 @@ int out_AC::Ctrl(itemCmd cmd, char* subItem , bool toExecute)
|
|||||||
data[10] = 77;
|
data[10] = 77;
|
||||||
data[11] = 95;
|
data[11] = 95;
|
||||||
AC_Serial.flush();
|
AC_Serial.flush();
|
||||||
|
uint32_t ts=item->getExt();
|
||||||
|
while (ts && !isTimeOver(ts,millis(),100)) yield();
|
||||||
SendData(data, sizeof(data)/sizeof(byte));
|
SendData(data, sizeof(data)/sizeof(byte));
|
||||||
//InsertData(data, sizeof(data)/sizeof(byte));
|
//InsertData(data, sizeof(data)/sizeof(byte));
|
||||||
//AC_Serial.flush();
|
//AC_Serial.flush();
|
||||||
|
//item->setExt(millisNZ());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,5 +36,6 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void InsertData(byte data[], size_t size);
|
void InsertData(byte data[], size_t size);
|
||||||
|
void SendData(byte req[], size_t size);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -423,15 +423,12 @@ int out_Modbus::sendModbus(char * paramName, int32_t value, uint8_t regType)
|
|||||||
|
|
||||||
switch(regType) {
|
switch(regType) {
|
||||||
case PAR_U16:
|
case PAR_U16:
|
||||||
//res = node.writeSingleRegister(regObj->valueint,value);
|
|
||||||
//break;
|
|
||||||
case PAR_I16:
|
case PAR_I16:
|
||||||
case PAR_TENS:
|
case PAR_TENS:
|
||||||
case PAR_100:
|
case PAR_100:
|
||||||
res = node.writeSingleRegister(regObj->valueint,value);
|
res = node.writeSingleRegister(regObj->valueint,value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case PAR_I32:
|
case PAR_I32:
|
||||||
case PAR_U32:
|
case PAR_U32:
|
||||||
@@ -440,11 +437,12 @@ int out_Modbus::sendModbus(char * paramName, int32_t value, uint8_t regType)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case PAR_U8L:
|
case PAR_U8L:
|
||||||
res = node.writeSingleRegister(regObj->valueint,value & 0xFF);
|
case PAR_I8L:
|
||||||
|
res = node.writeSingleRegister(regObj->valueint,value & 0xFF);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PAR_U8H:
|
case PAR_U8H:
|
||||||
|
case PAR_I8H:
|
||||||
res = node.writeSingleRegister(regObj->valueint,(value & 0xFFFF)>> 8);
|
res = node.writeSingleRegister(regObj->valueint,(value & 0xFFFF)>> 8);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -484,6 +482,7 @@ if (itemParametersObj && itemParametersObj->type ==aJson_Object)
|
|||||||
case 0: //fault
|
case 0: //fault
|
||||||
execObj->subtype |= MB_SEND_ERROR;
|
execObj->subtype |= MB_SEND_ERROR;
|
||||||
errorSerial<<F("MBus ")<<execObj->name<<F(" send error")<<endl;
|
errorSerial<<F("MBus ")<<execObj->name<<F(" send error")<<endl;
|
||||||
|
if ((execObj->subtype & 3) != MB_SEND_ATTEMPTS) execObj->subtype++;
|
||||||
break;
|
break;
|
||||||
default: //param not found
|
default: //param not found
|
||||||
errorSerial<<F("MBus param ")<<execObj->name<<F(" not found")<<endl;
|
errorSerial<<F("MBus param ")<<execObj->name<<F(" not found")<<endl;
|
||||||
@@ -507,6 +506,7 @@ if (itemParametersObj && itemParametersObj->type ==aJson_Object)
|
|||||||
while (execObj && execObj->type == aJson_Object)
|
while (execObj && execObj->type == aJson_Object)
|
||||||
{
|
{
|
||||||
if (execObj->subtype & MB_SEND_ERROR) execObj->subtype&=~ MB_SEND_ERROR;
|
if (execObj->subtype & MB_SEND_ERROR) execObj->subtype&=~ MB_SEND_ERROR;
|
||||||
|
if ((execObj->subtype & 0x3) >= MB_SEND_ATTEMPTS) execObj->subtype&=~ MB_NEED_SEND;
|
||||||
execObj=execObj->next;
|
execObj=execObj->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -545,68 +545,39 @@ int out_Modbus::getChanType()
|
|||||||
return CH_MBUS;
|
return CH_MBUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int out_Modbus::sendItemCmd(aJsonObject *templateParamObj, itemCmd cmd)
|
||||||
//!Control unified Modbus item
|
|
||||||
// Priority of selection sub-items control to:
|
|
||||||
// 1. if defined standard suffix Code inside cmd
|
|
||||||
// 2. custom textual subItem
|
|
||||||
// 3. non-standard numeric suffix Code equal param id
|
|
||||||
|
|
||||||
int out_Modbus::Ctrl(itemCmd cmd, char* subItem, bool toExecute)
|
|
||||||
{
|
{
|
||||||
int suffixCode = cmd.getSuffix();
|
|
||||||
aJsonObject *templateParamObj = NULL;
|
|
||||||
short mappedCmdVal = 0;
|
|
||||||
|
|
||||||
char * suffixStr = subItem;
|
|
||||||
|
|
||||||
// trying to find parameter in template with name == subItem (NB!! standard suffixes dint working here)
|
|
||||||
if (subItem && strlen (subItem) && store) templateParamObj = aJson.getObjectItem(store->parameters, subItem);
|
|
||||||
|
|
||||||
if (!templateParamObj && store)
|
|
||||||
{
|
|
||||||
// Fallback - Trying to find template parameter where id == suffixCode
|
|
||||||
templateParamObj = store->parameters->child;
|
|
||||||
|
|
||||||
while (templateParamObj)
|
|
||||||
{
|
|
||||||
//aJsonObject *regObj = aJson.getObjectItem(paramObj, "reg");
|
|
||||||
aJsonObject *idObj = aJson.getObjectItem(templateParamObj, "id");
|
|
||||||
if (idObj->type==aJson_Int && idObj->valueint == suffixCode)
|
|
||||||
{
|
|
||||||
suffixStr=templateParamObj->name;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// aJsonObject *mapObj = aJson.getObjectItem(templateParamObj, "mapcmd");
|
|
||||||
// if (mapObj && (mappedCmdVal = cmd.doReverseMappingCmd(mapObj))) break;
|
|
||||||
|
|
||||||
templateParamObj=templateParamObj->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (templateParamObj)
|
if (templateParamObj)
|
||||||
{
|
{
|
||||||
|
int suffixCode = cmd.getSuffix();
|
||||||
|
//bool isCommand = cmd.isCommand();
|
||||||
|
if (!suffixCode) return 0;
|
||||||
|
|
||||||
|
char *suffixStr =templateParamObj->name;
|
||||||
// We have find template for suffix or suffixCode
|
// We have find template for suffix or suffixCode
|
||||||
long Value = 0;
|
long Value = 0;
|
||||||
int8_t regType = PAR_I16;
|
int8_t regType = PAR_I16;
|
||||||
aJsonObject * typeObj = aJson.getObjectItem(templateParamObj, "type");
|
aJsonObject * typeObj = aJson.getObjectItem(templateParamObj, "type");
|
||||||
|
aJsonObject * mapObj = aJson.getObjectItem(templateParamObj, "map");
|
||||||
|
|
||||||
if (typeObj && typeObj->type == aJson_String) regType=str2regSize(typeObj->valuestring);
|
if (typeObj && typeObj->type == aJson_String) regType=str2regSize(typeObj->valuestring);
|
||||||
switch(regType) {
|
switch(regType) {
|
||||||
case PAR_I16:
|
case PAR_I16:
|
||||||
|
case PAR_U16:
|
||||||
case PAR_I32:
|
case PAR_I32:
|
||||||
case PAR_U32:
|
case PAR_U32:
|
||||||
case PAR_U8L:
|
case PAR_U8L:
|
||||||
case PAR_U8H:
|
case PAR_U8H:
|
||||||
Value=cmd.getInt();
|
case PAR_I8H:
|
||||||
|
case PAR_I8L:
|
||||||
|
|
||||||
|
Value=cmd.doMapping(mapObj).getInt();
|
||||||
break;
|
break;
|
||||||
case PAR_TENS:
|
case PAR_TENS:
|
||||||
Value=cmd.getTens();
|
Value=cmd.doMapping(mapObj).getTens();
|
||||||
break;
|
break;
|
||||||
case PAR_100:
|
case PAR_100:
|
||||||
Value=cmd.getTens_raw()*(100/TENS_BASE);
|
Value=cmd.doMapping(mapObj).getTens_raw()*(100/TENS_BASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
debugSerial<<F("MB suffix:")<<suffixStr<< F(" Val: ")<<Value<<endl;
|
debugSerial<<F("MB suffix:")<<suffixStr<< F(" Val: ")<<Value<<endl;
|
||||||
@@ -643,49 +614,52 @@ if (itemParametersObj && itemParametersObj->type ==aJson_Object)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else return 0;
|
||||||
}
|
}
|
||||||
else errorSerial<<F("No template for ")<<subItem<<F("/")<<suffixCode<<endl;
|
|
||||||
|
|
||||||
|
//!Control unified Modbus item
|
||||||
|
// Priority of selection sub-items control to:
|
||||||
|
// 1. if defined standard suffix Code inside cmd
|
||||||
|
// 2. custom textual subItem
|
||||||
|
// 3. non-standard numeric suffix Code equal param id
|
||||||
|
|
||||||
if (cmd.isCommand() && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
|
int out_Modbus::Ctrl(itemCmd cmd, char* subItem, bool toExecute)
|
||||||
|
|
||||||
switch(suffixCode)
|
|
||||||
{
|
{
|
||||||
case S_NOTFOUND:
|
if (!store) return -1;
|
||||||
// turn on and set
|
|
||||||
toExecute = true;
|
|
||||||
debugSerial<<F("Forced execution");
|
|
||||||
case S_SET:
|
|
||||||
//case S_ESET:
|
|
||||||
if (!cmd.isValue()) return 0;
|
|
||||||
|
|
||||||
//TODO
|
int suffixCode = cmd.getSuffix();
|
||||||
return 1;
|
aJsonObject *templateParamObj = NULL;
|
||||||
//break;
|
int res = -1;
|
||||||
|
|
||||||
case S_CMD:
|
// trying to find parameter in template with name == subItem (NB!! standard suffixes dint working here)
|
||||||
switch (cmd.getCmd())
|
if (subItem && strlen (subItem))
|
||||||
{
|
|
||||||
case CMD_ON:
|
{
|
||||||
|
templateParamObj = aJson.getObjectItem(store->parameters, subItem);
|
||||||
|
res= sendItemCmd(templateParamObj,cmd);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
|
||||||
return 1;
|
// No subitem, trying to find suffix with root item - (Trying to find template parameter where id == suffixCode)
|
||||||
|
{
|
||||||
case CMD_OFF:
|
templateParamObj = store->parameters->child;
|
||||||
|
bool suffixFinded = false;
|
||||||
return 1;
|
while (templateParamObj)
|
||||||
|
{
|
||||||
default:
|
aJsonObject *idObj = aJson.getObjectItem(templateParamObj, "id");
|
||||||
debugSerial<<F("Unknown cmd ")<<cmd.getCmd()<<endl;
|
if (idObj->type==aJson_Int && idObj->valueint == suffixCode)
|
||||||
} //switch cmd
|
{
|
||||||
|
res= sendItemCmd(templateParamObj,cmd);
|
||||||
default:
|
suffixFinded = true;
|
||||||
debugSerial<<F("Unknown suffix ")<<suffixCode<<endl;
|
}
|
||||||
} //switch suffix
|
templateParamObj=templateParamObj->next;
|
||||||
|
}
|
||||||
return 0;
|
if (!suffixFinded) errorSerial<<F("No template for ")<<subItem<<F(" or suffix ")<<suffixCode<<endl;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -22,8 +22,9 @@ public:
|
|||||||
aJsonObject * parameters;
|
aJsonObject * parameters;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MB_NEED_SEND 1
|
#define MB_NEED_SEND 8
|
||||||
#define MB_SEND_ERROR 2
|
#define MB_SEND_ERROR 4
|
||||||
|
#define MB_SEND_ATTEMPTS 3
|
||||||
|
|
||||||
|
|
||||||
class out_Modbus : public abstractOut {
|
class out_Modbus : public abstractOut {
|
||||||
@@ -46,5 +47,6 @@ protected:
|
|||||||
void pollModbus(aJsonObject * reg, int regType);
|
void pollModbus(aJsonObject * reg, int regType);
|
||||||
void initLine();
|
void initLine();
|
||||||
int sendModbus(char * paramName, int32_t value, uint8_t regType);
|
int sendModbus(char * paramName, int32_t value, uint8_t regType);
|
||||||
|
int sendItemCmd(aJsonObject *templateParamObj, itemCmd cmd);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
class out_pwm : public colorChannel {
|
class out_pwm : public colorChannel {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
out_pwm(Item * _item):colorChannel(_item){};
|
out_pwm(Item * _item):colorChannel(_item){numChannels=0;};
|
||||||
int Setup() override;
|
int Setup() override;
|
||||||
int Stop() override;
|
int Stop() override;
|
||||||
int Status() override;
|
int Status() override;
|
||||||
|
|||||||
+5
-2
@@ -142,7 +142,7 @@ itemCmd getNumber(char **chan) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fractlen) val.Int(atol(*chan));
|
if (!fractlen) val.Int((int32_t) atol(*chan));
|
||||||
else if (fractlen<=TENS_FRACT_LEN && intlen+TENS_FRACT_LEN<=9)
|
else if (fractlen<=TENS_FRACT_LEN && intlen+TENS_FRACT_LEN<=9)
|
||||||
{
|
{
|
||||||
long intpart = atol(*chan);
|
long intpart = atol(*chan);
|
||||||
@@ -162,7 +162,10 @@ itemCmd getNumber(char **chan) {
|
|||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP8266)
|
#if defined(ARDUINO_ARCH_ESP32) || defined(ESP8266)
|
||||||
unsigned long freeRam ()
|
unsigned long freeRam ()
|
||||||
{return system_get_free_heap_size();}
|
{
|
||||||
|
return esp_get_free_heap_size();//heap_caps_get_free_size();
|
||||||
|
//return system_get_free_heap_size();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__AVR__)
|
#if defined(__AVR__)
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
sed -i -- 's/void USART0_Handler(void)/void USART0_Handler(void ) __attribute__((weak)); void USART0_Handler(void )/g' ~/.platformio/packages/framework-arduinosam/variants/arduino_due_x/variant.cpp
|
sed -i -- 's/void USART0_Handler(void)/void USART0_Handler(void ) __attribute__((weak)); void USART0_Handler(void )/g' ~/.platformio/packages/framework-arduino-sam/variants/arduino_due_x/variant.cpp
|
||||||
|
|||||||
Reference in New Issue
Block a user