feat(eppp): Added CI job to build examples and tests

This commit is contained in:
David Cermak
2024-02-14 16:30:42 +01:00
parent 18f845275f
commit 7eefcf084e
17 changed files with 77 additions and 46 deletions

28
.github/workflows/eppp__build.yml vendored Normal file
View File

@ -0,0 +1,28 @@
name: "eppp_link: build-tests"
on:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, labeled]
jobs:
build_eppp:
if: contains(github.event.pull_request.labels.*.name, 'eppp') || github.event_name == 'push'
name: Build
strategy:
matrix:
idf_ver: ["latest"]
test: [ { app: host, path: "examples/host" }, { app: slave, path: "examples/slave" }, { app: test_app, path: "test/test_app" }]
runs-on: ubuntu-20.04
container: espressif/idf:${{ matrix.idf_ver }}
steps:
- name: Checkout esp-protocols
uses: actions/checkout@v3
- name: Build ${{ matrix.test.app }} with IDF-${{ matrix.idf_ver }}
shell: bash
run: |
${IDF_PATH}/install.sh --enable-pytest
. ${IDF_PATH}/export.sh
python ./ci/build_apps.py ./components/eppp_link/${{matrix.test.path}} -vv --preserve-all

View File

@ -92,6 +92,7 @@ jobs:
components/esp_modem;
components/esp_mqtt_cxx;
components/esp_websocket_client;
components/eppp_link;
components/mdns;
components/console_simple_init;
components/console_cmd_ping;

View File

@ -61,7 +61,7 @@ repos:
- repo: local
hooks:
- id: commit message scopes
name: "commit message must be scoped with: mdns, modem, websocket, asio, mqtt_cxx, console, common"
name: "commit message must be scoped with: mdns, modem, websocket, asio, mqtt_cxx, console, common, eppp"
entry: '\A(?!(feat|fix|ci|bump|test|docs)\((mdns|modem|common|console|websocket|asio|mqtt_cxx|examples|eppp)\)\:)'
language: pygrep
args: [--multiline]

View File

@ -1,8 +1,8 @@
---
commitizen:
bump_message: 'bump(eppp_link): $current_version -> $new_version'
bump_message: 'bump(eppp): $current_version -> $new_version'
pre_bump_hooks: python ../../ci/changelog.py eppp_link
tag_format: epp_link-v$version
version: 0.0.1
tag_format: eppp-v$version
version: 0.0.0
version_files:
- idf_component.yml

View File

