Other Parts Discussed in Thread: CC3220SF
Tool/software: Code Composer Studio
Hi, everyone!
disclaimer: my board works like this algorithm:
power on -> how is wake up? -> tcp (open socket, send/recv, close sock) -> hibernate
two problems
1) when my device is power on first time (power +3.3v pluged) it connect to AP and try to do sl_Connect three times. ALWAYS, first time is returned -111 error (SL_ERROR_BSD_ECONNREFUSED)
int32_t bsdTcpClient(uint32_t ipAddr, uint16_t port, int16_t sid, uint16_t lenght, uint8_t tx) { int16_t sockId; int32_t status = -1; PowerMeasure_CB.ipV4Addr.sin_family = SL_AF_INET; PowerMeasure_CB.ipV4Addr.sin_port = sl_Htons(port); PowerMeasure_CB.ipV4Addr.sin_addr.s_addr = sl_Htonl(ipAddr); if (sid < 0) { /* Need to open socket */ sockId = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0); ASSERT_ON_ERROR(sockId); /* Make connection establishment */ status = sl_Connect(sockId, ( SlSockAddr_t *)&PowerMeasure_CB.ipV4Addr, sizeof(SlSockAddrIn_t)); if( status < 0 ) { sl_Close(sockId); ASSERT_ON_ERROR(status); return status; } } else { /* Socket is already opened */ sockId = sid; } }
When it continue working - no problems! Everything perfect. There is no problem when device and server locate in one local net. Only when >=2 routers between device and server.
2) I don't know why but when I do sl_Close(sockId); after send/recv data device doesn't sent F. frame and server trys to sent F. frame many time
let me show you tcpdump:
where 192.168.20.195:2222 is server and 192.168.20.194 is cc3220sf device
you can see: no ACK to close connection correctly.
and it wakes up and do new socket connection every one minute.
after sl_Close(); a do sl_Stop(timeout); and go to hibernate.
What I have to do to open and close socket connections correctly?