From fa4ceb6173a4f2e7058b3725cd5d0a6ce90e4d01 Mon Sep 17 00:00:00 2001 From: "Morgan 'ARR\\!' Allen" Date: Thu, 28 Dec 2023 18:57:12 -0800 Subject: [PATCH] init --- CMakeLists.txt | 6 ++++++ main/CMakeLists.txt | 2 ++ main/main.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 main/CMakeLists.txt create mode 100644 main/main.c diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..bd37503 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,6 @@ +# The following lines of boilerplate have to be in your project's CMakeLists +# in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.16) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(coatt) diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt new file mode 100644 index 0000000..cf2c455 --- /dev/null +++ b/main/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "main.c" + INCLUDE_DIRS ".") diff --git a/main/main.c b/main/main.c new file mode 100644 index 0000000..9abb095 --- /dev/null +++ b/main/main.c @@ -0,0 +1,28 @@ +#include "esp_mac.h" +#include "esp_wifi.h" + +#include "nvs_flash.h" + +#include "esp_netif_now.h" + +void app_main() { + esp_netif_now_config_t config; + + esp_efuse_mac_get_default((uint8_t*)&config.mac); + + ESP_ERROR_CHECK(nvs_flash_init()); + ESP_ERROR_CHECK(esp_netif_init()); + ESP_ERROR_CHECK(esp_event_loop_create_default()); + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + ESP_ERROR_CHECK(esp_wifi_init(&cfg)); + ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); + ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA)); + ESP_ERROR_CHECK(esp_wifi_start()); + ESP_ERROR_CHECK(esp_wifi_set_channel(1, WIFI_SECOND_CHAN_NONE)); + + esp_netif_set_ip4_addr(&config.ip_info.ip, 10, 10 , 0, config.mac[5]); + esp_netif_set_ip4_addr(&config.ip_info.gw, 10, 10 , 0, 1); + esp_netif_set_ip4_addr(&config.ip_info.netmask, 255, 255 , 255, 0); + + esp_netif_now_init(&config); +}