feat: added get mac address

This commit is contained in:
Alexey Zholtikov 2025-05-06 11:32:11 +03:00
parent 1391c9b3c1
commit 0f35e48fe5
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");
send_message.float_value = 1.234;
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());
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;
for (;;)
{

View File

@ -171,13 +171,22 @@ extern "C"
* @brief Set battery mode.
*
* @param[in] battery_mode True to enable the mode false to disable it.
*
*
* @note If true the node does not receive messages.
*
* @return ESP_OK if success or an error code otherwise.
*/
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
}
#endif

View File

@ -1 +1 @@
1.6.0
1.7.0

View File

@ -592,4 +592,9 @@ esp_err_t zh_espnow_set_battery_mode(bool battery_mode)
_init_config.battery_mode = battery_mode;
ZH_ESPNOW_LOGI("Battery mode set successfully.");
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);
}