espressif / esp-iot-bridge

A smart bridge to make both ESP and the other MCU or smart device can access the Internet.
Apache License 2.0
141 stars 49 forks source link

Is it possible to support mac repeater or wds bridge? #16

Open Felix-mrf opened 1 year ago

Felix-mrf commented 1 year ago

I want to use esp32 to build a wifi+eth bridge device, but only dst mac esp32 sta will be receieve. Nat is still many restrictions.

tswen commented 1 year ago

Do you mean the external wants to communicate with the ethernet connected device, if so, you may need to add portmap in your code, currently Nat does have some limitations.

#define IP_PROTO_TCP     6
#define IP_PROTO_UDP     17
 static void ip_event_sta_got_ip_handler(void *arg, esp_event_base_t event_base,
                                         int32_t event_id, void *event_data)
 {
     ip_event_got_ip_t *event = (ip_event_got_ip_t *) event_data;
     ESP_LOGI(TAG, "Connected with IP Address:" IPSTR, IP2STR(&event->ip_info.ip));
     esp_gateway_netif_network_segment_conflict_update(event->esp_netif);
     ip_portmap_add(IP_PROTO_TCP, event->ip_info.ip.addr, 5001, ESP_IP4TOADDR(192, 168, 4, 2), 5001);
     xEventGroupSetBits(s_wifi_event_group, GATEWAY_EVENT_STA_CONNECTED);
 }