mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-03 03:01:40 +02:00
0.8.19
* added ms to serial log * added (debug) option to configure gap between inverter requests
This commit is contained in:
parent
e4ab7e9e5b
commit
1c12f4c141
13 changed files with 50 additions and 27 deletions
|
@ -1,5 +1,9 @@
|
|||
# Development Changes
|
||||
|
||||
## 0.8.19 - 2023-12-11
|
||||
* added ms to serial log
|
||||
* added (debug) option to configure gap between inverter requests
|
||||
|
||||
## 0.8.18 - 2023-12-10
|
||||
* copied even more from the original heuristic code #1259
|
||||
* added mDNS support #1262
|
||||
|
|
|
@ -54,7 +54,7 @@ void app::setup() {
|
|||
#endif
|
||||
#endif /* defined(ETHERNET) */
|
||||
|
||||
mCommunication.setup(&mTimestamp, &mConfig->serial.debug, &mConfig->serial.privacyLog, &mConfig->serial.printWholeTrace);
|
||||
mCommunication.setup(&mTimestamp, &mConfig->serial.debug, &mConfig->serial.privacyLog, &mConfig->serial.printWholeTrace, &mConfig->inst.gapMs);
|
||||
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++) {
|
||||
|
|
|
@ -211,15 +211,6 @@ class app : public IApp, public ah::Scheduler {
|
|||
return mConfig->cmt.pinIrq;
|
||||
}
|
||||
|
||||
String getTimeStr(uint32_t offset = 0) {
|
||||
char str[10];
|
||||
if(0 == mTimestamp)
|
||||
sprintf(str, "n/a");
|
||||
else
|
||||
sprintf(str, "%02d:%02d:%02d ", hour(mTimestamp + offset), minute(mTimestamp + offset), second(mTimestamp + offset));
|
||||
return String(str);
|
||||
}
|
||||
|
||||
uint32_t getTimezoneOffset() {
|
||||
return mApi.getTimezoneOffset();
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ class IApp {
|
|||
virtual uint32_t getSunrise() = 0;
|
||||
virtual uint32_t getSunset() = 0;
|
||||
virtual void setTimestamp(uint32_t newTime) = 0;
|
||||
virtual String getTimeStr(uint32_t offset) = 0;
|
||||
virtual uint32_t getTimezoneOffset() = 0;
|
||||
virtual void getSchedulerInfo(uint8_t *max) = 0;
|
||||
virtual void getSchedulerNames() = 0;
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
* https://arduino-esp8266.readthedocs.io/en/latest/filesystem.html#flash-layout
|
||||
* */
|
||||
|
||||
#define CONFIG_VERSION 3
|
||||
#define CONFIG_VERSION 4
|
||||
|
||||
|
||||
#define PROT_MASK_INDEX 0x0001
|
||||
|
@ -159,6 +159,7 @@ typedef struct {
|
|||
bool rstMaxValsMidNight;
|
||||
bool startWithoutTime;
|
||||
float yieldEffiency;
|
||||
uint16_t gapMs;
|
||||
} cfgInst_t;
|
||||
|
||||
typedef struct {
|
||||
|
@ -443,6 +444,7 @@ class settings {
|
|||
mCfg.inst.startWithoutTime = false;
|
||||
mCfg.inst.rstMaxValsMidNight = false;
|
||||
mCfg.inst.yieldEffiency = 1.0f;
|
||||
mCfg.inst.gapMs = 2000;
|
||||
|
||||
for(uint8_t i = 0; i < MAX_NUM_INVERTERS; i++) {
|
||||
mCfg.inst.iv[i].powerLevel = 0xff; // impossible high value
|
||||
|
@ -483,6 +485,9 @@ class settings {
|
|||
if(mCfg.configVersion < 3) {
|
||||
mCfg.serial.printWholeTrace = true;
|
||||
}
|
||||
if(mCfg.configVersion < 4) {
|
||||
mCfg.inst.gapMs = 2000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -708,12 +713,13 @@ class settings {
|
|||
void jsonInst(JsonObject obj, bool set = false) {
|
||||
if(set) {
|
||||
obj[F("en")] = (bool)mCfg.inst.enabled;
|
||||
obj[F("rstMidNight")] = (bool)mCfg.inst.rstYieldMidNight;
|
||||
obj[F("rstNotAvail")] = (bool)mCfg.inst.rstValsNotAvail;
|
||||
obj[F("rstComStop")] = (bool)mCfg.inst.rstValsCommStop;
|
||||
obj[F("strtWthtTime")] = (bool)mCfg.inst.startWithoutTime;
|
||||
obj[F("rstMidNight")] = (bool)mCfg.inst.rstYieldMidNight;
|
||||
obj[F("rstNotAvail")] = (bool)mCfg.inst.rstValsNotAvail;
|
||||
obj[F("rstComStop")] = (bool)mCfg.inst.rstValsCommStop;
|
||||
obj[F("strtWthtTime")] = (bool)mCfg.inst.startWithoutTime;
|
||||
obj[F("rstMaxMidNight")] = (bool)mCfg.inst.rstMaxValsMidNight;
|
||||
obj[F("yldEff")] = mCfg.inst.yieldEffiency;
|
||||
obj[F("yldEff")] = mCfg.inst.yieldEffiency;
|
||||
obj[F("gap")] = mCfg.inst.gapMs;
|
||||
}
|
||||
else {
|
||||
getVal<bool>(obj, F("en"), &mCfg.inst.enabled);
|
||||
|
@ -723,6 +729,7 @@ class settings {
|
|||
getVal<bool>(obj, F("strtWthtTime"), &mCfg.inst.startWithoutTime);
|
||||
getVal<bool>(obj, F("rstMaxMidNight"), &mCfg.inst.rstMaxValsMidNight);
|
||||
getVal<float>(obj, F("yldEff"), &mCfg.inst.yieldEffiency);
|
||||
getVal<uint16_t>(obj, F("gap"), &mCfg.inst.gapMs);
|
||||
|
||||
if(mCfg.inst.yieldEffiency < 0.5)
|
||||
mCfg.inst.yieldEffiency = 1.0f;
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//-------------------------------------
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 8
|
||||
#define VERSION_PATCH 18
|
||||
#define VERSION_PATCH 19
|
||||
|
||||
//-------------------------------------
|
||||
typedef struct {
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
#define FRSTMSG_TIMEOUT 150 // how long to wait for first msg to be received
|
||||
#define DEFAULT_TIMEOUT 500 // timeout for regular requests
|
||||
#define SINGLEFR_TIMEOUT 65 // timeout for single frame requests
|
||||
#define WAIT_GAP_TIMEOUT 200 // timeout after no complete payload
|
||||
#define MAX_BUFFER 250
|
||||
|
||||
typedef std::function<void(uint8_t, Inverter<> *)> payloadListenerType;
|
||||
|
@ -23,11 +22,12 @@ typedef std::function<void(Inverter<> *)> alarmListenerType;
|
|||
|
||||
class Communication : public CommQueue<> {
|
||||
public:
|
||||
void setup(uint32_t *timestamp, bool *serialDebug, bool *privacyMode, bool *printWholeTrace) {
|
||||
void setup(uint32_t *timestamp, bool *serialDebug, bool *privacyMode, bool *printWholeTrace, uint16_t *inverterGap) {
|
||||
mTimestamp = timestamp;
|
||||
mPrivacyMode = privacyMode;
|
||||
mSerialDebug = serialDebug;
|
||||
mPrintWholeTrace = printWholeTrace;
|
||||
mInverterGap = inverterGap;
|
||||
}
|
||||
|
||||
void addImportant(Inverter<> *iv, uint8_t cmd, bool delOnPop = true) {
|
||||
|
@ -134,7 +134,6 @@ class Communication : public CommQueue<> {
|
|||
DBGPRINT(String(millis() - mWaitTimeout + timeout));
|
||||
DBGPRINTLN(F("ms"));
|
||||
}
|
||||
|
||||
if(!q->iv->mGotFragment) {
|
||||
if((IV_HMS == q->iv->ivGen) || (IV_HMT == q->iv->ivGen)) {
|
||||
q->iv->radio->switchFrequency(q->iv, HOY_BOOT_FREQ_KHZ, (q->iv->config->frequency*FREQ_STEP_KHZ + HOY_BASE_FREQ_KHZ));
|
||||
|
@ -284,6 +283,7 @@ class Communication : public CommQueue<> {
|
|||
DHEX(buf[0]);DHEX(buf[1]);DHEX(buf[2]);DHEX(buf[3]);
|
||||
DBGPRINT(F(", expected: 0x"));
|
||||
DHEX(tmp[0]);DHEX(tmp[1]);DHEX(tmp[2]);DHEX(tmp[3]);
|
||||
DBGPRINTLN("");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -473,8 +473,8 @@ class Communication : public CommQueue<> {
|
|||
q->iv->radioStatistics.rxFail++; // got no complete payload
|
||||
else {
|
||||
q->iv->radioStatistics.rxFailNoAnser++; // got nothing
|
||||
mWaitTimeout = millis() + WAIT_GAP_TIMEOUT;
|
||||
}
|
||||
mWaitTimeout = millis() + *mInverterGap;
|
||||
|
||||
cmdDone(delCmd);
|
||||
q->iv->mGotFragment = false;
|
||||
|
@ -483,6 +483,7 @@ class Communication : public CommQueue<> {
|
|||
mIsResend = false;
|
||||
mFirstTry = false; // for correct reset
|
||||
mState = States::RESET;
|
||||
DBGPRINTLN("-----");
|
||||
}
|
||||
|
||||
inline void miHwDecode(packet_t *p, const queue_s *q) {
|
||||
|
@ -826,6 +827,7 @@ class Communication : public CommQueue<> {
|
|||
States mState = States::RESET;
|
||||
uint32_t *mTimestamp;
|
||||
bool *mPrivacyMode, *mSerialDebug, *mPrintWholeTrace;
|
||||
uint16_t *mInverterGap;
|
||||
uint32_t mWaitTimeout = 0;
|
||||
uint32_t mWaitTimeout_min = 0;
|
||||
std::array<frame_t, MAX_PAYLOAD_ENTRIES> mLocalBuf;
|
||||
|
|
|
@ -133,7 +133,10 @@ class Heuristic {
|
|||
DBGPRINT(F(", n: "));
|
||||
DBGPRINT(String(iv->radioStatistics.rxFailNoAnser));
|
||||
DBGPRINT(F(" | p: ")); // better debugging for helpers...
|
||||
DBGPRINTLN(String(iv->config->powerLevel));
|
||||
if((IV_HMS == iv->ivGen) || (IV_HMT == iv->ivGen))
|
||||
DBGPRINTLN(String(iv->config->powerLevel-10));
|
||||
else
|
||||
DBGPRINTLN(String(iv->config->powerLevel));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -70,6 +70,15 @@ namespace ah {
|
|||
return String(str);
|
||||
}
|
||||
|
||||
String getTimeStrMs(time_t t) {
|
||||
char str[13];
|
||||
if(0 == t)
|
||||
sprintf(str, "n/a");
|
||||
else
|
||||
sprintf(str, "%02d:%02d:%02d.%03d", hour(t), minute(t), second(t), millis() % 1000);
|
||||
return String(str);
|
||||
}
|
||||
|
||||
uint64_t Serial2u64(const char *val) {
|
||||
char tmp[3];
|
||||
uint64_t ret = 0ULL;
|
||||
|
|
|
@ -44,6 +44,7 @@ namespace ah {
|
|||
String getDateTimeStrShort(time_t t);
|
||||
String getDateTimeStrFile(time_t t);
|
||||
String getTimeStr(time_t t);
|
||||
String getTimeStrMs(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);
|
||||
}
|
||||
|
|
|
@ -389,6 +389,7 @@ class RestApi {
|
|||
obj[F("strtWthtTm")] = (bool)mConfig->inst.startWithoutTime;
|
||||
obj[F("rstMaxMid")] = (bool)mConfig->inst.rstMaxValsMidNight;
|
||||
obj[F("yldEff")] = mConfig->inst.yieldEffiency;
|
||||
obj[F("gap")] = mConfig->inst.gapMs;
|
||||
}
|
||||
|
||||
void getInverter(JsonObject obj, uint8_t id) {
|
||||
|
|
|
@ -148,6 +148,10 @@
|
|||
<div class="col-8 my-2">Interval [s]</div>
|
||||
<div class="col-4"><input type="number" name="invInterval" title="Invalid input"/></div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-8 my-2">Inverter Gap [ms]</div>
|
||||
<div class="col-4"><input type="number" name="invGap" title="Invalid input"/></div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-8 mb-2">Reset values and YieldDay at midnight</div>
|
||||
<div class="col-4"><input type="checkbox" name="invRstMid"/></div>
|
||||
|
@ -571,7 +575,7 @@
|
|||
}
|
||||
|
||||
function ivGlob(obj) {
|
||||
for(var i of [["invInterval", "interval"], ["yldEff", "yldEff"]])
|
||||
for(var i of [["invInterval", "interval"], ["yldEff", "yldEff"], ["invGap", "gap"]])
|
||||
document.getElementsByName(i[0])[0].value = obj[i[1]];
|
||||
for(var i of ["Mid", "ComStop", "NotAvail", "MaxMid"])
|
||||
document.getElementsByName("invRst"+i)[0].checked = obj["rst" + i];
|
||||
|
|
|
@ -208,10 +208,11 @@ class Web {
|
|||
|
||||
msg.replace("\r\n", "<rn>");
|
||||
if (mSerialAddTime) {
|
||||
if ((9 + mSerialBufFill) < WEB_SERIAL_BUF_SIZE) {
|
||||
if ((13 + mSerialBufFill) < WEB_SERIAL_BUF_SIZE) {
|
||||
if (mApp->getTimestamp() > 0) {
|
||||
strncpy(&mSerialBuf[mSerialBufFill], mApp->getTimeStr(mApp->getTimezoneOffset()).c_str(), 9);
|
||||
mSerialBufFill += 9;
|
||||
strncpy(&mSerialBuf[mSerialBufFill], ah::getTimeStrMs(mApp->getTimestamp() + mApp->getTimezoneOffset()).c_str(), 12);
|
||||
mSerialBuf[mSerialBufFill+12] = ' ';
|
||||
mSerialBufFill += 13;
|
||||
}
|
||||
} else {
|
||||
mSerialBufFill = 0;
|
||||
|
@ -495,6 +496,7 @@ class Web {
|
|||
mConfig->inst.startWithoutTime = (request->arg("strtWthtTm") == "on");
|
||||
mConfig->inst.rstMaxValsMidNight = (request->arg("invRstMaxMid") == "on");
|
||||
mConfig->inst.yieldEffiency = (request->arg("yldEff")).toFloat();
|
||||
mConfig->inst.gapMs = (request->arg("invGap")).toInt();
|
||||
|
||||
|
||||
// pinout
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue