Skip to content

Commit

Permalink
0.8.21
Browse files Browse the repository at this point in the history
* fix ethernet save inverter parameters #886
* fix ethernet OTA update #886
* improved radio statistics, fixed heuristic output for HMS and HMT inverters
  • Loading branch information
lumapu committed Dec 12, 2023
1 parent 689a295 commit 8c0ff5a
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 28 deletions.
5 changes: 5 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Development Changes

## 0.8.21 - 2023-12-12
* fix ethernet save inverter parameters #886
* fix ethernet OTA update #886
* improved radio statistics, fixed heuristic output for HMS and HMT inverters

## 0.8.20 - 2023-12-12
* improved HM communication #1259 #1249
* fix `loadDefaults` for ethernet builds #1263
Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 20
#define VERSION_PATCH 21

//-------------------------------------
typedef struct {
Expand Down
23 changes: 13 additions & 10 deletions src/hm/Communication.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class Communication : public CommQueue<> {
mWaitTimeout = millis() + 1000;
}
}
closeRequest(q, false, false);
closeRequest(q, false);
break;
}

Expand Down Expand Up @@ -192,7 +192,7 @@ class Communication : public CommQueue<> {
nextState = States::CHECK_PACKAGE;
} else if (p->packet[0] == (TX_REQ_DEVCONTROL + ALL_FRAMES)) { // response from dev control command
parseDevCtrl(p, q);
closeRequest(q, true, true);
closeRequest(q, true);
} else if(IV_MI == q->iv->ivGen) {
if(parseMiFrame(p, q))
q->iv->curFrmCnt++;
Expand All @@ -206,10 +206,13 @@ class Communication : public CommQueue<> {
yield();
}
if(0 == q->attempts)
closeRequest(q, false, true);
closeRequest(q, false);
else {
if(q->iv->ivGen != IV_MI)
if(q->iv->ivGen != IV_MI) {
mState = nextState;
if(States::RESET == mState)
closeRequest(q, false);
}
else {
if(q->iv->miMultiParts < 6) {
nextState = States::WAIT;
Expand All @@ -219,7 +222,7 @@ class Communication : public CommQueue<> {
|| ((q->cmd == MI_REQ_CH1) && (q->iv->type == INV_TYPE_1CH))) {
miComplete(q->iv);
}
closeRequest(q, true, true);
closeRequest(q, true);
}

}
Expand Down Expand Up @@ -272,7 +275,7 @@ class Communication : public CommQueue<> {
if(NULL != mCbPayload)
(mCbPayload)(q->cmd, q->iv);

closeRequest(q, true, true);
closeRequest(q, true);
break;
}
});
Expand Down Expand Up @@ -384,7 +387,7 @@ class Communication : public CommQueue<> {
DBGPRINTLN(F("-> Fail"));
/*q->iv->radioStatistics.rxFail++; // got fragments but not complete response
cmdDone();*/
closeRequest(q, false, false);
closeRequest(q, false);

} else
DBGPRINTLN(F("-> complete retransmit"));
Expand Down Expand Up @@ -432,7 +435,7 @@ class Communication : public CommQueue<> {
DBGPRINTLN(F(" bytes"));
}
/*q->iv->radioStatistics.rxFail++;*/
closeRequest(q, false, false);
closeRequest(q, false);

return;
}
Expand Down Expand Up @@ -465,12 +468,12 @@ class Communication : public CommQueue<> {
mState = States::WAIT;
} else {
//add(q, true);
closeRequest(q, false, true);
closeRequest(q, false);
}
}

