Skip to content

Commit 4a32188

Browse files
committed
0.8.148
* fixed send power limit #1757 * fix redirect after login
1 parent 0b83e8b commit 4a32188

File tree

5 files changed

+55
-32
lines changed

5 files changed

+55
-32
lines changed

src/CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Development Changes
22

3+
## 0.8.148 - 2024-09-30
4+
* fixed send power limit #1757
5+
* fix redirect after login
6+
37
## 0.8.147 - 2024-09-29
48
* improved queue, added mutex
59
* fixed send power limit #1757

src/defines.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
//-------------------------------------
1414
#define VERSION_MAJOR 0
1515
#define VERSION_MINOR 8
16-
#define VERSION_PATCH 147
16+
#define VERSION_PATCH 148
1717
//-------------------------------------
1818
typedef struct {
1919
uint8_t ch;

src/hm/CommQueue.h

+32-18
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,11 @@ class CommQueue {
5151
, isDevControl {devCtrl}
5252
{}
5353

54-
QueueElement(const QueueElement &other) // copy constructor
55-
: iv {other.iv}
56-
, cmd {other.cmd}
57-
, attempts {other.attempts}
58-
, attemptsMax {other.attemptsMax}
59-
, ts {other.ts}
60-
, isDevControl {other.isDevControl}
61-
{}
54+
QueueElement(const QueueElement&) = delete;
55+
56+
QueueElement(QueueElement&& other) : QueueElement{} {
57+
this->swap(other);
58+
}
6259

6360
void changeCmd(uint8_t cmd) {
6461
this->cmd = cmd;
@@ -79,6 +76,22 @@ class CommQueue {
7976
if (this->attempts > this->attemptsMax)
8077
this->attemptsMax = this->attempts;
8178
}
79+
80+
QueueElement& operator=(const QueueElement&) = delete;
81+
82+
QueueElement& operator = (QueueElement&& other) {
83+
this->swap(other);
84+
return *this;
85+
}
86+
87+
void swap(QueueElement& other) {
88+
std::swap(this->iv, other.iv);
89+
std::swap(this->cmd, other.cmd);
90+
std::swap(this->attempts, other.attempts);
91+
std::swap(this->attemptsMax, other.attemptsMax);
92+
std::swap(this->ts, other.ts);
93+
std::swap(this->isDevControl, other.isDevControl);
94+
}
8295
};
8396

8497
public:
@@ -101,16 +114,16 @@ class CommQueue {
101114
xSemaphoreTake(this->mutex, portMAX_DELAY);
102115
if(!isIncluded(&q)) {
103116
dec(&this->rdPtr);
104-
mQueue[this->rdPtr] = q;
117+
mQueue[this->rdPtr] = std::move(q);
105118
}
106119
xSemaphoreGive(this->mutex);
107120
}
108121

109122
void add(Inverter<> *iv, uint8_t cmd) {
110-
xSemaphoreTake(this->mutex, portMAX_DELAY);
111123
QueueElement q(iv, cmd, false);
124+
xSemaphoreTake(this->mutex, portMAX_DELAY);
112125
if(!isIncluded(&q)) {
113-
mQueue[this->wrPtr] = q;
126+
mQueue[this->wrPtr] = std::move(q);
114127
inc(&this->wrPtr);
115128
}
116129
xSemaphoreGive(this->mutex);
@@ -135,21 +148,22 @@ class CommQueue {
135148

136149
void add(QueueElement *q, bool rstAttempts = false) {
137150
xSemaphoreTake(this->mutex, portMAX_DELAY);
138-
mQueue[this->wrPtr] = *q;
139151
if(rstAttempts) {
140-
mQueue[this->wrPtr].attempts = DefaultAttempts;
141-
mQueue[this->wrPtr].attemptsMax = DefaultAttempts;
152+
q->attempts = DefaultAttempts;
153+
q->attemptsMax = DefaultAttempts;
142154
}
155+
mQueue[this->wrPtr] = std::move(*q);
143156
inc(&this->wrPtr);
144157
xSemaphoreGive(this->mutex);
145158
}
146159

147160
void get(std::function<void(bool valid, QueueElement *q)> cb) {
148-
if(this->rdPtr == this->wrPtr)
161+
xSemaphoreTake(this->mutex, portMAX_DELAY);
162+
if(this->rdPtr == this->wrPtr) {
163+
xSemaphoreGive(this->mutex);
149164
cb(false, nullptr); // empty
150-
else {
151-
xSemaphoreTake(this->mutex, portMAX_DELAY);
152-
QueueElement el = mQueue[this->rdPtr];
165+
} else {
166+
QueueElement el = std::move(mQueue[this->rdPtr]);
153167
inc(&this->rdPtr);
154168
xSemaphoreGive(this->mutex);
155169
cb(true, &el);

src/hm/Communication.h

+17-12
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Communication : public CommQueue<> {
3636

3737
void addImportant(Inverter<> *iv, uint8_t cmd) {
3838
if(!mIsDevControl) // only reset communication once there is no other devcontrol command
39-
mState = States::RESET; // cancel current operation
39+
mState = States::IDLE; // cancel current operation
4040
mIsDevControl = true;
4141
CommQueue::addImportant(iv, cmd);
4242
}
@@ -54,7 +54,7 @@ class Communication : public CommQueue<> {
5454
}
5555

5656
void loop() {
57-
if(States::RESET == mState) {
57+
if(States::IDLE == mState) {
5858
get([this](bool valid, QueueElement *q) {
5959
if(!valid) {
6060
if(mPrintSequenceDuration) {
@@ -63,12 +63,12 @@ class Communication : public CommQueue<> {
6363
DBGPRINT(String(millis() - mLastEmptyQueueMillis));
6464
DBGPRINTLN(F("ms"));
6565
DBGPRINTLN(F("-----"));
66-
el.iv = nullptr;
6766
}
6867
return; // empty
6968
}
7069

71-
el = *q;
70+
el = std::move(*q);
71+
mState = States::INIT;
7272
if(!mPrintSequenceDuration) // entry was added to the queue
7373
mLastEmptyQueueMillis = millis();
7474
mPrintSequenceDuration = true;
@@ -82,7 +82,11 @@ class Communication : public CommQueue<> {
8282
private:
8383
inline void innerLoop(QueueElement *q) {
8484
switch(mState) {
85-
case States::RESET:
85+
default:
86+
case States::IDLE:
87+
break;
88+
89+
case States::INIT:
8690
if (!mWaitTime.isTimeout())
8791
return;
8892

@@ -110,7 +114,8 @@ class Communication : public CommQueue<> {
110114
if((q->iv->ivGen == IV_MI) && ((q->cmd == MI_REQ_CH1) || (q->cmd == MI_REQ_4CH)))
111115
q->incrAttempt(q->iv->channels); // 2 more attempts for 2ch, 4 more for 4ch
112116

113-
mState = (NULL == q->iv->radio) ? States::RESET : States::START;
117+
if(NULL != q->iv->radio)
118+
mState = States::START;
114119
break;
115120

116121
case States::START:
@@ -293,7 +298,7 @@ class Communication : public CommQueue<> {
293298
q->iv->radioStatistics.txCnt--;
294299
q->iv->radioStatistics.retransmits++;
295300
mCompleteRetry = true;
296-
mState = States::RESET;
301+
mState = States::IDLE;
297302
return;
298303
}
299304
}
@@ -537,7 +542,7 @@ class Communication : public CommQueue<> {
537542
} else
538543
DBGPRINTLN(F("-> complete retransmit"));
539544
mCompleteRetry = true;
540-
mState = States::RESET;
545+
mState = States::IDLE;
541546
return false;
542547
}
543548

@@ -650,7 +655,7 @@ class Communication : public CommQueue<> {
650655
q->iv->miMultiParts = 0;
651656
mIsRetransmit = false;
652657
mCompleteRetry = false;
653-
mState = States::RESET;
658+
mState = States::IDLE;
654659
DBGPRINTLN(F("-----"));
655660
}
656661

@@ -797,7 +802,7 @@ class Communication : public CommQueue<> {
797802
inline void miDataDecode(packet_t *p, QueueElement *q) {
798803
record_t<> *rec = q->iv->getRecordStruct(RealTimeRunData_Debug); // choose the parser
799804
rec->ts = q->ts;
800-
//mState = States::RESET;
805+
//mState = States::IDLE;
801806
if(q->iv->miMultiParts < 6)
802807
q->iv->miMultiParts += 6;
803808

@@ -1031,7 +1036,7 @@ class Communication : public CommQueue<> {
10311036

10321037
private:
10331038
enum class States : uint8_t {
1034-
RESET, START, WAIT, CHECK_FRAMES, CHECK_PACKAGE
1039+
IDLE, INIT, START, WAIT, CHECK_FRAMES, CHECK_PACKAGE
10351040
};
10361041

10371042
typedef struct {
@@ -1041,7 +1046,7 @@ class Communication : public CommQueue<> {
10411046
} frame_t;
10421047

10431048
private:
1044-
States mState = States::RESET;
1049+
States mState = States::IDLE;
10451050
uint32_t *mTimestamp = nullptr;
10461051
QueueElement el;
10471052
bool *mPrivacyMode = nullptr, *mSerialDebug = nullptr, *mPrintWholeTrace = nullptr;

src/platformio.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ platform = [email protected]
154154
board = lolin_d32
155155
lib_deps =
156156
${env.lib_deps}
157-
https://github.com/mathieucarbou/ESPAsyncWebServer#v3.3.1
157+
https://github.com/mathieucarbou/ESPAsyncWebServer#v3.2.4
158158
build_flags = ${env.build_flags}
159159
-DSPI_HAL
160160
monitor_filters =

0 commit comments

Comments
 (0)