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