-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(eppp_link): Added test-app with server and client on one ESP
- Loading branch information
1 parent
046e7e4
commit 0ad6424
Showing
8 changed files
with
340 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,63 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD | ||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
esp_netif_t *eppp_connect(void); | ||
#define EPPP_DEFAULT_SERVER_IP() ESP_IP4TOADDR(192, 168, 11, 1) | ||
#define EPPP_DEFAULT_CLIENT_IP() ESP_IP4TOADDR(192, 168, 11, 2) | ||
|
||
esp_netif_t *eppp_listen(void); | ||
#define EPPP_DEFAULT_CONFIG(our_ip, their_ip) { \ | ||
.uart = { \ | ||
.port = UART_NUM_1, \ | ||
.baud = 921600, \ | ||
.tx_io = 25, \ | ||
.rx_io = 26, \ | ||
.queue_size = 16, \ | ||
.rx_buffer_size = 1024, \ | ||
}, \ | ||
. task = { \ | ||
.run_task = true, \ | ||
.stack_size = 4096, \ | ||
.priority = 18, \ | ||
}, \ | ||
. ppp = { \ | ||
.our_ip4_addr = our_ip, \ | ||
.their_ip4_addr = their_ip, \ | ||
} \ | ||
} | ||
|
||
#define EPPP_DEFAULT_SERVER_CONFIG() EPPP_DEFAULT_CONFIG(EPPP_DEFAULT_SERVER_IP(), EPPP_DEFAULT_CLIENT_IP()) | ||
#define EPPP_DEFAULT_CLIENT_CONFIG() EPPP_DEFAULT_CONFIG(EPPP_DEFAULT_CLIENT_IP(), EPPP_DEFAULT_SERVER_IP()) | ||
|
||
typedef enum eppp_type { | ||
EPPP_SERVER, | ||
EPPP_CLIENT, | ||
} eppp_type_t; | ||
|
||
typedef struct eppp_config_t { | ||
struct eppp_config_uart_s { | ||
int port; | ||
int baud; | ||
int tx_io; | ||
int rx_io; | ||
int queue_size; | ||
int rx_buffer_size; | ||
} uart; | ||
|
||
struct eppp_config_task_s { | ||
bool run_task; | ||
int stack_size; | ||
int priority; | ||
} task; | ||
|
||
struct eppp_config_pppos_s { | ||
uint32_t our_ip4_addr; | ||
uint32_t their_ip4_addr; | ||
} ppp; | ||
|
||
} eppp_config_t; | ||
|
||
esp_netif_t *eppp_connect(eppp_config_t *config); | ||
|
||
esp_netif_t *eppp_listen(eppp_config_t *config); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# The following four lines of boilerplate have to be in your project's CMakeLists | ||
# in this exact order for cmake to work correctly | ||
cmake_minimum_required(VERSION 3.16) | ||
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/tools/unit-test-app/components) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(test_app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
|
||
# Test application running both server and client on the same device | ||
|
||
Need to connect client's Tx to server's Rx and vice versa: | ||
GPIO25 - GPIO4 | ||
GPIO26 - GPIO5 | ||
|
||
We wait for the connection and then we start pinging the client's address on server's netif. | ||
|
||
## Example of output: | ||
|
||
``` | ||
I (393) eppp_test_app: [APP] Startup.. | ||
I (393) eppp_test_app: [APP] Free memory: 296332 bytes | ||
I (393) eppp_test_app: [APP] IDF version: v5.3-dev-1154-gf14d9e7431-dirty | ||
I (423) uart: ESP_INTR_FLAG_IRAM flag not set while CONFIG_UART_ISR_IN_IRAM is enabled, flag updated | ||
I (423) uart: queue free spaces: 16 | ||
I (433) eppp_link: Waiting for IP address | ||
I (433) uart: ESP_INTR_FLAG_IRAM flag not set while CONFIG_UART_ISR_IN_IRAM is enabled, flag updated | ||
I (443) uart: queue free spaces: 16 | ||
I (443) eppp_link: Waiting for IP address | ||
I (6473) esp-netif_lwip-ppp: Connected | ||
I (6513) eppp_link: Got IPv4 event: Interface "pppos_client" address: 192.168.11.2 | ||
I (6523) esp-netif_lwip-ppp: Connected | ||
I (6513) eppp_link: Connected! | ||
I (6523) eppp_link: Got IPv4 event: Interface "pppos_server" address: 192.168.11.1 | ||
I (6553) main_task: Returned from app_main() | ||
64bytes from 192.168.11.2 icmp_seq=1 ttl=255 time=18 ms | ||
64bytes from 192.168.11.2 icmp_seq=2 ttl=255 time=19 ms | ||
64bytes from 192.168.11.2 icmp_seq=3 ttl=255 time=19 ms | ||
64bytes from 192.168.11.2 icmp_seq=4 ttl=255 time=20 ms | ||
64bytes from 192.168.11.2 icmp_seq=5 ttl=255 time=19 ms | ||
64bytes from 192.168.11.2 icmp_seq=6 ttl=255 time=19 ms | ||
64bytes from 192.168.11.2 icmp_seq=7 ttl=255 time=19 ms | ||
From 192.168.11.2 icmp_seq=8 timeout // <-- Disconnected Tx-Rx wires | ||
From 192.168.11.2 icmp_seq=9 timeout | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
idf_component_register(SRCS app_main.c | ||
INCLUDE_DIRS "." | ||
REQUIRES test_utils | ||
PRIV_REQUIRES unity nvs_flash esp_netif driver esp_event) |
Oops, something went wrong.