Connect to best BSSID
This commit is contained in:
@@ -686,6 +686,11 @@ const String Network::networkDeviceName() const
|
||||
return _device->deviceName();
|
||||
}
|
||||
|
||||
const String Network::networkBSSID() const
|
||||
{
|
||||
return _device->BSSIDstr();
|
||||
}
|
||||
|
||||
void Network::publishFloat(const char* prefix, const char* topic, const float value, const uint8_t precision)
|
||||
{
|
||||
char str[30];
|
||||
|
||||
@@ -67,6 +67,7 @@ public:
|
||||
int mqttConnectionState(); // 0 = not connected; 1 = connected; 2 = connected and mqtt processed
|
||||
bool encryptionSupported();
|
||||
const String networkDeviceName() const;
|
||||
const String networkBSSID() const;
|
||||
|
||||
const NetworkDeviceType networkDeviceType();
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#define preference_network_hardware "nwhw"
|
||||
#define preference_network_hardware_gpio "nwhwdt" // obsolete
|
||||
#define preference_network_wifi_fallback_disabled "nwwififb"
|
||||
#define preference_find_best_rssi "nwbestrssi"
|
||||
#define preference_rssi_publish_interval "rssipb"
|
||||
#define preference_hostname "hostname"
|
||||
#define preference_network_timeout "nettmout"
|
||||
@@ -80,7 +81,7 @@ private:
|
||||
preference_mqtt_ca, preference_mqtt_crt, preference_mqtt_key, preference_mqtt_hass_discovery, preference_mqtt_hass_cu_url,
|
||||
preference_ip_dhcp_enabled, preference_ip_address, preference_ip_subnet, preference_ip_gateway, preference_ip_dns_server,
|
||||
preference_network_hardware, preference_network_wifi_fallback_disabled, preference_rssi_publish_interval,
|
||||
preference_hostname, preference_network_timeout, preference_restart_on_disconnect,
|
||||
preference_find_best_rssi, preference_hostname, preference_network_timeout, preference_restart_on_disconnect,
|
||||
preference_restart_ble_beacon_lost, preference_query_interval_lockstate,
|
||||
preference_query_interval_configuration, preference_query_interval_battery, preference_query_interval_keypad,
|
||||
preference_keypad_control_enabled, preference_admin_enabled, preference_keypad_info_enabled, preference_acl,
|
||||
@@ -100,7 +101,7 @@ private:
|
||||
std::vector<char*> _boolPrefs =
|
||||
{
|
||||
preference_started_before, preference_mqtt_log_enabled, preference_check_updates, preference_lock_enabled, preference_opener_enabled, preference_opener_continuous_mode,
|
||||
preference_restart_on_disconnect, preference_keypad_control_enabled, preference_admin_enabled, preference_keypad_info_enabled,
|
||||
preference_find_best_rssi, preference_restart_on_disconnect, preference_keypad_control_enabled, preference_admin_enabled, preference_keypad_info_enabled,
|
||||
preference_timecontrol_control_enabled, preference_timecontrol_info_enabled, preference_register_as_app, preference_ip_dhcp_enabled,
|
||||
preference_publish_authdata, preference_has_mac_saved, preference_publish_debug_info, preference_network_wifi_fallback_disabled
|
||||
};
|
||||
|
||||
@@ -112,6 +112,7 @@ In a browser navigate to the IP address assigned to the ESP32.
|
||||
- MQTT SSL Client Key: Optionally set to the Client SSL key of the MQTT broker, see the "MQTT Encryption" section of this README.
|
||||
- Network hardware: "Wi-Fi only" by default, set to one of the specified ethernet modules if available, see the "Supported Ethernet devices" and "Connecting via Ethernet" section of this README.
|
||||
- Disable fallback to Wi-Fi / Wi-Fi config portal: By default the Nuki Hub will fallback to Wi-Fi and open the Wi-Fi configuration portal when the network connection fails. Enable this setting to disable this fallback.
|
||||
- Connect to AP with the best signal in an environment with multiple APs with the same SSID: Enable to perform a scan for the Access Point with the best signal strenght for the specified SSID in a multi AP/Mesh environment.
|
||||
- RSSI Publish interval: Set to a positive integer to set the amount of seconds between updates to the maintenance/wifiRssi MQTT topic with the current Wi-Fi RSSI, set to -1 to disable, default 60.
|
||||
- Network Timeout until restart: Set to a positive integer to restart the Nuki Hub after the set amount of seconds has passed without an active connection to the MQTT broker, set to -1 to disable, default 60.
|
||||
- Restart on disconnect: Enable to restart the Nuki Hub after 60 seconds without a connection to a network.
|
||||
|
||||
@@ -371,6 +371,11 @@ bool WebCfgServer::processArgs(String& message)
|
||||
_preferences->putString(preference_mqtt_hass_cu_url, value);
|
||||
configChanged = true;
|
||||
}
|
||||
else if(key == "BESTRSSI")
|
||||
{
|
||||
_preferences->putBool(preference_find_best_rssi, (value == "1"));
|
||||
configChanged = true;
|
||||
}
|
||||
else if(key == "HOSTNAME")
|
||||
{
|
||||
_preferences->putString(preference_hostname, value);
|
||||
@@ -955,6 +960,7 @@ void WebCfgServer::buildMqttConfigHtml(String &response)
|
||||
printTextarea(response, "MQTTKEY", "MQTT SSL Client Key (*, optional)", _preferences->getString(preference_mqtt_key).c_str(), TLS_KEY_MAX_SIZE, _network->encryptionSupported(), true);
|
||||
printDropDown(response, "NWHW", "Network hardware", String(_preferences->getInt(preference_network_hardware)), getNetworkDetectionOptions());
|
||||
printCheckBox(response, "NWHWWIFIFB", "Disable fallback to Wi-Fi / Wi-Fi config portal", _preferences->getBool(preference_network_wifi_fallback_disabled));
|
||||
printCheckBox(response, "BESTRSSI", "Connect to AP with the best signal in an environment with multiple APs with the same SSID", _preferences->getBool(preference_find_best_rssi));
|
||||
printInputField(response, "RSSI", "RSSI Publish interval (seconds; -1 to disable)", _preferences->getInt(preference_rssi_publish_interval), 6);
|
||||
printInputField(response, "NETTIMEOUT", "Network Timeout until restart (seconds; -1 to disable)", _preferences->getInt(preference_network_timeout), 5);
|
||||
printCheckBox(response, "RSTDISC", "Restart on disconnect", _preferences->getBool(preference_restart_on_disconnect));
|
||||
@@ -1210,6 +1216,13 @@ void WebCfgServer::buildInfoHtml(String &response)
|
||||
response.concat("Network device: ");
|
||||
response.concat(_network->networkDeviceName());
|
||||
response.concat("\n");
|
||||
|
||||
if(_network->networkDeviceName() == "Built-in Wi-Fi")
|
||||
{
|
||||
response.concat("BSSID of AP: ");
|
||||
response.concat(_network->networkBSSID());
|
||||
response.concat("\n");
|
||||
}
|
||||
|
||||
response.concat("Uptime: ");
|
||||
response.concat(millis() / 1000 / 60);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -248,6 +248,7 @@ class WiFiManager
|
||||
{
|
||||
public:
|
||||
WiFiManager(Print& consolePort);
|
||||
WiFiManager(const char* user, const char* password);
|
||||
WiFiManager();
|
||||
~WiFiManager();
|
||||
void WiFiManagerInit();
|
||||
@@ -411,6 +412,9 @@ class WiFiManager
|
||||
|
||||
// if true (default) then stop the config portal from autoConnect when wifi is saved
|
||||
void setDisableConfigPortal(boolean enable);
|
||||
|
||||
// if true then find the AP with the best RSSI for the given SSID
|
||||
void setFindBestRSSI(boolean enabled);
|
||||
|
||||
// set a custom hostname, sets sta and ap dhcp client id for esp32, and sta for esp8266
|
||||
bool setHostname(const char * hostname);
|
||||
@@ -593,6 +597,7 @@ class WiFiManager
|
||||
boolean _showBack = false; // show back button
|
||||
boolean _enableConfigPortal = true; // FOR autoconnect - start config portal if autoconnect failed
|
||||
boolean _disableConfigPortal = true; // FOR autoconnect - stop config portal if cp wifi save
|
||||
boolean _findBestRSSI = false; // find best rssi ap in wifiscan
|
||||
String _hostname = ""; // hostname for esp8266 for dhcp, and or MDNS
|
||||
|
||||
const char* _customHeadElement = ""; // store custom head element html from user isnide <head>
|
||||
@@ -836,6 +841,10 @@ protected:
|
||||
std::function<void()> _resetcallback;
|
||||
std::function<void()> _preotaupdatecallback;
|
||||
std::function<void()> _configportaltimeoutcallback;
|
||||
|
||||
bool _hasCredentials = false;
|
||||
char _credUser[31] = {0};
|
||||
char _credPassword[31] = {0};
|
||||
|
||||
template <class T>
|
||||
auto optionalIPFromString(T *obj, const char *s) -> decltype( obj->fromString(s) ) {
|
||||
|
||||
@@ -143,3 +143,8 @@ String EthLan8720Device::localIP()
|
||||
{
|
||||
return ETH.localIP().toString();
|
||||
}
|
||||
|
||||
String EthLan8720Device::BSSIDstr()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
@@ -35,6 +35,7 @@ public:
|
||||
int8_t signalStrength() override;
|
||||
|
||||
String localIP() override;
|
||||
String BSSIDstr() override;
|
||||
|
||||
private:
|
||||
void onDisconnected();
|
||||
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
virtual int8_t signalStrength() = 0;
|
||||
|
||||
virtual String localIP() = 0;
|
||||
virtual String BSSIDstr() = 0;
|
||||
|
||||
virtual void mqttSetClientId(const char* clientId);
|
||||
virtual void mqttSetCleanSession(bool cleanSession);
|
||||
|
||||
@@ -225,3 +225,8 @@ String W5500Device::localIP()
|
||||
{
|
||||
return Ethernet.localIP().toString();
|
||||
}
|
||||
|
||||
String W5500Device::BSSIDstr()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
@@ -33,6 +33,7 @@ public:
|
||||
int8_t signalStrength() override;
|
||||
|
||||
String localIP() override;
|
||||
String BSSIDstr() override;
|
||||
|
||||
private:
|
||||
void resetDevice();
|
||||
|
||||
@@ -67,6 +67,7 @@ void WifiDevice::initialize()
|
||||
wm_menu.push_back("exit");
|
||||
_wm.setEnableConfigPortal(_startAp || !_preferences->getBool(preference_network_wifi_fallback_disabled));
|
||||
// reduced tieout if ESP is set to restart on disconnect
|
||||
_wm.setFindBestRSSI(_preferences->getBool(preference_find_best_rssi));
|
||||
_wm.setConfigPortalTimeout(_restartOnDisconnect ? 60 * 3 : 60 * 30);
|
||||
_wm.setShowInfoUpdate(false);
|
||||
_wm.setMenu(wm_menu);
|
||||
@@ -159,6 +160,11 @@ String WifiDevice::localIP()
|
||||
return WiFi.localIP().toString();
|
||||
}
|
||||
|
||||
String WifiDevice::BSSIDstr()
|
||||
{
|
||||
return WiFi.BSSIDstr();
|
||||
}
|
||||
|
||||
void WifiDevice::clearRtcInitVar(WiFiManager *)
|
||||
{
|
||||
memset(WiFiDevice_reconfdetect, 0, sizeof WiFiDevice_reconfdetect);
|
||||
|
||||
@@ -25,6 +25,7 @@ public:
|
||||
int8_t signalStrength() override;
|
||||
|
||||
String localIP() override;
|
||||
String BSSIDstr() override;
|
||||
|
||||
private:
|
||||
static void clearRtcInitVar(WiFiManager*);
|
||||
|
||||
Reference in New Issue
Block a user