Code: Select all
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: Select all
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.