From 96b4267c2ccbb8d2959350ddb2178994f89d0bdc Mon Sep 17 00:00:00 2001 From: "Morgan 'ARR\\!' Allen" Date: Mon, 6 May 2019 16:55:10 -0700 Subject: [PATCH] init --- Makefile | 8 ++++++++ main/main.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 Makefile create mode 100644 main/main.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..09365de --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +# +# This is a project Makefile. It is assumed the directory this Makefile resides in is a +# project subdirectory. +# + +PROJECT_NAME := grii + +include $(IDF_PATH)/make/project.mk diff --git a/main/main.c b/main/main.c new file mode 100644 index 0000000..88e94ca --- /dev/null +++ b/main/main.c @@ -0,0 +1,43 @@ +/* + * 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 +#include +#include +#include +#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]); +};