| 1426 | } |
| 1427 | |
| 1428 | void processResponseQueue() { |
| 1429 | unsigned long now = millis(); |
| 1430 | while (!responseQueue.empty()) { |
| 1431 | ProbeResponseTask &task = responseQueue.front(); |
| 1432 | if (now - task.timestamp > RESPONSE_TIMEOUT_MS) { |
| 1433 | responseQueue.pop(); |
| 1434 | continue; |
| 1435 | } |
| 1436 | uint8_t responseFrame[256]; |
| 1437 | size_t frameLen = buildEnhancedProbeResponse( |
| 1438 | responseFrame, task.ssid, task.targetMAC, task.channel, task.rsn, false |
| 1439 | ); |
| 1440 | if (sendRawFrameOnAp(responseFrame, frameLen, task.channel)) { |
| 1441 | karmaResponsesSent++; |
| 1442 | if (networkHistory.size() < MAX_NETWORK_HISTORY) { |
| 1443 | auto it = networkHistory.find(task.ssid); |
| 1444 | if (it == networkHistory.end()) { |
| 1445 | NetworkHistory history; |
| 1446 | history.ssid = task.ssid; |
| 1447 | history.responsesSent = 1; |
| 1448 | history.lastResponse = now; |
| 1449 | history.successfulConnections = 0; |
| 1450 | networkHistory[task.ssid] = history; |
| 1451 | } else { |
| 1452 | it->second.responsesSent++; |
| 1453 | it->second.lastResponse = now; |
| 1454 | } |
| 1455 | } |
| 1456 | bool found = false; |
| 1457 | for (auto &net : activeNetworks) { |
| 1458 | if (net.ssid == task.ssid) { |
| 1459 | found = true; |
| 1460 | net.lastActivity = now; |
| 1461 | break; |
| 1462 | } |
| 1463 | } |
| 1464 | if (!found && activeNetworks.size() < MAX_CONCURRENT_SSIDS) { |
| 1465 | ActiveNetwork net; |
| 1466 | net.ssid = task.ssid; |
| 1467 | net.channel = task.channel; |
| 1468 | net.rsn = task.rsn; |
| 1469 | net.lastActivity = now; |
| 1470 | net.lastBeacon = 0; |
| 1471 | activeNetworks.push_back(net); |
| 1472 | } |
| 1473 | } |
| 1474 | responseQueue.pop(); |
| 1475 | } |
| 1476 | } |
| 1477 | |
| 1478 | void processQueuedProbeEvents() { |
| 1479 | if (!karmaQueue) return; |
no test coverage detected