small bugfix for globalStatus
This commit is contained in:
parent
2a3445b9bb
commit
7c4adc0267
@ -57,19 +57,17 @@ void globalStatus() {
|
|||||||
DEBUGLOG("available Peers:");
|
DEBUGLOG("available Peers:");
|
||||||
WifiEspNowPeerInfo peers[MAX_PEERS];
|
WifiEspNowPeerInfo peers[MAX_PEERS];
|
||||||
int nPeers = std::min(WifiEspNow.listPeers(peers, MAX_PEERS), MAX_PEERS);
|
int nPeers = std::min(WifiEspNow.listPeers(peers, MAX_PEERS), MAX_PEERS);
|
||||||
byte loopPointer = (rxCounter - 1 >= 0) ? (rxCounter - 1) : MAX_PEERS - 1;
|
|
||||||
byte lastLoopPointer = rxCounter;
|
|
||||||
for (int i = 0; i < nPeers; ++i) {
|
for (int i = 0; i < nPeers; ++i) {
|
||||||
LOG(" %02X:%02X:%02X:%02X:%02X:%02X", peers[i].mac[0], peers[i].mac[1], peers[i].mac[2], peers[i].mac[3], peers[i].mac[4], peers[i].mac[5]);
|
byte loopPointer = (rxCounter - 1 >= 0) ? (rxCounter - 1) : MAX_PEERS - 1;
|
||||||
|
LOG(" %02X:%02X:%02X:%02X:%02X:%02X", peers[i].mac[0], peers[i].mac[1], peers[i].mac[2], peers[i].mac[3], peers[i].mac[4], peers[i].mac[5]);
|
||||||
//walk backwards through the buffer to get the latest message
|
//walk backwards through the buffer to get the latest message
|
||||||
while (loopPointer != lastLoopPointer)
|
while (loopPointer != rxCounter)
|
||||||
{
|
{
|
||||||
//DEBUGLOG("lastLoopPointer | loopPointer: %d|%d", lastLoopCounter, loopPointer);
|
//DEBUGLOG("rxCounter | loopPointer: %d|%d", rxCounter, loopPointer);
|
||||||
int ret = memcmp(&receiveBuffer[loopPointer].originMAC[0], &peers[i].mac, sizeof(receiveBuffer[loopPointer].originMAC));
|
int ret = memcmp(&receiveBuffer[loopPointer].originMAC[0], &peers[i].mac, sizeof(receiveBuffer[loopPointer].originMAC));
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
LOG("\tStatus: %c | BatWarn: %c", receiveBuffer[loopPointer].code, (receiveBuffer[loopPointer].batteryWarning) ? '!' : '.');
|
LOG("\tStatus: %c | BatWarn: %c", receiveBuffer[loopPointer].code, (receiveBuffer[loopPointer].batteryWarning) ? '!' : '.');
|
||||||
lastLoopPointer = loopPointer;
|
loopPointer = rxCounter + 1;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
if (loopPointer - 1 >= 0) {
|
if (loopPointer - 1 >= 0) {
|
||||||
loopPointer--;
|
loopPointer--;
|
||||||
@ -78,8 +76,8 @@ void globalStatus() {
|
|||||||
loopPointer = MAX_PEERS - 1;
|
loopPointer = MAX_PEERS - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
refreshGlobalStatus = false;
|
||||||
}
|
}
|
||||||
refreshGlobalStatus = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
Loading…
Reference in New Issue
Block a user