From 6dcc060ca7832109c6235188d09d9d85e92673d6 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 12 Jan 2024 10:27:58 +0100 Subject: [PATCH] fix(eppp_link): Updated per iperf --- components/eppp_link/eppp_link.c | 4 +- .../examples/rpc/client/main/app_main.c | 70 ++++++++++--------- .../eppp_link/examples/rpc/common/rpc.hpp | 2 +- .../rpc/server/main/station_example_main.c | 6 +- 4 files changed, 44 insertions(+), 38 deletions(-) diff --git a/components/eppp_link/eppp_link.c b/components/eppp_link/eppp_link.c index 73fba3ad76..68780ab23d 100644 --- a/components/eppp_link/eppp_link.c +++ b/components/eppp_link/eppp_link.c @@ -559,7 +559,7 @@ esp_err_t eppp_perform(esp_netif_t *netif) if (head->channel == 0) { esp_netif_receive(netif, in_buf + sizeof(struct header), head->short_size, NULL); } else { - ESP_LOGE(TAG, "Got channel %d size %d", head->channel, head->short_size); +// ESP_LOGE(TAG, "Got channel %d size %d", head->channel, head->short_size); if (s_rx != NULL) { s_rx(netif, in_buf + sizeof(struct header), head->short_size); } @@ -616,7 +616,7 @@ esp_err_t eppp_perform(esp_netif_t *netif) if (head->channel == 0) { esp_netif_receive(netif, in_buf + sizeof(struct header), head->size, NULL); } else { - ESP_LOGE(TAG, "Got channel %d size %d", head->channel, head->size); +// ESP_LOGE(TAG, "Got channel %d size %d", head->channel, head->size); if (s_rx != NULL) { s_rx(netif, in_buf + sizeof(struct header), head->size); } diff --git a/components/eppp_link/examples/rpc/client/main/app_main.c b/components/eppp_link/examples/rpc/client/main/app_main.c index cf466d2799..5a5357c1db 100644 --- a/components/eppp_link/examples/rpc/client/main/app_main.c +++ b/components/eppp_link/examples/rpc/client/main/app_main.c @@ -137,7 +137,7 @@ static eppp_channel_fn_t s_tx; static esp_err_t remote_wifi_receive(void *h, void *buffer, size_t len) { if (s_wifi_netif) { - printf("recv %d\n", len); +// printf("recv %d\n", len); return esp_netif_receive(s_wifi_netif, buffer, len, NULL); } return ESP_OK; @@ -146,7 +146,7 @@ static esp_err_t remote_wifi_receive(void *h, void *buffer, size_t len) esp_err_t remote_wifi_transmit_wrap(void *h, void *buffer, size_t len, void *netstack_buffer) { if (s_tx) { - printf("send %d\n", len); +// printf("send %d\n", len); return s_tx(s_ppp_netif, buffer, len); } return ESP_OK; @@ -162,7 +162,7 @@ static esp_err_t remote_wifi_transmit(void *h, void *buffer, size_t len) static void wifi_free(void *h, void *buffer) { - printf("wifi_free %p\n", buffer); +// printf("wifi_free %p\n", buffer); } static void remote_wifi_netif(void) @@ -183,6 +183,38 @@ static void remote_wifi_netif(void) s_wifi_netif = esp_netif_new(&netif_config); } +static void wifi_init(void *ctx) +{ + client_init(); + + wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); + ESP_ERROR_CHECK(esp_wifi_remote_init(&cfg)); + + wifi_config_t wifi_config = { + .sta = { + .ssid = CONFIG_ESP_WIFI_SSID, + .password = CONFIG_ESP_WIFI_PASSWORD, + }, + }; + + esp_err_t err = esp_wifi_remote_set_mode(WIFI_MODE_STA); + ESP_LOGI(TAG, "esp_wifi_remote_set_mode() returned = %x", err); + ESP_ERROR_CHECK(esp_wifi_remote_set_config(WIFI_IF_STA, &wifi_config) ); + ESP_ERROR_CHECK(esp_wifi_remote_start() ); + vTaskDelay(pdMS_TO_TICKS(1000)); + uint8_t mac[6]; + ESP_ERROR_CHECK(esp_wifi_remote_get_mac(WIFI_IF_STA, mac) ); + + esp_netif_set_mac(s_wifi_netif, mac); + vTaskDelay(pdMS_TO_TICKS(1000)); + + esp_netif_action_start(s_wifi_netif, 0, 0, 0); + ESP_ERROR_CHECK(esp_wifi_remote_connect() ); + + esp_netif_action_connected(s_wifi_netif, 0, 0, 0); + vTaskDelete(NULL); +} + void app_main(void) { ESP_LOGI(TAG, "[APP] Startup.."); @@ -198,7 +230,8 @@ void app_main(void) eppp_config_t config = EPPP_DEFAULT_CLIENT_CONFIG(); #if CONFIG_EPPP_LINK_DEVICE_SPI config.transport = EPPP_TRANSPORT_SPI; - config.task.priority = 5; + config.task.priority = 14; + config.spi.freq = 28000000; #else config.transport = EPPP_TRANSPORT_UART; config.uart.tx_io = 10; @@ -217,35 +250,8 @@ void app_main(void) return ; } - client_init(); - - - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); - ESP_LOG_BUFFER_HEXDUMP("cfg", &cfg, sizeof(cfg), ESP_LOG_WARN); - ESP_ERROR_CHECK(esp_wifi_remote_init(&cfg)); - - wifi_config_t wifi_config = { - .sta = { - .ssid = CONFIG_ESP_WIFI_SSID, - .password = CONFIG_ESP_WIFI_PASSWORD, - }, - }; - - esp_err_t err = esp_wifi_remote_set_mode(WIFI_MODE_STA); - ESP_LOGI(TAG, "esp_wifi_remote_set_mode() returned = %x", err); - ESP_ERROR_CHECK(esp_wifi_remote_set_config(WIFI_IF_STA, &wifi_config) ); - ESP_ERROR_CHECK(esp_wifi_remote_start() ); - vTaskDelay(pdMS_TO_TICKS(1000)); - uint8_t mac[6]; - ESP_ERROR_CHECK(esp_wifi_remote_get_mac(WIFI_IF_STA, mac) ); - esp_netif_set_mac(s_wifi_netif, mac); - vTaskDelay(pdMS_TO_TICKS(1000)); - - esp_netif_action_start(s_wifi_netif, 0, 0, 0); - ESP_ERROR_CHECK(esp_wifi_remote_connect() ); - - esp_netif_action_connected(s_wifi_netif, 0, 0, 0); + xTaskCreate(&wifi_init, "initwifi", 8192, NULL, 18, NULL); // // Setup global DNS // esp_netif_dns_info_t dns; // dns.ip.u_addr.ip4.addr = esp_netif_htonl(CONFIG_EXAMPLE_GLOBAL_DNS); diff --git a/components/eppp_link/examples/rpc/common/rpc.hpp b/components/eppp_link/examples/rpc/common/rpc.hpp index d4d80423be..b0d2f8160a 100644 --- a/components/eppp_link/examples/rpc/common/rpc.hpp +++ b/components/eppp_link/examples/rpc/common/rpc.hpp @@ -51,7 +51,7 @@ class RpcEngine { size_t size; auto buf = req.marshall(t, size); ESP_LOGI("rpc", "Sending API id:%d", (int)id); - ESP_LOG_BUFFER_HEXDUMP("rpc", buf, size, ESP_LOG_INFO); + ESP_LOG_BUFFER_HEXDUMP("rpc", buf, size, ESP_LOG_VERBOSE); int len = esp_tls_conn_write(tls_, buf, size); if (len <= 0) { ESP_LOGE("rpc", "Failed to write data to the connection"); diff --git a/components/eppp_link/examples/rpc/server/main/station_example_main.c b/components/eppp_link/examples/rpc/server/main/station_example_main.c index 6c47a877bd..310c02d30b 100644 --- a/components/eppp_link/examples/rpc/server/main/station_example_main.c +++ b/components/eppp_link/examples/rpc/server/main/station_example_main.c @@ -120,15 +120,15 @@ static esp_netif_t *s_ppp_netif; static esp_err_t netif_recv(void *h, void *buffer, size_t len) { // printf("recv %d\n", len); - ESP_LOG_BUFFER_HEXDUMP("cfg", buffer, len, ESP_LOG_WARN); +// ESP_LOG_BUFFER_HEXDUMP("cfg", buffer, len, ESP_LOG_WARN); return esp_wifi_internal_tx(WIFI_IF_STA, buffer, len); } static esp_err_t wifi_recv(void *buffer, uint16_t len, void *eb) { - printf("send %d\n", len); +// printf("send %d\n", len); if (s_tx) { - printf("send %d\n", len); +// printf("send %d\n", len); esp_err_t ret = s_tx(s_ppp_netif, buffer, len); esp_wifi_internal_free_rx_buffer(eb); return ret;