mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-10 22:51:36 +02:00
0.8.10
* fix Mi and HM inverter communication #1235 * added privacy mode option #1211 * changed serial debug option to work without reboot
This commit is contained in:
parent
49ef94cb7a
commit
b7f0e683ec
13 changed files with 75 additions and 50 deletions
|
@ -1,5 +1,10 @@
|
|||
# Development Changes
|
||||
|
||||
## 0.8.10 - 2023-11-19
|
||||
* fix Mi and HM inverter communication #1235
|
||||
* added privacy mode option #1211
|
||||
* changed serial debug option to work without reboot
|
||||
|
||||
## 0.8.9 - 2023-11-19
|
||||
* merged PR #1234
|
||||
* added new alarm codes
|
||||
|
|
|
@ -32,13 +32,11 @@ void app::setup() {
|
|||
DBGPRINTLN(F("false"));
|
||||
|
||||
if(mConfig->nrf.enabled) {
|
||||
mNrfRadio.setup(mConfig->nrf.pinIrq, mConfig->nrf.pinCe, mConfig->nrf.pinCs, mConfig->nrf.pinSclk, mConfig->nrf.pinMosi, mConfig->nrf.pinMiso);
|
||||
mNrfRadio.enableDebug();
|
||||
mNrfRadio.setup(&mConfig->serial.debug, &mConfig->serial.privacyLog, mConfig->nrf.pinIrq, mConfig->nrf.pinCe, mConfig->nrf.pinCs, mConfig->nrf.pinSclk, mConfig->nrf.pinMosi, mConfig->nrf.pinMiso);
|
||||
}
|
||||
#if defined(ESP32)
|
||||
if(mConfig->cmt.enabled) {
|
||||
mCmtRadio.setup(mConfig->cmt.pinSclk, mConfig->cmt.pinSdio, mConfig->cmt.pinCsb, mConfig->cmt.pinFcsb, false);
|
||||
mCmtRadio.enableDebug();
|
||||
mCmtRadio.setup(&mConfig->serial.debug, &mConfig->serial.privacyLog, mConfig->cmt.pinSclk, mConfig->cmt.pinSdio, mConfig->cmt.pinCsb, mConfig->cmt.pinFcsb, false);
|
||||
}
|
||||
#endif
|
||||
#ifdef ETHERNET
|
||||
|
@ -57,7 +55,7 @@ void app::setup() {
|
|||
#endif
|
||||
#endif /* defined(ETHERNET) */
|
||||
|
||||
mCommunication.setup(&mTimestamp);
|
||||
mCommunication.setup(&mTimestamp, &mConfig->serial.debug, &mConfig->serial.privacyLog);
|
||||
mCommunication.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1, std::placeholders::_2));
|
||||
mSys.setup(&mTimestamp, &mConfig->inst);
|
||||
for (uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) {
|
||||
|
|
|
@ -116,6 +116,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
bool showIv;
|
||||
bool debug;
|
||||
bool privacyLog;
|
||||
} cfgSerial_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -424,6 +425,7 @@ class settings {
|
|||
|
||||
mCfg.serial.showIv = false;
|
||||
mCfg.serial.debug = false;
|
||||
mCfg.serial.privacyLog = true;
|
||||
|
||||
mCfg.mqtt.port = DEF_MQTT_PORT;
|
||||
snprintf(mCfg.mqtt.broker, MQTT_ADDR_LEN, "%s", DEF_MQTT_BROKER);
|
||||
|
@ -617,9 +619,11 @@ class settings {
|
|||
if(set) {
|
||||
obj[F("show")] = mCfg.serial.showIv;
|
||||
obj[F("debug")] = mCfg.serial.debug;
|
||||
obj[F("prv")] = (bool) mCfg.serial.privacyLog;
|
||||
} else {
|
||||
getVal<bool>(obj, F("show"), &mCfg.serial.showIv);
|
||||
getVal<bool>(obj, F("debug"), &mCfg.serial.debug);
|
||||
getVal<bool>(obj, F("prv"), &mCfg.serial.privacyLog);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//-------------------------------------
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 8
|
||||
#define VERSION_PATCH 9
|
||||
#define VERSION_PATCH 10
|
||||
|
||||
//-------------------------------------
|
||||
typedef struct {
|
||||
|
|
|
@ -22,8 +22,10 @@ typedef std::function<void(Inverter<> *)> alarmListenerType;
|
|||
|
||||
class Communication : public CommQueue<> {
|
||||
public:
|
||||
void setup(uint32_t *timestamp) {
|
||||
void setup(uint32_t *timestamp, bool *serialDebug, bool *privacyMode) {
|
||||
mTimestamp = timestamp;
|
||||
mPrivacyMode = privacyMode;
|
||||
mSerialDebug = serialDebug;
|
||||
}
|
||||
|
||||
void addImportant(Inverter<> *iv, uint8_t cmd, bool delOnPop = true) {
|
||||
|
@ -57,13 +59,13 @@ class Communication : public CommQueue<> {
|
|||
mLocalBuf[i].len = 0;
|
||||
}
|
||||
|
||||
if(q->iv->radio->isSerialDebug())
|
||||
if(*mSerialDebug)
|
||||
mHeu.printStatus(q->iv);
|
||||
mHeu.getTxCh(q->iv);
|
||||
testMode = mHeu.getTestModeEnabled();
|
||||
q->iv->mGotFragment = false;
|
||||
q->iv->mGotLastMsg = false;
|
||||
mFirstTry = mFirstTry ? false : (((IV_HM == q->iv->ivGen) || (IV_MI == q->iv->ivGen) ) && (q->iv->isAvailable()) || (millis() < 120000));
|
||||
mFirstTry = mFirstTry ? false : (((IV_HM == q->iv->ivGen) || (IV_MI == q->iv->ivGen)) && ((q->iv->isAvailable()) || (millis() < 120000)));
|
||||
if(NULL == q->iv->radio)
|
||||
cmdDone(true); // can't communicate while radio is not defined!
|
||||
mState = States::START;
|
||||
|
@ -161,7 +163,10 @@ class Communication : public CommQueue<> {
|
|||
DBGPRINT(F(", "));
|
||||
DBGPRINT(String(p->rssi));
|
||||
DBGPRINT(F("dBm | "));
|
||||
ah::dumpBuf(p->packet, p->len, 1, 8, "#"+String(q->iv->id));
|
||||
if(*mPrivacyMode)
|
||||
ah::dumpBuf(p->packet, p->len, 1, 8);
|
||||
else
|
||||
ah::dumpBuf(p->packet, p->len);
|
||||
|
||||
if(checkIvSerial(&p->packet[1], q->iv)) {
|
||||
if(!testMode)
|
||||
|
@ -717,7 +722,7 @@ class Communication : public CommQueue<> {
|
|||
|
||||
|
||||
inline void miComplete(Inverter<> *iv) {
|
||||
if (iv->radio->isSerialDebug()) {
|
||||
if (*mSerialDebug) {
|
||||
DPRINT_IVID(DBG_INFO, iv->id);
|
||||
DBGPRINTLN(F("got all data msgs"));
|
||||
}
|
||||
|
@ -766,6 +771,7 @@ class Communication : public CommQueue<> {
|
|||
private:
|
||||
States mState = States::RESET;
|
||||
uint32_t *mTimestamp;
|
||||
bool *mPrivacyMode, *mSerialDebug;
|
||||
uint32_t mWaitTimeout = 0;
|
||||
uint32_t mWaitTimeout_min = 0;
|
||||
std::array<frame_t, MAX_PAYLOAD_ENTRIES> mLocalBuf;
|
||||
|
|
|
@ -29,7 +29,19 @@ template <uint8_t IRQ_PIN = DEF_NRF_IRQ_PIN, uint8_t CE_PIN = DEF_NRF_CE_PIN, ui
|
|||
class HmRadio : public Radio {
|
||||
public:
|
||||
HmRadio() : mNrf24(CE_PIN, CS_PIN, SPI_SPEED) {
|
||||
if(mSerialDebug) {
|
||||
mDtuSn = DTU_SN;
|
||||
mIrqRcvd = false;
|
||||
}
|
||||
~HmRadio() {}
|
||||
|
||||
void setup(bool *serialDebug, bool *privacyMode, uint8_t irq = IRQ_PIN, uint8_t ce = CE_PIN, uint8_t cs = CS_PIN, uint8_t sclk = SCLK_PIN, uint8_t mosi = MOSI_PIN, uint8_t miso = MISO_PIN) {
|
||||
DPRINTLN(DBG_VERBOSE, F("hmRadio.h:setup"));
|
||||
pinMode(irq, INPUT_PULLUP);
|
||||
|
||||
mSerialDebug = serialDebug;
|
||||
mPrivacyMode = privacyMode;
|
||||
|
||||
if(*mSerialDebug) {
|
||||
DPRINT(DBG_VERBOSE, F("hmRadio.h : HmRadio():mNrf24(CE_PIN: "));
|
||||
DBGPRINT(String(CE_PIN));
|
||||
DBGPRINT(F(", CS_PIN: "));
|
||||
|
@ -38,16 +50,6 @@ class HmRadio : public Radio {
|
|||
DBGPRINT(String(SPI_SPEED));
|
||||
DBGPRINTLN(F(")"));
|
||||
}
|
||||
mDtuSn = DTU_SN;
|
||||
|
||||
mSerialDebug = false;
|
||||
mIrqRcvd = false;
|
||||
}
|
||||
~HmRadio() {}
|
||||
|
||||
void setup(uint8_t irq = IRQ_PIN, uint8_t ce = CE_PIN, uint8_t cs = CS_PIN, uint8_t sclk = SCLK_PIN, uint8_t mosi = MOSI_PIN, uint8_t miso = MISO_PIN) {
|
||||
DPRINTLN(DBG_VERBOSE, F("hmRadio.h:setup"));
|
||||
pinMode(irq, INPUT_PULLUP);
|
||||
|
||||
generateDtuSn();
|
||||
DTU_RADIO_ID = ((uint64_t)(((mDtuSn >> 24) & 0xFF) | ((mDtuSn >> 8) & 0xFF00) | ((mDtuSn << 8) & 0xFF0000) | ((mDtuSn << 24) & 0xFF000000)) << 8) | 0x01;
|
||||
|
@ -252,9 +254,12 @@ class HmRadio : public Radio {
|
|||
p.millis = millis() - mMillis;
|
||||
mNrf24.read(p.packet, p.len);
|
||||
if (p.packet[0] != 0x00) {
|
||||
if(!checkIvSerial(&p.packet[1], mLastIv)) {
|
||||
DPRINT(DBG_WARN, "RX other inverter: ");
|
||||
ah::dumpBuf(p.packet, p.len);
|
||||
if(!checkIvSerial(p.packet, mLastIv)) {
|
||||
DPRINT(DBG_WARN, "RX other inverter ");
|
||||
if(*mPrivacyMode)
|
||||
ah::dumpBuf(p.packet, p.len, 1, 4);
|
||||
else
|
||||
ah::dumpBuf(p.packet, p.len);
|
||||
return false;
|
||||
}
|
||||
mLastIv->mGotFragment = true;
|
||||
|
@ -281,14 +286,17 @@ class HmRadio : public Radio {
|
|||
// set TX and RX channels
|
||||
mTxChIdx = mRfChLst[iv->txRfChId];
|
||||
|
||||
if(mSerialDebug) {
|
||||
if(*mSerialDebug) {
|
||||
DPRINT_IVID(DBG_INFO, iv->id);
|
||||
DBGPRINT(F("TX "));
|
||||
DBGPRINT(String(len));
|
||||
DBGPRINT(" CH");
|
||||
DBGPRINT(String(mTxChIdx));
|
||||
DBGPRINT(F(" | "));
|
||||
ah::dumpBuf(mTxBuf, len, 1, 4, "#"+String(iv->id));
|
||||
if(*mPrivacyMode)
|
||||
ah::dumpBuf(mTxBuf, len, 1, 4);
|
||||
else
|
||||
ah::dumpBuf(mTxBuf, len);
|
||||
}
|
||||
|
||||
mNrf24.stopListening();
|
||||
|
@ -309,8 +317,8 @@ class HmRadio : public Radio {
|
|||
}
|
||||
|
||||
inline bool checkIvSerial(uint8_t buf[], Inverter<> *iv) {
|
||||
for(uint8_t i = 0; i < 4; i++) {
|
||||
if(buf[3-i] != iv->radioId.b[i])
|
||||
for(uint8_t i = 1; i < 5; i++) {
|
||||
if(buf[i] != iv->radioId.b[i])
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -34,14 +34,6 @@ class Radio {
|
|||
mIrqRcvd = true;
|
||||
}
|
||||
|
||||
void enableDebug() {
|
||||
mSerialDebug = true;
|
||||
}
|
||||
|
||||
bool isSerialDebug() {
|
||||
return mSerialDebug;
|
||||
}
|
||||
|
||||
void sendCmdPacket(Inverter<> *iv, uint8_t mid, uint8_t pid, bool isRetransmit, bool appendCrc16=true) {
|
||||
initPacket(getIvId(iv), mid, pid);
|
||||
sendPacket(iv, 10, isRetransmit, appendCrc16);
|
||||
|
@ -55,7 +47,7 @@ class Radio {
|
|||
return;
|
||||
}
|
||||
|
||||
if(mSerialDebug) {
|
||||
if(*mSerialDebug) {
|
||||
DPRINT(DBG_DEBUG, F("prepareDevInformCmd 0x"));
|
||||
DPRINTLN(DBG_DEBUG,String(cmd, HEX));
|
||||
}
|
||||
|
@ -115,7 +107,8 @@ class Radio {
|
|||
|
||||
uint32_t mDtuSn;
|
||||
volatile bool mIrqRcvd;
|
||||
bool mSerialDebug;
|
||||
bool *mSerialDebug;
|
||||
bool *mPrivacyMode;
|
||||
uint8_t mTxBuf[MAX_RF_PAYLOAD_SIZE];
|
||||
|
||||
};
|
||||
|
|
|
@ -19,14 +19,18 @@ class CmtRadio : public Radio {
|
|||
mCmtAvail = false;
|
||||
}
|
||||
|
||||
void setup(uint8_t pinSclk, uint8_t pinSdio, uint8_t pinCsb, uint8_t pinFcsb, bool genDtuSn = true) {
|
||||
void setup(bool *serialDebug, bool *privacyMode, uint8_t pinSclk, uint8_t pinSdio, uint8_t pinCsb, uint8_t pinFcsb, bool genDtuSn = true) {
|
||||
mCmt.setup(pinSclk, pinSdio, pinCsb, pinFcsb);
|
||||
reset(genDtuSn);
|
||||
mPrivacyMode = privacyMode;
|
||||
mSerialDebug = serialDebug;
|
||||
}
|
||||
|
||||
void setup(bool genDtuSn = true) {
|
||||
void setup(bool *serialDebug, bool *privacyMode, bool genDtuSn = true) {
|
||||
mCmt.setup();
|
||||
reset(genDtuSn);
|
||||
mPrivacyMode = privacyMode;
|
||||
mSerialDebug = serialDebug;
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
@ -88,12 +92,15 @@ class CmtRadio : public Radio {
|
|||
|
||||
updateCrcs(&len, appendCrc16);
|
||||
|
||||
if(mSerialDebug) {
|
||||
if(*mSerialDebug) {
|
||||
DPRINT_IVID(DBG_INFO, iv->id);
|
||||
DBGPRINT(F("TX "));
|
||||
DBGPRINT(String(mCmt.getFreqKhz()/1000.0f));
|
||||
DBGPRINT(F("Mhz | "));
|
||||
ah::dumpBuf(mTxBuf, len);
|
||||
if(*mPrivacyMode)
|
||||
ah::dumpBuf(mTxBuf, len, 1, 4);
|
||||
else
|
||||
ah::dumpBuf(mTxBuf, len);
|
||||
}
|
||||
|
||||
uint8_t status = mCmt.tx(mTxBuf, len);
|
||||
|
@ -125,7 +132,6 @@ class CmtRadio : public Radio {
|
|||
mCmt.goRx();
|
||||
}
|
||||
|
||||
mSerialDebug = false;
|
||||
mIrqRcvd = false;
|
||||
mRqstGetRx = false;
|
||||
}
|
||||
|
|
|
@ -86,12 +86,12 @@ namespace ah {
|
|||
return ret;
|
||||
}
|
||||
|
||||
void dumpBuf(uint8_t buf[], uint8_t len, uint8_t firstRepl, uint8_t lastRepl, String repl) {
|
||||
void dumpBuf(uint8_t buf[], uint8_t len, uint8_t firstRepl, uint8_t lastRepl) {
|
||||
for(uint8_t i = 0; i < len; i++) {
|
||||
if(i < firstRepl || i > lastRepl)
|
||||
if((i < firstRepl) || (i > lastRepl) || (0 == firstRepl))
|
||||
DHEX(buf[i]);
|
||||
else
|
||||
DBGPRINT(repl);
|
||||
DBGPRINT(F(" *"));
|
||||
DBGPRINT(" ");
|
||||
}
|
||||
DBGPRINTLN("");
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace ah {
|
|||
String getDateTimeStrFile(time_t t);
|
||||
String getTimeStr(time_t t);
|
||||
uint64_t Serial2u64(const char *val);
|
||||
void dumpBuf(uint8_t buf[], uint8_t len, uint8_t firstRepl = 0, uint8_t lastRepl = 0, String repl = "");
|
||||
void dumpBuf(uint8_t buf[], uint8_t len, uint8_t firstRepl = 0, uint8_t lastRepl = 0);
|
||||
}
|
||||
|
||||
#endif /*__HELPER_H__*/
|
||||
|
|
|
@ -561,6 +561,7 @@ class RestApi {
|
|||
void getSerial(JsonObject obj) {
|
||||
obj[F("show_live_data")] = mConfig->serial.showIv;
|
||||
obj[F("debug")] = mConfig->serial.debug;
|
||||
obj[F("priv")] = mConfig->serial.privacyLog;
|
||||
}
|
||||
|
||||
void getStaticIp(JsonObject obj) {
|
||||
|
|
|
@ -48,6 +48,10 @@
|
|||
<div class="col-8 col-sm-3">Serial Debug</div>
|
||||
<div class="col-4 col-sm-9"><input type="checkbox" name="serDbg"/></div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-8 col-sm-3">Privacy Mode</div>
|
||||
<div class="col-4 col-sm-9"><input type="checkbox" name="priv"/></div>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
|
||||
|
@ -933,7 +937,7 @@
|
|||
/*ENDIF_ESP32*/
|
||||
|
||||
function parseSerial(obj) {
|
||||
for(var i of [["serEn", "show_live_data"], ["serDbg", "debug"]])
|
||||
for(var i of [["serEn", "show_live_data"], ["serDbg", "debug"], ["priv", "priv"]])
|
||||
document.getElementsByName(i[0])[0].checked = obj[i[1]];
|
||||
}
|
||||
|
||||
|
|
|
@ -559,6 +559,7 @@ class Web {
|
|||
|
||||
// serial console
|
||||
mConfig->serial.debug = (request->arg("serDbg") == "on");
|
||||
mConfig->serial.privacyLog = (request->arg("priv") == "on");
|
||||
mConfig->serial.showIv = (request->arg("serEn") == "on");
|
||||
|
||||
// display
|
||||
|
@ -634,7 +635,6 @@ class Web {
|
|||
{
|
||||
Inverter<> *iv;
|
||||
record_t<> *rec;
|
||||
statistics_t *stat;
|
||||
String promUnit, promType;
|
||||
String metrics;
|
||||
char type[60], topic[100], val[25];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue