mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
fix local port; fix max sockets
This commit is contained in:
parent
09137f8dab
commit
fc3986ad8c
@ -1528,6 +1528,9 @@ void jswrap_ESP8266_wifi_init1() {
|
||||
|
||||
// register the state change handler so we get debug printout for sure
|
||||
wifi_set_event_handler_cb(wifiEventHandler);
|
||||
|
||||
// tell the SDK to let us have 10 connections
|
||||
espconn_tcp_set_max_con(MAX_SOCKETS);
|
||||
DBG("< Wifi init1, phy=%d mode=%d\n", wifi_get_phy_mode(), wifi_get_opmode());
|
||||
}
|
||||
|
||||
|
||||
@ -32,13 +32,6 @@ typedef long long int64_t;
|
||||
|
||||
#define espconn_abort espconn_disconnect
|
||||
|
||||
/**
|
||||
* The maximum number of concurrently open sockets we support.
|
||||
* We should probably pair this with the ESP8266 concept of the maximum number of sockets
|
||||
* that an ESP8266 instance can also support.
|
||||
*/
|
||||
#define MAX_SOCKETS (10)
|
||||
|
||||
// Set NET_DBG to 0 to disable debug printf's, to 1 for important printf's
|
||||
#define NET_DBG 1
|
||||
// Normal debug
|
||||
@ -998,6 +991,7 @@ int net_ESP8266_BOARD_createSocket(
|
||||
pEspconn->state = ESPCONN_NONE;
|
||||
pEspconn->proto.tcp = (esp_tcp *)os_zalloc(sizeof(esp_tcp));
|
||||
pEspconn->proto.tcp->remote_port = port;
|
||||
pEspconn->proto.tcp->local_port = espconn_port(); // using 0 doesn't work
|
||||
pEspconn->reverse = pSocketData;
|
||||
espconn_set_opt(pEspconn, ESPCONN_NODELAY); // disable nagle, don't need the extra delay
|
||||
|
||||
@ -1042,6 +1036,12 @@ static int connectSocket(
|
||||
espconn_regist_recvcb(pEspconn, esp8266_callback_recvCB);
|
||||
|
||||
// Make a call to espconn_connect.
|
||||
#if 0
|
||||
DBG("%s: connecting socket %d/%p/%p to %d.%d.%d.%d:%d from :%d\n",
|
||||
DBG_LIB, pSocketData->socketId, pSocketData, pEspconn,
|
||||
IP2STR(pEspconn->proto.tcp->remote_ip), pEspconn->proto.tcp->remote_port,
|
||||
pEspconn->proto.tcp->local_port);
|
||||
#endif
|
||||
int rc = espconn_connect(pEspconn);
|
||||
if (rc != 0) {
|
||||
DBG("%s: error %d connecting socket %d: %s\n", DBG_LIB,
|
||||
|
||||
@ -18,6 +18,14 @@
|
||||
#define LIBS_NETWORK_ESP8266_NETWORK_ESP8266_H_
|
||||
|
||||
#include "network.h"
|
||||
|
||||
/**
|
||||
* The maximum number of concurrently open sockets we support.
|
||||
* We should probably pair this with the ESP8266 concept of the maximum number of sockets
|
||||
* that an ESP8266 instance can also support.
|
||||
*/
|
||||
#define MAX_SOCKETS (10)
|
||||
|
||||
void netInit_esp8266_board();
|
||||
void netSetCallbacks_esp8266_board(JsNetwork *net);
|
||||
void esp8266_dumpSocket(int socketId);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user