MI - dec control plus debug (#4)

* restructure serial debug output (partly) 

+ MI - more code review

* fix debug output for power control cmds

* MI - limitation commands answered

* Debug - add more macros and texts

Might as well help for https://github.com/lumapu/ahoy/pull/478

Unfortunately, this atm doesn't really lower used flash memory

* MI - limit command

- now seems to work for MI-600 (to be verified)
- debug - more use of macros (wrt. to real effect see last remark)
This commit is contained in:
rejoe2 2023-03-19 13:49:07 +01:00 committed by GitHub
parent 296597a589
commit a7bacf1f11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 243 additions and 109 deletions

View file

@ -175,18 +175,39 @@ class HmRadio {
mSerialDebug = true;
}
void sendControlPacket(uint64_t invId, uint8_t cmd, uint16_t *data, bool isRetransmit) {
void sendControlPacket(uint64_t invId, uint8_t cmd, uint16_t *data, bool isRetransmit, bool isNoMI = true) {
DPRINT(DBG_INFO, F("sendControlPacket cmd: 0x"));
DBGPRINTLN(String(cmd, HEX));
initPacket(invId, TX_REQ_DEVCONTROL, SINGLE_FRAME);
uint8_t cnt = 10;
mTxBuf[cnt++] = cmd; // cmd -> 0 on, 1 off, 2 restart, 11 active power, 12 reactive power, 13 power factor
mTxBuf[cnt++] = 0x00;
if(cmd >= ActivePowerContr && cmd <= PFSet) { // ActivePowerContr, ReactivePowerContr, PFSet
mTxBuf[cnt++] = ((data[0] * 10) >> 8) & 0xff; // power limit
mTxBuf[cnt++] = ((data[0] * 10) ) & 0xff; // power limit
mTxBuf[cnt++] = ((data[1] ) >> 8) & 0xff; // setting for persistens handlings
mTxBuf[cnt++] = ((data[1] ) ) & 0xff; // setting for persistens handling
if (isNoMI) {
mTxBuf[cnt++] = cmd; // cmd -> 0 on, 1 off, 2 restart, 11 active power, 12 reactive power, 13 power factor
mTxBuf[cnt++] = 0x00;
if(cmd >= ActivePowerContr && cmd <= PFSet) { // ActivePowerContr, ReactivePowerContr, PFSet
mTxBuf[cnt++] = ((data[0] * 10) >> 8) & 0xff; // power limit
mTxBuf[cnt++] = ((data[0] * 10) ) & 0xff; // power limit
mTxBuf[cnt++] = ((data[1] ) >> 8) & 0xff; // setting for persistens handlings
mTxBuf[cnt++] = ((data[1] ) ) & 0xff; // setting for persistens handling
}
} else { //MI 2nd gen. specific
switch (cmd) {
case TurnOn:
mTxBuf[9] = 0x55;
mTxBuf[10] = 0xaa;
break;
case TurnOff:
mTxBuf[9] = 0xaa;
mTxBuf[10] = 0x55;
break;
case ActivePowerContr:
cnt++;
mTxBuf[9] = 0x5a;
mTxBuf[10] = 0x5a;
mTxBuf[11] = data[0]; // power limit
break;
default:
return;
}
}
sendPacket(invId, cnt, isRetransmit, true);
}