Merge pull request #17184 from fightforlife/development_eb3ble_retries

BLE eQ3 - allow to set retries at runtime
This commit is contained in:
Theo Arends 2022-12-09 10:55:18 +01:00 committed by GitHub
commit 1098ec2098
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 1 deletions

View File

@ -32,6 +32,7 @@ trv 001A22092EE0 settemp 22.5
trvperiod n - set polling period in seconds (default teleperiod at boot)
trvonlyaliased *0/1 - only hear devices with BLEAlias set
trvretries n - set the number of retries (default 4 at boot)
trvMatchPrefix 0/*1 - if set, then it will add trvs to the seen list which have mac starting with :
macs in macprefixes, currently only 001a22
Note: anything with BLEAlias starting "EQ3" will be added to the seen list.
@ -147,6 +148,7 @@ namespace EQ3_ESP32 {
void CmndTrv(void);
void CmndTrvPeriod(void);
void CmndTrvRetries(void);
void CmndTrvOnlyAliased(void);
void CmndTrvMatchPrefix(void);
void CmndTrvMinRSSI(void);
@ -155,6 +157,7 @@ void CmndTrvHideFailedPoll(void);
const char kEQ3_Commands[] PROGMEM = D_CMND_EQ3"|"
"|"
"period|"
"retries|"
"onlyaliased|"
"MatchPrefix|"
"MinRSSI|"
@ -163,6 +166,7 @@ const char kEQ3_Commands[] PROGMEM = D_CMND_EQ3"|"
void (*const EQ3_Commands[])(void) PROGMEM = {
&CmndTrv,
&CmndTrvPeriod,
&CmndTrvRetries,
&CmndTrvOnlyAliased,
&CmndTrvMatchPrefix,
&CmndTrvMinRSSI,
@ -234,6 +238,7 @@ eq3_device_tag EQ3Devices[EQ3_NUM_DEVICESLOTS];
SemaphoreHandle_t EQ3mutex = nullptr;
int EQ3Period = 300;
int EQ3Retries = 4;
uint8_t EQ3OnlyAliased = 0;
uint8_t EQ3MatchPrefix = 1;
uint8_t opInProgress = 0;
@ -365,7 +370,7 @@ int EQ3DoOp(){
if (!opInProgress){
if (opQueue.size()){
op_t* op = opQueue[0];
if (EQ3Operation(op->addr, op->towrite, op->writelen, op->cmdtype, 4)){
if (EQ3Operation(op->addr, op->towrite, op->writelen, op->cmdtype, EQ3Retries)){
opQueue.pop_front();
opInProgress = 1;
AddLog(LOG_LEVEL_DEBUG, PSTR("EQ3 %s:Op dequeued len now %d"), addrStr(op->addr, (op->cmdtype & 0x80)), opQueue.size());
@ -1488,6 +1493,13 @@ void CmndTrvPeriod(void) {
ResponseCmndNumber(EQ3Period);
}
void CmndTrvRetries(void) {
if (XdrvMailbox.data_len > 0) {
EQ3Retries = XdrvMailbox.payload;
}
ResponseCmndNumber(EQ3Retries);
}
void CmndTrvOnlyAliased(void){
if (XdrvMailbox.data_len > 0) {
EQ3OnlyAliased = XdrvMailbox.payload;