mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 11:49:51 +03:00
XNova CRYPT,SHAREDSECRET,PROTECTED_PINS,PULSEPIN12
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
-DPID_DISABLE
|
-DPID_DISABLE
|
||||||
-DOTA
|
-DOTA
|
||||||
-DMOTOR_DISABLE
|
-DMOTOR_DISABLE
|
||||||
|
-DMULTIVENT_DISABLE
|
||||||
#-DWiz5100
|
#-DWiz5100
|
||||||
-DARDUINO_OTA_MDNS_DISABLE
|
-DARDUINO_OTA_MDNS_DISABLE
|
||||||
-DMDNS_ENABLE
|
-DMDNS_ENABLE
|
||||||
|
|||||||
16
compiled/DUE_16u2_reflash/reflash16u2DUE.bat
Normal file
16
compiled/DUE_16u2_reflash/reflash16u2DUE.bat
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
REM fetch DeviceID of Arduino Port from WMI Service
|
||||||
|
FOR /f "tokens=* skip=1" %%a IN ('wmic PATH Win32_SerialPort Where "Caption LIKE '%%Arduino Uno%%'" get DeviceID') DO (
|
||||||
|
SET COMX=%%a
|
||||||
|
GOTO exit1
|
||||||
|
)
|
||||||
|
|
||||||
|
REM Arduino Due Programming Port not exist
|
||||||
|
GOTO error_comport
|
||||||
|
|
||||||
|
:exit1
|
||||||
|
|
||||||
|
REM remove blank
|
||||||
|
SET COMPORT=%COMX: =%
|
||||||
|
|
||||||
|
|
||||||
|
..\tools\win\tool-avrdude\avrdude -C ..\tools\win\tool-avrdude\avrdude.conf -c arduino -P %COMPORT% -b 19200 -p m16u2 -vvv -U flash:w:16u2.hex:i
|
||||||
1
compiled/lighthub21/ListSerialPorts.bat
Normal file
1
compiled/lighthub21/ListSerialPorts.bat
Normal file
@@ -0,0 +1 @@
|
|||||||
|
wmic PATH Win32_SerialPort get DeviceID
|
||||||
@@ -28,7 +28,7 @@ REM bin file exist?
|
|||||||
IF NOT EXIST "%BINFILE%" GOTO error_binfile
|
IF NOT EXIST "%BINFILE%" GOTO error_binfile
|
||||||
|
|
||||||
REM fetch DeviceID of Arduino Due Programming Port from WMI Service
|
REM fetch DeviceID of Arduino Due Programming Port from WMI Service
|
||||||
FOR /f "tokens=* skip=1" %%a IN ('wmic PATH Win32_SerialPort Where "Caption LIKE '%%USB%%'" get DeviceID') DO (
|
FOR /f "tokens=* skip=1" %%a IN ('wmic PATH Win32_SerialPort Where "Caption LIKE '%%Due%%'" get DeviceID') DO (
|
||||||
SET COMX=%%a
|
SET COMX=%%a
|
||||||
GOTO exit1
|
GOTO exit1
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class chPersistent {};
|
|||||||
class abstractOut : public abstractCh{
|
class abstractOut : public abstractCh{
|
||||||
public:
|
public:
|
||||||
abstractOut(Item * _item):abstractCh(){item=_item;};
|
abstractOut(Item * _item):abstractCh(){item=_item;};
|
||||||
virtual int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) =0;
|
virtual int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized = false) =0;
|
||||||
virtual int isActive();
|
virtual int isActive();
|
||||||
virtual bool isAllowed(itemCmd cmd){return true;};
|
virtual bool isAllowed(itemCmd cmd){return true;};
|
||||||
virtual itemCmd getDefaultOnVal(){return itemCmd().Percents255(255);};
|
virtual itemCmd getDefaultOnVal(){return itemCmd().Percents255(255);};
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ return val;
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int colorChannel::Ctrl(itemCmd cmd, char* subItem, bool toExecute)
|
int colorChannel::Ctrl(itemCmd cmd, char* subItem, bool toExecute, bool authorized)
|
||||||
{
|
{
|
||||||
debugSerial<<F("clrCtr: ");
|
debugSerial<<F("clrCtr: ");
|
||||||
cmd.debugOut();
|
cmd.debugOut();
|
||||||
@@ -67,7 +67,8 @@ case S_CMD:
|
|||||||
switch (cmd.getCmd())
|
switch (cmd.getCmd())
|
||||||
{
|
{
|
||||||
case CMD_ON:
|
case CMD_ON:
|
||||||
if (vol=cmd.getPercents()<MIN_VOLUME && vol>=0)
|
vol=cmd.getPercents();
|
||||||
|
if (vol<MIN_VOLUME && vol>=0)
|
||||||
{
|
{
|
||||||
cmd.setPercents(INIT_VOLUME);
|
cmd.setPercents(INIT_VOLUME);
|
||||||
cmd.saveItem(item);
|
cmd.saveItem(item);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public:
|
|||||||
if (iaddr<0) iaddr=-iaddr;
|
if (iaddr<0) iaddr=-iaddr;
|
||||||
numArgs = item->getArgCount(); // and how many addresses is configured
|
numArgs = item->getArgCount(); // and how many addresses is configured
|
||||||
};
|
};
|
||||||
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override;
|
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized=false) override;
|
||||||
int getDefaultStorageType()override;
|
int getDefaultStorageType()override;
|
||||||
virtual int PixelCtrl(itemCmd cmd, char* subItem=NULL, bool show=true ) =0;
|
virtual int PixelCtrl(itemCmd cmd, char* subItem=NULL, bool show=true ) =0;
|
||||||
short getChannelAddr(short n =0);
|
short getChannelAddr(short n =0);
|
||||||
|
|||||||
@@ -696,7 +696,7 @@ st.setSuffix(suffixCode);
|
|||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ctrl(st,subItem);
|
return Ctrl(st,subItem,true,authorized);
|
||||||
}
|
}
|
||||||
case CMD_UP:
|
case CMD_UP:
|
||||||
case CMD_DN:
|
case CMD_DN:
|
||||||
@@ -704,13 +704,13 @@ st.setSuffix(suffixCode);
|
|||||||
itemCmd Par0 = getNumber((char **) &payload);
|
itemCmd Par0 = getNumber((char **) &payload);
|
||||||
Par0.Cmd(cmd);
|
Par0.Cmd(cmd);
|
||||||
Par0.setSuffix(suffixCode);
|
Par0.setSuffix(suffixCode);
|
||||||
return Ctrl(Par0, subItem);
|
return Ctrl(Par0, subItem,true,authorized);
|
||||||
}
|
}
|
||||||
default: //some known command
|
default: //some known command
|
||||||
{
|
{
|
||||||
int32_t intParam = getInt((char **) &payload);
|
int32_t intParam = getInt((char **) &payload);
|
||||||
if (intParam) st.Int(intParam);
|
if (intParam) st.Int(intParam);
|
||||||
return Ctrl(st, subItem);
|
return Ctrl(st,NULL, true, authorized);
|
||||||
}
|
}
|
||||||
} //ctrl
|
} //ctrl
|
||||||
return 0;
|
return 0;
|
||||||
@@ -719,7 +719,7 @@ return 0;
|
|||||||
// Recursive function with small stack consumption
|
// Recursive function with small stack consumption
|
||||||
// if cmd defined - execute Ctrl for any group members recursively
|
// if cmd defined - execute Ctrl for any group members recursively
|
||||||
// else performs Activity check for group members and return true if any member is active
|
// else performs Activity check for group members and return true if any member is active
|
||||||
bool digGroup (aJsonObject *itemArr, itemCmd *cmd, char* subItem)
|
bool digGroup (aJsonObject *itemArr, itemCmd *cmd, char* subItem, bool authorized)
|
||||||
{ if (!itemArr || itemArr->type!=aJson_Array) return false;
|
{ if (!itemArr || itemArr->type!=aJson_Array) return false;
|
||||||
// Iterate across array of names
|
// Iterate across array of names
|
||||||
aJsonObject *i = itemArr->child;
|
aJsonObject *i = itemArr->child;
|
||||||
@@ -731,13 +731,13 @@ bool digGroup (aJsonObject *itemArr, itemCmd *cmd, char* subItem)
|
|||||||
if (nextItem && nextItem->type == aJson_Array) //nextItem is correct item
|
if (nextItem && nextItem->type == aJson_Array) //nextItem is correct item
|
||||||
{
|
{
|
||||||
Item it(nextItem);
|
Item it(nextItem);
|
||||||
if (cmd && it.isValid()) it.Ctrl(*cmd,subItem,false); //Execute (non recursive)
|
if (cmd && it.isValid()) it.Ctrl(*cmd,subItem,false,authorized); //Execute (non recursive)
|
||||||
//Retrieve itemType
|
//Retrieve itemType
|
||||||
aJsonObject * itemtype = aJson.getArrayItem(nextItem,0);
|
aJsonObject * itemtype = aJson.getArrayItem(nextItem,0);
|
||||||
if (itemtype && itemtype->type == aJson_Int && itemtype->valueint == CH_GROUP)
|
if (itemtype && itemtype->type == aJson_Int && itemtype->valueint == CH_GROUP)
|
||||||
{ //is Group
|
{ //is Group
|
||||||
aJsonObject * itemSubArray = aJson.getArrayItem(nextItem,1);
|
aJsonObject * itemSubArray = aJson.getArrayItem(nextItem,1);
|
||||||
short res = digGroup(itemSubArray,cmd,subItem);
|
short res = digGroup(itemSubArray,cmd,subItem,authorized);
|
||||||
if (!cmd && res)
|
if (!cmd && res)
|
||||||
{
|
{
|
||||||
configLocked--;
|
configLocked--;
|
||||||
@@ -769,7 +769,7 @@ aJsonObject *timestampObj = aJson.getArrayItem(itemArr, I_TIMESTAMP);
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Item::scheduleOppositeCommand(itemCmd cmd)
|
int Item::scheduleOppositeCommand(itemCmd cmd,bool authorized)
|
||||||
{
|
{
|
||||||
itemCmd nextCmd=cmd;
|
itemCmd nextCmd=cmd;
|
||||||
|
|
||||||
@@ -798,11 +798,11 @@ int Item::scheduleOppositeCommand(itemCmd cmd)
|
|||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
debugSerial<<F("CTRL: Schedule cmd ")<<nextCmd.getCmd()<<F(" for (ms):")<<nextCmd.getInt()<<endl;
|
debugSerial<<F("CTRL: Schedule cmd ")<<nextCmd.getCmd()<<F(" for (ms):")<<nextCmd.getInt()<<endl;
|
||||||
scheduleCommand(nextCmd);
|
scheduleCommand(nextCmd,authorized);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Item::scheduleCommand(itemCmd cmd)
|
int Item::scheduleCommand(itemCmd cmd,bool authorized)
|
||||||
{
|
{
|
||||||
if (!itemArr) return 0;
|
if (!itemArr) return 0;
|
||||||
|
|
||||||
@@ -816,7 +816,8 @@ int Item::scheduleCommand(itemCmd cmd)
|
|||||||
{
|
{
|
||||||
timestampObj->valueint = millis()+cmd.getInt();
|
timestampObj->valueint = millis()+cmd.getInt();
|
||||||
timestampObj->type = aJson_Int;
|
timestampObj->type = aJson_Int;
|
||||||
timestampObj->subtype=cmd.getCmd();
|
timestampObj->subtype=(cmd.getCmd() & 0xF) | ((authorized?1:0)<<4);
|
||||||
|
|
||||||
debugSerial<<F( "Armed for ")<< cmd.getInt() << F(" ms :")<<timestampObj->valueint<<endl;
|
debugSerial<<F( "Armed for ")<< cmd.getInt() << F(" ms :")<<timestampObj->valueint<<endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -836,6 +837,7 @@ int Item::scheduleCommand(itemCmd cmd)
|
|||||||
// -3 ignored
|
// -3 ignored
|
||||||
// -1 system error
|
// -1 system error
|
||||||
// -4 invalid argument
|
// -4 invalid argument
|
||||||
|
// -5 unauthorized
|
||||||
int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized)
|
int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized)
|
||||||
{
|
{
|
||||||
int fr = freeRam();
|
int fr = freeRam();
|
||||||
@@ -876,7 +878,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
/// DELAYED COMMANDS processing
|
/// DELAYED COMMANDS processing
|
||||||
if (suffixCode == S_DELAYED)
|
if (suffixCode == S_DELAYED)
|
||||||
{
|
{
|
||||||
return scheduleCommand(cmd);
|
return scheduleCommand(cmd,authorized);
|
||||||
}
|
}
|
||||||
///
|
///
|
||||||
int8_t chActive = -1;
|
int8_t chActive = -1;
|
||||||
@@ -1012,14 +1014,14 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
{
|
{
|
||||||
status2Send |= FLAG_PARAMETERS | FLAG_SEND_DEFFERED;
|
status2Send |= FLAG_PARAMETERS | FLAG_SEND_DEFFERED;
|
||||||
cmd.setSuffix(S_SET);
|
cmd.setSuffix(S_SET);
|
||||||
} else {cmd=fallbackCmd;invalidArgument=true;}
|
} else {cmd=fallbackCmd;invalidArgument=true; errorSerial << F("Invalid arg")<<endl;}
|
||||||
break;
|
break;
|
||||||
case S_SAT:
|
case S_SAT:
|
||||||
if (cmd.incrementS(step))
|
if (cmd.incrementS(step))
|
||||||
{
|
{
|
||||||
status2Send |= FLAG_PARAMETERS | FLAG_SEND_DEFFERED;
|
status2Send |= FLAG_PARAMETERS | FLAG_SEND_DEFFERED;
|
||||||
cmd.setSuffix(S_SET);
|
cmd.setSuffix(S_SET);
|
||||||
} else {cmd=fallbackCmd;invalidArgument=true;}
|
} else {cmd=fallbackCmd;invalidArgument=true; errorSerial << F("Invalid arg")<<endl;}
|
||||||
} //switch suffix
|
} //switch suffix
|
||||||
|
|
||||||
} //Case UP/DOWN
|
} //Case UP/DOWN
|
||||||
@@ -1036,7 +1038,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
if (allowRecursion && itemArg->type == aJson_Array && operation)
|
if (allowRecursion && itemArg->type == aJson_Array && operation)
|
||||||
{
|
{
|
||||||
chActive=(isActive()>0);
|
chActive=(isActive()>0);
|
||||||
digGroup(itemArg,&cmd,subItem);
|
digGroup(itemArg,&cmd,subItem,authorized);
|
||||||
}
|
}
|
||||||
res=1;
|
res=1;
|
||||||
|
|
||||||
@@ -1046,7 +1048,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
case CMD_RESTORE: // individual for group members
|
case CMD_RESTORE: // individual for group members
|
||||||
switch (t = getCmd()) {
|
switch (t = getCmd()) {
|
||||||
case CMD_HALT: //previous command was HALT ?
|
case CMD_HALT: //previous command was HALT ?
|
||||||
if ((suffixCode==S_CMD) && cmd.isValue() && (!chActive || isScheduled())) scheduleOppositeCommand(cmd);
|
if ((suffixCode==S_CMD) && cmd.isValue() && (!chActive || isScheduled())) scheduleOppositeCommand(cmd,authorized);
|
||||||
debugSerial << F("CTRL: Restored from:") << t << endl;
|
debugSerial << F("CTRL: Restored from:") << t << endl;
|
||||||
cmd.loadItemDef(this);
|
cmd.loadItemDef(this);
|
||||||
cmd.Cmd(CMD_ON); //turning on
|
cmd.Cmd(CMD_ON); //turning on
|
||||||
@@ -1060,7 +1062,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
case CMD_XOFF: // individual for group members
|
case CMD_XOFF: // individual for group members
|
||||||
switch (t = getCmd()) {
|
switch (t = getCmd()) {
|
||||||
case CMD_XON: //previous command was CMD_XON ?
|
case CMD_XON: //previous command was CMD_XON ?
|
||||||
if ((suffixCode==S_CMD) && cmd.isValue() && (chActive || isScheduled())) scheduleOppositeCommand(cmd);
|
if ((suffixCode==S_CMD) && cmd.isValue() && (chActive || isScheduled())) scheduleOppositeCommand(cmd,authorized);
|
||||||
debugSerial << F("CTRL: Turned off from:") << t << endl;
|
debugSerial << F("CTRL: Turned off from:") << t << endl;
|
||||||
cmd.Cmd(CMD_OFF); //turning Off
|
cmd.Cmd(CMD_OFF); //turning Off
|
||||||
status2Send |= FLAG_COMMAND | FLAG_SEND_IMMEDIATE;
|
status2Send |= FLAG_COMMAND | FLAG_SEND_IMMEDIATE;
|
||||||
@@ -1077,7 +1079,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
{
|
{
|
||||||
if (chActive == -1) chActive=(isActive()>0);
|
if (chActive == -1) chActive=(isActive()>0);
|
||||||
|
|
||||||
if ((suffixCode==S_CMD) && cmd.isValue() && (!chActive || isScheduled())) scheduleOppositeCommand(cmd);
|
if ((suffixCode==S_CMD) && cmd.isValue() && (!chActive || isScheduled())) scheduleOppositeCommand(cmd,authorized);
|
||||||
|
|
||||||
|
|
||||||
if (!chActive) //if channel was'nt active before CMD_XON
|
if (!chActive) //if channel was'nt active before CMD_XON
|
||||||
@@ -1104,7 +1106,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
break;
|
break;
|
||||||
case CMD_HALT:
|
case CMD_HALT:
|
||||||
if (chActive == -1) chActive=(isActive()>0);
|
if (chActive == -1) chActive=(isActive()>0);
|
||||||
if ((suffixCode==S_CMD) && cmd.isValue() && (chActive || isScheduled())) scheduleOppositeCommand(cmd);
|
if ((suffixCode==S_CMD) && cmd.isValue() && (chActive || isScheduled())) scheduleOppositeCommand(cmd,authorized);
|
||||||
if (chActive) //if channel was active before CMD_HALT /// HERE bug - if cmd == On but 0 = active
|
if (chActive) //if channel was active before CMD_HALT /// HERE bug - if cmd == On but 0 = active
|
||||||
{
|
{
|
||||||
cmd.Cmd(CMD_OFF);
|
cmd.Cmd(CMD_OFF);
|
||||||
@@ -1147,7 +1149,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
}
|
}
|
||||||
else // Fast track for commands to subitems
|
else // Fast track for commands to subitems
|
||||||
{
|
{
|
||||||
if (driver) return driver->Ctrl(cmd,subItem,toExecute);
|
if (driver) return driver->Ctrl(cmd,subItem,toExecute,authorized);
|
||||||
///// return 0;
|
///// return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1160,7 +1162,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
switch (t = getCmd()) {
|
switch (t = getCmd()) {
|
||||||
case CMD_HALT: //previous command was HALT ?
|
case CMD_HALT: //previous command was HALT ?
|
||||||
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (chActive || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (chActive || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
||||||
scheduleOppositeCommand(cmd);
|
scheduleOppositeCommand(cmd,authorized);
|
||||||
|
|
||||||
debugSerial << F("CTRL: Restored from:") << t << endl;
|
debugSerial << F("CTRL: Restored from:") << t << endl;
|
||||||
cmd.loadItemDef(this);
|
cmd.loadItemDef(this);
|
||||||
@@ -1178,7 +1180,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
switch (t = getCmd()) {
|
switch (t = getCmd()) {
|
||||||
case CMD_XON: //previous command was CMD_XON ?
|
case CMD_XON: //previous command was CMD_XON ?
|
||||||
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (chActive || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (chActive || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
||||||
scheduleOppositeCommand(cmd);
|
scheduleOppositeCommand(cmd,authorized);
|
||||||
debugSerial << F("CTRL: Turned off from:") << t << endl;
|
debugSerial << F("CTRL: Turned off from:") << t << endl;
|
||||||
toExecute=true;
|
toExecute=true;
|
||||||
cmd.Cmd(CMD_OFF); //turning Off
|
cmd.Cmd(CMD_OFF); //turning Off
|
||||||
@@ -1195,7 +1197,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
if (!getFlag(FLAG_DISABLED))
|
if (!getFlag(FLAG_DISABLED))
|
||||||
{
|
{
|
||||||
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (!chActive || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (!chActive || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
||||||
scheduleOppositeCommand(cmd);
|
scheduleOppositeCommand(cmd,authorized);
|
||||||
|
|
||||||
if (!chActive) //if channel was'nt active before CMD_XON
|
if (!chActive) //if channel was'nt active before CMD_XON
|
||||||
{
|
{
|
||||||
@@ -1222,7 +1224,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
|
|
||||||
case CMD_HALT:
|
case CMD_HALT:
|
||||||
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (chActive || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (chActive || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
||||||
scheduleOppositeCommand(cmd);
|
scheduleOppositeCommand(cmd,authorized);
|
||||||
if (chActive) //if channel was active before CMD_HALT
|
if (chActive) //if channel was active before CMD_HALT
|
||||||
{
|
{
|
||||||
cmd.Cmd(CMD_OFF);
|
cmd.Cmd(CMD_OFF);
|
||||||
@@ -1247,7 +1249,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
if (getCmd() == CMD_HALT) return 3; //Halted, ignore OFF
|
if (getCmd() == CMD_HALT) return 3; //Halted, ignore OFF
|
||||||
|
|
||||||
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (chActive || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (chActive || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
||||||
scheduleOppositeCommand(cmd);
|
scheduleOppositeCommand(cmd,authorized);
|
||||||
status2Send |= FLAG_COMMAND | FLAG_SEND_IMMEDIATE;
|
status2Send |= FLAG_COMMAND | FLAG_SEND_IMMEDIATE;
|
||||||
toExecute=true;
|
toExecute=true;
|
||||||
break;
|
break;
|
||||||
@@ -1255,7 +1257,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
case CMD_ON:
|
case CMD_ON:
|
||||||
|
|
||||||
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (!chActive || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (!chActive || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
||||||
scheduleOppositeCommand(cmd);
|
scheduleOppositeCommand(cmd,authorized);
|
||||||
|
|
||||||
if (!cmd.isChannelCommand()) //Command for driver, not for whole channel
|
if (!cmd.isChannelCommand()) //Command for driver, not for whole channel
|
||||||
{
|
{
|
||||||
@@ -1298,7 +1300,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
toExecute=true;
|
toExecute=true;
|
||||||
//debugSerial<<F("Disable Flag is:")<<getFlag(FLAG_DISABLED)<<endl;
|
//debugSerial<<F("Disable Flag is:")<<getFlag(FLAG_DISABLED)<<endl;
|
||||||
if (allowRecursion && cmd.isValue() && (getFlag(FLAG_DISABLED) || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
if (allowRecursion && cmd.isValue() && (getFlag(FLAG_DISABLED) || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
||||||
scheduleOppositeCommand(cmd);
|
scheduleOppositeCommand(cmd,authorized);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_DISABLE:
|
case CMD_DISABLE:
|
||||||
@@ -1307,7 +1309,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
toExecute=true;
|
toExecute=true;
|
||||||
//debugSerial<<F("Disable Flag is:")<<getFlag(FLAG_DISABLED)<<endl;
|
//debugSerial<<F("Disable Flag is:")<<getFlag(FLAG_DISABLED)<<endl;
|
||||||
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (!getFlag(FLAG_DISABLED) || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (!getFlag(FLAG_DISABLED) || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
||||||
scheduleOppositeCommand(cmd);
|
scheduleOppositeCommand(cmd,authorized);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_UNFREEZE:
|
case CMD_UNFREEZE:
|
||||||
@@ -1316,7 +1318,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
toExecute=true;
|
toExecute=true;
|
||||||
//debugSerial<<F("Disable Flag is:")<<getFlag(FLAG_DISABLED)<<endl;
|
//debugSerial<<F("Disable Flag is:")<<getFlag(FLAG_DISABLED)<<endl;
|
||||||
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (getFlag(FLAG_FREEZED) || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (getFlag(FLAG_FREEZED) || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
||||||
scheduleOppositeCommand(cmd);
|
scheduleOppositeCommand(cmd,authorized);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CMD_FREEZE:
|
case CMD_FREEZE:
|
||||||
@@ -1326,7 +1328,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
|||||||
toExecute=true;
|
toExecute=true;
|
||||||
//debugSerial<<F("Disable Flag is:")<<getFlag(FLAG_DISABLED)<<endl;
|
//debugSerial<<F("Disable Flag is:")<<getFlag(FLAG_DISABLED)<<endl;
|
||||||
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (!getFlag(FLAG_FREEZED) || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
if ((suffixCode==S_CMD) && allowRecursion && cmd.isValue() && (!getFlag(FLAG_FREEZED) || isScheduled())) //invoked not as group part, delayed, non Active or re-schedule
|
||||||
scheduleOppositeCommand(cmd);
|
scheduleOppositeCommand(cmd,authorized);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -1345,7 +1347,7 @@ if ((!driver || driver->isAllowed(cmd)) && (!getFlag(FLAG_FREEZED)))
|
|||||||
|
|
||||||
if (driver) //New style modular code
|
if (driver) //New style modular code
|
||||||
{
|
{
|
||||||
res = driver->Ctrl(cmd, subItem, toExecute);
|
res = driver->Ctrl(cmd, subItem, toExecute,authorized);
|
||||||
if (driver->getChanType() == CH_THERMO) status2Send |= FLAG_SEND_IMMEDIATE;
|
if (driver->getChanType() == CH_THERMO) status2Send |= FLAG_SEND_IMMEDIATE;
|
||||||
//if (res==-1) status2Send=0; ///////not working
|
//if (res==-1) status2Send=0; ///////not working
|
||||||
if (status2Send & FLAG_FLAGS) res =1; //ENABLE & DISABLE processed by core
|
if (status2Send & FLAG_FLAGS) res =1; //ENABLE & DISABLE processed by core
|
||||||
@@ -1361,6 +1363,7 @@ if ((!driver || driver->isAllowed(cmd)) && (!getFlag(FLAG_FREEZED)))
|
|||||||
|
|
||||||
short iaddr=getArg();
|
short iaddr=getArg();
|
||||||
short icmd =cmd.getCmd();
|
short icmd =cmd.getCmd();
|
||||||
|
if (!authorized && isProtectedPin(iaddr)) {errorSerial<<F("Unauthorized")<<endl; return -5;}
|
||||||
|
|
||||||
if (iaddr)
|
if (iaddr)
|
||||||
{
|
{
|
||||||
@@ -1397,6 +1400,7 @@ if ((!driver || driver->isAllowed(cmd)) && (!getFlag(FLAG_FREEZED)))
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
debugSerial<<F("Pin:")<<iaddr<<F("=")<<k<<endl;
|
debugSerial<<F("Pin:")<<iaddr<<F("=")<<k<<endl;
|
||||||
|
if (isProtectedPin(iaddr) && !isScheduled()) attachMaturaTimer();
|
||||||
status2Send |= FLAG_COMMAND | FLAG_SEND_IMMEDIATE;
|
status2Send |= FLAG_COMMAND | FLAG_SEND_IMMEDIATE;
|
||||||
res=1;
|
res=1;
|
||||||
}
|
}
|
||||||
@@ -1564,7 +1568,8 @@ if (isPendedModbusWrites) resumeModbus();
|
|||||||
aJsonObject *timestampObj = aJson.getArrayItem(itemArr, I_TIMESTAMP);
|
aJsonObject *timestampObj = aJson.getArrayItem(itemArr, I_TIMESTAMP);
|
||||||
if (timestampObj)
|
if (timestampObj)
|
||||||
{
|
{
|
||||||
uint8_t cmd = timestampObj->subtype;
|
uint8_t cmd = timestampObj->subtype & 0xF;
|
||||||
|
bool authorized = timestampObj->subtype & 0x10;
|
||||||
int32_t remain = (uint32_t) timestampObj->valueint - (uint32_t)millis();
|
int32_t remain = (uint32_t) timestampObj->valueint - (uint32_t)millis();
|
||||||
|
|
||||||
if (cmd) {
|
if (cmd) {
|
||||||
@@ -1588,9 +1593,9 @@ if (timestampObj)
|
|||||||
errorSerial<<F("CTRL/poll: OutOfMemory: ")<<fr<<endl;
|
errorSerial<<F("CTRL/poll: OutOfMemory: ")<<fr<<endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ctrl(itemCmd(ST_VOID,cmd));
|
|
||||||
timestampObj->subtype=0;
|
timestampObj->subtype=0;
|
||||||
|
Ctrl(itemCmd(ST_VOID,cmd),NULL,true,authorized);
|
||||||
|
//timestampObj->subtype=0; ////
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ extern aJsonObject *items;
|
|||||||
extern short thermoSetCurTemp(char *name, float t);
|
extern short thermoSetCurTemp(char *name, float t);
|
||||||
|
|
||||||
int txt2cmd (char * payload);
|
int txt2cmd (char * payload);
|
||||||
bool digGroup (aJsonObject *itemArr, itemCmd *cmd = NULL, char* subItem = NULL);
|
bool digGroup (aJsonObject *itemArr, itemCmd *cmd = NULL, char* subItem = NULL, bool authorized = false);
|
||||||
class Item
|
class Item
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -148,8 +148,8 @@ class Item
|
|||||||
inline int On (){return Ctrl(itemCmd(ST_VOID,CMD_ON));};
|
inline int On (){return Ctrl(itemCmd(ST_VOID,CMD_ON));};
|
||||||
inline int Off(){return Ctrl(itemCmd(ST_VOID,CMD_OFF));};
|
inline int Off(){return Ctrl(itemCmd(ST_VOID,CMD_OFF));};
|
||||||
inline int Toggle(){return Ctrl(itemCmd(ST_VOID,CMD_TOGGLE));};
|
inline int Toggle(){return Ctrl(itemCmd(ST_VOID,CMD_TOGGLE));};
|
||||||
int scheduleCommand(itemCmd cmd);
|
int scheduleCommand(itemCmd cmd, bool authorized);
|
||||||
int scheduleOppositeCommand(itemCmd cmd);
|
int scheduleOppositeCommand(itemCmd cmd,bool authorized);
|
||||||
int isScheduled();
|
int isScheduled();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -98,6 +98,10 @@ lan_status lanStatus = INITIAL_STATE;
|
|||||||
const char configserver[] PROGMEM = CONFIG_SERVER;
|
const char configserver[] PROGMEM = CONFIG_SERVER;
|
||||||
const char verval_P[] PROGMEM = QUOTE(PIO_SRC_REV);
|
const char verval_P[] PROGMEM = QUOTE(PIO_SRC_REV);
|
||||||
|
|
||||||
|
#ifdef CRYPT
|
||||||
|
char cryptoKey[] = QUOTE(SHAREDSECRET);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__SAM3X8E__)
|
#if defined(__SAM3X8E__)
|
||||||
UID UniqueID;
|
UID UniqueID;
|
||||||
#endif
|
#endif
|
||||||
@@ -2046,6 +2050,56 @@ int16_t attachTimer(double microseconds, timerCallback callback, const char* Tim
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__SAM3X8E__) && defined (PULSEPIN12)
|
||||||
|
#define MATURA_PULSE 100
|
||||||
|
#define MATURA_PERIOD 2500
|
||||||
|
|
||||||
|
void maturaTimerHandler(void){ }
|
||||||
|
|
||||||
|
volatile int maturaTimerNumber = -1;
|
||||||
|
int16_t attachMaturaTimer()
|
||||||
|
{
|
||||||
|
if (maturaTimerNumber==-1)
|
||||||
|
{
|
||||||
|
DueTimerInterrupt dueTimerInterrupt = DueTimerInterrupt(8);
|
||||||
|
dueTimerInterrupt.attachInterruptInterval(MATURA_PERIOD*1000, maturaTimerHandler);
|
||||||
|
maturaTimerNumber = dueTimerInterrupt.getTimerNumber();
|
||||||
|
TC_SetRB(TC2,2,REG_TC2_RC2 - (REG_TC2_RC2 / MATURA_PERIOD * MATURA_PULSE));
|
||||||
|
REG_TC2_CMR2 |= TC_CMR_BCPB_SET | TC_CMR_BCPC_CLEAR | TC_CMR_EEVT_XC0; // on CTR==A -> SET; on CTR == C - CLEAR pin, enable TIOB as out
|
||||||
|
}
|
||||||
|
debugSerial<<F("Matura attached to Timer(")<<maturaTimerNumber<<F(")")<<endl;
|
||||||
|
//pinMode(11,OUTPUT); //PIO_PD7B_TIOA8 PERIPH_B //T7
|
||||||
|
pinMode(12,OUTPUT); //PIO_PD8B_TIOB8 PERIPH_B //T8
|
||||||
|
|
||||||
|
// Memo for some future use timers:
|
||||||
|
//pinMode(2,OUTPUT); //PIO_PB25B_TIOA0 PERIPH_B
|
||||||
|
//pinMode(13,OUTPUT);//PIO_PB27B_TIOB0 PERIPH_B
|
||||||
|
|
||||||
|
//pinMode(3,OUTPUT); //PIO_PC28B_TIOA7 PERIPH_B
|
||||||
|
//pinMode(10,OUTPUT);//PIO_PC29B_TIOB7 PERIPH_B
|
||||||
|
|
||||||
|
//pinMode(5,OUTPUT); //PIO_PC25B_TIOA6 PERIPH_B
|
||||||
|
//pinMode(4,OUTPUT); //PIO_PC26B_TIOB6 PERIPH_B
|
||||||
|
|
||||||
|
// 11 & 12 pins example (TC2 ch2 (#8) A & B channels for some future use)
|
||||||
|
//REG_PIOD_PDR = PIO_PD7 | PIO_PD8;
|
||||||
|
//REG_PIOD_ABSR |= PIO_PD7 | PIO_PD8;
|
||||||
|
//REG_TC2_CMR2 |= TC_CMR_ACPA_SET | TC_CMR_ACPC_CLEAR | TC_CMR_BCPB_SET | TC_CMR_BCPC_CLEAR | TC_CMR_EEVT_XC0;
|
||||||
|
//TC_SetRA(TC2,2,1000000);TC_SetRB(TC2,2,1500000);
|
||||||
|
|
||||||
|
REG_PIOD_PDR = PIO_PD8; //Disabling PD8 IO - move to pereferia
|
||||||
|
REG_PIOD_ABSR |= PIO_PD8; //Select Pereferia B
|
||||||
|
//REG_TC2_CMR2 |= TC_CMR_BCPB_SET | TC_CMR_BCPC_CLEAR | TC_CMR_EEVT_XC0; // on CTR==A -> SET; on CTR == C - CLEAR pin, enable TIOB as out
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//REG_PIOD_WPMR = PIO_WPMR_WPKEY(0x50494f) | 1; //Write protect whole IOD
|
||||||
|
return maturaTimerNumber;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
int16_t attachMaturaTimer(){};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(WIFI_ENABLE)
|
#if defined(WIFI_ENABLE)
|
||||||
#if defined (ESP32)
|
#if defined (ESP32)
|
||||||
void WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info)
|
void WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info)
|
||||||
@@ -2804,6 +2858,8 @@ configLocked++;
|
|||||||
#if defined(__SAM3X8E__) && defined (TIMER_INT)
|
#if defined(__SAM3X8E__) && defined (TIMER_INT)
|
||||||
// Interval in microsecs
|
// Interval in microsecs
|
||||||
attachTimer(TIMER_CHECK_INPUT * 1000, TimerHandler, "ITimer");
|
attachTimer(TIMER_CHECK_INPUT * 1000, TimerHandler, "ITimer");
|
||||||
|
attachMaturaTimer();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
configLocked--;
|
configLocked--;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -319,4 +319,6 @@ void printCurentLanConfig();
|
|||||||
|
|
||||||
void onMQTTConnect();
|
void onMQTTConnect();
|
||||||
|
|
||||||
|
int16_t attachMaturaTimer();
|
||||||
|
|
||||||
//void printFreeRam();
|
//void printFreeRam();
|
||||||
|
|||||||
@@ -433,7 +433,7 @@ debugSerial<<F("AC: ")<<portNum<<F(" >> ");
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
int out_AC::Ctrl(itemCmd cmd, char* subItem , bool toExecute)
|
int out_AC::Ctrl(itemCmd cmd, char* subItem , bool toExecute, bool authorized)
|
||||||
{
|
{
|
||||||
//char s_mode[10];
|
//char s_mode[10];
|
||||||
char s_speed[10];
|
char s_speed[10];
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public:
|
|||||||
int isActive() override;
|
int isActive() override;
|
||||||
int getChanType() override;
|
int getChanType() override;
|
||||||
int getDefaultStorageType(){return ST_FLOAT_CELSIUS;};
|
int getDefaultStorageType(){return ST_FLOAT_CELSIUS;};
|
||||||
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override;
|
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized = false) override;
|
||||||
void SubmitParameters(const char * name, itemCmd value);
|
void SubmitParameters(const char * name, itemCmd value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ uint32_t timer = item->getExt();
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int out_counter::Ctrl(itemCmd cmd, char* subItem, bool toExecute)
|
int out_counter::Ctrl(itemCmd cmd, char* subItem, bool toExecute,bool authorized)
|
||||||
{
|
{
|
||||||
debugSerial<<F("Counter: ");
|
debugSerial<<F("Counter: ");
|
||||||
cmd.debugOut();
|
cmd.debugOut();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public:
|
|||||||
int Status() override;
|
int Status() override;
|
||||||
|
|
||||||
int getChanType() override;
|
int getChanType() override;
|
||||||
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override;
|
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized = false) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//float impulse;
|
//float impulse;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public:
|
|||||||
int getChanType() override;
|
int getChanType() override;
|
||||||
// int Ctrl(itemCmd cmd, char* subItem=NULL) override;
|
// int Ctrl(itemCmd cmd, char* subItem=NULL) override;
|
||||||
// int PixelCtrl(itemCmd cmd) override;
|
// int PixelCtrl(itemCmd cmd) override;
|
||||||
virtual int PixelCtrl(itemCmd cmd, char* subItem=NULL, bool show=true ) override;
|
virtual int PixelCtrl(itemCmd cmd, char* subItem=NULL, bool show=true) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -337,6 +337,7 @@ int out_Mercury::Poll(short cause)
|
|||||||
//bool lineInitialized = false;
|
//bool lineInitialized = false;
|
||||||
if (cause==POLLING_SLOW) return 0;
|
if (cause==POLLING_SLOW) return 0;
|
||||||
if (modbusBusy || ( mbusSlenceTimer && !isTimeOver(mbusSlenceTimer,millis(),100))) return 0;
|
if (modbusBusy || ( mbusSlenceTimer && !isTimeOver(mbusSlenceTimer,millis(),100))) return 0;
|
||||||
|
if (store->driverStatus == CST_FAILED) return 0;
|
||||||
if (!getConfig()) return 0;
|
if (!getConfig()) return 0;
|
||||||
|
|
||||||
switch (Status())
|
switch (Status())
|
||||||
@@ -474,7 +475,7 @@ int out_Mercury::getChanType()
|
|||||||
|
|
||||||
|
|
||||||
//!Control unified item
|
//!Control unified item
|
||||||
int out_Mercury::Ctrl(itemCmd cmd, char* subItem, bool toExecute)
|
int out_Mercury::Ctrl(itemCmd cmd, char* subItem, bool toExecute,bool authorized)
|
||||||
{
|
{
|
||||||
if (!store) return -1;
|
if (!store) return -1;
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
int Stop() override;
|
int Stop() override;
|
||||||
int Status() override;
|
int Status() override;
|
||||||
int getChanType() override;
|
int getChanType() override;
|
||||||
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override;
|
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized = false) override;
|
||||||
int getDefaultStorageType(){return ST_INT32;};
|
int getDefaultStorageType(){return ST_INT32;};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -856,7 +856,7 @@ else return 0;
|
|||||||
// 2. custom textual subItem
|
// 2. custom textual subItem
|
||||||
// 3. non-standard numeric suffix Code equal param id
|
// 3. non-standard numeric suffix Code equal param id
|
||||||
|
|
||||||
int out_Modbus::Ctrl(itemCmd cmd, char* subItem, bool toExecute)
|
int out_Modbus::Ctrl(itemCmd cmd, char* subItem, bool toExecute,bool authorized)
|
||||||
{
|
{
|
||||||
if (!store) return -1;
|
if (!store) return -1;
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ public:
|
|||||||
int Stop() override;
|
int Stop() override;
|
||||||
int Status() override;
|
int Status() override;
|
||||||
int getChanType() override;
|
int getChanType() override;
|
||||||
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override;
|
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized = false) override;
|
||||||
int getDefaultStorageType(){return ST_INT32;};
|
int getDefaultStorageType(){return ST_INT32;};
|
||||||
//int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
|
//int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ else if (curPos>=0)
|
|||||||
else
|
else
|
||||||
dif=targetPos-255/2; // Have No feedback
|
dif=targetPos-255/2; // Have No feedback
|
||||||
|
|
||||||
debugSerial<<F("Motor: in:")<<pinFeedback<<F(" Val:")<<fb<<F("/")<<curPos<<F("->")<<targetPos<<F(" delta:")<<dif<<endl;
|
//debugSerial<<F("Motor: in:")<<pinFeedback<<F(" Val:")<<fb<<F("/")<<curPos<<F("->")<<targetPos<<F(" delta:")<<dif<<endl;
|
||||||
|
|
||||||
if (dif<-POS_ERR)
|
if (dif<-POS_ERR)
|
||||||
{
|
{
|
||||||
@@ -261,7 +261,7 @@ int out_Motor::getChanType()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int out_Motor::Ctrl(itemCmd cmd, char* subItem , bool toExecute)
|
int out_Motor::Ctrl(itemCmd cmd, char* subItem , bool toExecute,bool authorized)
|
||||||
{
|
{
|
||||||
int suffixCode = cmd.getSuffix();
|
int suffixCode = cmd.getSuffix();
|
||||||
if (cmd.isCommand() && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
|
if (cmd.isCommand() && !suffixCode) suffixCode=S_CMD; //if some known command find, but w/o correct suffix - got it
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public:
|
|||||||
int getChanType() override;
|
int getChanType() override;
|
||||||
int getDefaultStorageType(){return ST_PERCENTS255;};
|
int getDefaultStorageType(){return ST_PERCENTS255;};
|
||||||
//int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
|
//int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
|
||||||
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override;
|
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized = false) override;
|
||||||
|
|
||||||
int8_t pinUp;
|
int8_t pinUp;
|
||||||
int8_t pinDown;
|
int8_t pinDown;
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ int out_Multivent::getChanType()
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int out_Multivent::Ctrl(itemCmd cmd, char* subItem , bool toExecute)
|
int out_Multivent::Ctrl(itemCmd cmd, char* subItem , bool toExecute, bool authorized)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (cmd.getCmd()==CMD_DISABLE || cmd.getCmd()==CMD_ENABLE) return 0;
|
if (cmd.getCmd()==CMD_DISABLE || cmd.getCmd()==CMD_ENABLE) return 0;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public:
|
|||||||
//int isActive() override;
|
//int isActive() override;
|
||||||
int getChanType() override;
|
int getChanType() override;
|
||||||
int getDefaultStorageType(){return ST_PERCENTS255;};
|
int getDefaultStorageType(){return ST_PERCENTS255;};
|
||||||
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override;
|
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized = false) override;
|
||||||
protected:
|
protected:
|
||||||
void getConfig();
|
void getConfig();
|
||||||
aJsonObject * gatesObj;
|
aJsonObject * gatesObj;
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ int out_pid::getChanType()
|
|||||||
// /val suffix - to put value into controller
|
// /val suffix - to put value into controller
|
||||||
// accept ON and OFF commands
|
// accept ON and OFF commands
|
||||||
|
|
||||||
int out_pid::Ctrl(itemCmd cmd, char* subItem, bool toExecute)
|
int out_pid::Ctrl(itemCmd cmd, char* subItem, bool toExecute, bool authorized)
|
||||||
{
|
{
|
||||||
if (!store || !store->pid || (Status() != CST_INITIALIZED)) return 0;
|
if (!store || !store->pid || (Status() != CST_INITIALIZED)) return 0;
|
||||||
int suffixCode = cmd.getSuffix();
|
int suffixCode = cmd.getSuffix();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
int isActive() override;
|
int isActive() override;
|
||||||
int getChanType() override;
|
int getChanType() override;
|
||||||
int getDefaultStorageType(){return ST_FLOAT;};
|
int getDefaultStorageType(){return ST_FLOAT;};
|
||||||
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override;
|
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized = false) override;
|
||||||
void alarm(bool);
|
void alarm(bool);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ bool needToOff = isTimeOver(timer,millis(),period*val/255);
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int out_relay::Ctrl(itemCmd cmd, char* subItem, bool toExecute)
|
int out_relay::Ctrl(itemCmd cmd, char* subItem, bool toExecute,bool authorized)
|
||||||
{
|
{
|
||||||
debugSerial<<F("relayCtr: ");
|
debugSerial<<F("relayCtr: ");
|
||||||
cmd.debugOut();
|
cmd.debugOut();
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public:
|
|||||||
int Status() override;
|
int Status() override;
|
||||||
|
|
||||||
int getChanType() override;
|
int getChanType() override;
|
||||||
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override;
|
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized = false) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
short pin;
|
short pin;
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ int out_UARTbridge::getChanType()
|
|||||||
// 2. custom textual subItem
|
// 2. custom textual subItem
|
||||||
// 3. non-standard numeric suffix Code equal param id
|
// 3. non-standard numeric suffix Code equal param id
|
||||||
|
|
||||||
int out_UARTbridge::Ctrl(itemCmd cmd, char* subItem, bool toExecute)
|
int out_UARTbridge::Ctrl(itemCmd cmd, char* subItem, bool toExecute, bool authorized)
|
||||||
{
|
{
|
||||||
//int chActive = item->isActive();
|
//int chActive = item->isActive();
|
||||||
//bool toExecute = (chActive>0);
|
//bool toExecute = (chActive>0);
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public:
|
|||||||
int Stop() override;
|
int Stop() override;
|
||||||
int Status() override;
|
int Status() override;
|
||||||
int getChanType() override;
|
int getChanType() override;
|
||||||
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true) override;
|
int Ctrl(itemCmd cmd, char* subItem=NULL, bool toExecute=true, bool authorized = false) override;
|
||||||
int getDefaultStorageType(){return ST_INT32;};
|
int getDefaultStorageType(){return ST_INT32;};
|
||||||
//int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
|
//int Ctrl(short cmd, short n=0, int * Parameters=NULL, int suffixCode=0, char* subItem=NULL) override;
|
||||||
|
|
||||||
|
|||||||
@@ -361,4 +361,18 @@
|
|||||||
#define minimalMemory 200
|
#define minimalMemory 200
|
||||||
#else
|
#else
|
||||||
#define minimalMemory 1200
|
#define minimalMemory 1200
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if not defined PROTECTED_PINS
|
||||||
|
#define PROTECTED_PINS
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const short protectedPins[]={PROTECTED_PINS};
|
||||||
|
#define protectedPinsNum (sizeof(protectedPins)/sizeof(short))
|
||||||
|
|
||||||
|
#ifdef CRYPT
|
||||||
|
#if not defined SHAREDSECRET
|
||||||
|
#define SHAREDSECRET "12345678"
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -99,12 +99,12 @@ void SetAddr(char *out, uint8_t *addr) {
|
|||||||
|
|
||||||
// chan is pointer to pointer to string
|
// chan is pointer to pointer to string
|
||||||
// Function return first retrived integer and move pointer to position next after ','
|
// Function return first retrived integer and move pointer to position next after ','
|
||||||
int getInt(char **chan) {
|
long getInt(char **chan) {
|
||||||
if (chan && *chan && **chan)
|
if (chan && *chan && **chan)
|
||||||
{
|
{
|
||||||
//Skip non-numeric values
|
//Skip non-numeric values
|
||||||
while (**chan && !(**chan == '-' || (**chan >= '0' && **chan<='9'))) *chan += 1;
|
while (**chan && !(**chan == '-' || (**chan >= '0' && **chan<='9'))) *chan += 1;
|
||||||
int ch = atoi(*chan);
|
long ch = atol(*chan);
|
||||||
|
|
||||||
//Move pointer to next element (after ,)
|
//Move pointer to next element (after ,)
|
||||||
*chan = strchr(*chan, ',');
|
*chan = strchr(*chan, ',');
|
||||||
@@ -362,7 +362,8 @@ uint32_t ReadUniqueID( uint32_t * pdwUniqueID )
|
|||||||
|
|
||||||
return *(uint32_t *)(IFLASH1_ADDR + 128); // dont remove: SAM defect workaround - MPU dont leave Unique Identifier mode until read flash out UID of range
|
return *(uint32_t *)(IFLASH1_ADDR + 128); // dont remove: SAM defect workaround - MPU dont leave Unique Identifier mode until read flash out UID of range
|
||||||
|
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
//#pragma optimize("", on)
|
//#pragma optimize("", on)
|
||||||
@@ -814,13 +815,12 @@ bool getPinVal(uint8_t pin)
|
|||||||
{
|
{
|
||||||
return (0!=(*portOutputRegister( digitalPinToPort(pin) ) & digitalPinToBitMask(pin)));
|
return (0!=(*portOutputRegister( digitalPinToPort(pin) ) & digitalPinToBitMask(pin)));
|
||||||
}
|
}
|
||||||
#ifdef CRYPT
|
|
||||||
|
|
||||||
|
#ifdef CRYPT
|
||||||
#define HASH_SIZE 32
|
#define HASH_SIZE 32
|
||||||
SHA256 sha256;
|
SHA256 sha256;
|
||||||
extern uint32_t cryptoSalt;
|
extern uint32_t cryptoSalt;
|
||||||
//extern
|
extern char cryptoKey[];
|
||||||
const char cryptoKey[] ="12345678";
|
|
||||||
|
|
||||||
bool checkToken(char * token, char * data)
|
bool checkToken(char * token, char * data)
|
||||||
{
|
{
|
||||||
@@ -864,5 +864,12 @@ bool checkToken(char * token, char * data)
|
|||||||
{return true;}
|
{return true;}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool isProtectedPin(short pin)
|
||||||
|
{
|
||||||
|
for (short i=0; i<protectedPinsNum; i++)
|
||||||
|
if (pin==protectedPins[i]) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#pragma message(VAR_NAME_VALUE(debugSerial))
|
#pragma message(VAR_NAME_VALUE(debugSerial))
|
||||||
#pragma message(VAR_NAME_VALUE(SERIAL_BAUD))
|
#pragma message(VAR_NAME_VALUE(SERIAL_BAUD))
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ void PrintBytes(uint8_t* addr, uint8_t count, bool newline);
|
|||||||
void SetBytes(uint8_t* addr, uint8_t count, char * out);
|
void SetBytes(uint8_t* addr, uint8_t count, char * out);
|
||||||
void SetAddr(char * out, uint8_t* addr);
|
void SetAddr(char * out, uint8_t* addr);
|
||||||
uint8_t HEX2DEC(char i);
|
uint8_t HEX2DEC(char i);
|
||||||
int getInt(char ** chan);
|
long getInt(char ** chan);
|
||||||
itemCmd getNumber(char ** chan);
|
itemCmd getNumber(char ** chan);
|
||||||
unsigned long freeRam ();
|
unsigned long freeRam ();
|
||||||
void parseBytes(const char* str, char separator, byte* bytes, int maxBytes, int base);
|
void parseBytes(const char* str, char separator, byte* bytes, int maxBytes, int base);
|
||||||
@@ -78,3 +78,4 @@ String toString(const IPAddress& address);
|
|||||||
bool getPinVal(uint8_t pin);
|
bool getPinVal(uint8_t pin);
|
||||||
int str2regSize(char * str);
|
int str2regSize(char * str);
|
||||||
bool checkToken(char * token, char * data);
|
bool checkToken(char * token, char * data);
|
||||||
|
bool isProtectedPin(short pin);
|
||||||
|
|||||||
Reference in New Issue
Block a user