diff options
author | Mimmo La Fauci <mlafauci@metodo2.it> | 2013-03-26 19:49:19 +0100 |
---|---|---|
committer | Mimmo La Fauci <mlafauci@metodo2.it> | 2013-03-26 19:49:19 +0100 |
commit | 6265d401817934c4b2d9ee3bf8dab44de1bb08cb (patch) | |
tree | f284f5c1f16209da9a5be3364bcb4c9cd9ed9dfb /firmwares/wifishield/wifiHD/src/ard_tcp.c | |
parent | ed452961326cd5f9ad6d766bc8340a6193d16d64 (diff) |
Fix issue on client side
Diffstat (limited to 'firmwares/wifishield/wifiHD/src/ard_tcp.c')
-rw-r--r-- | firmwares/wifishield/wifiHD/src/ard_tcp.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/firmwares/wifishield/wifiHD/src/ard_tcp.c b/firmwares/wifishield/wifiHD/src/ard_tcp.c index c15858f..0a73b20 100644 --- a/firmwares/wifishield/wifiHD/src/ard_tcp.c +++ b/firmwares/wifishield/wifiHD/src/ard_tcp.c @@ -565,14 +565,21 @@ static int atcp_start(struct ttcp* ttcp) { atcp_init_pend_flags(ttcp); if (ttcp->mode == TTCP_MODE_TRANSMIT) { - setNewClientConn(ttcp, p, 0); - struct tcp_pcb * pcb = GET_FIRST_CLIENT_TCP(ttcp); + int8_t id = insertNewClientConn(ttcp, p); + ttcp->payload[id] = malloc(ttcp->buflen); + INFO_TCP("Alloc payload %d-%p\n", id, ttcp->payload[id]); + if (ttcp->payload[id] == NULL) { + WARN("TTCP [%p]: could not allocate payload\n", ttcp); + return -1; + } + + struct tcp_pcb * pcb = p; tcp_err(pcb, atcp_conn_cli_err_cb); tcp_recv(pcb, atcp_recv_cb); tcp_sent(pcb, tcp_data_sent); tcp_poll(pcb, atcp_poll_conn, 4); _connected = false; - INFO_TCP("[tpcb]-%p payload:%p\n", pcb, ttcp->payload[currConnId]); + INFO_TCP("[tpcb]-%p payload:%p\n", pcb, ttcp->payload[id]); DUMP_TCP_STATE(ttcp); if (tcp_connect(pcb, &ttcp->addr, ttcp->port, tcp_connect_cb) != ERR_OK) { |