espconn_connect() returns ESPCONN_RTE
Posted: Wed Feb 18, 2015 12:13 pm
I've managed to get my ESP8266 to have Chromecast-esque set up functionality and the ability to establish TCP connections to a webserver (thanks to sprite_tm and his e-ink example: http://git.spritesserver.nl/espeink.git/). However, I'm hitting a problem where espconn_connect() returns ESPCONN_RTE. Here's my bit of code:
However, if I called espconn_gethostbyname() (with a URL instead of an IP address) before espconn_connect(), then the ESP8266 connects to it fine. Does espconn_connect() work without calling espconn_gethostbyname()? Or does anyone know what espconn_connect() returning ESPCONN_RTE means?
Code: Select all
void ICACHE_FLASH_ATTR httpclientFetchIP(ip_addr_t *ip) {
...
struct espconn *pespconn = (struct espconn *)os_zalloc(sizeof(struct espconn));
pespconn->type = ESPCONN_TCP;
pespconn->state = ESPCONN_NONE;
pespconn->proto.tcp = (esp_tcp *)os_zalloc(sizeof(esp_tcp));
pespconn->proto.tcp->local_port = espconn_port();
pespconn->proto.tcp->remote_port = 80;
*((uint8 *) &pespconn->proto.tcp->remote_ip) = (ip->addr >> 24) & 0xff;
*((uint8 *) &pespconn->proto.tcp->remote_ip + 1) = (ip->addr >> 16) & 0xff;
*((uint8 *) &pespconn->proto.tcp->remote_ip + 2) = (ip->addr >> 8) & 0xff;
*((uint8 *) &pespconn->proto.tcp->remote_ip + 3) = (ip->addr) & 0xff;
espconn_regist_connectcb(pespconn, httpclientConnectedCb);
espconn_regist_disconcb(&conn, httpclientDisconCb);
// espconn_regist_reconcb(pespconn, httpclientDisconCb);
int8_t res = espconn_connect(pespconn);
os_printf("espconn_connect() returned %d", res);
}
However, if I called espconn_gethostbyname() (with a URL instead of an IP address) before espconn_connect(), then the ESP8266 connects to it fine. Does espconn_connect() work without calling espconn_gethostbyname()? Or does anyone know what espconn_connect() returning ESPCONN_RTE means?