Set OTA name as Gateway_Short_Name + MAC if using mac as gateway name. (#1023)
* Set OTA name as Gateway_Short_Name + MAC if using mac as gateway name. This will set the OTA name of the gateway to the *Gateway_Short_Name*_*MAC* when USE_MAC_AS_GATEWAY_NAME is defined in the config. * Log OTA hostname when using MAC as gateway name.
This commit is contained in:
1 parent
4f1960a566
commit
379df34701
1 file changed
+7
-2
+7
-2
@@ -168,7 +168,10 @@ char mqtt_topic[mqtt_topic_max_size] = Base_Topic;
|
||||
char gateway_name[parameters_size * 2] = Gateway_Name;
|
||||
#ifdef USE_MAC_AS_GATEWAY_NAME
|
||||
# undef WifiManager_ssid
|
||||
char WifiManager_ssid[20];
|
||||
# undef ota_hostname
|
||||
# define MAC_NAME_MAX_LEN 30
|
||||
char WifiManager_ssid[MAC_NAME_MAX_LEN];
|
||||
char ota_hostname[MAC_NAME_MAX_LEN];
|
||||
#endif
|
||||
bool connectedOnce = false; //indicate if we have been connected once to MQTT
|
||||
int failure_number_ntwk = 0; // number of failure connecting to network
|
||||
@@ -595,7 +598,9 @@ void setup() {
|
||||
String s = WiFi.macAddress();
|
||||
sprintf(gateway_name, "%.2s%.2s%.2s%.2s%.2s%.2s",
|
||||
s.c_str(), s.c_str() + 3, s.c_str() + 6, s.c_str() + 9, s.c_str() + 12, s.c_str() + 15);
|
||||
sprintf(WifiManager_ssid, "%s_%s", Gateway_Short_Name, gateway_name);
|
||||
snprintf(WifiManager_ssid, MAC_NAME_MAX_LEN, "%s_%s", Gateway_Short_Name, gateway_name);
|
||||
strcpy(ota_hostname, WifiManager_ssid);
|
||||
Log.notice(F("OTA Hostname: %s.local" CR), ota_hostname);
|
||||
# endif
|
||||
|
||||
# ifdef ESP32_ETHERNET
|
||||
|
||||
Reference in new issue
Block a user