mirror of
https://github.com/anklimov/lighthub
synced 2025-12-06 03:39:49 +03:00
less CAN logging
DISABLE for group channel (disarming) reguire signature trace level logging fixed esp32 = changed compilation options
This commit is contained in:
@@ -358,10 +358,10 @@ switch (state)
|
||||
bool canDriver::processPacket(canid_t id, datagram_t *packet, uint8_t len, bool rtr)
|
||||
{
|
||||
|
||||
debugSerial.print("CAN: Rcvd ");
|
||||
debugSerial.print(len);
|
||||
debugSerial.print(" bytes id:");
|
||||
debugSerial.println(id.id,HEX);
|
||||
traceSerial.print("CAN: Rcvd ");
|
||||
traceSerial.print(len);
|
||||
traceSerial.print(" bytes id:");
|
||||
traceSerial.println(id.id,HEX);
|
||||
|
||||
//if (id.deviceId && (id.deviceId != controllerId) && !id.status) return false;
|
||||
|
||||
@@ -638,6 +638,9 @@ while (remoteConfObj)
|
||||
}
|
||||
remoteConfObj=remoteConfObj->next;
|
||||
}
|
||||
//debugSerial<<"Subscribed"<<endl;
|
||||
//delay(100);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -689,7 +692,7 @@ bool canDriver::write(uint32_t msg_id, datagram_t * buf, uint8_t size)
|
||||
CAN_TX_msg.id = msg_id;
|
||||
CAN_TX_msg.flags.extended = 1; // To enable extended ID
|
||||
CAN_TX_msg.len=size;
|
||||
if (res=STMCan.write(CAN_TX_msg)) debugSerial<<("CAN: Wrote ")<<size<<" bytes, id "<<_HEX(msg_id)<<endl;
|
||||
if (res=STMCan.write(CAN_TX_msg)) {traceSerial<<("CAN: Wrote ")<<size<<" bytes, id "<<_HEX(msg_id)<<endl;}
|
||||
else debugSerial.println("CAN: Write error");
|
||||
return res;
|
||||
#endif
|
||||
@@ -699,7 +702,7 @@ bool canDriver::write(uint32_t msg_id, datagram_t * buf, uint8_t size)
|
||||
CAN.beginExtendedPacket(msg_id,size);
|
||||
CAN.write(buf->data,size);
|
||||
//for(uint8_t i=0;i<size; i++) CAN.write(buf[i]);
|
||||
if (res=CAN.endPacket()) debugSerial<< ("CAN: Wrote ")<<size << " bytes, id "<<_HEX(msg_id)<<endl;
|
||||
if (res=CAN.endPacket()) {traceSerial<< ("CAN: Wrote ")<<size << " bytes, id "<<_HEX(msg_id)<<endl;}
|
||||
else debugSerial.println("CAN: Write error");
|
||||
return res;
|
||||
#endif
|
||||
@@ -712,8 +715,8 @@ bool canDriver::write(uint32_t msg_id, datagram_t * buf, uint8_t size)
|
||||
//outgoing.priority = 4; //0-15 lower is higher priority
|
||||
if (buf) for(uint8_t i=0;i<size; i++) CAN_TX_msg.data.bytes[i]=buf->data[i];
|
||||
res=Can0.sendFrame(CAN_TX_msg);
|
||||
if (res) debugSerial<<("CAN: Wrote ")<<size<<" bytes, id "<<_HEX(msg_id)<<endl;
|
||||
else debugSerial.println("CAN: Write error");
|
||||
if (res) {traceSerial<<F("CAN: Wrote ")<<size<<" bytes, id "<<_HEX(msg_id)<<endl;}
|
||||
else errorSerial.println("CAN: Write error");
|
||||
return res;
|
||||
#endif
|
||||
}
|
||||
@@ -724,7 +727,7 @@ bool canDriver::write(uint32_t msg_id, datagram_t * buf, uint8_t size)
|
||||
|
||||
bool canDriver::sendStatus(uint16_t itemNum, itemCmd cmd, int subItem)
|
||||
{
|
||||
if (!itemNum) return false;
|
||||
if (!itemNum || !controllerId) return false;
|
||||
return sendCommand(controllerId, itemNum, cmd, true, subItem);
|
||||
}
|
||||
|
||||
@@ -771,7 +774,7 @@ bool canDriver::sendCommand(uint8_t devID, uint16_t itemID,itemCmd cmd, bool sta
|
||||
packet.cmd = cmd.cmd;
|
||||
packet.param = cmd.param;
|
||||
|
||||
debugSerial << ((status)?"CAN: send Status":"CAN: send Command");
|
||||
debugSerial << ((status)?"CAN: Send Status":"CAN: Send Command");
|
||||
debugSerial<<F(" ->[")<<devID<<":"<<itemID<<"] ";
|
||||
if (subItemID!=NO_SUBITEM) debugSerial<<F("Subitem:")<<subItemID<<" ";
|
||||
cmd.debugOut();
|
||||
|
||||
@@ -1215,15 +1215,45 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
||||
}
|
||||
if (allowRecursion && itemArg->type == aJson_Array && operation)
|
||||
{
|
||||
chActive=(isActive()>0);
|
||||
digGroup(itemArg,&cmd,subItem,authorized);
|
||||
if ((suffixCode==S_CMD) && ((cmd.getCmd() == CMD_ENABLE) || (cmd.getCmd() == CMD_DISABLE)))
|
||||
{
|
||||
debugSerial<<F("CTRL: command just for ")<<itemArr->name<<endl;
|
||||
|
||||
switch (cmd.getCmd())
|
||||
{
|
||||
case CMD_ENABLE:
|
||||
clearFlag(FLAG_DISABLED);
|
||||
setCmd(CMD_ENABLE);
|
||||
break;
|
||||
case CMD_DISABLE:
|
||||
if (!authorized)
|
||||
{
|
||||
errorSerial<<F("Disarming not authorized")<<endl;
|
||||
return -5;
|
||||
}
|
||||
setFlag(FLAG_DISABLED);
|
||||
setCmd(CMD_DISABLE);
|
||||
}
|
||||
status2Send = FLAG_FLAGS;
|
||||
if (operation) SendStatus(status2Send);
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
chActive=(isActive()>0);
|
||||
if ((suffixCode!=S_CMD) || (cmd.getCmd() != CMD_XON) || !getFlag(FLAG_DISABLED))
|
||||
{
|
||||
digGroup(itemArg,&cmd,subItem,authorized);
|
||||
if ((suffixCode==S_CMD) && cmd.isValue())
|
||||
{
|
||||
scheduleOppositeCommand(originalCmd,chActive,authorized);
|
||||
scheduledOppositeCommand = true;
|
||||
}
|
||||
if (subItem) status2Send |= FLAG_SEND_IMMEDIATE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res=1;
|
||||
|
||||
|
||||
@@ -1458,7 +1488,7 @@ int Item::Ctrl(itemCmd cmd, char* subItem, bool allowRecursion, bool authorized
|
||||
{
|
||||
debugSerial<<F("CTRL: ON:Already Active\n");
|
||||
setCmd(CMD_ON);
|
||||
SendStatus(FLAG_COMMAND | FLAG_SEND_DEFFERED);
|
||||
SendStatus(FLAG_COMMAND | FLAG_SEND_DEFFERED,subItem);
|
||||
return 3;
|
||||
}
|
||||
|
||||
@@ -1680,7 +1710,7 @@ if ((!driver || driver->isAllowed(cmd)) && (!getFlag(FLAG_FREEZED)))
|
||||
|
||||
//update command for HALT & XON and send MQTT status
|
||||
if (command2Set) setCmd(command2Set | FLAG_COMMAND);
|
||||
if (operation) SendStatus(status2Send);
|
||||
if (operation) SendStatus(status2Send,subItem);
|
||||
} //alowed cmd
|
||||
else
|
||||
{
|
||||
@@ -1858,7 +1888,7 @@ void Item::sendDelayedStatus()
|
||||
}
|
||||
|
||||
|
||||
int Item::SendStatus(int sendFlags) {
|
||||
int Item::SendStatus(int sendFlags, char * subItem) {
|
||||
if (sendFlags & FLAG_SEND_IMMEDIATE) sendFlags &= ~ (FLAG_SEND_IMMEDIATE | FLAG_SEND_DEFFERED);
|
||||
if ((sendFlags & FLAG_SEND_DEFFERED) || freeRam()<150 || (!isNotRetainingStatus() )) {
|
||||
setFlag(sendFlags & (FLAG_COMMAND | FLAG_PARAMETERS | FLAG_FLAGS));
|
||||
@@ -1870,7 +1900,7 @@ int Item::SendStatus(int sendFlags) {
|
||||
itemCmd st(ST_VOID,CMD_VOID);
|
||||
st.loadItem(this, FLAG_COMMAND | FLAG_PARAMETERS);
|
||||
sendFlags |= getFlag(FLAG_COMMAND | FLAG_PARAMETERS | FLAG_FLAGS); //if some delayed status is pending
|
||||
return SendStatusImmediate(st,sendFlags);
|
||||
return SendStatusImmediate(st,sendFlags,subItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ class Item
|
||||
void setFloatVal(float par);
|
||||
void setSubtype(uint8_t par);
|
||||
int Poll(int cause);
|
||||
int SendStatus(int sendFlags);
|
||||
int SendStatus(int sendFlags, char * subItem=NULL);
|
||||
int SendStatusImmediate(itemCmd st, int sendFlags, char * subItem=NULL);
|
||||
int isActive();
|
||||
int getChanType();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#define MAXFLASHSTR 32
|
||||
#define PWDFLASHSTR 16
|
||||
#define EEPROM_SIGNATURE "LHC2"
|
||||
#define EEPROM_SIGNATURE "LHC3"
|
||||
#define EEPROM_SIGNATURE_LENGTH 4
|
||||
|
||||
//#define EEPROM_offsetJSON IFLASH_PAGE_SIZE
|
||||
@@ -25,11 +25,13 @@ const char EEPROM_signature[] = EEPROM_SIGNATURE;
|
||||
struct
|
||||
{
|
||||
uint8_t serialDebugLevel:4;
|
||||
uint8_t udpDebugLevel:4;
|
||||
|
||||
uint8_t notGetConfigFromHTTP:1;
|
||||
uint8_t udpDebugLevel:3;
|
||||
uint8_t notSaveSuccedConfig:1;
|
||||
uint8_t dhcpFallback:1;
|
||||
uint8_t spare2:6;
|
||||
uint8_t spare2:5;
|
||||
|
||||
uint16_t sysConfigHash;
|
||||
};
|
||||
} systemConfigFlags;
|
||||
|
||||
@@ -193,8 +193,9 @@ monitor_speed = 115200
|
||||
platform = espressif32
|
||||
framework = arduino
|
||||
monitor_filters = esp32_exception_decoder
|
||||
;build_type = debug
|
||||
board = esp32-evb
|
||||
build_type = debug
|
||||
board = upesy_wroom
|
||||
board_build.partitions = min_spiffs.csv
|
||||
extra_scripts = extra_script.py
|
||||
monitor_speed = 115200
|
||||
|
||||
|
||||
Reference in New Issue
Block a user