mac address: add user set mac address
add menuconfig for user to set mac address of wifi, bt and ethernet.
This commit is contained in:
parent
c025dfbfa7
commit
fabe0493c2
7 changed files with 101 additions and 3 deletions
|
@ -3,6 +3,15 @@ menuconfig BT_ENABLED
|
||||||
help
|
help
|
||||||
Select this option to enable Bluetooth stack and show the submenu with Bluetooth configuration choices.
|
Select this option to enable Bluetooth stack and show the submenu with Bluetooth configuration choices.
|
||||||
|
|
||||||
|
config ESP_MAC_OFFSET_BT
|
||||||
|
int "MAC address offset value of WiFi station"
|
||||||
|
depends on BT_ENABLED
|
||||||
|
range 0 255
|
||||||
|
default 2
|
||||||
|
help
|
||||||
|
The offset value of bluetooth MAC address from the MAC address which is read from efuse.
|
||||||
|
This offset value must be different from that of WiFi softap, WiFi station and ethernet.
|
||||||
|
|
||||||
config BTC_TASK_STACK_SIZE
|
config BTC_TASK_STACK_SIZE
|
||||||
int "Bluetooth event (callback to application) task stack size"
|
int "Bluetooth event (callback to application) task stack size"
|
||||||
depends on BT_ENABLED
|
depends on BT_ENABLED
|
||||||
|
|
|
@ -481,6 +481,24 @@ menuconfig WIFI_ENABLED
|
||||||
help
|
help
|
||||||
Select this option to enable WiFi stack and show the submenu with WiFi configuration choices.
|
Select this option to enable WiFi stack and show the submenu with WiFi configuration choices.
|
||||||
|
|
||||||
|
config ESP_MAC_OFFSET_WIFI_STA
|
||||||
|
int "MAC address offset value of WiFi station"
|
||||||
|
depends on WIFI_ENABLED
|
||||||
|
range 0 255
|
||||||
|
default 0
|
||||||
|
help
|
||||||
|
The offset value of WiFi station MAC address from the MAC address which is read from efuse.
|
||||||
|
This offset value must be different from that of WiFi softap, bluetooth and ethernet.
|
||||||
|
|
||||||
|
config ESP_MAC_OFFSET_WIFI_SOFTAP
|
||||||
|
int "MAC address offset value of WiFi softap"
|
||||||
|
depends on WIFI_ENABLED
|
||||||
|
range 0 255
|
||||||
|
default 1
|
||||||
|
help
|
||||||
|
The offset value of WiFi softap MAC address from the MAC address which is read from efuse.
|
||||||
|
This offset value must be different from that of WiFi station, bluetooth and ethernet.
|
||||||
|
|
||||||
config SW_COEXIST_ENABLE
|
config SW_COEXIST_ENABLE
|
||||||
bool "Software controls WiFi/Bluetooth coexistence"
|
bool "Software controls WiFi/Bluetooth coexistence"
|
||||||
depends on WIFI_ENABLED && BT_ENABLED
|
depends on WIFI_ENABLED && BT_ENABLED
|
||||||
|
|
|
@ -24,6 +24,13 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum {
|
||||||
|
ESP_MAC_WIFI_STA,
|
||||||
|
ESP_MAC_WIFI_SOFTAP,
|
||||||
|
ESP_MAC_BT,
|
||||||
|
ESP_MAC_ETH,
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @attention application don't need to call this function anymore. It do nothing and will
|
* @attention application don't need to call this function anymore. It do nothing and will
|
||||||
* be removed in future version.
|
* be removed in future version.
|
||||||
|
@ -115,6 +122,19 @@ esp_err_t esp_efuse_read_mac(uint8_t* mac);
|
||||||
*/
|
*/
|
||||||
esp_err_t system_efuse_read_mac(uint8_t mac[6]) __attribute__ ((deprecated));
|
esp_err_t system_efuse_read_mac(uint8_t mac[6]) __attribute__ ((deprecated));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Read hardware MAC address and set MAC address of the interface.
|
||||||
|
*
|
||||||
|
* This function first reads hardware MAC address from efuse. Then set the MAC address of the interface
|
||||||
|
* including wifi station, wifi softap, bluetooth and ethernet according to the offset value in menuconfig.
|
||||||
|
*
|
||||||
|
* @param mac MAC address of the interface, length: 6 bytes.
|
||||||
|
* @param interface interface, 0:wifi station, 1:wifi softap, 2:bluetooth, 3:ethernet.
|
||||||
|
*
|
||||||
|
* @return ESP_OK on success
|
||||||
|
*/
|
||||||
|
esp_err_t esp_read_mac(uint8_t* mac, int interface);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get SDK version
|
* Get SDK version
|
||||||
*
|
*
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 7b06303c0fa416aea7f86b7596e84db367189066
|
Subproject commit e22ec1a5140dca2bb44f9bfb3147911fa4ebb8fe
|
|
@ -12,6 +12,8 @@
|
||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_wifi.h"
|
#include "esp_wifi.h"
|
||||||
|
@ -72,6 +74,47 @@ esp_err_t esp_efuse_read_mac(uint8_t* mac)
|
||||||
|
|
||||||
esp_err_t system_efuse_read_mac(uint8_t mac[6]) __attribute__((alias("esp_efuse_read_mac")));
|
esp_err_t system_efuse_read_mac(uint8_t mac[6]) __attribute__((alias("esp_efuse_read_mac")));
|
||||||
|
|
||||||
|
esp_err_t esp_read_mac(uint8_t* mac, int interface)
|
||||||
|
{
|
||||||
|
uint8_t efuse_mac[6];
|
||||||
|
|
||||||
|
if (mac == NULL) {
|
||||||
|
ESP_LOGE(TAG, "mac address param is NULL");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_efuse_read_mac(efuse_mac);
|
||||||
|
|
||||||
|
switch (interface) {
|
||||||
|
#if CONFIG_WIFI_ENABLED
|
||||||
|
case ESP_MAC_WIFI_STA:
|
||||||
|
memcpy(mac, efuse_mac, 6);
|
||||||
|
mac[5] += CONFIG_ESP_MAC_OFFSET_WIFI_STA;
|
||||||
|
break;
|
||||||
|
case ESP_MAC_WIFI_SOFTAP:
|
||||||
|
memcpy(mac, efuse_mac, 6);
|
||||||
|
mac[5] += CONFIG_ESP_MAC_OFFSET_WIFI_SOFTAP;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#if CONFIG_BT_ENABLED
|
||||||
|
case ESP_MAC_BT:
|
||||||
|
memcpy(mac, efuse_mac, 6);
|
||||||
|
mac[5] += CONFIG_ESP_MAC_OFFSET_BT;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#if CONFIG_ETHERNET
|
||||||
|
case ESP_MAC_ETH:
|
||||||
|
memcpy(mac, efuse_mac, 6);
|
||||||
|
mac[5] += CONFIG_ESP_MAC_OFFSET_ETH;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default:
|
||||||
|
ESP_LOGW(TAG, "wrong mac type");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
void esp_restart_noos() __attribute__ ((noreturn));
|
void esp_restart_noos() __attribute__ ((noreturn));
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,15 @@ menuconfig ETHERNET
|
||||||
help
|
help
|
||||||
Select this option to enable ethernet driver and show the submenu with ethernet features.
|
Select this option to enable ethernet driver and show the submenu with ethernet features.
|
||||||
|
|
||||||
|
config ESP_MAC_OFFSET_ETH
|
||||||
|
int "MAC address offset value of ethernet"
|
||||||
|
depends on ETHERNET
|
||||||
|
range 0 255
|
||||||
|
default 3
|
||||||
|
help
|
||||||
|
The offset value of ethernet MAC address from the MAC address which is read from efuse.
|
||||||
|
This offset value must be different from that of WiFi softap, bluetooth and WiFi station.
|
||||||
|
|
||||||
config DMA_RX_BUF_NUM
|
config DMA_RX_BUF_NUM
|
||||||
int "Number of DMA RX buffers"
|
int "Number of DMA RX buffers"
|
||||||
range 3 20
|
range 3 20
|
||||||
|
|
|
@ -75,8 +75,7 @@ esp_err_t emac_post(emac_sig_t sig, emac_par_t par);
|
||||||
|
|
||||||
static void emac_macaddr_init(void)
|
static void emac_macaddr_init(void)
|
||||||
{
|
{
|
||||||
esp_efuse_read_mac(&(emac_config.macaddr[0]));
|
esp_read_mac(&(emac_config.macaddr[0]), ESP_MAC_ETH);
|
||||||
emac_config.macaddr[5] = emac_config.macaddr[5] + 3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void esp_eth_get_mac(uint8_t mac[6])
|
void esp_eth_get_mac(uint8_t mac[6])
|
||||||
|
|
Loading…
Reference in a new issue