Transfer data

This commit is contained in:
Florian Hoss 2022-07-29 10:27:39 +02:00
parent cac6d98908
commit c43dd6121a
27 changed files with 3237 additions and 0 deletions

View file

@ -0,0 +1,6 @@
# This file was automatically generated for projects
# without default 'CMakeLists.txt' file.
FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*)
idf_component_register(SRCS ${app_sources})

72
esp32example/src/main.cpp Normal file
View file

@ -0,0 +1,72 @@
#include "Arduino.h"
#include "theSecrets.h"
#include "WiFi.h"
#include "lwip_hooks.h"
#include "esp32/Firewall.hpp"
#include "esp32/API.hpp"
fw::Firewall *firewall;
fw::API *firewallApi;
int lwip_hook_ip4_input(struct pbuf *pbuf, struct netif *input_netif)
{
// Firewall is not setup yet
if (firewall != NULL)
{
if (firewall->is_packet_allowed(pbuf))
return 0;
else
{
pbuf_free(pbuf);
return 1;
}
}
return 0;
}
void initFirewall(const String ip)
{
firewall = new fw::Firewall();
firewallApi = new fw::API(firewall, username, password, ip);
}
void handle_wifi_events(WiFiEvent_t event, WiFiEventInfo_t info)
{
switch (event)
{
case ARDUINO_EVENT_WIFI_STA_START:
Serial.println("[WiFi] connecting...");
break;
case ARDUINO_EVENT_WIFI_STA_CONNECTED:
Serial.println("[WiFi] connected");
break;
case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
Serial.println("[WiFi] disconnected");
WiFi.reconnect();
break;
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
initFirewall(WiFi.localIP().toString());
break;
default:
Serial.print("[WiFi] other event: ");
Serial.println(event);
}
}
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.onEvent(handle_wifi_events, ARDUINO_EVENT_MAX);
WiFi.begin(ssid, psk);
// fix for https://github.com/espressif/arduino-esp32/issues/4732
WiFi.config(((u32_t)0x0UL), ((u32_t)0x0UL), ((u32_t)0x0UL));
}
void loop()
{
// https://docs.espressif.com/projects/arduino-esp32/en/latest/esp-idf_component.html
sleep(1);
}