2026-08-27 13:28:27 +02:00
2026-08-27 13:28:27 +02:00
ver
2026-06-19 15:03:26 +02:00
2026-08-07 15:27:39 +02:00
2026-06-19 13:26:33 +02:00
2026-06-19 13:34:01 +02:00

Network component for ESP-IDF

Generic network component for esp-idf v6.0, because copying it over and over was a pain

How use

quite simply add it to ur idf-component.yml

  esp-network:
    git: git@git.drath.cc:drath/esp-network.git

and then in C

#include <network.h>
#include <esp_event.h>

static const struct wifi_networks_t known_networks = {
	.nets = {
		{"DAA+", "password", true},
		{"DAA", "password", false},
	},
	.num_nets = 2
};


void app_main(void) {
    esp_event_loop_create_default();
    init_wifi(&known_networks, "piec_monitor");
    // or
    init_ethernet("pmbus_monitor");
    // NEVER BOTH
} 

V important to call esp_event_loop_create_default();, then you can just use callbacks from related modules when IP get, ie.

void on_get_ip(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) {
    const ip_event_got_ip_t* event = (ip_event_got_ip_t*)event_data;
    ESP_LOGI(TAG, "ip getto: " IPSTR, IP2STR(&event->ip_info.ip));
    /* do further shit */
}

just register the callback before with

esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &on_get_ip, nullptr);

Event loop is global so as long as you include <esp_event.h> you can write and register a callback to anything you need to. You might also need <esp_netif.h>

Description
No description provided
Readme 46 KiB
Languages
C 93.1%
CMake 6.9%