mirror of
https://github.com/lumapu/ahoy.git
synced 2025-04-29 18:26:21 +02:00
parent
0b83e8bcb1
commit
4a32188bb2
5 changed files with 55 additions and 32 deletions
|
@ -1,5 +1,9 @@
|
||||||
# Development Changes
|
# Development Changes
|
||||||
|
|
||||||
|
## 0.8.148 - 2024-09-30
|
||||||
|
* fixed send power limit #1757
|
||||||
|
* fix redirect after login
|
||||||
|
|
||||||
## 0.8.147 - 2024-09-29
|
## 0.8.147 - 2024-09-29
|
||||||
* improved queue, added mutex
|
* improved queue, added mutex
|
||||||
* fixed send power limit #1757
|
* fixed send power limit #1757
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 8
|
#define VERSION_MINOR 8
|
||||||
#define VERSION_PATCH 147
|
#define VERSION_PATCH 148
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t ch;
|
uint8_t ch;
|
||||||
|
|
|
@ -51,14 +51,11 @@ class CommQueue {
|
||||||
, isDevControl {devCtrl}
|
, isDevControl {devCtrl}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QueueElement(const QueueElement &other) // copy constructor
|
QueueElement(const QueueElement&) = delete;
|
||||||
: iv {other.iv}
|
|
||||||
, cmd {other.cmd}
|
QueueElement(QueueElement&& other) : QueueElement{} {
|
||||||
, attempts {other.attempts}
|
this->swap(other);
|
||||||
, attemptsMax {other.attemptsMax}
|
}
|
||||||
, ts {other.ts}
|
|
||||||
, isDevControl {other.isDevControl}
|
|
||||||
{}
|
|
||||||
|
|
||||||
void changeCmd(uint8_t cmd) {
|
void changeCmd(uint8_t cmd) {
|
||||||
this->cmd = cmd;
|
this->cmd = cmd;
|
||||||
|
@ -79,6 +76,22 @@ class CommQueue {
|
||||||
if (this->attempts > this->attemptsMax)
|
if (this->attempts > this->attemptsMax)
|
||||||
this->attemptsMax = this->attempts;
|
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:
|
public:
|
||||||
|
@ -101,16 +114,16 @@ class CommQueue {
|
||||||
xSemaphoreTake(this->mutex, portMAX_DELAY);
|
xSemaphoreTake(this->mutex, portMAX_DELAY);
|
||||||
if(!isIncluded(&q)) {
|
if(!isIncluded(&q)) {
|
||||||
dec(&this->rdPtr);
|
dec(&this->rdPtr);
|
||||||
mQueue[this->rdPtr] = q;
|
mQueue[this->rdPtr] = std::move(q);
|
||||||
}
|
}
|
||||||
xSemaphoreGive(this->mutex);
|
xSemaphoreGive(this->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(Inverter<> *iv, uint8_t cmd) {
|
void add(Inverter<> *iv, uint8_t cmd) {
|
||||||
xSemaphoreTake(this->mutex, portMAX_DELAY);
|
|
||||||
QueueElement q(iv, cmd, false);
|
QueueElement q(iv, cmd, false);
|
||||||
|
xSemaphoreTake(this->mutex, portMAX_DELAY);
|
||||||
if(!isIncluded(&q)) {
|
if(!isIncluded(&q)) {
|
||||||
mQueue[this->wrPtr] = q;
|
mQueue[this->wrPtr] = std::move(q);
|
||||||
inc(&this->wrPtr);
|
inc(&this->wrPtr);
|
||||||
}
|
}
|
||||||
xSemaphoreGive(this->mutex);
|
xSemaphoreGive(this->mutex);
|
||||||
|
@ -135,21 +148,22 @@ class CommQueue {
|
||||||
|
|
||||||
void add(QueueElement *q, bool rstAttempts = false) {
|
void add(QueueElement *q, bool rstAttempts = false) {
|
||||||
xSemaphoreTake(this->mutex, portMAX_DELAY);
|
xSemaphoreTake(this->mutex, portMAX_DELAY);
|
||||||
mQueue[this->wrPtr] = *q;
|
|
||||||
if(rstAttempts) {
|
if(rstAttempts) {
|
||||||
mQueue[this->wrPtr].attempts = DefaultAttempts;
|
q->attempts = DefaultAttempts;
|
||||||
mQueue[this->wrPtr].attemptsMax = DefaultAttempts;
|
q->attemptsMax = DefaultAttempts;
|
||||||
}
|
}
|
||||||
|
mQueue[this->wrPtr] = std::move(*q);
|
||||||
inc(&this->wrPtr);
|
inc(&this->wrPtr);
|
||||||
xSemaphoreGive(this->mutex);
|
xSemaphoreGive(this->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
void get(std::function<void(bool valid, QueueElement *q)> cb) {
|
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
|
cb(false, nullptr); // empty
|
||||||
else {
|
} else {
|
||||||
xSemaphoreTake(this->mutex, portMAX_DELAY);
|
QueueElement el = std::move(mQueue[this->rdPtr]);
|
||||||
QueueElement el = mQueue[this->rdPtr];
|
|
||||||
inc(&this->rdPtr);
|
inc(&this->rdPtr);
|
||||||
xSemaphoreGive(this->mutex);
|
xSemaphoreGive(this->mutex);
|
||||||
cb(true, &el);
|
cb(true, &el);
|
||||||
|
|
|
@ -36,7 +36,7 @@ class Communication : public CommQueue<> {
|
||||||
|
|
||||||
void addImportant(Inverter<> *iv, uint8_t cmd) {
|
void addImportant(Inverter<> *iv, uint8_t cmd) {
|
||||||
if(!mIsDevControl) // only reset communication once there is no other devcontrol command
|
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;
|
mIsDevControl = true;
|
||||||
CommQueue::addImportant(iv, cmd);
|
CommQueue::addImportant(iv, cmd);
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class Communication : public CommQueue<> {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
if(States::RESET == mState) {
|
if(States::IDLE == mState) {
|
||||||
get([this](bool valid, QueueElement *q) {
|
get([this](bool valid, QueueElement *q) {
|
||||||
if(!valid) {
|
if(!valid) {
|
||||||
if(mPrintSequenceDuration) {
|
if(mPrintSequenceDuration) {
|
||||||
|
@ -63,12 +63,12 @@ class Communication : public CommQueue<> {
|
||||||
DBGPRINT(String(millis() - mLastEmptyQueueMillis));
|
DBGPRINT(String(millis() - mLastEmptyQueueMillis));
|
||||||
DBGPRINTLN(F("ms"));
|
DBGPRINTLN(F("ms"));
|
||||||
DBGPRINTLN(F("-----"));
|
DBGPRINTLN(F("-----"));
|
||||||
el.iv = nullptr;
|
|
||||||
}
|
}
|
||||||
return; // empty
|
return; // empty
|
||||||
}
|
}
|
||||||
|
|
||||||
el = *q;
|
el = std::move(*q);
|
||||||
|
mState = States::INIT;
|
||||||
if(!mPrintSequenceDuration) // entry was added to the queue
|
if(!mPrintSequenceDuration) // entry was added to the queue
|
||||||
mLastEmptyQueueMillis = millis();
|
mLastEmptyQueueMillis = millis();
|
||||||
mPrintSequenceDuration = true;
|
mPrintSequenceDuration = true;
|
||||||
|
@ -82,7 +82,11 @@ class Communication : public CommQueue<> {
|
||||||
private:
|
private:
|
||||||
inline void innerLoop(QueueElement *q) {
|
inline void innerLoop(QueueElement *q) {
|
||||||
switch(mState) {
|
switch(mState) {
|
||||||
case States::RESET:
|
default:
|
||||||
|
case States::IDLE:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case States::INIT:
|
||||||
if (!mWaitTime.isTimeout())
|
if (!mWaitTime.isTimeout())
|
||||||
return;
|
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)))
|
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
|
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;
|
break;
|
||||||
|
|
||||||
case States::START:
|
case States::START:
|
||||||
|
@ -293,7 +298,7 @@ class Communication : public CommQueue<> {
|
||||||
q->iv->radioStatistics.txCnt--;
|
q->iv->radioStatistics.txCnt--;
|
||||||
q->iv->radioStatistics.retransmits++;
|
q->iv->radioStatistics.retransmits++;
|
||||||
mCompleteRetry = true;
|
mCompleteRetry = true;
|
||||||
mState = States::RESET;
|
mState = States::IDLE;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -537,7 +542,7 @@ class Communication : public CommQueue<> {
|
||||||
} else
|
} else
|
||||||
DBGPRINTLN(F("-> complete retransmit"));
|
DBGPRINTLN(F("-> complete retransmit"));
|
||||||
mCompleteRetry = true;
|
mCompleteRetry = true;
|
||||||
mState = States::RESET;
|
mState = States::IDLE;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,7 +655,7 @@ class Communication : public CommQueue<> {
|
||||||
q->iv->miMultiParts = 0;
|
q->iv->miMultiParts = 0;
|
||||||
mIsRetransmit = false;
|
mIsRetransmit = false;
|
||||||
mCompleteRetry = false;
|
mCompleteRetry = false;
|
||||||
mState = States::RESET;
|
mState = States::IDLE;
|
||||||
DBGPRINTLN(F("-----"));
|
DBGPRINTLN(F("-----"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -797,7 +802,7 @@ class Communication : public CommQueue<> {
|
||||||
inline void miDataDecode(packet_t *p, QueueElement *q) {
|
inline void miDataDecode(packet_t *p, QueueElement *q) {
|
||||||
record_t<> *rec = q->iv->getRecordStruct(RealTimeRunData_Debug); // choose the parser
|
record_t<> *rec = q->iv->getRecordStruct(RealTimeRunData_Debug); // choose the parser
|
||||||
rec->ts = q->ts;
|
rec->ts = q->ts;
|
||||||
//mState = States::RESET;
|
//mState = States::IDLE;
|
||||||
if(q->iv->miMultiParts < 6)
|
if(q->iv->miMultiParts < 6)
|
||||||
q->iv->miMultiParts += 6;
|
q->iv->miMultiParts += 6;
|
||||||
|
|
||||||
|
@ -1031,7 +1036,7 @@ class Communication : public CommQueue<> {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class States : uint8_t {
|
enum class States : uint8_t {
|
||||||
RESET, START, WAIT, CHECK_FRAMES, CHECK_PACKAGE
|
IDLE, INIT, START, WAIT, CHECK_FRAMES, CHECK_PACKAGE
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1041,7 +1046,7 @@ class Communication : public CommQueue<> {
|
||||||
} frame_t;
|
} frame_t;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
States mState = States::RESET;
|
States mState = States::IDLE;
|
||||||
uint32_t *mTimestamp = nullptr;
|
uint32_t *mTimestamp = nullptr;
|
||||||
QueueElement el;
|
QueueElement el;
|
||||||
bool *mPrivacyMode = nullptr, *mSerialDebug = nullptr, *mPrintWholeTrace = nullptr;
|
bool *mPrivacyMode = nullptr, *mSerialDebug = nullptr, *mPrintWholeTrace = nullptr;
|
||||||
|
|
|
@ -154,7 +154,7 @@ platform = espressif32@6.7.0
|
||||||
board = lolin_d32
|
board = lolin_d32
|
||||||
lib_deps =
|
lib_deps =
|
||||||
${env.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}
|
build_flags = ${env.build_flags}
|
||||||
-DSPI_HAL
|
-DSPI_HAL
|
||||||
monitor_filters =
|
monitor_filters =
|
||||||
|
|
Loading…
Add table
Reference in a new issue