as stated in the title, I want to make a direct connection between two esp32 devices via Ethernet. Ethernet runs with the help of W5500 controllers and I am using a crossover cable. This way the status-LEDs of the RJ45-sockets are on and the Ethernet Link is up.
My plan was to give both ESPs static ip addresses. One will have a webserver running from which the other one will get information.
The way I set the static IPs:
Code: Select all
esp_netif_ip_info_t ip_info;
IP4_ADDR(&ip_info.ip, 192, 168, 20, 1);
IP4_ADDR(&ip_info.gw, 192, 168, 20, 1);
IP4_ADDR(&ip_info.netmask, 255, 255, 255, 0);
esp_netif_dhcpc_stop(eth_netif);
esp_netif_set_ip_info(eth_netif, &ip_info);
I am not very familiar with networking so the gateway address may be an issue?
The way I set up the webserver:
Code: Select all
static httpd_handle_t start_webserver(void)
{
httpd_handle_t server = NULL;
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
config.uri_match_fn = httpd_uri_match_wildcard;
config.lru_purge_enable = true;
config.max_uri_handlers = 12;
ESP_LOGI(TAG, "Starting server on port: '%d'", config.server_port);
if (httpd_start(&server, &config) == ESP_OK) {
ESP_LOGI(TAG, "Registering URI handlers");
httpd_register_uri_handler(server, &root_uri); // Root
ESP_LOGI(TAG, "Started webserver");
return server;
}
ESP_LOGI(TAG, "Error starting server!");
return NULL;
}
Code: Select all
esp_http_client_config_t config = {
.url = "http://192.168.20.1",
.event_handler = _http_event_handler,
.method = HTTP_METHOD_HEAD
};
esp_http_client_handle_t client = esp_http_client_init(&config);
esp_err_t err = esp_http_client_perform(client);
if (err == ESP_OK) {
ESP_LOGI(TAG, "HTTPS Status = %d, content_length = %d",
esp_http_client_get_status_code(client),
esp_http_client_get_content_length(client));
} else {
ESP_LOGE(TAG, "Error perform http request %s", esp_err_to_name(err));
}
esp_http_client_cleanup(client);
Via Wifi this wouldn't be much of a problem but I really want to make it work via Ethernet.E (730557) TRANS_TCP: [sock=54] select() timeout
E (730557) HTTP_CLIENT: Connection failed, sock < 0
E (730557) main: Error perform http request ESP_ERR_HTTP_CONNECT
Anyone got any idea on how to get this working?
Thanks in advance. Any help would be appreciated