Skip to content

Commit

Permalink
feat(eppp): Add simple CI check
Browse files Browse the repository at this point in the history
  • Loading branch information
david-cermak committed Feb 14, 2024
1 parent 4d587cc commit 9b319c4
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 28 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/eppp__build.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ repos:
- repo: local
hooks:
- id: commit message scopes
name: "commit message must be scoped with: mdns, modem, websocket, asio, mqtt_cxx, console, common"
entry: '\A(?!(feat|fix|ci|bump|test|docs)\((mdns|modem|common|console|websocket|asio|mqtt_cxx|examples|eppp_link)\)\:)'
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]
stages: [commit-msg]
2 changes: 1 addition & 1 deletion components/eppp_link/.cz.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
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
Expand Down
23 changes: 12 additions & 11 deletions components/eppp_link/eppp_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -85,7 +87,6 @@ struct eppp_handle {
};



static esp_err_t transmit(void *h, void *buffer, size_t len)
{
struct eppp_handle *handle = h;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions components/eppp_link/examples/host/sdkconfig.ci.spi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_EPPP_LINK_DEVICE_SPI=y
2 changes: 1 addition & 1 deletion components/eppp_link/examples/slave/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
idf_component_register(SRCS "station_example_main.c"
idf_component_register(SRCS "eppp_slave.c"
INCLUDE_DIRS ".")
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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();

Expand Down Expand Up @@ -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)
{
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions components/eppp_link/examples/slave/sdkconfig.ci.spi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_EPPP_LINK_DEVICE_SPI=y
1 change: 0 additions & 1 deletion components/eppp_link/examples/slave/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@ 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
6 changes: 3 additions & 3 deletions components/eppp_link/test/test_app/main/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 2 additions & 5 deletions components/eppp_link/test/test_app/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 9b319c4

Please sign in to comment.