From 81c521d286aa6ca6da80deece7c38226155df2de Mon Sep 17 00:00:00 2001 From: hathach Date: Tue, 10 Jun 2025 11:00:40 +0700 Subject: [PATCH] use base mac for getMACaddr() if interface is not up --- boards/fruitjam_c6/board.h | 2 +- main/CommandHandler.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/boards/fruitjam_c6/board.h b/boards/fruitjam_c6/board.h index bccf85f..5969a9a 100644 --- a/boards/fruitjam_c6/board.h +++ b/boards/fruitjam_c6/board.h @@ -6,6 +6,6 @@ #define AIRLIFT_MISO 6 #define AIRLIFT_SCK 22 #define AIRLIFT_CS 7 -#define AIRLIFT_BUSY CONFIG_BT_LE_HCI_UART_RTS_PIN // ready +#define AIRLIFT_BUSY CONFIG_BT_LE_HCI_UART_RTS_PIN // 18, aka ready #endif diff --git a/main/CommandHandler.cpp b/main/CommandHandler.cpp index 50992f6..e1c6be4 100644 --- a/main/CommandHandler.cpp +++ b/main/CommandHandler.cpp @@ -35,6 +35,7 @@ // ADAFRUIT-CHANGE: Adafruit-style enterprise wifi support #include "esp_eap_client.h" #include "esp_wifi.h" +#include "esp_mac.h" #include "esp_log.h" #include "esp_sntp.h" @@ -517,6 +518,13 @@ int getMACaddr(const uint8_t command[], uint8_t response[]) WiFi.macAddress(mac); + if (mac[0] == 0x00 && mac[1] == 0x00 && mac[2] == 0x00 && + mac[3] == 0x00 && mac[4] == 0x00 && mac[5] == 0x00) { + // If the MAC address is all zeros, STA/AP interface is not enabled/ready. + // use base mac address + esp_base_mac_addr_get(mac); + } + response[2] = 1; // number of parameters response[3] = sizeof(mac); // parameter 1 length