mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
fix: only let wifiStrength broadcasts move the RSSI baseline
The emit to a newly connected client also stored the RSSI and time, which restarted the 10s hold-off and hid a real change from the clients already connected. The baseline moves into RssiBroadcast, which ignores per-client emits, with unit tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c4472ba8e8
commit
e47381b19e
5 changed files with 72 additions and 11 deletions
|
|
@ -135,3 +135,12 @@ bool rssiNeedsEmit(int rssi, int lastRssi, int channel, int lastChannel, uint32_
|
|||
int delta = rssi > lastRssi ? rssi - lastRssi : lastRssi - rssi;
|
||||
return delta >= minDelta && sinceLastMs >= minMs;
|
||||
}
|
||||
bool RssiBroadcast::due(int rssi, int channel, uint32_t now, int minDelta, uint32_t minMs) const {
|
||||
return rssiNeedsEmit(rssi, this->rssi, channel, this->channel, now - this->at, minDelta, minMs);
|
||||
}
|
||||
void RssiBroadcast::sent(bool broadcast, int rssi, int channel, uint32_t now) {
|
||||
if(!broadcast) return;
|
||||
this->rssi = rssi;
|
||||
this->channel = channel;
|
||||
this->at = now;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue