MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / processDataReq

Function processDataReq

ESP32_AP-Flasher/src/newproto.cpp:521–619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

519}
520
521void 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));

Callers 4

rxCmdProcessorFunction · 0.85
processPacketMethod · 0.85
BLETaskFunction · 0.85
sendAvailFunction · 0.85

Calls 11

mac2hexFunction · 0.85
memcpyFunction · 0.85
wsLogFunction · 0.85
countQueueItemFunction · 0.85
memsetFunction · 0.85
logLineFunction · 0.85
checkQueueFunction · 0.85
wsSendTaginfoFunction · 0.85
printfMethod · 0.80
netProcessDataReqMethod · 0.80
printMethod · 0.45

Tested by

no test coverage detected