Post topics, source code that relate to the Arduino Platform

User avatar
By rodmcm
#54223 I entered a test program from Sparkfun to demonstrate AP mode
const char WiFiAPPSK[] = "sparkfun";
.
.
.
void setupWiFi()
{
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 = "ESP8266 Thing " + macID;

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);
}

and then I altered the security login and AP_namestring
const char WiFiAPPSK[] = "TEST";
String AP_NameString = "TESTController " + macID;

My program compiles and downloads fine but then sets up a connection using the sparkfun information, not the new information

Tried lots of resets etc but always the same....

Any ideas
User avatar
By martinayotte
#54256 Wow, so much ugly code to handle this simple SSID name... :lol: :ugeek:
Also, beware that some clients will choke if SSID contains space characters, use dashes instead.

Code: Select allString mac = WiFi.softAPmacAddress();
mac.toUpperCase();
String ssid = String("ESP8266-Thing-") + mac;
WiFi.softAP((const char *)ssid.c_str(), WiFiAPPSK);
User avatar
By rodmcm
#54292 Thanks for that simplification, added it in, uploaded and again it did not work; reverted back to original
You do not have the required permissions to view the files attached to this post.
User avatar
By John Milner
#54645
rodmcm wrote:I entered a test program from Sparkfun to demonstrate AP mode
const char WiFiAPPSK[] = "sparkfun";
.
.
.
void setupWiFi()
{
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 = "ESP8266 Thing " + macID;

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);
}

and then I altered the security login and AP_namestring
const char WiFiAPPSK[] = "TEST";
String AP_NameString = "TESTController " + macID;

My program compiles and downloads fine but then sets up a connection using the sparkfun information, not the new information

Tried lots of resets etc but always the same....

Any ideas


Your password needs to be 8 or more characters. That's why you're seeing the old values. Hope this helps!