Basic setup with hook and arduino for esp32
This commit is contained in:
parent
8c36882772
commit
bb999311a7
9 changed files with 2812 additions and 0 deletions
3
ESP32Firewall/.gitignore
vendored
Normal file
3
ESP32Firewall/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
.pio
|
||||
.vscode
|
||||
include/theSecrets.h
|
3
ESP32Firewall/CMakeLists.txt
Normal file
3
ESP32Firewall/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
cmake_minimum_required(VERSION 3.16.0)
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
project(ESP32Firewall)
|
20
ESP32Firewall/include/lwip_hooks.h
Normal file
20
ESP32Firewall/include/lwip_hooks.h
Normal 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_ */
|
9
ESP32Firewall/include/theSecrets-example.h
Normal file
9
ESP32Firewall/include/theSecrets-example.h
Normal 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
|
18
ESP32Firewall/platformio.ini
Normal file
18
ESP32Firewall/platformio.ini
Normal 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"'
|
1439
ESP32Firewall/sdkconfig.az-delivery-devkit-v4
Normal file
1439
ESP32Firewall/sdkconfig.az-delivery-devkit-v4
Normal file
File diff suppressed because it is too large
Load diff
1276
ESP32Firewall/sdkconfig.az-delivery-devkit-v4.old
Normal file
1276
ESP32Firewall/sdkconfig.az-delivery-devkit-v4.old
Normal file
File diff suppressed because it is too large
Load diff
6
ESP32Firewall/src/CMakeLists.txt
Normal file
6
ESP32Firewall/src/CMakeLists.txt
Normal 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})
|
38
ESP32Firewall/src/main.cpp
Normal file
38
ESP32Firewall/src/main.cpp
Normal 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);
|
||||
}
|
Reference in a new issue