MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / configAP

Method configAP

contributed/modClock/main.js:672–708  ·  view source on GitHub ↗
(ssid, password)

Source from the content-addressed store, hash-verified

670 }
671
672 configAP(ssid, password) {
673trace(`Configure access point ${ssid}\n`);
674 let iter = 2;
675 let clockAP;
676 let disp = 'ap ';
677 while (undefined !== (clockAP = accessPointList.find(x => x.ssid === ap_name))) {
678trace(` ap - ${clockAP.ssid} found iterating\n`);
679 ap_name = AP_NAME + `_${iter}`;
680 disp = `ap_${iter}`;
681 iter++;
682 }
683
684 this.usingAP = true;
685 if (!this.rtc.valid)
686 this.display.value(disp).blink();
687
688 this.myWiFi?.close();
689 delete this.myWiFi;
690
691 this.AP = WiFi.accessPoint({ ssid:ap_name, password, station: true });
692
693 this.configServer();
694 this.doWiFiScan();
695
696 if (this.prefs.ssid) { // saved SSID failed. wait a bit (2 minutes initially). them, if saved SSID is visible, try again.
697 let delay = 2 * 60_000;
698 Timer.repeat(id => {
699 if (delay < (60_000 * 60)) {
700 delay *= 2;
701 Timer.schedule(id, delay, delay);
702 }
703
704 if (accessPointList.findIndex(x => x.ssid === this.prefs.ssid) >= 0)
705 doRestart(this);
706 }, delay);
707 }
708 }
709 apScan() {
710 WiFi.scan({}, item => {
711 if (!item) {

Callers 2

constructorMethod · 0.95
connectMethod · 0.95

Calls 11

configServerMethod · 0.95
doWiFiScanMethod · 0.95
findMethod · 0.80
repeatMethod · 0.80
scheduleMethod · 0.80
doRestartFunction · 0.70
closeMethod · 0.65
findIndexMethod · 0.65
blinkMethod · 0.45
valueMethod · 0.45
accessPointMethod · 0.45

Tested by

no test coverage detected