Browse Source

0.8.148

* fixed send power limit #1757
* fix redirect after login
pull/1759/head
lumapu 6 months ago
parent
commit
4a32188bb2
  1. 4
      src/CHANGES.md
  2. 2
      src/defines.h
  3. 50
      src/hm/CommQueue.h
  4. 29
      src/hm/Communication.h
  5. 2
      src/platformio.ini

4
src/CHANGES.md

@ -1,5 +1,9 @@
# Development Changes
## 0.8.148 - 2024-09-30
* fixed send power limit #1757
* fix redirect after login
## 0.8.147 - 2024-09-29
* improved queue, added mutex
* fixed send power limit #1757

2
src/defines.h

@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 147
#define VERSION_PATCH 148
//-------------------------------------
typedef struct {
uint8_t ch;

50
src/hm/CommQueue.h

@ -51,14 +51,11 @@ class CommQueue {
, isDevControl {devCtrl}
{}
QueueElement(const QueueElement &other) // copy constructor
: iv {other.iv}
, cmd {other.cmd}
, attempts {other.attempts}
, attemptsMax {other.attemptsMax}
, ts {other.ts}
, isDevControl {other.isDevControl}
{}
QueueElement(const QueueElement&) = delete;
QueueElement(QueueElement&& other) : QueueElement{} {
this->swap(other);
}
void changeCmd(uint8_t cmd) {
this->cmd = cmd;
@ -79,6 +76,22 @@ class CommQueue {
if (this->attempts > this->attemptsMax)
this->attemptsMax = this->attempts;
}
QueueElement& operator=(const QueueElement&) = delete;
QueueElement& operator = (QueueElement&& other) {
this->swap(other);
return *this;
}
void swap(QueueElement& other) {
std::swap(this->iv, other.iv);
std::swap(this->cmd, other.cmd);
std::swap(this->attempts, other.attempts);
std::swap(this->attemptsMax, other.attemptsMax);
std::swap(this->ts, other.ts);
std::swap(this->isDevControl, other.isDevControl);
}
};
public:
@ -101,16 +114,16 @@ class CommQueue {
xSemaphoreTake(this->mutex, portMAX_DELAY);
if(!isIncluded(&q)) {
dec(&this->rdPtr);
mQueue[this->rdPtr] = q;
mQueue[this->rdPtr] = std::move(q);
}
xSemaphoreGive(this->mutex);
}
void add(Inverter<> *iv, uint8_t cmd) {
xSemaphoreTake(this->mutex, portMAX_DELAY);
QueueElement q(iv, cmd, false);
xSemaphoreTake(this->mutex, portMAX_DELAY);
if(!isIncluded(&q)) {
mQueue[this->wrPtr] = q;
mQueue[this->wrPtr] = std::move(q);
inc(&this->wrPtr);
}
xSemaphoreGive(this->mutex);
@ -135,21 +148,22 @@ class CommQueue {
void add(QueueElement *q, bool rstAttempts = false) {
xSemaphoreTake(this->mutex, portMAX_DELAY);
mQueue[this->wrPtr] = *q;
if(rstAttempts) {
mQueue[this->wrPtr].attempts = DefaultAttempts;
mQueue[this->wrPtr].attemptsMax = DefaultAttempts;
q->attempts = DefaultAttempts;
q->attemptsMax = DefaultAttempts;
}
mQueue[this->wrPtr] = std::move(*q);
inc(&this->wrPtr);
xSemaphoreGive(this->mutex);
}
void get(std::function<void(bool valid, QueueElement *q)> cb) {
if(this->rdPtr == this->wrPtr)
xSemaphoreTake(this->mutex, portMAX_DELAY);
if(this->rdPtr == this->wrPtr) {
xSemaphoreGive(this->mutex);
cb(false, nullptr); // empty
else {
xSemaphoreTake(this->mutex, portMAX_DELAY);
QueueElement el = mQueue[this->rdPtr];
} else {
QueueElement el = std::move(mQueue[this->rdPtr]);
inc(&this->rdPtr);
xSemaphoreGive(this->mutex);
cb(true, &el);

29
src/hm/Communication.h

@ -36,7 +36,7 @@ class Communication : public CommQueue<> {
void addImportant(Inverter<> *iv, uint8_t cmd) {
if(!mIsDevControl) // only reset communication once there is no other devcontrol command
mState = States::RESET; // cancel current operation
mState = States::IDLE; // cancel current operation
mIsDevControl = true;
CommQueue::addImportant(iv, cmd);
}
@ -54,7 +54,7 @@ class Communication : public CommQueue<> {
}
void loop() {
if(States::RESET == mState) {
if(States::IDLE == mState) {
get([this](bool valid, QueueElement *q) {
if(!valid) {
if(mPrintSequenceDuration) {
@ -63,12 +63,12 @@ class Communication : public CommQueue<> {
DBGPRINT(String(millis() - mLastEmptyQueueMillis));
DBGPRINTLN(F("ms"));
DBGPRINTLN(F("-----"));
el.iv = nullptr;
}
return; // empty
}
el = *q;
el = std::move(*q);
mState = States::INIT;
if(!mPrintSequenceDuration) // entry was added to the queue
mLastEmptyQueueMillis = millis();
mPrintSequenceDuration = true;
@ -82,7 +82,11 @@ class Communication : public CommQueue<> {
private:
inline void innerLoop(QueueElement *q) {
switch(mState) {
case States::RESET:
default:
case States::IDLE:
break;
case States::INIT:
if (!mWaitTime.isTimeout())
return;
@ -110,7 +114,8 @@ class Communication : public CommQueue<> {
if((q->iv->ivGen == IV_MI) && ((q->cmd == MI_REQ_CH1) || (q->cmd == MI_REQ_4CH)))
q->incrAttempt(q->iv->channels); // 2 more attempts for 2ch, 4 more for 4ch
mState = (NULL == q->iv->radio) ? States::RESET : States::START;
if(NULL != q->iv->radio)
mState = States::START;
break;
case States::START:
@ -293,7 +298,7 @@ class Communication : public CommQueue<> {
q->iv->radioStatistics.txCnt--;
q->iv->radioStatistics.retransmits++;
mCompleteRetry = true;
mState = States::RESET;
mState = States::IDLE;
return;
}
}
@ -537,7 +542,7 @@ class Communication : public CommQueue<> {
} else
DBGPRINTLN(F("-> complete retransmit"));
mCompleteRetry = true;
mState = States::RESET;
mState = States::IDLE;
return false;
}
@ -650,7 +655,7 @@ class Communication : public CommQueue<> {
q->iv->miMultiParts = 0;
mIsRetransmit = false;
mCompleteRetry = false;
mState = States::RESET;
mState = States::IDLE;
DBGPRINTLN(F("-----"));
}
@ -797,7 +802,7 @@ class Communication : public CommQueue<> {
inline void miDataDecode(packet_t *p, QueueElement *q) {
record_t<> *rec = q->iv->getRecordStruct(RealTimeRunData_Debug); // choose the parser
rec->ts = q->ts;
//mState = States::RESET;
//mState = States::IDLE;
if(q->iv->miMultiParts < 6)
q->iv->miMultiParts += 6;
@ -1031,7 +1036,7 @@ class Communication : public CommQueue<> {
private:
enum class States : uint8_t {
RESET, START, WAIT, CHECK_FRAMES, CHECK_PACKAGE
IDLE, INIT, START, WAIT, CHECK_FRAMES, CHECK_PACKAGE
};
typedef struct {
@ -1041,7 +1046,7 @@ class Communication : public CommQueue<> {
} frame_t;
private:
States mState = States::RESET;
States mState = States::IDLE;
uint32_t *mTimestamp = nullptr;
QueueElement el;
bool *mPrivacyMode = nullptr, *mSerialDebug = nullptr, *mPrintWholeTrace = nullptr;

2
src/platformio.ini

@ -154,7 +154,7 @@ platform = espressif32@6.7.0
board = lolin_d32
lib_deps =
${env.lib_deps}
https://github.com/mathieucarbou/ESPAsyncWebServer#v3.3.1
https://github.com/mathieucarbou/ESPAsyncWebServer#v3.2.4
build_flags = ${env.build_flags}
-DSPI_HAL
monitor_filters =

Loading…
Cancel
Save