Chat freely about anything...

User avatar
By elektronika_ba
#9616 Hi,
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:
Code: Select all// 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:
Code: Select all// 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? :roll:
User avatar
By elektronika_ba
#9629 I thought about something like that but wasn't really sure about it :)

Should I use their system_os_task() and system_os_post() API's (is that the threading method you mentioned?) or a timer that consumes that ring buffer in some intervals?
Do you have some ideas on how I should implement threading?

Thanks