标签:Use set ESP32 MAC How mac address query
You can to
set
andquery
the MAC address of ESP32 in various ways. As follows:
1 Use the AT commands
to set
and query
the MAC address of the ESP32 device
1.1 Use the AT command to set
and query
the MAC
address of the Wi-Fi Station
mode
- Use the
AT+CIPSTAMAC="22:33:44:55:66:77"
command toset
the MAC address of the Wi-Fi Station mode. - Use the
AT+CIPSTAMAC?
command toquery
the MAC address of the Wi-Fi Station mode.
1.2 Use the AT command to set
and query
the MAC
address of the Wi-Fi SoftAP
mode
- Use the
AT+CIPAPMAC="22:33:44:55:66:77"
command toset
the MAC address of the Wi-Fi SoftAP mode. - Use the
AT+CIPAPMAC?
command toquery
the MAC address of the Wi-Fi SoftAP mode.
1.3 Use the AT command to set
and query
the MAC
address of Ethernet
- Use the
AT+CIPETHMAC="1a:fe:35:98:d4:7b"
command toset
the MAC address of the Ethernet. - Use the
AT+CIPETHMAC?
command toquery
the MAC address of the Ethernet.
1.4 Use the AT command to set
and query
the MAC
address of BLE (BT) mode
- **Use the
AT+BLEADDR=1,"f8:7f:24:87:1c:7b"
command toset
the MAC address of the BLE (BT) mode ** - Use the
AT+BLEADDR?
command toquery
the MAC address of the BLE(BT) mode.
1.5 Use the AT command to query
the MAC
address of the ESP32 device in current mode
The MAC address in current mode can be queried only after the ESP32 obtains the valid interface information .
- Use the
AT+CIFSR
command toquery
the MAC address of the ESP32 device in current mode.
2 Use the esptool to set
and query
the MAC
address of the ESP32 device
You can run the
espefuse.py --h
command to query the usage of related commands firstly. As follows:
2.1 Use the esptool to query
the default MAC
address written into the EFUSE BLOCK0
before the ESP32 device is delivered.
- Use the
espefuse.py summary
toquery
the defaultMAC
address written into theEFUSE BLOCK0
before the ESP32 device is delivered. As follows:
- The default MAC address in
EFUSE BLOCK0
isbase_mac
. The defaultbase_mac
is the MAC address of theWi-Fi Station
mode. You can obtain the MAC address of theWi-Fi SoftAP
mode,Bluetooth
mode, andEthernet
based on the MAC address of the Wi-Fi Station mode. Please refer to the " MAC Address " instructions. As follows:
2.2 Use the esptool to set a Custom MAC
address in EFUSE BLOCK3
- Use the
espefuse.py burn_custom_mac 12:22:33:44:55:66
command to set aCustom MAC
address inEFUSE BLOCK3
. As follows:
Note: The
Bit 1
cannot be1
inEFUSE BLOCK3
2.3 Use the esptool to query the Custom MAC
address in EFUSE BLOCK3
- Use the
espefuse.py get_custom_mac
command to query theCustom MAC
address inEFUSE BLOCK3
. As follows:
- Or use the
espefuse.py summary
command can also query theCustom MAC
address inEFUSE BLOCK3
. As follows:
3 Use the related APIs
to set
and query
the MAC
address of the ESP32 device
-
Use the esp_base_mac_addr_set(uint8_t *mac); API to set a
Custom MAC
address inEFUSE BLOCK3
asbase_mac
. Thisbase_mac
default is the MAC address ofWi-Fi Station
mode. For example:“ esp_base_mac_addr_set(12:22:33:44:55:FF)“,
-
The MAC addresses of other modes are as follows:
> STA(FF) > AP(FF + 1 -> 01) > BT(FF + 2 -> 02) > ETH(FF + 3 -> 03)`(not-carry)`
Please refer to the " MAC Address " instructions. As follows:
-
Therefore:
"esp_wifi_set_mac(ESP_IF_WIFI_STA, 12:22:33:44:55:FF)" "esp_wifi_set_mac(ESP_IF_WIFI_AP, 12:22:33:44:55:01)"
-
Use the esp_efuse_mac_get_custom(uint8_t *mac) API to
query
theCustom MAC
address inEFUSE BLOCK3
. -
Use the esp_base_mac_addr_get(uint8_t *mac) API to
query
thebase_mac
of the ESP32 device. If no Custom Base MAC has been set, this will returns the defaultMAC
address written into theEFUSE BLOCK0
before the ESP32 device is delivered(base_mac). -
Use the esp_read_mac(uint8_t *mac, esp_mac_type_t type) API first
query
thebase_mac
address using esp_base_mac_addr_get(uint8_t *mac) . -
Use the esp_efuse_mac_get_default(uint8_t *mac) to
query
the defaultMAC
address written into theEFUSE BLOCK0
before the ESP32 device is delivered.Note:Use the esp_efuse_mac_get_default(uint8_t *mac) to
query
the defaultMAC
address written into theEFUSE BLOCK0
before the ESP32 device is delivered is a unique MAC address in the world.
4 使用 NVS 写入 MAC 地址
4 Write MAC addresses using NVS
- Build a specific NVS partition table to write MAC addresses
- Then use the “ nvs_get_str(nvs_handle_thandle,const char * key,char * out_value,size_t * length)” function to read the specific NVS partition table to get the MAC address written to a specific NVS partition table.
- Please refer to the “NVS Partition Generator Utility” to learn the application of NVS.
【MAC Address】
- By scanning the
QR code
on the ESP32 module, we can also get the default "base_mac
" address written into theEFUSE BLOCK0
before the ESP32 device is delivered . - The default
base_mac
address written into theEFUSE BLOCK0
before the ESP32 device is delivered is theMAC
address ofWi-Fi Station
mode. The "base_mac, +1
to the last octet " is theMAC
address ofWi-Fi SoftAP
mode. The "base_mac, +2
to the last octet " is theMAC
address ofBLE(BT)
mode. The "base_mac, +3
to the last octet " is theMAC
address ofEthernet
. - The default
MAC
address written into theEFUSE BLOCK0
before the ESP32 device is delivered isa unique MAC address in the world
, and each batch is different.
标签:Use,set,ESP32,MAC,How,mac,address,query 来源: https://blog.csdn.net/Marchtwentytwo/article/details/122785048
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。