From 821c94ddd5d9cd10f69545fee8c933f382c97793 Mon Sep 17 00:00:00 2001 From: alanmaxwell Date: Tue, 9 Apr 2024 11:46:24 +0800 Subject: [PATCH] fix(wifi_host): support esp32p4 host get mac addr from target --- components/esp_wifi/esp32p4/esp_adapter.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/components/esp_wifi/esp32p4/esp_adapter.c b/components/esp_wifi/esp32p4/esp_adapter.c index f78dc1972d..7ac4d7157d 100644 --- a/components/esp_wifi/esp32p4/esp_adapter.c +++ b/components/esp_wifi/esp32p4/esp_adapter.c @@ -53,6 +53,8 @@ extern void wifi_apb80m_request(void); extern void wifi_apb80m_release(void); #endif +extern uint8_t *esp_extconn_get_mac(void); + IRAM_ATTR void *wifi_malloc(size_t size) { #if CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP @@ -402,7 +404,21 @@ static void esp_log_write_wrapper(unsigned int level, const char *tag, const cha static esp_err_t esp_read_mac_wrapper(uint8_t *mac, unsigned int type) { - return ESP_FAIL; + if (mac == NULL) { + ESP_LOGE(TAG, "mac address param is NULL"); + return ESP_ERR_INVALID_ARG; + } + + // get mac address from target + memcpy(mac, esp_extconn_get_mac(), 6); + + if (type == ESP_MAC_WIFI_SOFTAP) { + mac[5] += 1; + } + + ESP_LOGD(TAG, "%s MAC addr: " MACSTR, (type == ESP_MAC_WIFI_STA ? "STA" : "AP"), MAC2STR(mac)); + + return ESP_OK; } static int coex_init_wrapper(void)