esp32 obtiene la dirección mac bluetooth y la dirección mac wifi

dirección mac bluetooth 

#include "esp_bt_device.h"
const uint8_t *bleAddr = esp_bt_dev_get_address(); //查询蓝牙的mac地址,务必要在蓝牙初始化后方可调用!
printf("蓝牙mac地址: %02x:%02x:%02x:%02x:%02x:%02x\n", bleAddr[0], bleAddr[1], bleAddr[2], bleAddr[3], bleAddr[4], bleAddr[5]);

dirección wifi mac

//获取mac b8:d6:1a:5c:08:68
uint8_t macAddr[6]; // 定义macAddr为uint8_t类型的数组,这个数组含有6个元素。
esp_wifi_get_mac(WIFI_IF_STA,macAddr);  //MAC地址会储存在这个macAddr数组里面
printf("用转存到数组的方式获取MAC地址: %02x:%02x:%02x:%02x:%02x:%02x\n", macAddr[0], macAddr[1], macAddr[2], macAddr[3], macAddr[4], macAddr[5]);

Supongo que te gusta

Origin blog.csdn.net/weixin_41012767/article/details/128748978
Recomendado
Clasificación