mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-06 13:45:54 +02:00
0.8.151
* add button for CMT inverters to catch them independend on which frequency they were before #1749
This commit is contained in:
parent
28b303cac2
commit
f06e56c14f
9 changed files with 89 additions and 7 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
## 0.8.151 - 2024-10-03
|
## 0.8.151 - 2024-10-03
|
||||||
* don't interrupt current command by setting a new limit #1757
|
* don't interrupt current command by setting a new limit #1757
|
||||||
|
* add button for CMT inverters to catch them independend on which frequency they were before #1749
|
||||||
|
|
||||||
## 0.8.150 - 2024-10-02
|
## 0.8.150 - 2024-10-02
|
||||||
* fix nullptr exception
|
* fix nullptr exception
|
||||||
|
|
23
src/app.h
23
src/app.h
|
@ -291,6 +291,29 @@ class app : public IApp, public ah::Scheduler {
|
||||||
return mConfig->cmt.enabled;
|
return mConfig->cmt.enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmtSearch(uint8_t id, uint8_t toCh) override {
|
||||||
|
#if defined(ESP32)
|
||||||
|
Inverter<> *iv;
|
||||||
|
|
||||||
|
for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) {
|
||||||
|
iv = mSys.getInverterByPos(i, true);
|
||||||
|
if(nullptr != iv) {
|
||||||
|
if(i == id)
|
||||||
|
break;
|
||||||
|
else
|
||||||
|
iv = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(nullptr != iv) {
|
||||||
|
mCmtRadio.catchInverter(iv, toCh);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t getNrfIrqPin(void) {
|
uint8_t getNrfIrqPin(void) {
|
||||||
return mConfig->nrf.pinIrq;
|
return mConfig->nrf.pinIrq;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,8 @@ class IApp {
|
||||||
virtual bool getNrfEnabled() = 0;
|
virtual bool getNrfEnabled() = 0;
|
||||||
virtual bool getCmtEnabled() = 0;
|
virtual bool getCmtEnabled() = 0;
|
||||||
|
|
||||||
|
virtual bool cmtSearch(uint8_t id, uint8_t toCh) = 0;
|
||||||
|
|
||||||
virtual uint32_t getMqttRxCnt() = 0;
|
virtual uint32_t getMqttRxCnt() = 0;
|
||||||
virtual uint32_t getMqttTxCnt() = 0;
|
virtual uint32_t getMqttTxCnt() = 0;
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@ class Radio {
|
||||||
virtual void sendControlPacket(Inverter<> *iv, uint8_t cmd, uint16_t *data, bool isRetransmit) = 0;
|
virtual void sendControlPacket(Inverter<> *iv, uint8_t cmd, uint16_t *data, bool isRetransmit) = 0;
|
||||||
virtual bool switchFrequency(Inverter<> *iv, uint32_t fromkHz, uint32_t tokHz) { return true; }
|
virtual bool switchFrequency(Inverter<> *iv, uint32_t fromkHz, uint32_t tokHz) { return true; }
|
||||||
virtual bool switchFrequencyCh(Inverter<> *iv, uint8_t fromCh, uint8_t toCh) { return true; }
|
virtual bool switchFrequencyCh(Inverter<> *iv, uint8_t fromCh, uint8_t toCh) { return true; }
|
||||||
|
virtual void catchInverter(Inverter<> *iv, uint8_t toCh) {}
|
||||||
virtual bool isChipConnected(void) const { return false; }
|
virtual bool isChipConnected(void) const { return false; }
|
||||||
virtual uint16_t getBaseFreqMhz() { return 0; }
|
virtual uint16_t getBaseFreqMhz() { return 0; }
|
||||||
virtual uint16_t getBootFreqMhz() { return 0; }
|
virtual uint16_t getBootFreqMhz() { return 0; }
|
||||||
|
|
|
@ -35,6 +35,11 @@ class CmtRadio : public Radio {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mCmt.loop();
|
mCmt.loop();
|
||||||
|
if(nullptr != mCatchIv) {
|
||||||
|
if(mCmt.isTxReady())
|
||||||
|
catchInverterLoop();
|
||||||
|
}
|
||||||
|
|
||||||
if((!mIrqRcvd) && (!mRqstGetRx))
|
if((!mIrqRcvd) && (!mRqstGetRx))
|
||||||
return;
|
return;
|
||||||
getRx();
|
getRx();
|
||||||
|
@ -93,6 +98,28 @@ class CmtRadio : public Radio {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void catchInverter(Inverter<> *iv, uint8_t toCh) override {
|
||||||
|
if(!isChipConnected())
|
||||||
|
return;
|
||||||
|
|
||||||
|
mCatchIv = iv;
|
||||||
|
mCatchIvCh = 1;
|
||||||
|
mCatchIvToCh = toCh;
|
||||||
|
|
||||||
|
mCmt.switchChannel(0);
|
||||||
|
sendSwitchChCmd(iv, toCh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void catchInverterLoop() {
|
||||||
|
mCmt.switchChannel(mCatchIvCh);
|
||||||
|
sendSwitchChCmd(mCatchIv, mCatchIvToCh);
|
||||||
|
|
||||||
|
if(++mCatchIvCh == 0x29) {
|
||||||
|
mCmt.switchChannel(mCatchIvToCh);
|
||||||
|
mCatchIv = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t getBaseFreqMhz(void) override {
|
uint16_t getBaseFreqMhz(void) override {
|
||||||
return mCmt.getBaseFreqMhz();
|
return mCmt.getBaseFreqMhz();
|
||||||
}
|
}
|
||||||
|
@ -168,10 +195,6 @@ class CmtRadio : public Radio {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void sendSwitchChCmd(Inverter<> *iv, uint8_t ch) {
|
inline void sendSwitchChCmd(Inverter<> *iv, uint8_t ch) {
|
||||||
//if(CMT_SWITCH_CHANNEL_CYCLE > ++mSwitchCycle)
|
|
||||||
// return;
|
|
||||||
//mSwitchCycle = 0;
|
|
||||||
|
|
||||||
/** ch:
|
/** ch:
|
||||||
* 0x00: 860.00 MHz
|
* 0x00: 860.00 MHz
|
||||||
* 0x01: 860.25 MHz
|
* 0x01: 860.25 MHz
|
||||||
|
@ -194,7 +217,6 @@ class CmtRadio : public Radio {
|
||||||
packet_t p;
|
packet_t p;
|
||||||
p.millis = millis() - mMillis;
|
p.millis = millis() - mMillis;
|
||||||
if(CmtStatus::SUCCESS == mCmt.getRx(p.packet, &p.len, 28, &p.rssi)) {
|
if(CmtStatus::SUCCESS == mCmt.getRx(p.packet, &p.len, 28, &p.rssi)) {
|
||||||
//mSwitchCycle = 0;
|
|
||||||
p.ch = 0; // not used for CMT inverters
|
p.ch = 0; // not used for CMT inverters
|
||||||
mBufCtrl.push(p);
|
mBufCtrl.push(p);
|
||||||
}
|
}
|
||||||
|
@ -210,7 +232,10 @@ class CmtRadio : public Radio {
|
||||||
bool mCmtAvail = false;
|
bool mCmtAvail = false;
|
||||||
bool mRqstGetRx = false;
|
bool mRqstGetRx = false;
|
||||||
uint32_t mMillis = 0;
|
uint32_t mMillis = 0;
|
||||||
//uint8_t mSwitchCycle = 0;
|
|
||||||
|
Inverter<> *mCatchIv = nullptr;
|
||||||
|
uint8_t mCatchIvCh = 0;
|
||||||
|
uint8_t mCatchIvToCh = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*__HMS_RADIO_H__*/
|
#endif /*__HMS_RADIO_H__*/
|
||||||
|
|
|
@ -188,6 +188,10 @@ class Cmt2300a {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isTxReady() {
|
||||||
|
return !mTxPending;
|
||||||
|
}
|
||||||
|
|
||||||
CmtStatus goRx(void) {
|
CmtStatus goRx(void) {
|
||||||
if(mTxPending)
|
if(mTxPending)
|
||||||
return CmtStatus::ERR_TX_PENDING;
|
return CmtStatus::ERR_TX_PENDING;
|
||||||
|
|
|
@ -1131,6 +1131,11 @@ class RestApi {
|
||||||
iv->setDevCommand(jsonIn[F("val")].as<int>());
|
iv->setDevCommand(jsonIn[F("val")].as<int>());
|
||||||
} else if(F("restart_ahoy") == jsonIn[F("cmd")]) {
|
} else if(F("restart_ahoy") == jsonIn[F("cmd")]) {
|
||||||
mApp->setRebootFlag();
|
mApp->setRebootFlag();
|
||||||
|
} else if(F("cmt_search") == jsonIn[F("cmd")]) {
|
||||||
|
if(!mApp->cmtSearch(jsonIn[F("id")], jsonIn[F("to_ch")])) {
|
||||||
|
jsonOut[F("error")] = F("ERR_INVERTER_NOT_FOUND");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
jsonOut[F("error")] = F("ERR_UNKNOWN_CMD");
|
jsonOut[F("error")] = F("ERR_UNKNOWN_CMD");
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -817,7 +817,8 @@
|
||||||
ml("input", {type: "hidden", name: "isnrf"}, null),
|
ml("input", {type: "hidden", name: "isnrf"}, null),
|
||||||
ml("div", {id: "setcmt"}, [
|
ml("div", {id: "setcmt"}, [
|
||||||
divRow("{#INV_FREQUENCY}", sel("freq", esp32cmtFreq, obj.freq)),
|
divRow("{#INV_FREQUENCY}", sel("freq", esp32cmtFreq, obj.freq)),
|
||||||
divRow("{#INV_POWER_LEVEL}", sel("cmtpa", esp32cmtPa, obj.pa))
|
divRow("{#INV_POWER_LEVEL}", sel("cmtpa", esp32cmtPa, obj.pa)),
|
||||||
|
divRow("{#INV_SEARCH}", ml("input", {type: "button", value: "{#BTN_SEARCH}", class: "btn", onclick: function() { cmtSearch(); }}, null))
|
||||||
]),
|
]),
|
||||||
ml("div", {id: "setnrf"},
|
ml("div", {id: "setnrf"},
|
||||||
divRow("{#INV_POWER_LEVEL}", sel("nrfpa", nrfPa, obj.pa))
|
divRow("{#INV_POWER_LEVEL}", sel("nrfpa", nrfPa, obj.pa))
|
||||||
|
@ -902,6 +903,16 @@
|
||||||
getAjax("/api/setup", cb, "POST", JSON.stringify(o));
|
getAjax("/api/setup", cb, "POST", JSON.stringify(o));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cmtSearch() {
|
||||||
|
var o = {}
|
||||||
|
o.cmd = "cmt_search"
|
||||||
|
o.token = "*"
|
||||||
|
o.id = obj.id
|
||||||
|
o.to_ch = document.getElementsByName("freq")[0].value;
|
||||||
|
|
||||||
|
getAjax("/api/ctrl", cb, "POST", JSON.stringify(o));
|
||||||
|
}
|
||||||
|
|
||||||
function convHerf(sn) {
|
function convHerf(sn) {
|
||||||
let sn_int = 0n;
|
let sn_int = 0n;
|
||||||
const CHARS = "0123456789ABCDEFGHJKLMNPRSTUVWXY";
|
const CHARS = "0123456789ABCDEFGHJKLMNPRSTUVWXY";
|
||||||
|
|
|
@ -698,6 +698,16 @@
|
||||||
"en": "Pause communication during night (lat. and lon. need to be set)",
|
"en": "Pause communication during night (lat. and lon. need to be set)",
|
||||||
"de": "Kommunikation während der Nacht pausieren (Breiten- und Längengrad müssen gesetzt sein"
|
"de": "Kommunikation während der Nacht pausieren (Breiten- und Längengrad müssen gesetzt sein"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"token": "INV_SEARCH",
|
||||||
|
"en": "Catch Inverter",
|
||||||
|
"de": "Wechselrichter suchen"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"token": "BTN_SEARCH",
|
||||||
|
"en": "start",
|
||||||
|
"de": "starten"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"token": "BTN_SAVE",
|
"token": "BTN_SAVE",
|
||||||
"en": "save",
|
"en": "save",
|
||||||
|
|
Loading…
Add table
Reference in a new issue