Hi,
I try to use the LwIP netconn API, but I cannot read from the connection object. I have the followings:
* EK-TM4C1294XL board
* FreeRTOS V7.6.0
* LwIP from the TivaWare 2.1
what I would like to do is done with Raw API and works well, but I would like strongly to migrate this solution from Raw API to netconn API. The code has to send an HTTP GET message to the server, receive the response and process it. I'm working on the following testcode:
netconn* connection = NULL; connection = netconn_new(NETCONN_TCP); if (connection == NULL) {UARTprintf("failed to create new connection\n"); while(1);} if (ERR_OK != netconn_connect(connection, &_serverIP, port)) {UARTprintf("failed to connect server\n"); while(1);} UARTprintf("Successful connection to the server\n"); UARTprintf("state: %d\n", connection->state); if (ERR_OK != netconn_write(connection, _request.request, _request.len, NETCONN_COPY)) {while(1);} UARTprintf("data is sent successful\n"); netbuf* buf = NULL; if(ERR_OK != netconn_recv(connection, &buf)) {while(1);}
As you can see, I create a new connection, connect to the given server (the server IP is given), write the well formatted HTTP GET into the connection, try to block the thread until the netconn_recv returns.
I observed the followings:
* if I print the connection state, it print out a zero (it's the NETCONN_NONE): I don't know, is that wrong, neutral or god for me...
* if I debug the netconn_recv method, there is an precondition at the beginning of the method:
LWIP_ERROR("netconn_accept: invalid recvmbox", sys_mbox_valid(&conn->recvmbox), return ERR_CONN;);
where the execution returns. I guess, the conn->recvmbox would be for thread safety...
Can anybody help me, what did I wrong, or how can I wait and read / receive the answer from an TCP connection via netconn API?
Regards,
Norbert