Running in AP mode?
smartcontracts opened this issue · 4 comments
Heyo, I'm interested in running the webserver in AP mode instead of connecting to a wifi network. I'm planning to use my device on the go so I won't have a stable wifi to connect to. Happy to modify source if necessary to get this working!
Gonna try replacing these lines with WiFi.softAP and see what happens:
Removing the WiFi manager and including WiFi.softAP did work. Now just having issues connecting on iOS and webserver seems to randomly stall after a while. Gonna debug and see where I get.
DId you remove anything more for it to work in AP Mode? I replaced the line you shared above with WiFi.softAP('mySSID') - and I don't see an AP with the SSID I specified
This is from an older version, the version I use
const bool apMode = true;
if (apMode) {
WiFi.mode(WIFI_AP);
// Do a little work to get a unique-ish name. Append the
// last two bytes of the MAC (HEX'd) to "Thing-":
uint8_t mac[WL_MAC_ADDR_LENGTH];
WiFi.softAPmacAddress(mac);
String macID = String(mac[WL_MAC_ADDR_LENGTH - 2], HEX) +
String(mac[WL_MAC_ADDR_LENGTH - 1], HEX);
macID.toUpperCase();
String AP_NameString = "Elvira";
char AP_NameChar[AP_NameString.length() + 1];
memset(AP_NameChar, 0, AP_NameString.length() + 1);
for (int i = 0; i < AP_NameString.length(); i++)
AP_NameChar[i] = AP_NameString.charAt(i);
WiFi.softAP(AP_NameChar, WiFiAPPSK);
Serial.printf("Connect to Wi-Fi access point: %s\n", AP_NameChar);
Serial.println("and open http://192.168.4.1 in your browser");
}
else {
WiFi.mode(WIFI_STA);
Serial.printf("Connecting to %s\n", ssid);
if (String(WiFi.SSID()) != String(ssid)) {
WiFi.begin(ssid, password);
}
}