Rework setHostname for WiFi STA
Fixes: https://github.com/espressif/arduino-esp32/issues/2537
This commit is contained in:
		
							parent
							
								
									5de03a3918
								
							
						
					
					
						commit
						ad4cf1461b
					
				| @ -379,6 +379,7 @@ esp_err_t WiFiGenericClass::_eventCallback(void *arg, system_event_t *event, wif | ||||
|     } else if(event->event_id == SYSTEM_EVENT_STA_START) { | ||||
|         WiFiSTAClass::_setStatus(WL_DISCONNECTED); | ||||
|         setStatusBits(STA_STARTED_BIT); | ||||
|         tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA, WiFiSTAClass::_hostname.c_str()); | ||||
|     } else if(event->event_id == SYSTEM_EVENT_STA_STOP) { | ||||
|         WiFiSTAClass::_setStatus(WL_NO_SHIELD); | ||||
|         clearStatusBits(STA_STARTED_BIT | STA_CONNECTED_BIT | STA_HAS_IP_BIT | STA_HAS_IP6_BIT); | ||||
|  | ||||
| @ -71,6 +71,7 @@ static bool sta_config_equal(const wifi_config_t& lhs, const wifi_config_t& rhs) | ||||
| 
 | ||||
| bool WiFiSTAClass::_autoReconnect = true; | ||||
| bool WiFiSTAClass::_useStaticIp = false; | ||||
| String WiFiSTAClass::_hostname = "esp32-arduino"; | ||||
| 
 | ||||
| static wl_status_t _sta_status = WL_NO_SHIELD; | ||||
| static EventGroupHandle_t _sta_status_group = NULL; | ||||
| @ -283,7 +284,6 @@ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subne | ||||
|     } | ||||
| 
 | ||||
|     tcpip_adapter_ip_info_t info; | ||||
|     log_d("STA IP uint32_t: %u.%u.%u.%u\n", local_ip[0], local_ip[1], local_ip[2], local_ip[3]); | ||||
| 
 | ||||
|     if(local_ip != (uint32_t)0x00000000 && local_ip != INADDR_NONE){ | ||||
|         info.ip.addr = static_cast<uint32_t>(local_ip); | ||||
| @ -637,6 +637,7 @@ const char * WiFiSTAClass::getHostname() | ||||
|  */ | ||||
| bool WiFiSTAClass::setHostname(const char * hostname) | ||||
| { | ||||
|     _hostname = hostname; | ||||
|     if(WiFiGenericClass::getMode() == WIFI_MODE_NULL){ | ||||
|         return false; | ||||
|     } | ||||
|  | ||||
| @ -86,6 +86,7 @@ public: | ||||
|     int8_t RSSI(); | ||||
| 
 | ||||
|     static void _setStatus(wl_status_t status); | ||||
|     static String _hostname; | ||||
| protected: | ||||
|     static bool _useStaticIp; | ||||
|     static bool _autoReconnect; | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user