@ -43,6 +43,8 @@ struct packet {
#define MIN_TRIGGER_US 20
#define SPI_HEADER_MAGIC 0x1234
static void timer_callback(void *arg);
struct header {
uint16_t magic;
uint16_t size;
@ -85,7 +87,6 @@ struct eppp_handle {
};
static esp_err_t transmit(void *h, void *buffer, size_t len)
{
struct eppp_handle *handle = h;
@ -128,14 +129,6 @@ static esp_err_t transmit(void *h, void *buffer, size_t len)
return ESP_OK;
}
static void IRAM_ATTR timer_callback(void *arg)
{
struct eppp_handle *h = arg;
if (h->blocked == SLAVE_WANTS_WRITE) {
gpio_set_level(h->gpio_intr, 0);
}
}
static void netif_deinit(esp_netif_t *netif)
{
if (netif == NULL) {
@ -332,7 +325,15 @@ static void on_ip_event(void *arg, esp_event_base_t base, int32_t event_id, void
#define SPI_ALIGN(size) (((size) + 3U) & ~(3U))
#define TRANSFER_SIZE SPI_ALIGN((MAX_PAYLOAD + 6))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define NEXT_TRANSACTION_SIZE(a,b) (((a)>(b))?(a):(b)) /* next transaction: whichever is bigger */
static void IRAM_ATTR timer_callback(void *arg)
{
struct eppp_handle *h = arg;
if (h->blocked == SLAVE_WANTS_WRITE) {
gpio_set_level(h->gpio_intr, 0);
}
}
static void IRAM_ATTR gpio_isr_handler(void *arg)
{
@ -598,7 +599,7 @@ esp_err_t eppp_perform(esp_netif_t *netif)
ESP_LOG_BUFFER_HEXDUMP(TAG, in_buf + sizeof(struct header), head->size, ESP_LOG_VERBOSE);
esp_netif_receive(netif, in_buf + sizeof(struct header), head->size, NULL);
}
h->transaction_size = MAX(next_tx_size, head->next_size);
h->transaction_size = NEXT_TRANSACTION_SIZE(next_tx_size, head->next_size);
return ESP_OK;
}

View File

@ -121,27 +121,23 @@ void app_main(void)
dns.ip.type = ESP_IPADDR_TYPE_V4;
ESP_ERROR_CHECK(esp_netif_set_dns_info(eppp_netif, ESP_NETIF_DNS_MAIN, &dns));
// Initialize console REPL
ESP_ERROR_CHECK(console_cmd_init());
#if CONFIG_EXAMPLE_IPERF
register_iperf();
printf("\n =======================================================\n");
printf(" | Steps to Test PPP Client Bandwidth |\n");
printf(" | Steps to Test EPPP-host bandwidth |\n");
printf(" | |\n");
printf(" | 1. Enter 'help', check all supported commands |\n");
printf(" | 2. Start PPP server on host system |\n");
printf(" | - pppd /dev/ttyUSB1 115200 192.168.11.1:192.168.11.2 modem local noauth debug nocrtscts nodetach +ipv6\n");
printf(" | 3. Wait ESP32 to get IP from PPP server |\n");
printf(" | 4. Enter 'pppd info' (optional) |\n");
printf(" | 5. Server: 'iperf -u -s -i 3' |\n");
printf(" | 6. Client: 'iperf -u -c SERVER_IP -t 60 -i 3' |\n");
printf(" | 1. Wait for the ESP32 to get an IP |\n");
printf(" | 2. Server: 'iperf -u -s -i 3' (on host) |\n");
printf(" | 3. Client: 'iperf -u -c SERVER_IP -t 60 -i 3' |\n");
printf(" | |\n");
printf(" =======================================================\n\n");
#endif // CONFIG_EXAMPLE_IPERF
// Initialize console REPL
ESP_ERROR_CHECK(console_cmd_init());
// Register the ping command
ESP_ERROR_CHECK(console_cmd_ping_register());
// start console REPL

View File

@ -0,0 +1 @@
CONFIG_EPPP_LINK_DEVICE_SPI=y

View File

@ -0,0 +1 @@
CONFIG_EPPP_LINK_DEVICE_UART=y

View File

@ -1,7 +1,3 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) 5.3.0 Project Minimal Configuration
#
CONFIG_UART_ISR_IN_IRAM=y
CONFIG_LWIP_PPP_SUPPORT=y
CONFIG_LWIP_PPP_SERVER_SUPPORT=y
CONFIG_LWIP_PPP_VJ_HEADER_COMPRESSION=n

View File

@ -1,2 +1,2 @@
idf_component_register(SRCS "station_example_main.c"
idf_component_register(SRCS "eppp_slave.c"
INCLUDE_DIRS ".")

View File

@ -14,6 +14,10 @@
#include "nvs_flash.h"
#include "eppp_link.h"
static const char *TAG = "eppp_slave";
#if CONFIG_SOC_WIFI_SUPPORTED
/* FreeRTOS event group to signal when we are connected*/
static EventGroupHandle_t s_wifi_event_group;
@ -23,7 +27,6 @@ static EventGroupHandle_t s_wifi_event_group;
#define WIFI_CONNECTED_BIT BIT0
#define WIFI_FAIL_BIT BIT1
static const char *TAG = "sta2pppos";
static int s_retry_num = 0;
@ -48,7 +51,7 @@ static void event_handler(void *arg, esp_event_base_t event_base, int32_t event_
}
}
void wifi_init_sta(void)
void init_network_interface(void)
{
s_wifi_event_group = xEventGroupCreate();
@ -105,6 +108,14 @@ void wifi_init_sta(void)
ESP_LOGE(TAG, "UNEXPECTED EVENT");
}
}
#else
void init_network_interface(void)
{
// placeholder to initialize any other network interface if WiFi is not available
}
#endif // SoC WiFi capable chip
void app_main(void)
{
@ -116,8 +127,7 @@ void app_main(void)
}
ESP_ERROR_CHECK(ret);
ESP_LOGI(TAG, "ESP_WIFI_MODE_STA");
wifi_init_sta();
init_network_interface(); // WiFi station if withing SoC capabilities (otherwise a placeholder)
eppp_config_t config = EPPP_DEFAULT_SERVER_CONFIG();
#if CONFIG_EPPP_LINK_DEVICE_SPI

View File

@ -0,0 +1 @@
CONFIG_EPPP_LINK_DEVICE_SPI=y

View File

@ -0,0 +1 @@
CONFIG_EPPP_LINK_DEVICE_UART=y

View File

@ -1,8 +1,6 @@
CONFIG_UART_ISR_IN_IRAM=y
CONFIG_LWIP_IP_FORWARD=y
CONFIG_LWIP_IPV4_NAPT=y
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=4096
CONFIG_LWIP_PPP_SUPPORT=y
CONFIG_LWIP_PPP_SERVER_SUPPORT=y
CONFIG_LWIP_PPP_VJ_HEADER_COMPRESSION=n
CONFIG_EPPP_LINK_DEVICE_SPI=y

View File

@ -1,4 +1,4 @@
version: 0.0.9
version: 0.0.0
url: https://github.com/espressif/esp-protocols/tree/master/components/eppp_link
description: The component provides a general purpose PPP connectivity, typically used as WiFi-PPP router
dependencies:

View File

@ -171,7 +171,7 @@ TEST(eppp_test, open_close)
TEST_ASSERT_NOT_NULL(client.netif);
// Now that we're connected, let's try to ping clients address
bits = ping_test(config.ppp.their_ip4_addr, eppp_server, client.event);
bits = ping_test(config.ppp.their_ip4_addr.addr, eppp_server, client.event);
TEST_ASSERT_EQUAL(bits & (PING_SUCCEEDED | PING_FAILED), PING_SUCCEEDED);
// Trigger client disconnection and close the server
@ -237,7 +237,7 @@ TEST(eppp_test, open_close_nonblocking)
TEST_ASSERT_EQUAL(bits & wait_bits, wait_bits);
// Now that we're connected, let's try to ping clients address
bits = ping_test(server_config.ppp.their_ip4_addr, eppp_server, event);
bits = ping_test(server_config.ppp.their_ip4_addr.addr, eppp_server, event);
TEST_ASSERT_EQUAL(bits & (PING_SUCCEEDED | PING_FAILED), PING_SUCCEEDED);
// stop network for both client and server
@ -304,7 +304,7 @@ TEST(eppp_test, open_close_taskless)
xEventGroupClearBits(info.event, wait_bits);
// Now that we're connected, let's try to ping clients address
bits = ping_test(server_config.ppp.their_ip4_addr, info.eppp_server, info.event);
bits = ping_test(server_config.ppp.their_ip4_addr.addr, info.eppp_server, info.event);
TEST_ASSERT_EQUAL(bits & (PING_SUCCEEDED | PING_FAILED), PING_SUCCEEDED);
// stop network for both client and server, we won't wait for completion so expecting ESP_FAIL

View File

@ -1,12 +1,9 @@
# This file was generated using idf.py save-defconfig. It can be edited manually.
# Espressif IoT Development Framework (ESP-IDF) 5.3.0 Project Minimal Configuration
#
CONFIG_IDF_TARGET="esp32"
CONFIG_UART_ISR_IN_IRAM=y
CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=0
CONFIG_FREERTOS_UNICORE=y
CONFIG_HEAP_TRACING_STANDALONE=y
CONFIG_HEAP_TRACING_STACK_DEPTH=6
CONFIG_LWIP_PPP_SUPPORT=y
CONFIG_LWIP_PPP_SERVER_SUPPORT=y
CONFIG_LWIP_PPP_VJ_HEADER_COMPRESSION=n
CONFIG_LWIP_PPP_DEBUG_ON=y
CONFIG_UNITY_ENABLE_FIXTURE=y