I am trying to build an app for ESP8266EX that forwards all received TCP data to GPRS modem via UART. Here is how I did it:
// In my code I declare callback for receiving TCP data like so:
espconn_regist_recvcb(pespconn, ctrl_platform_recv_cb);
Then I have the function that processes received TCP data like so:
// This is the function that uses received data
static void ICACHE_FLASH_ATTR ctrl_platform_recv_cb(void *arg, char *pdata, unsigned short len)
{
struct espconn *pespconn = arg;
forwardDataToGprs(pdata, len);
}
My function forwardDataToGprs(char*, unsigned short) communicates to GPRS modem and issues AT commands to prepare modem to accept that data and then it sends data to it. That function executes for a second or even more.
Problem: It all works fine if ESP8266EX doesn't receive next TCP data while function forwardDataToGprs() is executing. The ESP crashes when function forwardDataToGprs() has not returned yet but new TCP data arrived! ESP actually has some sort of internal buffer to buffer that TCP data, but after it receives, say 3 TCP packets, and if function forwardDataToGprs() hasn't returned in the meantime, it will crash.
Anyone have any ideas how to fix this problem?