8000 Changes for #132 · kebot-embedded/esp32-snippets@b40811f · GitHub
[go: up one dir, main page]

Skip to content

Commit b40811f

Browse files
committed
Changes for nkolban#132
1 parent 3893a18 commit b40811f

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

networking/bootwifi/BootWiFi.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void BootWiFi::bootWiFi2() {
222222
m_wifi.setWifiEventHandler(new BootWifiEventHandler(this));
223223
if (checkOverrideGpio()) {
224224
ESP_LOGD(LOG_TAG, "- GPIO override detected");
225-
m_wifi.startAP("Duktape", "Duktape");
225+
m_wifi.startAP(m_ssid, m_password);
226226
} else {
227227
// There was NO GPIO override, proceed as normal. This means we retrieve
228228
// our stored access point information of the access point we should connect
@@ -249,19 +249,30 @@ void BootWiFi::bootWiFi2() {
249249
// point that serves up a web server and allow a browser user to specify
250250
// the details that will be eventually used to allow us to connect
251251
// as a station.
252-
m_wifi.startAP("Duktape", "Duktape");
252+
m_wifi.startAP(m_ssid, m_password);
253253
} // We do NOT have connection info
254254
}
255255
ESP_LOGD(LOG_TAG, "<< bootWiFi2");
256256
} // bootWiFi2
257257

258258

259+
/**
260+
* @brief Set the userid/password pair that will be used for the ESP32 access point.
261+
* @param [in] ssid The network id of the ESP32 when it becomes an access point.
262+
* @param [in] password The password for the ESP32 when it becomes an access point.
263+
*/
264+
void BootWiFi::setAccessPointCredentials(std::string ssid, std::string password) {
265+
m_ssid = ssid;
266+
m_password = password;
267+
} // setAccessPointCredentials
268+
259269

260270
void BootWiFi::boot() {
261271
ESP_LOGD(LOG_TAG, ">> boot");
262272
ESP_LOGD(LOG_TAG, " +----------+");
263273
ESP_LOGD(LOG_TAG, " | BootWiFi |");
264274
ESP_LOGD(LOG_TAG, " +----------+");
275+
ESP_LOGD(LOG_TAG, " Access point credentials: %s/%s", m_ssid.c_str(), m_password.c_str());
265276
m_completeSemaphore.take("boot"); // Take the semaphore which will be unlocked when we complete booting.
266277
bootWiFi2();
267278
m_completeSemaphore.wait("boot"); // Wait for the semaphore that indicated we have completed booting.
@@ -270,4 +281,5 @@ void BootWiFi::boot() {
270281

271282
BootWiFi::BootWiFi() {
272283
m_httpServerStarted = false;
284+
setAccessPointCredentials("esp32", "password");
273285
}

networking/bootwifi/BootWiFi.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,16 @@ class BootWiFi {
1919
private:
2020
friend BootWifiEventHandler;
2121
void bootWiFi2();
22-
WiFi m_wifi;
23-
HttpServer m_httpServer;
24-
bool m_httpServerStarted;
22+
WiFi m_wifi;
23+
HttpServer m_httpServer;
24+
bool m_httpServerStarted;
25+
std::string m_ssid;
26+
std::string m_password;
2527
FreeRTOS::Semaphore m_completeSemaphore = FreeRTOS::Semaphore("completeSemaphore");
2628

2729
public:
2830
BootWiFi();
31+
void setAccessPointCredentials(std::string ssid, std::string password);
2932
void boot();
3033
};
3134

0 commit comments

Comments
 (0)
0