Basic setup with hook and arduino for esp32

This commit is contained in:
Florian Hoss 2022-07-26 08:37:03 +02:00
parent 8c36882772
commit bb999311a7
9 changed files with 2812 additions and 0 deletions

3
ESP32Firewall/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
.pio
.vscode
include/theSecrets.h

View file

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 3.16.0)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(ESP32Firewall)

View file

@ -0,0 +1,20 @@
#ifndef _LWIP_HOOKS_H_
#define _LWIP_HOOKS_H_
#include "lwip/netif.h"
#include "lwip/pbuf.h"
#include "lwip/ip4.h"
#ifdef __cplusplus
extern "C"
{
#endif
int lwip_hook_ip4_input(struct pbuf *pbuf, struct netif *input_netif);
#define LWIP_HOOK_IP4_INPUT lwip_hook_ip4_input
#ifdef __cplusplus
}
#endif
#endif /* _LWIP_HOOKS_H_ */

View file

@ -0,0 +1,9 @@
#ifndef _THE_SECRETS_H_
#define _THE_SECRETS_H_
const char *ssid = "Wifi";
const char *psk = "password";
const char *username = "username";
const char *password = "password";
#endif

View file

@ -0,0 +1,18 @@
; PlatformIO Project Configuration File
;
; Build options: build flags, source filter
; Upload options: custom upload port, speed and extra flags
; Library options: dependencies, extra library storages
; Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html
[env:az-delivery-devkit-v4]
platform = espressif32
board = az-delivery-devkit-v4
framework = espidf
monitor_speed = 115200
build_flags =
'-Iinclude'
'-DESP_IDF_LWIP_HOOK_FILENAME="lwip_hooks.h"'

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

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})

View file

@ -0,0 +1,38 @@
#include "Arduino.h"
#include "theSecrets.h"
#include "WiFi.h"
#include "lwip_hooks.h"
int lwip_hook_ip4_input(struct pbuf *pbuf, struct netif *input_netif)
{
const struct ip_hdr *iphdr;
char ip_address[IP_HLEN];
iphdr = (struct ip_hdr *)pbuf->payload;
sprintf(ip_address, "%d.%d.%d.%d", ip4_addr1_16_val(iphdr->src), ip4_addr2_16_val(iphdr->src), ip4_addr3_16_val(iphdr->src), ip4_addr4_16_val(iphdr->src));
Serial.print((u16_t)IPH_PROTO(iphdr));
Serial.print(": ");
Serial.println(ip_address);
return 0;
}
void setup()
{
Serial.begin(115200);
Serial.println();
WiFi.begin(ssid, psk);
while (!WiFi.isConnected())
{
Serial.print(".");
delay(200);
}
Serial.println();
Serial.print("[WiFi] IP: ");
Serial.println(WiFi.localIP());
}
void loop()
{
Serial.println("test");
sleep(1000);
}