ESP8266 Developer Zone The Official ESP8266 Forum 2016-01-12T14:20:36+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=1614 2016-01-12T14:20:36+08:00 2016-01-12T14:20:36+08:00 https://bbs.espressif.com:443/viewtopic.php?t=1614&p=5344#p5344 <![CDATA[RTOS SDK / ESPCONN: allocating in RX callback?]]>

Code:

static void
network_resoved_cb (void* arg, char* data, usigned short len)


I assume (please correct me if this is wrong) that "data" will be freed when the callback returns. Therefore, I need to move "data" to a safe place where it can wait for delayed processing.

I am thinking of doing something like this:

Code:

receive_callback(data, len):
  //using heap_4.c
  saved_data = pvPortMalloc(len)
  copy data -> saved_data
  xQueueSendToBack(saved_data)
 
processing_thread:
  saved_data = xQueueReceive()
  //do something with saved_data
  vPortFree(saved_data)


Is this a bad idea? Use of heap_4.c is supposed to limit heap fragmentation, but I thought it would be better to ask first.

Statistics: Posted by esp03madness — Tue Jan 12, 2016 2:20 pm


]]>