mirror of
https://github.com/lumapu/ahoy.git
synced 2025-07-14 23:17:15 +02:00
review #804
This commit is contained in:
parent
a1fb4aa911
commit
3f2e40848e
3 changed files with 17 additions and 41 deletions
|
@ -144,10 +144,8 @@ class Inverter {
|
||||||
void enqueCommand(uint8_t cmd) {
|
void enqueCommand(uint8_t cmd) {
|
||||||
_commandQueue.push(std::make_shared<T>(cmd));
|
_commandQueue.push(std::make_shared<T>(cmd));
|
||||||
DPRINT_IVID(DBG_INFO, id);
|
DPRINT_IVID(DBG_INFO, id);
|
||||||
//DPRINT(DBG_INFO, F("(#"));
|
DBGPRINTLN(F("enqueCommand: 0x"));
|
||||||
//DBGPRINT(String(id));
|
DBGHEXLN(cmd);
|
||||||
DBGPRINTLN(F("enqueCommand: 0x") + String(cmd, HEX));
|
|
||||||
//DBGHEXLN(cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setQueuedCmdFinished() {
|
void setQueuedCmdFinished() {
|
||||||
|
@ -305,7 +303,8 @@ class Inverter {
|
||||||
DPRINTLN(DBG_DEBUG, "add config");
|
DPRINTLN(DBG_DEBUG, "add config");
|
||||||
if (getPosByChFld(0, FLD_ACT_ACTIVE_PWR_LIMIT, rec) == pos){
|
if (getPosByChFld(0, FLD_ACT_ACTIVE_PWR_LIMIT, rec) == pos){
|
||||||
actPowerLimit = rec->record[pos];
|
actPowerLimit = rec->record[pos];
|
||||||
DPRINTLN(DBG_DEBUG, F("Inverter actual power limit: ") + String(actPowerLimit, 1));
|
DPRINT(DBG_DEBUG, F("Inverter actual power limit: "));
|
||||||
|
DBGPRINTLN(String(actPowerLimit, 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (rec->assign == AlarmDataAssignment) {
|
else if (rec->assign == AlarmDataAssignment) {
|
||||||
|
|
|
@ -118,10 +118,6 @@ class HmPayload {
|
||||||
iv->setQueuedCmdFinished(); // command failed
|
iv->setQueuedCmdFinished(); // command failed
|
||||||
if (mSerialDebug) {
|
if (mSerialDebug) {
|
||||||
DPRINTLN(DBG_INFO, F("enqueued cmd failed/timeout"));
|
DPRINTLN(DBG_INFO, F("enqueued cmd failed/timeout"));
|
||||||
//if (mSerialDebug) {
|
|
||||||
//DPRINT(DBG_INFO, F("(#"));
|
|
||||||
//DBGPRINT(String(iv->id));
|
|
||||||
//DBGPRINT(F(") no Payload received! (retransmits: "));
|
|
||||||
DPRINT_IVID(DBG_INFO, iv->id);
|
DPRINT_IVID(DBG_INFO, iv->id);
|
||||||
DBGPRINT(F("no Payload received! (retransmits: "));
|
DBGPRINT(F("no Payload received! (retransmits: "));
|
||||||
DBGPRINT(String(mPayload[iv->id].retransmits));
|
DBGPRINT(String(mPayload[iv->id].retransmits));
|
||||||
|
@ -137,18 +133,12 @@ class HmPayload {
|
||||||
yield();
|
yield();
|
||||||
if (mSerialDebug) {
|
if (mSerialDebug) {
|
||||||
DPRINT_IVID(DBG_INFO, iv->id);
|
DPRINT_IVID(DBG_INFO, iv->id);
|
||||||
//DPRINT(DBG_INFO, F("(#"));
|
|
||||||
//DBGPRINT(String(iv->id));
|
|
||||||
//DBGPRINT(F(") Requesting Inv SN "));
|
|
||||||
DBGPRINT(F("Requesting Inv SN "));
|
DBGPRINT(F("Requesting Inv SN "));
|
||||||
DBGPRINTLN(String(iv->config->serial.u64, HEX));
|
DBGPRINTLN(String(iv->config->serial.u64, HEX));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iv->getDevControlRequest()) {
|
if (iv->getDevControlRequest()) {
|
||||||
if (mSerialDebug) {
|
if (mSerialDebug) {
|
||||||
//DPRINT(DBG_INFO, F("(#"));
|
|
||||||
//DBGPRINT(String(iv->id));
|
|
||||||
//DBGPRINT(F(") Devcontrol request 0x"));
|
|
||||||
DPRINT_IVID(DBG_INFO, iv->id);
|
DPRINT_IVID(DBG_INFO, iv->id);
|
||||||
DBGPRINT(F("Devcontrol request 0x"));
|
DBGPRINT(F("Devcontrol request 0x"));
|
||||||
DBGPRINT(String(iv->devControlCmd, HEX));
|
DBGPRINT(String(iv->devControlCmd, HEX));
|
||||||
|
@ -161,9 +151,6 @@ class HmPayload {
|
||||||
//iv->enqueCommand<InfoCommand>(SystemConfigPara); // read back power limit
|
//iv->enqueCommand<InfoCommand>(SystemConfigPara); // read back power limit
|
||||||
} else {
|
} else {
|
||||||
uint8_t cmd = iv->getQueuedCmd();
|
uint8_t cmd = iv->getQueuedCmd();
|
||||||
//DPRINT(DBG_INFO, F("(#"));
|
|
||||||
//DBGPRINT(String(iv->id));
|
|
||||||
//DBGPRINT(F(") prepareDevInformCmd 0x"));
|
|
||||||
DPRINT_IVID(DBG_INFO, iv->id);
|
DPRINT_IVID(DBG_INFO, iv->id);
|
||||||
DBGPRINT(F("prepareDevInformCmd 0x"));
|
DBGPRINT(F("prepareDevInformCmd 0x"));
|
||||||
DBGHEXLN(cmd);
|
DBGHEXLN(cmd);
|
||||||
|
@ -180,7 +167,8 @@ class HmPayload {
|
||||||
if (*pid == 0x00) {
|
if (*pid == 0x00) {
|
||||||
DPRINTLN(DBG_DEBUG, F("fragment number zero received and ignored"));
|
DPRINTLN(DBG_DEBUG, F("fragment number zero received and ignored"));
|
||||||
} else {
|
} else {
|
||||||
DPRINTLN(DBG_DEBUG, F("PID: 0x") + String(*pid, HEX));
|
DPRINT(DBG_DEBUG, F("PID: 0x"));
|
||||||
|
DBGHEXLN(*pid);
|
||||||
if ((*pid & 0x7F) < MAX_PAYLOAD_ENTRIES) {
|
if ((*pid & 0x7F) < MAX_PAYLOAD_ENTRIES) {
|
||||||
memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->packet[10], p->len - 11);
|
memcpy(mPayload[iv->id].data[(*pid & 0x7F) - 1], &p->packet[10], p->len - 11);
|
||||||
mPayload[iv->id].len[(*pid & 0x7F) - 1] = p->len - 11;
|
mPayload[iv->id].len[(*pid & 0x7F) - 1] = p->len - 11;
|
||||||
|
@ -208,17 +196,14 @@ class HmPayload {
|
||||||
mApp->setMqttPowerLimitAck(iv);
|
mApp->setMqttPowerLimitAck(iv);
|
||||||
else
|
else
|
||||||
ok = false;
|
ok = false;
|
||||||
//DPRINT(DBG_INFO, F("(#"));
|
|
||||||
//DBGPRINT(String(iv->id));
|
|
||||||
if (mSerialDebug) {
|
|
||||||
DPRINT_IVID(DBG_INFO, iv->id);
|
DPRINT_IVID(DBG_INFO, iv->id);
|
||||||
DBGPRINT(F(" has "));
|
DBGPRINT(F("has "));
|
||||||
if(!ok) DBGPRINT(F("not "));
|
if(!ok) DBGPRINT(F("not "));
|
||||||
DBGPRINT(F("accepted power limit set point "));
|
DBGPRINT(F("accepted power limit set point "));
|
||||||
DBGPRINT(String(iv->powerLimit[0]));
|
DBGPRINT(String(iv->powerLimit[0]));
|
||||||
DBGPRINT(F(" with PowerLimitControl "));
|
DBGPRINT(F(" with PowerLimitControl "));
|
||||||
DBGPRINTLN(String(iv->powerLimit[1]));
|
DBGPRINTLN(String(iv->powerLimit[1]));
|
||||||
}
|
|
||||||
|
|
||||||
iv->clearCmdQueue();
|
iv->clearCmdQueue();
|
||||||
iv->enqueCommand<InfoCommand>(SystemConfigPara); // read back power limit
|
iv->enqueCommand<InfoCommand>(SystemConfigPara); // read back power limit
|
||||||
|
@ -254,8 +239,6 @@ class HmPayload {
|
||||||
DPRINTLN(DBG_INFO, F("Prevent retransmit on Restart / CleanState_LockAndAlarm..."));
|
DPRINTLN(DBG_INFO, F("Prevent retransmit on Restart / CleanState_LockAndAlarm..."));
|
||||||
mPayload[iv->id].retransmits = mMaxRetrans;
|
mPayload[iv->id].retransmits = mMaxRetrans;
|
||||||
} else if(iv->devControlCmd == ActivePowerContr) {
|
} else if(iv->devControlCmd == ActivePowerContr) {
|
||||||
//DPRINT(DBG_INFO, F("(#"));
|
|
||||||
//DBGPRINT(String(iv->id));
|
|
||||||
DPRINT_IVID(DBG_INFO, iv->id);
|
DPRINT_IVID(DBG_INFO, iv->id);
|
||||||
DPRINTLN(DBG_INFO, F("retransmit power limit"));
|
DPRINTLN(DBG_INFO, F("retransmit power limit"));
|
||||||
mSys->Radio.sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit, true);
|
mSys->Radio.sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit, true);
|
||||||
|
@ -267,16 +250,12 @@ class HmPayload {
|
||||||
DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") prepareDevInformCmd 0x") + String(mPayload[iv->id].txCmd, HEX));
|
DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") prepareDevInformCmd 0x") + String(mPayload[iv->id].txCmd, HEX));
|
||||||
mSys->Radio.prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true);
|
mSys->Radio.prepareDevInformCmd(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex, true);
|
||||||
*/
|
*/
|
||||||
//DPRINT(DBG_INFO, F("(#"));
|
|
||||||
//DBGPRINT(String(iv->id));
|
|
||||||
DPRINT_IVID(DBG_INFO, iv->id);
|
DPRINT_IVID(DBG_INFO, iv->id);
|
||||||
DBGPRINTLN(F("nothing received"));
|
DBGPRINTLN(F("nothing received"));
|
||||||
mPayload[iv->id].retransmits = mMaxRetrans;
|
mPayload[iv->id].retransmits = mMaxRetrans;
|
||||||
} else {
|
} else {
|
||||||
for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId - 1); i++) {
|
for (uint8_t i = 0; i < (mPayload[iv->id].maxPackId - 1); i++) {
|
||||||
if (mPayload[iv->id].len[i] == 0) {
|
if (mPayload[iv->id].len[i] == 0) {
|
||||||
//DPRINT(DBG_WARN, F("(#"));
|
|
||||||
//DBGPRINT(String(iv->id));
|
|
||||||
DPRINT_IVID(DBG_WARN, iv->id);
|
DPRINT_IVID(DBG_WARN, iv->id);
|
||||||
DBGPRINT(F("Frame "));
|
DBGPRINT(F("Frame "));
|
||||||
DBGPRINT(String(i + 1));
|
DBGPRINT(String(i + 1));
|
||||||
|
@ -295,8 +274,6 @@ class HmPayload {
|
||||||
mPayload[iv->id].retransmits++;
|
mPayload[iv->id].retransmits++;
|
||||||
DPRINTLN(DBG_WARN, F("CRC Error: Request Complete Retransmit"));
|
DPRINTLN(DBG_WARN, F("CRC Error: Request Complete Retransmit"));
|
||||||
mPayload[iv->id].txCmd = iv->getQueuedCmd();
|
mPayload[iv->id].txCmd = iv->getQueuedCmd();
|
||||||
//DPRINT(DBG_INFO, F("(#"));
|
|
||||||
//DBGPRINT(String(iv->id));
|
|
||||||
DPRINT_IVID(DBG_INFO, iv->id);
|
DPRINT_IVID(DBG_INFO, iv->id);
|
||||||
DBGPRINT(F("prepareDevInformCmd 0x"));
|
DBGPRINT(F("prepareDevInformCmd 0x"));
|
||||||
DBGHEXLN(mPayload[iv->id].txCmd);
|
DBGHEXLN(mPayload[iv->id].txCmd);
|
||||||
|
@ -307,7 +284,8 @@ class HmPayload {
|
||||||
DBGHEXLN(mPayload[iv->id].txCmd);
|
DBGHEXLN(mPayload[iv->id].txCmd);
|
||||||
DPRINT(DBG_INFO, F("procPyld: txid: 0x"));
|
DPRINT(DBG_INFO, F("procPyld: txid: 0x"));
|
||||||
DBGHEXLN(mPayload[iv->id].txId);
|
DBGHEXLN(mPayload[iv->id].txId);
|
||||||
DPRINTLN(DBG_DEBUG, F("procPyld: max: ") + String(mPayload[iv->id].maxPackId));
|
DPRINT(DBG_DEBUG, F("procPyld: max: "));
|
||||||
|
DBGPRINTLN(String(mPayload[iv->id].maxPackId));
|
||||||
record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser
|
record_t<> *rec = iv->getRecordStruct(mPayload[iv->id].txCmd); // choose the parser
|
||||||
mPayload[iv->id].complete = true;
|
mPayload[iv->id].complete = true;
|
||||||
|
|
||||||
|
|
|
@ -62,8 +62,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void DBGHEXLN(uint8_t b) {
|
inline void DBGHEXLN(uint8_t b) {
|
||||||
if( b<0x10 ) DBGPRINT(F("0"));
|
DHEX(b);
|
||||||
DBGPRINT(String(b, HEX));
|
|
||||||
DBGPRINT(F("\r\n"));
|
DBGPRINT(F("\r\n"));
|
||||||
}
|
}
|
||||||
/*inline void DHEX(uint16_t b) {
|
/*inline void DHEX(uint16_t b) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue