| 519 | } |
| 520 | |
| 521 | void processDataReq(struct espAvailDataReq* eadr, bool local, IPAddress remoteIP) { |
| 522 | if (config.runStatus == RUNSTATUS_STOP) { |
| 523 | return; |
| 524 | } |
| 525 | char buffer[64]; |
| 526 | |
| 527 | char hexmac[17]; |
| 528 | mac2hex(eadr->src, hexmac); |
| 529 | |
| 530 | tagRecord* taginfo = tagRecord::findByMAC(eadr->src); |
| 531 | if (taginfo == nullptr) { |
| 532 | if (config.lock == 1 || (config.lock == 2 && eadr->adr.wakeupReason != WAKEUP_REASON_FIRSTBOOT)) return; |
| 533 | #ifdef HAS_SUBGHZ |
| 534 | if (apInfo.hasSubGhz && eadr->adr.currentChannel > 0 && eadr->adr.currentChannel == apInfo.SubGhzChannel) { |
| 535 | // Empty intentionally |
| 536 | } else |
| 537 | #endif |
| 538 | if (local == true && eadr->adr.currentChannel > 0 && eadr->adr.currentChannel != apInfo.channel) { |
| 539 | Serial.printf("Tag %s reports illegal channel %d\r\n", hexmac, eadr->adr.currentChannel); |
| 540 | return; |
| 541 | } |
| 542 | taginfo = new tagRecord; |
| 543 | memcpy(taginfo->mac, eadr->src, sizeof(taginfo->mac)); |
| 544 | taginfo->pendingCount = 0; |
| 545 | tagDB.push_back(taginfo); |
| 546 | } |
| 547 | time_t now; |
| 548 | time(&now); |
| 549 | |
| 550 | if (!local) { |
| 551 | if (taginfo->isExternal == false) { |
| 552 | wsLog("moved AP from local to external " + String(hexmac)); |
| 553 | taginfo->isExternal = true; |
| 554 | } |
| 555 | taginfo->apIp = remoteIP; |
| 556 | } else { |
| 557 | if (taginfo->isExternal == true) { |
| 558 | wsLog("moved AP from external to local " + String(hexmac)); |
| 559 | taginfo->isExternal = false; |
| 560 | } |
| 561 | taginfo->apIp = IPAddress(0, 0, 0, 0); |
| 562 | } |
| 563 | |
| 564 | if (taginfo->pendingIdle == 0 || countQueueItem(eadr->src) > 0) { |
| 565 | if (taginfo->expectedNextCheckin < now + 60) taginfo->expectedNextCheckin = now + 60; |
| 566 | } else if (taginfo->pendingIdle == 9999) { |
| 567 | taginfo->expectedNextCheckin = 3216153600; |
| 568 | } else { |
| 569 | taginfo->expectedNextCheckin = now + taginfo->pendingIdle; |
| 570 | } |
| 571 | taginfo->pendingIdle = 0; |
| 572 | taginfo->lastseen = now; |
| 573 | |
| 574 | if (eadr->adr.lastPacketRSSI != 0) { |
| 575 | if (eadr->adr.wakeupReason >= 0xE0) { |
| 576 | if (taginfo->pendingCount == 0) { |
| 577 | taginfo->nextupdate = 0; |
| 578 | memset(taginfo->md5, 0, sizeof(taginfo->md5)); |
no test coverage detected