Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ESP32]fix get wrong MAC on SoftAP mode #7777

Merged
merged 1 commit into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion src/platform/ESP32/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,28 @@ CHIP_ERROR ConfigurationManagerImpl::_Init()

CHIP_ERROR ConfigurationManagerImpl::_GetPrimaryWiFiMACAddress(uint8_t * buf)
{
return esp_wifi_get_mac(WIFI_IF_STA, buf);
wifi_mode_t mode;
esp_wifi_get_mode(&mode);
if ((mode == WIFI_MODE_AP) || (mode == WIFI_MODE_APSTA))
return MapConfigError(esp_wifi_get_mac(WIFI_IF_AP, buf));
woody-apple marked this conversation as resolved.
Show resolved Hide resolved
else
return MapConfigError(esp_wifi_get_mac(WIFI_IF_STA, buf));
}

CHIP_ERROR ConfigurationManagerImpl::MapConfigError(esp_err_t error)
{
switch (error)
{
case ESP_OK:
return CHIP_NO_ERROR;
case ESP_ERR_WIFI_NOT_INIT:
return CHIP_ERROR_WELL_UNINITIALIZED;
case ESP_ERR_INVALID_ARG:
case ESP_ERR_WIFI_IF:
return CHIP_ERROR_INVALID_ARGUMENT;
default:
return CHIP_ERROR_INTERNAL;
}
}

bool ConfigurationManagerImpl::_CanFactoryReset()
Expand Down
1 change: 1 addition & 0 deletions src/platform/ESP32/ConfigurationManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class ConfigurationManagerImpl final : public ConfigurationManager,
CHIP_ERROR _GetPrimaryWiFiMACAddress(uint8_t * buf);
bool _CanFactoryReset(void);
void _InitiateFactoryReset(void);
CHIP_ERROR MapConfigError(esp_err_t error);
CHIP_ERROR _ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value);
CHIP_ERROR _WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value);

Expand Down