Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "esp_system.h"
- #include "esp_spi_flash.h"
- #include "driver/gpio.h"
- char *get_device_id()
- {
- uint8_t mac_addr[6];
- char *id = (char*)malloc((sizeof(char)*(6*2))+1);
- if (id == NULL) return NULL;
- esp_read_mac(mac_addr, ESP_MAC_WIFI_STA);
- for (int i=0; i<6; i++) {
- snprintf(id+(i*2), 3, "%02X", mac_addr[i]);
- }
- return id;
- }
- void app_main()
- {
- printf("Program: Unikatny identifikator cipu ESP8266\n");
- char *uuid = get_device_id();
- printf("UUID: %s \n", uuid);
- free(uuid);
- while (1) {
- vTaskDelay(1000 / portTICK_PERIOD_MS);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement