commit 2bda6eff6cc73d5f716528c6d9a8de1f4735052f Author: drath Date: Tue May 5 23:59:17 2026 +0200 first commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..7fdb06b --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# Network component for ESP-IDF + +because copying it over and over was a pain + +## TODO +- needs timezone var for sntp +- still doesnt work with hidden ssids, need2fix + +### How use + +quite simply + +```c++ +#include +#include + + +static const wifi_networks_t known_networks = { + .nets = { + {"DAA+", "password"}, + {"DAA", "password"}, + }, + .num_nets = 2 +}; + +void app_main(void) { + esp_event_loop_create_default(); + init_wifi(&known_networks, "piec_monitor"); +} +``` + +V important to call `esp_event_loop_create_default();`, then you can just use callbacks from related modules when IP get, ie. + +```c++ +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 +```c++ +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 `` you can write and register a callback to anything you need to.