changed folder structure
used advices from https://docs.espressif.com/projects/esp-idf/en/v5.2.1/esp32/api-guides/build-system.html Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -6,3 +6,5 @@ cmake_minimum_required(VERSION 3.16)
|
|||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
project(firmware_thomas_the_tank_engine)
|
project(firmware_thomas_the_tank_engine)
|
||||||
|
|
||||||
|
# idf_build_set_property(COMPILE_OPTIONS "-Wno-error" APPEND)
|
||||||
|
3
components/ble/CMakeLists.txt
Normal file
3
components/ble/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(SRCS "osr_ble.c"
|
||||||
|
INCLUDE_DIRS "."
|
||||||
|
REQUIRES "nvs_flash")
|
20
components/ble/osr_ble.c
Normal file
20
components/ble/osr_ble.c
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#include "osr_ble.h"
|
||||||
|
|
||||||
|
#include <nvs.h>
|
||||||
|
#include <nvs_flash.h>
|
||||||
|
|
||||||
|
void nvs_init()
|
||||||
|
{
|
||||||
|
esp_err_t ret = nvs_flash_init();
|
||||||
|
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
|
||||||
|
{
|
||||||
|
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||||
|
ret = nvs_flash_init();
|
||||||
|
}
|
||||||
|
ESP_ERROR_CHECK(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void osr_ble_init()
|
||||||
|
{
|
||||||
|
nvs_init();
|
||||||
|
}
|
3
components/ble/osr_ble.h
Normal file
3
components/ble/osr_ble.h
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
void osr_ble_init();
|
15
main/main.c
15
main/main.c
@@ -1,22 +1,11 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <esp_task_wdt.h>
|
#include <esp_task_wdt.h>
|
||||||
#include <nvs.h>
|
|
||||||
#include <nvs_flash.h>
|
|
||||||
|
|
||||||
void nvs_init()
|
#include "osr_ble.h"
|
||||||
{
|
|
||||||
esp_err_t ret = nvs_flash_init();
|
|
||||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
|
|
||||||
{
|
|
||||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
|
||||||
ret = nvs_flash_init();
|
|
||||||
}
|
|
||||||
ESP_ERROR_CHECK(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
nvs_init();
|
osr_ble_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
Reference in New Issue
Block a user