feat: added get mac address

This commit is contained in:
Alexey Zholtikov 2025-05-06 11:32:11 +03:00
parent 1391c9b3c1
commit 6e508c49b0
4 changed files with 20 additions and 3 deletions

View File

@ -86,8 +86,11 @@ void app_main(void)
strcpy(send_message.char_value, "THIS IS A CHAR"); strcpy(send_message.char_value, "THIS IS A CHAR");
send_message.float_value = 1.234; send_message.float_value = 1.234;
send_message.bool_value = false; send_message.bool_value = false;
printf("Used ESP-NOW version %d.\n", zh_espnow_get_version()); printf("ESP-NOW version %d.\n", zh_espnow_get_version());
printf("ESP-NOW channel %d. \n", zh_espnow_get_channel()); printf("ESP-NOW channel %d. \n", zh_espnow_get_channel());
uint8_t node_mac[6] = {0};
zh_espnow_get_mac(node_mac);
printf("ESP-NOW MAC %02X:%02X:%02X:%02X:%02X:%02X.\n", MAC2STR(node_mac));
uint8_t counter = 0; uint8_t counter = 0;
for (;;) for (;;)
{ {

View File

@ -178,6 +178,15 @@ extern "C"
*/ */
esp_err_t zh_espnow_set_battery_mode(bool battery_mode); esp_err_t zh_espnow_set_battery_mode(bool battery_mode);
/**
* @brief Get MAC address of the node.
*
* @param[out] mac_addr Pointer to a buffer containing an eight-byte MAC.
*
* @return ESP_OK if success or an error code otherwise.
*/
esp_err_t zh_espnow_get_mac(uint8_t *mac_addr);
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1 +1 @@
1.6.0 1.7.0

View File

@ -593,3 +593,8 @@ esp_err_t zh_espnow_set_battery_mode(bool battery_mode)
ZH_ESPNOW_LOGI("Battery mode set successfully."); ZH_ESPNOW_LOGI("Battery mode set successfully.");
return ESP_OK; return ESP_OK;
} }
esp_err_t zh_espnow_get_mac(uint8_t *mac_addr)
{
return esp_wifi_get_mac(_init_config.wifi_interface, mac_addr);
}