Moving into components parts of the provider project

This commit is contained in:
2026-03-26 20:36:27 -04:00
parent cfe19d5e65
commit f483a4d292
12 changed files with 48 additions and 30 deletions
+3
View File
@@ -0,0 +1,3 @@
idf_component_register(SRCS "led.cpp"
INCLUDE_DIRS "." "../shared"
PRIV_REQUIRES led_strip)
View File
+79
View File
@@ -0,0 +1,79 @@
// Project includes
#include "led.hpp"
// SDK Includes
#include "led_strip.h"
// Could be a config but its the GPIO on my ESP32-S3-ETH
#define LED_GPIO GPIO_NUM_21
internal led_strip_handle_t led_strip;
void setup_led(void)
{
/* LED strip initialization with the GPIO and pixels number*/
led_strip_config_t strip_config = {};
strip_config.strip_gpio_num = LED_GPIO;
strip_config.max_leds = 1; // at least one LED on board
led_strip_rmt_config_t rmt_config = {};
rmt_config.resolution_hz = 10 * 1000 * 1000; // 10MHz
rmt_config.flags.with_dma = false;
ESP_ERROR_CHECK(
led_strip_new_rmt_device(&strip_config, &rmt_config, &led_strip));
led_strip_clear(led_strip);
}
void turn_off_led(void) { led_strip_clear(led_strip); }
void set_led_status(led_status status)
{
switch (status)
{
case led_status::ConnectingEthernet:
led_strip_set_pixel(led_strip, 0, 255, 165, 0);
break;
case led_status::ConnectingWifi:
led_strip_set_pixel(led_strip, 0, 148, 0, 211);
break;
case led_status::ReadyEthernet:
led_strip_set_pixel(led_strip, 0, 0, 255, 0); // Green
break;
case led_status::ReadyWifi:
led_strip_set_pixel(led_strip, 0, 0, 0, 255); // Blue
break;
case led_status::Failed:
led_strip_set_pixel(led_strip, 0, 255, 0, 0);
break;
}
led_strip_refresh(led_strip);
}
void led_blink_number(int n, uint8_t r, uint8_t g, uint8_t b)
{
if (n <= 0)
{
for (int i = 0; i < 2; i++)
{
led_strip_set_pixel(led_strip, 0, r, g, b);
led_strip_refresh(led_strip);
vTaskDelay(pdMS_TO_TICKS(50));
led_strip_clear(led_strip);
led_strip_refresh(led_strip);
vTaskDelay(pdMS_TO_TICKS(50));
}
vTaskDelay(pdMS_TO_TICKS(1000));
return;
}
for (int i = 0; i < n; i++)
{
led_strip_set_pixel(led_strip, 0, r, g, b);
led_strip_refresh(led_strip);
vTaskDelay(pdMS_TO_TICKS(300));
led_strip_clear(led_strip);
led_strip_refresh(led_strip);
vTaskDelay(pdMS_TO_TICKS(300));
}
vTaskDelay(pdMS_TO_TICKS(1000));
}
+18
View File
@@ -0,0 +1,18 @@
#pragma once
// Project includes
#include "types.hpp"
enum class led_status : uint8
{
ConnectingEthernet,
ConnectingWifi,
ReadyEthernet,
ReadyWifi,
Failed
};
void setup_led(void);
void turn_off_led(void);
void set_led_status(led_status status);
void led_blink_number(int n, uint8_t r, uint8_t g, uint8_t b);
+1 -1
View File
@@ -1,3 +1,3 @@
idf_component_register(SRCS "network.cpp"
INCLUDE_DIRS "."
INCLUDE_DIRS "." "../shared"
PRIV_REQUIRES esp_eth esp_wifi esp_netif driver)
+2 -4
View File
@@ -16,13 +16,11 @@
#include "freertos/semphr.h"
#include "freertos/timers.h"
#include "types.hpp"
// Project includes
#include "network.hpp"
#ifndef internal
#define internal static
#endif
// Forward declarations
#if CONFIG_CALENDINK_BLINK_IP
internal esp_err_t get_ip_info(esp_netif_ip_info_t *ip_info);
+2 -1
View File
@@ -1,8 +1,9 @@
#pragma once
#include "esp_err.h"
#include <cstdint>
#include "esp_err.h"
esp_err_t connect_ethernet(bool blockUntilIPAcquired);
void disconnect_ethernet();
esp_err_t check_ethernet_connection(uint32_t timeoutSeconds);
+15
View File
@@ -0,0 +1,15 @@
#pragma once
#include <cstdint>
using uint8 = uint8_t;
using uint16 = uint16_t;
using uint32 = uint32_t;
using uint64 = uint64_t;
using int8 = int8_t;
using int16 = int16_t;
using int32 = int32_t;
using int64 = int64_t;
#define internal static