[realtek-ambz] Fix reading MAC address without WiFi enabled

This commit is contained in:
Kuba Szczodrzyński
2022-07-05 13:16:51 +02:00
parent cf584c3bd6
commit 15facd8866
2 changed files with 9 additions and 3 deletions

View File

@@ -43,6 +43,7 @@ uint32_t LibreTuya::getChipId() {
// TODO do what EFUSE_LogicalMapRead() does, and read only the used data
EFUSE_LogicalMap_Read(efuse);
memcpy(id, efuse + 0x11A + 3, 3);
free(efuse);
return chipId;
}

View File

@@ -145,9 +145,14 @@ IPAddress WiFiClass::localIP() {
}
uint8_t *WiFiClass::macAddress(uint8_t *mac) {
uint8_t *macLocal = LwIP_GetMAC(NETIF_RTW_STA);
memcpy(mac, macLocal, ETH_ALEN);
free(macLocal);
if (getMode() == WIFI_MODE_NULL) {
uint8_t *efuse = (uint8_t *)malloc(512);
EFUSE_LogicalMap_Read(efuse);
memcpy(mac, efuse + 0x11A, ETH_ALEN);
free(efuse);
return mac;
}
memcpy(mac, LwIP_GetMAC(NETIF_RTW_STA), ETH_ALEN);
return mac;
}