1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-03-14 11:29:26 +01:00

Fixed issue on connected() function

This commit is contained in:
Mimmo La Fauci 2012-03-20 09:46:17 +01:00
parent d847c381c2
commit 22504d0c8c
4 changed files with 11 additions and 5 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1008,12 +1008,16 @@ cmd_spi_state_t get_client_state_tcp_cmd_cb(char* recv, char* reply, void* ctx,
uint8_t _state = CLOSED; uint8_t _state = CLOSED;
if ((recv[3]==1)&&(recv[4]>=0)&&(recv[4]<MAX_SOCK_NUM)) if ((recv[3]==1)&&(recv[4]>=0)&&(recv[4]<MAX_SOCK_NUM))
{ {
void * p= mapSockTCP[(uint8_t)recv[4]];
// get if we are in server or Transmit mode (0) // get if we are in server or Transmit mode (0)
if (getModeTcp(mapSockTCP[(uint8_t)recv[4]]) == TTCP_MODE_TRANSMIT) if (getModeTcp(p) == TTCP_MODE_TRANSMIT)
{ {
_state = _connected ? ESTABLISHED : CLOSED;
_state = getStateTcp(p, 1);
INFO_TCP("p=%p _ttcp=%p state:%d\n",
p, ((struct ttcp*) p)->tpcb, _state);
}else { }else {
_state = getStateTcp(mapSockTCP[(uint8_t)recv[4]], 1); _state = getStateTcp(p, 1);
} }
} }
PUT_DATA_BYTE(_state, reply, 3); PUT_DATA_BYTE(_state, reply, 3);

View File

@ -211,9 +211,9 @@ tcp_sent_cb(void *arg, struct tcp_pcb *pcb, u16_t len)
static err_t tcp_connect_cb(void *arg, struct tcp_pcb *tpcb, err_t err) { static err_t tcp_connect_cb(void *arg, struct tcp_pcb *tpcb, err_t err) {
struct ttcp* ttcp = arg; struct ttcp* ttcp = arg;
INFO_TCP("TTCP [%p]: connect %d %d\n", ttcp, err, ttcp->tpcb->state); INFO_TCP("TTCP [%p-%p]: connect %d %d\n", ttcp, tpcb, err, ttcp->tpcb->state);
_connected = true; _connected = ( ttcp->tpcb->state == ESTABLISHED) ? 1 : 0;
ttcp->start_time = timer_get_ms(); ttcp->start_time = timer_get_ms();
@ -315,6 +315,8 @@ static int atcp_start(struct ttcp* ttcp) {
tcp_err(ttcp->tpcb, atcp_conn_err_cb); tcp_err(ttcp->tpcb, atcp_conn_err_cb);
tcp_recv(ttcp->tpcb, atcp_recv_cb); tcp_recv(ttcp->tpcb, atcp_recv_cb);
_connected = false; _connected = false;
INFO_TCP("[tpcb]- %p\n", ttcp->tpcb);
if (tcp_connect(ttcp->tpcb, &ttcp->addr, ttcp->port, tcp_connect_cb) if (tcp_connect(ttcp->tpcb, &ttcp->addr, ttcp->port, tcp_connect_cb)
!= ERR_OK) { != ERR_OK) {
WARN("TTCP [%p]: tcp connect failed\n", ttcp); WARN("TTCP [%p]: tcp connect failed\n", ttcp);