diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..60d6b0d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "src/jannex.c" "src/ota.c" + INCLUDE_DIRS "include") \ No newline at end of file diff --git a/Kconfig.projbuild b/Kconfig.projbuild new file mode 100644 index 0000000..67606cc --- /dev/null +++ b/Kconfig.projbuild @@ -0,0 +1,71 @@ +menu "Jannex Configuration" + + config ESP_WIFI_SSID + string "WiFi SSID" + default "myssid" + help + SSID (network name) for the example to connect to. + + config ESP_WIFI_PASSWORD + string "WiFi Password" + default "mypassword" + help + WiFi password (WPA or WPA2) for the example to use. + + config ESP_WIFI_AP + bool "Create AP when no Wifi values are entered" + default n + help + Create AP when no Wifi values are entered. + + config ESP_OTA_SERVER + string "OTA Server domain" + default "" + help + Enter the URL + + choice FIRMWARE_BRANCH + prompt "Select branch" + default SELECTION_MASTER + help + Choose default branch. + + config SELECTION_MASTER + bool "master" + + config SELECTION_BETA + bool "beta" + + config SELECTION_STABLE + bool "stable" + + config SELECTION_PRODUCTION + bool "production" + + config SELECTION_CUSTOM + bool "Enter custom branch" + + endchoice + + config FIRMWARE_BRANCH_CUSTOM + string "Enter branch name" + depends on SELECTION_CUSTOM + help + Enter custom branch + + config FIRMWARE_UPDATE_SCAN + default 10 + bool "Scan interval for updates" + help + Scans the ota server for new updates. + + config FIRMWARE_UPDATE_SCAN_SECONDS + default 10 + int "Scan interval for updates (in Seconds)" + depends on FIRMWARE_UPDATE_SCAN + help + Enter 0 to disable + + + +endmenu diff --git a/idf_component.yml b/idf_component.yml new file mode 100644 index 0000000..d1fbca6 --- /dev/null +++ b/idf_component.yml @@ -0,0 +1,2 @@ +version: '0.0.1' +description: 'This is a test component' diff --git a/include/jannex.h b/include/jannex.h new file mode 100644 index 0000000..ff9ee39 --- /dev/null +++ b/include/jannex.h @@ -0,0 +1,15 @@ +#pragma once + +#include "esp_system.h" + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +#ifndef CONFIG_ESP_WIFI_SSID +#error "WIFI SSID is not defined!" +#endif + +static const char *jannexTAG = "JANNEX"; + +void initJannex(); +void updateJannex(); \ No newline at end of file diff --git a/include/ota.h b/include/ota.h new file mode 100644 index 0000000..602ce7f --- /dev/null +++ b/include/ota.h @@ -0,0 +1 @@ +void checkForUpdatesAndInstall(void *parameter); \ No newline at end of file diff --git a/src/jannex.c b/src/jannex.c new file mode 100644 index 0000000..125a836 --- /dev/null +++ b/src/jannex.c @@ -0,0 +1,20 @@ +#include "jannex.h" + +#include "ota.h" + +#include +#include "esp_log.h" + +#include +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" + +void initJannex() +{ + ESP_LOGI(jannexTAG, "LUL"); +} + +void updateJannex() +{ + xTaskCreate(&checkForUpdatesAndInstall, "checkForUpdatesAndInstall", configMINIMAL_STACK_SIZE, NULL, 5, NULL); +} \ No newline at end of file diff --git a/src/ota.c b/src/ota.c new file mode 100644 index 0000000..c5c40f3 --- /dev/null +++ b/src/ota.c @@ -0,0 +1,20 @@ +#include "jannex.h" + +void checkForUpdatesAndInstall(void *parameter) +{ + while (1) + { + printf("Task is running\n"); + +#ifdef CONFIG_FIRMWARE_UPDATE_SCAN_SECONDS + if (CONFIG_FIRMWARE_UPDATE_SCAN_SECONDS >= 1) + { + vTaskDelay(pdMS_TO_TICKS(CONFIG_FIRMWARE_UPDATE_SCAN_SECONDS * 1000)); // Delay for 1000 milliseconds + } + else +#endif + { + vTaskDelete(NULL); + } + } +}