Enable to set the WM pwd from the Mac (#1323)
So as to reinforce security for AP configuration access, enable to set the Wifi Manager Password from the 8 first digits of the ESP Mac address
This commit is contained in:
1 parent
4afb4a972f
commit
2ada47c3bc
3 files changed
+18
-5
No files matched your search
+5
-2
@@ -114,8 +114,11 @@ const byte mac[] = {0xDE, 0xED, 0xBA, 0xFE, 0x54, 0x95}; //W5100 ethernet shield
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WifiManager_password
|
#define WM_PWD_FROM_MAC false // enable to set the password from the 8 first digit of the ESP mac address for enhanced security, enabling this option requires to have access to the MAC address, either through a sticker or with serial monitoring
|
||||||
# define WifiManager_password "your_password" //this is going to be the WPA2-PSK password for the initial setup access point
|
#if !WM_PWD_FROM_MAC
|
||||||
|
# ifndef WifiManager_password
|
||||||
|
# define WifiManager_password "your_password" //this is going to be the WPA2-PSK password for the initial setup access point
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef WifiManager_ssid
|
#ifndef WifiManager_ssid
|
||||||
# define WifiManager_ssid Gateway_Name //this is the network name of the initial setup access point
|
# define WifiManager_ssid Gateway_Name //this is the network name of the initial setup access point
|
||||||
|
|||||||
+12
-3
@@ -1233,9 +1233,18 @@ void setup_wifimanager(bool reset_settings) {
|
|||||||
|
|
||||||
if (!wifi_reconnect_bypass()) // if we didn't connect with saved credential we start Wifimanager web portal
|
if (!wifi_reconnect_bypass()) // if we didn't connect with saved credential we start Wifimanager web portal
|
||||||
{
|
{
|
||||||
|
// Wifi Manager password
|
||||||
|
String wm_password;
|
||||||
|
# if WM_PWD_FROM_MAC // From ESP Mac Address
|
||||||
|
wm_password = WiFi.macAddress();
|
||||||
|
wm_password.replace(":", "");
|
||||||
|
wm_password.substring(0, 8);
|
||||||
|
# else
|
||||||
|
wm_password = WifiManager_password; // From macro definition
|
||||||
|
# endif
|
||||||
# ifdef ESP32
|
# ifdef ESP32
|
||||||
if (lowpowermode < 2) {
|
if (lowpowermode < 2) {
|
||||||
displayPrint("Connect your phone to WIFI AP:", WifiManager_ssid, WifiManager_password);
|
displayPrint("Connect your phone to WIFI AP:", WifiManager_ssid, const_cast<char*>(wm_password.c_str()));
|
||||||
} else { // in case of low power mode we put the ESP to sleep again if we didn't get connected (typical in case the wifi is down)
|
} else { // in case of low power mode we put the ESP to sleep again if we didn't get connected (typical in case the wifi is down)
|
||||||
# ifdef ZgatewayBT
|
# ifdef ZgatewayBT
|
||||||
lowPowerESP32();
|
lowPowerESP32();
|
||||||
@@ -1245,11 +1254,11 @@ void setup_wifimanager(bool reset_settings) {
|
|||||||
|
|
||||||
ErrorIndicatorON();
|
ErrorIndicatorON();
|
||||||
InfoIndicatorON();
|
InfoIndicatorON();
|
||||||
Log.notice(F("Connect your phone to WIFI AP: %s with PWD: %s" CR), WifiManager_ssid, WifiManager_password);
|
Log.notice(F("Connect your phone to WIFI AP: %s with PWD: %s" CR), WifiManager_ssid, wm_password.c_str());
|
||||||
//fetches ssid and pass and tries to connect
|
//fetches ssid and pass and tries to connect
|
||||||
//if it does not connect it starts an access point with the specified name
|
//if it does not connect it starts an access point with the specified name
|
||||||
//and goes into a blocking loop awaiting configuration
|
//and goes into a blocking loop awaiting configuration
|
||||||
if (!wifiManager.autoConnect(WifiManager_ssid, WifiManager_password)) {
|
if (!wifiManager.autoConnect(WifiManager_ssid, wm_password.c_str())) {
|
||||||
Log.warning(F("failed to connect and hit timeout" CR));
|
Log.warning(F("failed to connect and hit timeout" CR));
|
||||||
delay(3000);
|
delay(3000);
|
||||||
//reset and try again
|
//reset and try again
|
||||||
|
|||||||
@@ -291,6 +291,7 @@ build_flags =
|
|||||||
'-DZsensorGPIOKeyCode="GPIOKeyCode"'
|
'-DZsensorGPIOKeyCode="GPIOKeyCode"'
|
||||||
'-DZgatewayWeatherStation="WeatherStation"'
|
'-DZgatewayWeatherStation="WeatherStation"'
|
||||||
'-DsimplePublishing=true'
|
'-DsimplePublishing=true'
|
||||||
|
'-DWM_PWD_FROM_MAC=true'
|
||||||
'-DGateway_Name="OpenMQTTGateway_ESP32_ALL"'
|
'-DGateway_Name="OpenMQTTGateway_ESP32_ALL"'
|
||||||
|
|
||||||
[env:esp32dev-rf]
|
[env:esp32dev-rf]
|
||||||
|
|||||||
Reference in new issue
Block a user