esp32-ricoh-gr2/main/main.c
Morgan 'ARR\!' Allen 96b4267c2c init
2019-05-06 16:55:10 -07:00

43 lines
989 B
C

/*
* Copyright 2019 by Morgan Allen
*
* This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International
* https://creativecommons.org/licenses/by-nc/4.0/
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "driver/spi_master.h"
#include "esp_system.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "esp_http_client.h"
#define TAG "CACO"
static uint8_t id;
void app_main() {
esp_err_t ret;
// Initialize NVS.
ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
ESP_LOGI(TAG, "Erasing flash memory");
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK( ret );
uint8_t *mac;
mac = (uint8_t *)malloc(6);
esp_efuse_mac_get_default(mac);
id = mac[5];
ESP_LOGI(TAG, "MAC: %X:%X:%X:%X:%X:%X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
};