I am writing a STM32H745 app, to connect to an external 3rd party device with a web POST API, via onboard LANxxxx IC ethernet.
The data transactions are reasonably standard web POST requests, with the caveat, that the inbound request may arrive in several/multiple packets / chunks.
The external web API request formatting ALWAYS has a known EOF delimiter pattern, at the end of the total request. (which I'm using as one of the exit conditions for recv_data
The issue I'm having, is that I can receive 10 to 15 inbound requests absolutely fine (I've used both WireShark, and HAL_UART printing of httpBuffer to confirm this)
After so many requests, the content of httpBuffer appears to be either shorter or longer, and contain small segments of old netbuff content in some places.
(IE the request looks nearly right, but, that scrambled bit their, is where we've switched from current request string, got a few chars of last request, then switched back to current request)
I have verified this, by temporarily adding memset(but, '*', buflen); after memcpy(httpBuff+totalLen,buf,buflen); and found that I'd suddenly get a block of 10..30 asterisks somewhere in my final erroring request IE
"POST / http 1.1 .blah blah Content-Len**************************Oh look, in this case header has been truncated, a few stars, then valid content"
I believe there is an LwIP buffer re-use issue somewhere..
Can someone please advise, if this is a code issue, or a LwIP config issue, and what the resolution could be?
I have attached 2 files
The 1st is a snippet, with just the multi packet receive, the 2nd has web loop and more context