Hello everyone,
After to have estblish connection sucessfull with ethernet i would like to bridge with wifi,
In the examples i see eth2ap example but in this net_if library is not use ,
Following documentation of version 4.1 The purpose of ESP-NETIF library is twofold:
It provides an abstraction layer for the application on top of the TCP/IP stack. This will allow applications to choose between IP stacks
in the future.
The APIs it provides are thread safe, even if the underlying TCP/IP stack APIs are not.
Is it possible to use net_if and in that case how with 2 interfaces , is it necessary to define 2 instances?
esp_netif_config_t netif_config = ESP_NETIF_DEFAULT_WIFI_STA();
esp_netif_config_t netif_config = ESP_NETIF_DEFAULT_ETH();...........
Thanks,
Bridging ethernet and wifi
-
- Posts: 69
- Joined: Thu Nov 01, 2018 8:32 am
Re: Bridging ethernet and wifi
Hi pascal21
Yes, that's correct. The IDF example "eth2ap" doesn't use network interfaces at all. It just connects the wifi driver to the ethernet driver, so the packets are directly passed from one to another without going through the TCP/IP stack (which has its benefits).
Yes, it is possible to use standard network interfaces for ethernet and WiFi AP netif to do the same, but there's no such example in IDF. I think you have two options:
1) bridge mode: setup ethernet netif with static IP, setup default AP with the same subnet, enable IP forwarding in lwip
2) NAT mode: setup default ethernet netif (dhcp client), setup default AP (with dhcp server) with arbitrary local subnet, enable NAPT in lwip
Yes, that's correct. The IDF example "eth2ap" doesn't use network interfaces at all. It just connects the wifi driver to the ethernet driver, so the packets are directly passed from one to another without going through the TCP/IP stack (which has its benefits).
Yes, it is possible to use standard network interfaces for ethernet and WiFi AP netif to do the same, but there's no such example in IDF. I think you have two options:
1) bridge mode: setup ethernet netif with static IP, setup default AP with the same subnet, enable IP forwarding in lwip
2) NAT mode: setup default ethernet netif (dhcp client), setup default AP (with dhcp server) with arbitrary local subnet, enable NAPT in lwip
Re: Bridging ethernet and wifi
Hi,
1) bridge mode: setup ethernet netif with static IP, setup default AP with the same subnet, enable IP forwarding in lwip
Can you give me some more information how to setup default ap with the same subnet in the process of wifi setting
esp_netif_create_default_wifi_ap();
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL));
wifi_config_t wifi_config = {
.ap = {
.ssid = ESP_WIFI_SSID,
.ssid_len = strlen(ESP_WIFI_SSID),
.channel = ESP_WIFI_CHANNEL,
.password = ESP_WIFI_PASS,
.max_connection = MAX_STA_CONN,
.authmode = WIFI_AUTH_WPA_WPA2_PSK
},
};
if (strlen(ESP_WIFI_PASS) == 0) {
wifi_config.ap.authmode = WIFI_AUTH_OPEN;
}
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start());
Regards,
1) bridge mode: setup ethernet netif with static IP, setup default AP with the same subnet, enable IP forwarding in lwip
Can you give me some more information how to setup default ap with the same subnet in the process of wifi setting
esp_netif_create_default_wifi_ap();
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL));
wifi_config_t wifi_config = {
.ap = {
.ssid = ESP_WIFI_SSID,
.ssid_len = strlen(ESP_WIFI_SSID),
.channel = ESP_WIFI_CHANNEL,
.password = ESP_WIFI_PASS,
.max_connection = MAX_STA_CONN,
.authmode = WIFI_AUTH_WPA_WPA2_PSK
},
};
if (strlen(ESP_WIFI_PASS) == 0) {
wifi_config.ap.authmode = WIFI_AUTH_OPEN;
}
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start());
Regards,
Re: Bridging ethernet and wifi
Hi,
After some test it begin to work (see file joint) but bridge doesn't work
Connection with ethernet ok
Connection wifi ok
Test Dialog socket with wifi ok
Test Dialog socket with ethernet problem
as soon i try to dialog with socket on ethernet there is problem ,
I'm not sure if the process to init and run wifi is good because i create a new instance net_if for wifi ,
it seems to overlead net_if of ethernet in transfer of packet see (see subroutine wifi_init_softap) ?
Regards,
After some test it begin to work (see file joint) but bridge doesn't work
Connection with ethernet ok
Connection wifi ok
Test Dialog socket with wifi ok
Test Dialog socket with ethernet problem
as soon i try to dialog with socket on ethernet there is problem ,
I'm not sure if the process to init and run wifi is good because i create a new instance net_if for wifi ,
it seems to overlead net_if of ethernet in transfer of packet see (see subroutine wifi_init_softap) ?
Regards,
- Attachments
-
- tcp_client.c
- (3.45 KiB) Downloaded 518 times
Who is online
Users browsing this forum: No registered users and 74 guests