HostName Änderungen aufgeräumt und standard Hostname auf "watermeter" gesetzt

This commit is contained in:
phlupp
2020-09-15 22:12:35 +02:00
committed by GitHub
parent e1a33003f0
commit 7d84891813

View File

@@ -23,6 +23,8 @@ std::string ssid;
std::string passphrase;
std::string hostname;
std::string std_hostname = "watermeter";
static EventGroupHandle_t wifi_event_group;
@@ -107,8 +109,9 @@ void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _ho
wifi_event_group = xEventGroupCreate();
ssid = _ssid;
passphrase = _passphrase;
if(_hostname.length() <= 0){
_hostname = "watermeter";
hostname = _hostname;
if(hostname.length() <= 0){
hostname = std_hostname;
}
esp_log_level_set("wifi", ESP_LOG_NONE); // disable wifi driver logging
tcpip_adapter_init();
@@ -116,7 +119,7 @@ void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _ho
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
ESP_ERROR_CHECK( esp_wifi_start() );
esp_err_t ret = tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA , _hostname.c_str());
esp_err_t ret = tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA , hostname.c_str());
if(ret != ESP_OK ){
ESP_LOGE(MAIN_TAG,"failed to set hostname:%d",ret);
}
@@ -124,7 +127,7 @@ void initialise_wifi(std::string _ssid, std::string _passphrase, std::string _ho
tcpip_adapter_ip_info_t ip_info;
ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
printf("IPv4 : %s\n", ip4addr_ntoa(&ip_info.ip));
printf("HostName : %s\n", _hostname.c_str());
printf("HostName : %s\n", hostname.c_str());
}
@@ -132,7 +135,7 @@ void LoadWlanFromFile(std::string fn, std::string &_ssid, std::string &_passphra
{
string line = "";
std::vector<string> zerlegt;
_hostname = "iciruit";
_hostname = std_hostname;
FILE* pFile;
fn = FormatFileName(fn);