Skip to content

Commit

Permalink
fix(eppp_link): Updated per iperf
Browse files Browse the repository at this point in the history
  • Loading branch information
david-cermak committed Jan 12, 2024
1 parent cba0160 commit 6dcc060
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 38 deletions.
4 changes: 2 additions & 2 deletions components/eppp_link/eppp_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
70 changes: 38 additions & 32 deletions components/eppp_link/examples/rpc/client/main/app_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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)
Expand All @@ -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..");
Expand All @@ -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;
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion components/eppp_link/examples/rpc/common/rpc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6dcc060

Please sign in to comment.