-->
Page 1 of 2

Trouble with wdt reset in espconn_regist_recvcb callback

PostPosted: Fri Feb 13, 2015 2:54 am
by elektronika_ba
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:

Re: Trouble with wdt reset in espconn_regist_recvcb callback

PostPosted: Fri Feb 13, 2015 3:35 am
by Sprite_tm
I think the easiest way is to dump the received data in a ring buffer, then have a secondary routine (triggered by eg the send interrupt of the uart, or maybe running as a separate thread) empty out that buffer to the serial port.

Re: Trouble with wdt reset in espconn_regist_recvcb callback

PostPosted: Fri Feb 13, 2015 5:26 am
by elektronika_ba
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

Re: Trouble with wdt reset in espconn_regist_recvcb callback

PostPosted: Sat Feb 14, 2015 9:51 pm
by Athena
Hi,

could you offer more information about your problem,like UART output log?

How do you know it still in forwardDataToGprs ?