Skip to content

Commit

Permalink
log wifi mac on boot (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
matslina authored Jul 13, 2023
1 parent ef000e1 commit 1fa602e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ void app_main(void) {
}
esp_register_shutdown_handler(&wifi_shutdown);

uint8_t mac[6];
if (!wifi_get_mac(mac)) {
ESP_LOGI(TAG, "WiFi MAC: %02x:%02x:%02x:%02x:%02x:%02x", mac[0], mac[1],
mac[2], mac[3], mac[4], mac[5]);
}

for (;;) {
uint8_t* webp;
size_t len;
Expand Down
9 changes: 9 additions & 0 deletions src/wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,12 @@ void wifi_shutdown() {
esp_wifi_stop();
esp_wifi_deinit();
}

int wifi_get_mac(uint8_t mac[6]) {
esp_err_t err = esp_wifi_get_mac(WIFI_IF_STA, mac);
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to get MAC address: %s", esp_err_to_name(err));
return 1;
}
return 0;
}
4 changes: 3 additions & 1 deletion src/wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@

int wifi_initialize(const char *ssid, const char *password);

void wifi_shutdown();
void wifi_shutdown();

int wifi_get_mac(uint8_t mac[6]);

0 comments on commit 1fa602e

Please sign in to comment.