0

看了以下文章,是先station mode再轉為AP mode

但現在想反過來,先AP mode,再Station mode,所以只在void setup()改了順序如下

void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
while (true);
}
String fv = WiFi.firmwareVersion();
if (fv != "1.1.0") {
Serial.println("Please upgrade the firmware");
}

// attempt to start AP:

Serial.print("Attempting to start AP with SSID: ");
Serial.println(apssid);
status = WiFi.apbegin(apssid, appass, channel);
delay(10000);

//AP MODE already started:
Serial.println("AP mode already started");
Serial.println();
printWifiData();
printCurrentNet();

WiFi.disconnect();

while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to WPA SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network:
status = WiFi.begin(ssid, pass);

// wait 10 seconds for connection:
delay(10000);
}

}

後來發現AP一直沒轉成staion mode,猜測應該不是用WiFi.disconnect()這個指令,請問怎麼讓AP停下來換成staion呢?

另外,用standard SDK也可以達成AP/Station mode切換嗎?

sean 回答了