Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
if(IDF_VERSION_MAJOR GREATER_EQUAL 4)
idf_component_register(SRC_DIRS src
REQUIRES log nvs_flash mdns wpa_supplicant lwip esp_http_server
REQUIRES log nvs_flash esp_wifi mdns wpa_supplicant lwip esp_http_server
REQUIRES log nvs_flash esp_wifi mdns wpa_supplicant lwip esp_http_server
INCLUDE_DIRS src
EMBED_FILES src/style.css src/code.js src/index.html)
else()
set(COMPONENT_SRCDIRS src)
set(COMPONENT_ADD_INCLUDEDIRS src)
set(COMPONENT_REQUIRES log nvs_flash mdns wpa_supplicant lwip esp_http_server)
set(COMPONENT_REQUIRES log nvs_flash esp_wifi mdns wpa_supplicant lwip esp_http_server)
set(COMPONENT_EMBED_FILES src/style.css src/code.js src/index.html)
register_component()
endif()
11 changes: 11 additions & 0 deletions src/wifi_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ Contains the freeRTOS task and all necessary support
#include "lwip/err.h"
#include "lwip/netdb.h"
#include "lwip/ip4_addr.h"
#include "esp_mac.h"


#include "json.h"
Expand Down Expand Up @@ -604,6 +605,16 @@ static void wifi_manager_event_handler(void* arg, esp_event_base_t event_base, i
* the application is LwIP-based, then you need to wait until the got ip event comes in. */
case WIFI_EVENT_STA_CONNECTED:
ESP_LOGI(TAG, "WIFI_EVENT_STA_CONNECTED");

uint8_t mac_address[8];
char hostname[16];

esp_base_mac_addr_get(&mac_address);
sprintf(hostname, "tn-%02x%02x%02x%02x%02x%02x", mac_address[0], mac_address[1], mac_address[2], mac_address[3], mac_address[4], mac_address[5]);

ESP_LOGI(TAG, "Setting hostname to %s", hostname);
esp_netif_set_hostname(esp_netif_sta, hostname);

break;

/* This event can be generated in the following scenarios:
Expand Down