private:
void closeRequest(const queue_s *q, bool crcPass, bool delCmd) {
void closeRequest(const queue_s *q, bool crcPass) {
mHeu.evalTxChQuality(q->iv, crcPass, (4 - q->attempts), q->iv->curFrmCnt);
if(crcPass)
q->iv->radioStatistics.rxSuccess++;
Expand Down
11 changes: 7 additions & 4 deletions src/hm/Heuristic.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,14 @@ class Heuristic {
void printStatus(Inverter<> *iv) {
DPRINT_IVID(DBG_INFO, iv->id);
DBGPRINT(F("Radio infos:"));
for(uint8_t i = 0; i < RF_MAX_CHANNEL_ID; i++) {
DBGPRINT(F(" "));
DBGPRINT(String(iv->heuristics.txRfQuality[i]));
if((IV_HMS != iv->ivGen) && (IV_HMT != iv->ivGen)) {
for(uint8_t i = 0; i < RF_MAX_CHANNEL_ID; i++) {
DBGPRINT(F(" "));
DBGPRINT(String(iv->heuristics.txRfQuality[i]));
}
DBGPRINT(F(" |"));
}
DBGPRINT(F(" | t: "));
DBGPRINT(F(" t: "));
DBGPRINT(String(iv->radioStatistics.txCnt));
DBGPRINT(F(", s: "));
DBGPRINT(String(iv->radioStatistics.rxSuccess));
Expand Down
10 changes: 0 additions & 10 deletions src/hm/hmRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@ class HmRadio : public Radio {
mPrivacyMode = privacyMode;
mPrintWholeTrace = printWholeTrace;

if(*mSerialDebug) {
DPRINT(DBG_VERBOSE, F("hmRadio.h : HmRadio():mNrf24(CE_PIN: "));
DBGPRINT(String(CE_PIN));
DBGPRINT(F(", CS_PIN: "));
DBGPRINT(String(CS_PIN));
DBGPRINT(F(", SPI_SPEED: "));
DBGPRINT(String(SPI_SPEED));
DBGPRINTLN(F(")"));
}

generateDtuSn();
DTU_RADIO_ID = ((uint64_t)(((mDtuSn >> 24) & 0xFF) | ((mDtuSn >> 8) & 0xFF00) | ((mDtuSn << 8) & 0xFF0000) | ((mDtuSn << 24) & 0xFF000000)) << 8) | 0x01;

Expand Down
2 changes: 1 addition & 1 deletion src/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ build_flags = ${env.build_flags}
-DDEF_LED1=17
-DLED_ACTIVE_HIGH
-DARDUINO_USB_MODE=1
#-DARDUINO_USB_CDC_ON_BOOT=1
-DARDUINO_USB_CDC_ON_BOOT=1
monitor_filters =
esp32_exception_decoder, colorize

Expand Down
10 changes: 9 additions & 1 deletion src/web/RestApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class RestApi {
mRadioCmt = (CmtRadio<>*)mApp->getRadioObj(false);
#endif
mConfig = config;
mSrv->on("/api", HTTP_GET, std::bind(&RestApi::onApi, this, std::placeholders::_1));
mSrv->on("/api", HTTP_POST, std::bind(&RestApi::onApiPost, this, std::placeholders::_1)).onBody(
std::bind(&RestApi::onApiPostBody, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5));
mSrv->on("/api", HTTP_GET, std::bind(&RestApi::onApi, this, std::placeholders::_1));

mSrv->on("/get_setup", HTTP_GET, std::bind(&RestApi::onDwnldSetup, this, std::placeholders::_1));
}
Expand All @@ -72,6 +72,8 @@ class RestApi {

private:
void onApi(AsyncWebServerRequest *request) {
DPRINTLN(DBG_VERBOSE, String("onApi: ") + String((uint16_t)request->method())); // 1 == Get, 3 == POST

mHeapFree = ESP.getFreeHeap();
#ifndef ESP32
mHeapFreeBlk = ESP.getMaxFreeBlockSize();
Expand Down Expand Up @@ -120,6 +122,12 @@ class RestApi {

void onApiPost(AsyncWebServerRequest *request) {
DPRINTLN(DBG_VERBOSE, "onApiPost");
#if defined(ETHERNET)
// workaround for AsyncWebServer_ESP32_W5500, because it can't distinguish
// between HTTP_GET and HTTP_POST if both are registered
if(request->method() == HTTP_GET)
onApi(request);
#endif
}

void onApiPostBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total) {
Expand Down
9 changes: 8 additions & 1 deletion src/web/web.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ class Web {
mWeb.on("/metrics", HTTP_ANY, std::bind(&Web::showMetrics, this, std::placeholders::_1));
#endif

mWeb.on("/update", HTTP_GET, std::bind(&Web::onUpdate, this, std::placeholders::_1));
mWeb.on("/update", HTTP_POST, std::bind(&Web::showUpdate, this, std::placeholders::_1),
std::bind(&Web::showUpdate2, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6));
mWeb.on("/update", HTTP_GET, std::bind(&Web::onUpdate, this, std::placeholders::_1));
mWeb.on("/upload", HTTP_POST, std::bind(&Web::onUpload, this, std::placeholders::_1),
std::bind(&Web::onUpload2, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6));
mWeb.on("/serial", HTTP_GET, std::bind(&Web::onSerial, this, std::placeholders::_1));
Expand Down Expand Up @@ -273,6 +273,13 @@ class Web {
}

void showUpdate(AsyncWebServerRequest *request) {
#if defined(ETHERNET)
// workaround for AsyncWebServer_ESP32_W5500, because it can't distinguish
// between HTTP_GET and HTTP_POST if both are registered
if(request->method() == HTTP_GET)
onUpdate(request);
#endif

bool reboot = (!Update.hasError());

String html = F("<!doctype html><html><head><title>Update</title><meta http-equiv=\"refresh\" content=\"20; URL=/\"></head><body>Update: ");
Expand Down

0 comments on commit 8c0ff5a

Please sign in to comment.