Squashed commit of the following:
commite8b53dc953Author: Patedam <pgillen.pro@gmail.com> Date: Tue Mar 3 01:15:17 2026 -0500 Updated backend to make sure it works properly with frontend. Fixed one frontend issue (free heap was not correctly named) commit3428808f83Author: Patedam <pgillen.pro@gmail.com> Date: Tue Mar 3 00:36:01 2026 -0500 Fixing various build errors. Activated minimal build commit59364ac22dAuthor: Patedam <pgillen.pro@gmail.com> Date: Tue Mar 3 00:03:24 2026 -0500 Added info and reboot api into the backend. Created the basics for a backend server. commit37291557ebAuthor: Patedam <pgillen.pro@gmail.com> Date: Mon Mar 2 23:05:10 2026 -0500 feat: Add API endpoints for system reboot and retrieving system information. commita010b0c352Author: Patedam <pgillen.pro@gmail.com> Date: Mon Mar 2 22:56:13 2026 -0500 Added AgentTasks into git ignore we will use it to store current tasks so we can createnew contexts chat when its too big commit75bab78137Author: Patedam <pgillen.pro@gmail.com> Date: Mon Mar 2 22:42:29 2026 -0500 feat: Initialize ESP-IDF project with core build configuration, component dependencies, and web frontend deployment. commitbba4c63f93Author: Patedam <pgillen.pro@gmail.com> Date: Mon Mar 2 22:21:52 2026 -0500 docs: Add backend architecture documentation for the ESP32-S3 provider.
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
// SDK
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_log.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
@@ -10,26 +9,32 @@
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/gpio_num.h"
|
||||
|
||||
// Project cpp
|
||||
#include "connect.cpp"
|
||||
#include "led_status.cpp"
|
||||
// Project headers
|
||||
#include "appstate.hpp"
|
||||
#include "types.hpp"
|
||||
|
||||
// TODO : Make it configurable
|
||||
internal constexpr bool blockUntilEthernetEstablished = false;
|
||||
internal bool ethernetInitialized = false;
|
||||
internal bool wifiInitialized = false;
|
||||
// Project cpp (Unity Build entry)
|
||||
// clang-format off
|
||||
#include "connect.cpp"
|
||||
#include "http_server.cpp"
|
||||
#include "led_status.cpp"
|
||||
// clang-format on
|
||||
|
||||
internal constexpr bool kBlockUntilEthernetEstablished = false;
|
||||
|
||||
extern "C" void app_main() {
|
||||
printf("Hello, Worldi!\n");
|
||||
|
||||
httpd_handle_t web_server = NULL;
|
||||
|
||||
ESP_ERROR_CHECK(nvs_flash_init());
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
|
||||
setup_led();
|
||||
|
||||
set_led_status(led_status::ConnectingEthernet);
|
||||
ethernetInitialized = true;
|
||||
esp_err_t result = connect_ethernet(blockUntilEthernetEstablished);
|
||||
g_Ethernet_Initialized = true;
|
||||
esp_err_t result = connect_ethernet(kBlockUntilEthernetEstablished);
|
||||
if (result != ESP_OK) {
|
||||
set_led_status(led_status::Failed);
|
||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||
@@ -37,7 +42,7 @@ extern "C" void app_main() {
|
||||
}
|
||||
|
||||
// Check for ethernet connection until its made
|
||||
if (!blockUntilEthernetEstablished) {
|
||||
if (!kBlockUntilEthernetEstablished) {
|
||||
uint8 retries = 1;
|
||||
do {
|
||||
set_led_status(led_status::ConnectingEthernet);
|
||||
@@ -56,20 +61,20 @@ extern "C" void app_main() {
|
||||
if (result != ESP_OK) {
|
||||
printf("Ethernet failed, trying wifi\n");
|
||||
disconnect_ethernet();
|
||||
ethernetInitialized = false;
|
||||
g_Ethernet_Initialized = false;
|
||||
|
||||
set_led_status(led_status::ConnectingWifi);
|
||||
wifiInitialized = true;
|
||||
g_Wifi_Initialized = true;
|
||||
result =
|
||||
connect_wifi(CONFIG_CALENDINK_WIFI_SSID, CONFIG_CALENDINK_WIFI_PASSWORD,
|
||||
blockUntilEthernetEstablished);
|
||||
kBlockUntilEthernetEstablished);
|
||||
if (result != ESP_OK) {
|
||||
set_led_status(led_status::Failed);
|
||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||
goto shutdown;
|
||||
}
|
||||
|
||||
if (!blockUntilEthernetEstablished) {
|
||||
if (!kBlockUntilEthernetEstablished) {
|
||||
uint8 retries = 1;
|
||||
do {
|
||||
set_led_status(led_status::ConnectingWifi);
|
||||
@@ -98,20 +103,30 @@ extern "C" void app_main() {
|
||||
}
|
||||
|
||||
printf("Connected!\n");
|
||||
vTaskDelay(pdMS_TO_TICKS(5000));
|
||||
|
||||
// TODO Main loop
|
||||
// Start the webserver
|
||||
web_server = start_webserver();
|
||||
|
||||
// Keep the main task alive indefinitely
|
||||
while (true) {
|
||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||
}
|
||||
|
||||
shutdown:
|
||||
printf("Shutting down.\n");
|
||||
|
||||
if (ethernetInitialized) {
|
||||
disconnect_ethernet();
|
||||
ethernetInitialized = false;
|
||||
if (web_server) {
|
||||
stop_webserver(web_server);
|
||||
web_server = NULL;
|
||||
}
|
||||
if (wifiInitialized) {
|
||||
|
||||
if (g_Ethernet_Initialized) {
|
||||
disconnect_ethernet();
|
||||
g_Ethernet_Initialized = false;
|
||||
}
|
||||
if (g_Wifi_Initialized) {
|
||||
disconnect_wifi();
|
||||
wifiInitialized = false;
|
||||
g_Wifi_Initialized = false;
|
||||
}
|
||||
|
||||
destroy_led();
|
||||
|
||||
Reference in New Issue
Block a user