Separate MAC addresses for each supported mode in device_info.

This commit is contained in:
DrZlo13 2021-12-03 10:21:12 +10:00
parent 80e7a8b262
commit 7000a7a244
2 changed files with 73 additions and 13 deletions

View File

@ -7,20 +7,74 @@
#include <esp_system.h>
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);

View File

@ -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);