I have setup a Wiznet 5500 module as a simple TCP client on an STM32G0B1KET6.
Here are the two snippets which make the connection to the server as well as create the socket.
bool connectSocket()
{
int8_t sockret=socket(1,Sn_MR_TCP,80,0);
if(sockret==1)
{
Send_UART1("SOCKET OKrn");
return true;
}
else
{
Send_UART1("SOCKET failedrn");
return false;
}
}
bool connectServer()
{
int8_t ret=connect(1, destination_ip, destination_port);
if(ret==SOCK_OK)
{
Send_UART1("TCP connectedrn");
return true;
}
else
{
char err[32];
memset(err,0,32);
sprintf(err,"TCP not connected-%irn",ret);
Send_UART1(err);
return false;
}
}
void sendTCP(uint8_t * msg,uint16_t len)
{
int32_t x=send(1,msg,len);
char snt[20];
memset(snt,0,20);
sprintf(snt,"SENT:%lirn",x);
Send_UART1(snt);
}
void readTCP(uint8_t * msg,uint16_t len)
{
int32_t x=recv(1,msg,len);
char snt[20];
memset(snt,0,20);
sprintf(snt,"RCV:%lirn",x);
Send_UART1(snt);
}
I can connect to the Module and make a GET request.
I can make a send() to the Server successfully.
I can make an initial recv() successfully.
I can write a second time to the server.
Up until this point the getSn_SR(1) returns 0x17 (SOCK_ESTABLISHED)
But, on the second recv() the socket getSn_SR(1) returns 0x00 (SOCK_CLOSED)
Any help would be appreciated!
I have literally tried everyhting, to no avail. This is just some notes on my attempts.
- The second write is identical to the first write. So I dont think its a error in the GET request.
- The GET request has a keep-open conn status
- I can do the same GET request using a C# app I wrote and the server answers every time.
- I am convinced I havent got the correct values in the
int8_t sockret=socket(1,Sn_MR_TCP,80,0);
call. But finding the correct documentation is a quagmire on the wiznet website.