From 7000a7a24486e579b7d21fd02279f3ea724ab0a8 Mon Sep 17 00:00:00 2001 From: DrZlo13 Date: Fri, 3 Dec 2021 10:21:12 +1000 Subject: [PATCH] Separate MAC addresses for each supported mode in device_info. --- main/cli-commands-device-info.c | 83 +++++++++++++++++++++++++++------ main/network-http.c | 3 ++ 2 files changed, 73 insertions(+), 13 deletions(-) diff --git a/main/cli-commands-device-info.c b/main/cli-commands-device-info.c index 21a1696..856a74d 100644 --- a/main/cli-commands-device-info.c +++ b/main/cli-commands-device-info.c @@ -7,20 +7,74 @@ #include void cli_device_info(Cli* cli, mstring_t* args) { - uint8_t mac_addr[6] = {0}; - ESP_ERROR_CHECK(esp_read_mac(mac_addr, ESP_MAC_WIFI_STA)); + uint8_t mac_addr[8] = {0}; - cli_printf(cli, "hardware_uid: "); - cli_printf( - cli, - "%02x%02x%02x%02x%02x%02x", - mac_addr[0], - mac_addr[1], - mac_addr[2], - mac_addr[3], - mac_addr[4], - mac_addr[5]); - cli_write_eol(cli); + if(esp_read_mac(mac_addr, ESP_MAC_WIFI_STA) == ESP_OK) { + cli_printf( + cli, + "mac_wifi_sta: %02x%02x%02x%02x%02x%02x", + mac_addr[0], + mac_addr[1], + mac_addr[2], + mac_addr[3], + mac_addr[4], + mac_addr[5]); + cli_write_eol(cli); + } + + if(esp_read_mac(mac_addr, ESP_MAC_WIFI_SOFTAP) == ESP_OK) { + cli_printf( + cli, + "mac_wifi_ap: %02x%02x%02x%02x%02x%02x", + mac_addr[0], + mac_addr[1], + mac_addr[2], + mac_addr[3], + mac_addr[4], + mac_addr[5]); + cli_write_eol(cli); + } + + if(esp_read_mac(mac_addr, ESP_MAC_BT) == ESP_OK) { + cli_printf( + cli, + "mac_bt: %02x%02x%02x%02x%02x%02x", + mac_addr[0], + mac_addr[1], + mac_addr[2], + mac_addr[3], + mac_addr[4], + mac_addr[5]); + cli_write_eol(cli); + } + + if(esp_read_mac(mac_addr, ESP_MAC_ETH) == ESP_OK) { + cli_printf( + cli, + "mac_eth: %02x%02x%02x%02x%02x%02x", + mac_addr[0], + mac_addr[1], + mac_addr[2], + mac_addr[3], + mac_addr[4], + mac_addr[5]); + cli_write_eol(cli); + } + + if(esp_read_mac(mac_addr, ESP_MAC_IEEE802154) == ESP_OK) { + cli_printf( + cli, + "mac_IEEE802154: %02x%02x%02x%02x%02x%02x%02x%02x", + mac_addr[0], + mac_addr[1], + mac_addr[2], + mac_addr[3], + mac_addr[4], + mac_addr[5], + mac_addr[6], + mac_addr[7]); + cli_write_eol(cli); + } cli_printf(cli, "idf_version: %s", IDF_VER); cli_write_eol(cli); @@ -62,6 +116,9 @@ void cli_device_info(Cli* cli, mstring_t* args) { case CHIP_ESP32C3: cli_write_str(cli, "ESP32-C3"); break; + default: + cli_write_str(cli, "UNKNOWN"); + break; } cli_write_eol(cli); diff --git a/main/network-http.c b/main/network-http.c index 0b8ae71..d1157bb 100644 --- a/main/network-http.c +++ b/main/network-http.c @@ -212,6 +212,9 @@ static esp_err_t system_info_get_handler(httpd_req_t* req) { case CHIP_ESP32C3: cJSON_AddStringToObject(root, "model", "ESP32-C3"); break; + default: + cJSON_AddStringToObject(root, "model", "UNKNOWN"); + break; } cJSON_AddNumberToObject(root, "revision", chip_info.revision); cJSON_AddNumberToObject(root, "cores", chip_info.cores);