diff --git a/.github/workflows/eppp__build.yml b/.github/workflows/eppp__build.yml new file mode 100644 index 00000000000..eb106923463 --- /dev/null +++ b/.github/workflows/eppp__build.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2c5b8ec94ff..f60a43c21e3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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] diff --git a/components/eppp_link/.cz.yaml b/components/eppp_link/.cz.yaml index abdb7071800..6fa28eedba0 100644 --- a/components/eppp_link/.cz.yaml +++ b/components/eppp_link/.cz.yaml @@ -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 diff --git a/components/eppp_link/eppp_link.c b/components/eppp_link/eppp_link.c index 1d3e89f8dc0..a2a8e6a1b37 100644 --- a/components/eppp_link/eppp_link.c +++ b/components/eppp_link/eppp_link.c @@ -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; } diff --git a/components/eppp_link/examples/host/sdkconfig.ci.spi b/components/eppp_link/examples/host/sdkconfig.ci.spi new file mode 100644 index 00000000000..125cdee30ae --- /dev/null +++ b/components/eppp_link/examples/host/sdkconfig.ci.spi @@ -0,0 +1 @@ +CONFIG_EPPP_LINK_DEVICE_SPI=y diff --git a/components/eppp_link/examples/host/sdkconfig.ci.uart b/components/eppp_link/examples/host/sdkconfig.ci.uart new file mode 100644 index 00000000000..15d212a821b --- /dev/null +++ b/components/eppp_link/examples/host/sdkconfig.ci.uart @@ -0,0 +1 @@ +CONFIG_EPPP_LINK_DEVICE_UART=y diff --git a/components/eppp_link/examples/host/sdkconfig.defaults b/components/eppp_link/examples/host/sdkconfig.defaults index ceb19a67c6b..ba88b9016ee 100644 --- a/components/eppp_link/examples/host/sdkconfig.defaults +++ b/components/eppp_link/examples/host/sdkconfig.defaults @@ -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 diff --git a/components/eppp_link/examples/slave/main/CMakeLists.txt b/components/eppp_link/examples/slave/main/CMakeLists.txt index 2ba044442a2..12c5007a379 100644 --- a/components/eppp_link/examples/slave/main/CMakeLists.txt +++ b/components/eppp_link/examples/slave/main/CMakeLists.txt @@ -1,2 +1,2 @@ -idf_component_register(SRCS "station_example_main.c" +idf_component_register(SRCS "eppp_slave.c" INCLUDE_DIRS ".") diff --git a/components/eppp_link/examples/slave/main/station_example_main.c b/components/eppp_link/examples/slave/main/eppp_slave.c similarity index 92% rename from components/eppp_link/examples/slave/main/station_example_main.c rename to components/eppp_link/examples/slave/main/eppp_slave.c index ff39dcc5064..3ad20ad7ba2 100644 --- a/components/eppp_link/examples/slave/main/station_example_main.c +++ b/components/eppp_link/examples/slave/main/eppp_slave.c @@ -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 diff --git a/components/eppp_link/examples/slave/sdkconfig.ci.spi b/components/eppp_link/examples/slave/sdkconfig.ci.spi new file mode 100644 index 00000000000..125cdee30ae --- /dev/null +++ b/components/eppp_link/examples/slave/sdkconfig.ci.spi @@ -0,0 +1 @@ +CONFIG_EPPP_LINK_DEVICE_SPI=y diff --git a/components/eppp_link/examples/slave/sdkconfig.ci.uart b/components/eppp_link/examples/slave/sdkconfig.ci.uart new file mode 100644 index 00000000000..15d212a821b --- /dev/null +++ b/components/eppp_link/examples/slave/sdkconfig.ci.uart @@ -0,0 +1 @@ +CONFIG_EPPP_LINK_DEVICE_UART=y diff --git a/components/eppp_link/examples/slave/sdkconfig.defaults b/components/eppp_link/examples/slave/sdkconfig.defaults index ec1a1a43b03..f2afde68504 100644 --- a/components/eppp_link/examples/slave/sdkconfig.defaults +++ b/components/eppp_link/examples/slave/sdkconfig.defaults @@ -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 diff --git a/components/eppp_link/test/test_app/main/app_main.c b/components/eppp_link/test/test_app/main/app_main.c index e4edfa487be..d36646ac66d 100644 --- a/components/eppp_link/test/test_app/main/app_main.c +++ b/components/eppp_link/test/test_app/main/app_main.c @@ -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 diff --git a/components/eppp_link/test/test_app/sdkconfig.defaults b/components/eppp_link/test/test_app/sdkconfig.defaults index 0442a3bc8a8..3240d12658f 100644 --- a/components/eppp_link/test/test_app/sdkconfig.defaults +++ b/components/eppp_link/test/test_app/sdkconfig.defaults @@ -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