From 0422eeeb9a111dc0af14de95943b9b92062f1e0d Mon Sep 17 00:00:00 2001 From: Florian Hoss Date: Mon, 25 Jul 2022 16:01:07 +0200 Subject: [PATCH] Finally external files working --- ESPTest/.vscode/settings.json | 4 +++- ESPTest/include/lwip_hooks.h | 21 +++++++++++++++++++-- ESPTest/include/myhook.c | 9 --------- ESPTest/include/myhook.h | 15 --------------- ESPTest/platformio.ini | 3 ++- ESPTest/src/lwip_hooks.c | 7 +++++++ 6 files changed, 31 insertions(+), 28 deletions(-) delete mode 100644 ESPTest/include/myhook.c delete mode 100644 ESPTest/include/myhook.h create mode 100644 ESPTest/src/lwip_hooks.c diff --git a/ESPTest/.vscode/settings.json b/ESPTest/.vscode/settings.json index 49c023b..81dbd53 100644 --- a/ESPTest/.vscode/settings.json +++ b/ESPTest/.vscode/settings.json @@ -1,5 +1,7 @@ { "files.associations": { - "esp_wifi_default.h": "c" + "esp_wifi_default.h": "c", + "esp_log.h": "c", + "lwip_hooks.h": "c" } } diff --git a/ESPTest/include/lwip_hooks.h b/ESPTest/include/lwip_hooks.h index 6f28d23..f261ee9 100644 --- a/ESPTest/include/lwip_hooks.h +++ b/ESPTest/include/lwip_hooks.h @@ -1,3 +1,20 @@ -#pragma once +#ifndef _LWIP_HOOKS_H_ +#define _LWIP_HOOKS_H_ -#define LWIP_HOOK_IP4_INPUT lwip_hook_ip4_input \ No newline at end of file +#include "lwip/netif.h" +#include "lwip/pbuf.h" +#include "esp_log.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_ */ diff --git a/ESPTest/include/myhook.c b/ESPTest/include/myhook.c deleted file mode 100644 index b870fee..0000000 --- a/ESPTest/include/myhook.c +++ /dev/null @@ -1,9 +0,0 @@ -#include "lwip/netif.h" -#include "lwip/pbuf.h" -#include "esp_log.h" - -int lwip_hook_ip4_input(struct pbuf *pbuf, struct netif *input_netif) -{ - ESP_LOGI("HOOK", "Testing..."); - return 0; // we don't consume the packet -} \ No newline at end of file diff --git a/ESPTest/include/myhook.h b/ESPTest/include/myhook.h deleted file mode 100644 index c7c8472..0000000 --- a/ESPTest/include/myhook.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#include "lwip/netif.h" -#include "lwip/pbuf.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - - int lwip_hook_ip4_input(struct pbuf *pbuf, struct netif *input_netif); - -#ifdef __cplusplus -} -#endif \ No newline at end of file diff --git a/ESPTest/platformio.ini b/ESPTest/platformio.ini index 2bb487d..27de195 100644 --- a/ESPTest/platformio.ini +++ b/ESPTest/platformio.ini @@ -14,4 +14,5 @@ board = az-delivery-devkit-v4 framework = espidf monitor_speed = 115200 build_flags = - '-DLWIP_HOOK_IP4_INPUT(pbuf, input_netif)=({ESP_LOGI("HOOK","TEST");0;})' \ No newline at end of file + '-Iinclude' + '-DESP_IDF_LWIP_HOOK_FILENAME="lwip_hooks.h"' diff --git a/ESPTest/src/lwip_hooks.c b/ESPTest/src/lwip_hooks.c new file mode 100644 index 0000000..72e39ba --- /dev/null +++ b/ESPTest/src/lwip_hooks.c @@ -0,0 +1,7 @@ +#include "lwip_hooks.h" + +int lwip_hook_ip4_input(struct pbuf *pbuf, struct netif *input_netif) +{ + ESP_LOGI("Hook", "Testing..."); + return 0; +}