MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / dispatchScan

Function dispatchScan

Tactility/Source/service/wifi/WifiEsp.cpp:688–719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

686}
687
688static void dispatchScan(std::shared_ptr<Wifi> wifi) {
689 LOGGER.info("dispatchScan()");
690 auto lock = wifi->radioMutex.asScopedLock();
691
692 if (!lock.lock(10 / portTICK_PERIOD_MS)) {
693 LOGGER.error(LOG_MESSAGE_MUTEX_LOCK_FAILED);
694 return;
695 }
696
697 RadioState state = wifi->getRadioState();
698 if (state != RadioState::On && state != RadioState::ConnectionActive && state != RadioState::ConnectionPending) {
699 LOGGER.warn("Scan unavailable: wifi not enabled");
700 return;
701 }
702
703 if (wifi->isScanActive()) {
704 LOGGER.warn("Scan already pending");
705 return;
706 }
707
708 // TODO: Thread safety
709 wifi->last_scan_time = tt::kernel::getTicks();
710
711 if (esp_wifi_scan_start(nullptr, false) != ESP_OK) {
712 LOGGER.info("Can't start scan");
713 return;
714 }
715
716 LOGGER.info("Starting scan");
717 wifi->setScanActive(true);
718 publish_event(wifi, WifiEvent::ScanStarted);
719}
720
721static void dispatchConnect(std::shared_ptr<Wifi> wifi) {
722 LOGGER.info("dispatchConnect()");

Callers 2

scanFunction · 0.85
onAutoConnectTimerFunction · 0.85

Calls 10

getTicksFunction · 0.85
infoMethod · 0.80
asScopedLockMethod · 0.80
errorMethod · 0.80
warnMethod · 0.80
isScanActiveMethod · 0.80
setScanActiveMethod · 0.80
publish_eventFunction · 0.70
lockMethod · 0.45
getRadioStateMethod · 0.45

Tested by

no test coverage detected