Skip to content

Commit

Permalink
Add AP password (nrwiersma#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
nrwiersma committed Sep 26, 2018
1 parent 8666c91 commit 5c6aede
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -82,6 +82,13 @@ void setAPName(const char *name)
```
> Sets the name used for the access point.
### setAPPassword
```
void setAPPassword(const char *password)
```
> Sets the password used for the access point. For WPA2-PSK network it should be at least 8 character long.
> If not specified, the access point will be open for anybody to connect to.
### setAPFilename
```
void setAPFilename(const char *filename)
Expand Down
6 changes: 5 additions & 1 deletion src/ConfigManager.cpp
Expand Up @@ -15,6 +15,10 @@ void ConfigManager::setAPName(const char *name) {
this->apName = (char *)name;
}

void ConfigManager::setAPPassword(const char *password) {
this->apPassword = (char *)password;
}

void ConfigManager::setAPFilename(const char *filename) {
this->apFilename = (char *)filename;
}
Expand Down Expand Up @@ -242,7 +246,7 @@ void ConfigManager::startAP() {
IPAddress ip(192, 168, 1, 1);
WiFi.mode(WIFI_AP);
WiFi.softAPConfig(ip, ip, IPAddress(255, 255, 255, 0));
WiFi.softAP(apName);
WiFi.softAP(apName, apPassword);

delay(500); // Need to wait to get IP

Expand Down
2 changes: 2 additions & 0 deletions src/ConfigManager.h
Expand Up @@ -122,6 +122,7 @@ class ConfigManager {

Mode getMode();
void setAPName(const char *name);
void setAPPassword(const char *password);
void setAPFilename(const char *filename);
void setAPTimeout(const int timeout);
void setWifiConnectRetries(const int retries);
Expand Down Expand Up @@ -162,6 +163,7 @@ class ConfigManager {
size_t configSize;

char *apName = (char *)"Thing";
char *apPassword = NULL;
char *apFilename = (char *)"/index.html";
int apTimeout = 0;
unsigned long apStart = 0;
Expand Down

0 comments on commit 5c6aede

Please sign in to comment.