I've two problems.
I've implementing some code between LwIP and WWD. My code contains one thread with queue (I use own queue implementation).
I found point of integration of my code between LwIP and WWD. To receive data from LwIP I've used own function instead of wiced_network_send_ethernet_data() function and in my code I call wiced_network_send_ethernet_data() function to send data to WWD. I receive data from WWD in function host_network_process_raw_packet().
So, my code receives data from WWD, then does some modification in own thread and then sends it to LwIP.
Also I've enabled monitor mode and changed in function wiced_wifi_prepare_join parameter for ioctl WLC_SET_INFRA to zero to enable Ad-Hoc mode.
First my problem is about function wiced_network_send_ethernet_data().
If I allocate own packet by function host_buffer_get and function wiced_network_send_ethernet_data() often fails inside itself in piece code:
/* Add link space at front of packet */
result = host_buffer_add_remove_at_front( &buffer, (int32_t) -WICED_LINK_OVERHEAD_BELOW_ETHERNET_FRAME );
if ( result != WICED_SUCCESS )
So, it means that function host_buffer_add_remove_at_front can't allocate additional space before buffer.
I found 2 workarounds here. First is to allocate new temp buffer by malloc, then copy current to buffer to it, and then create new buffer by function host_buffer_get with enough space.
Second workaround is to allocate huge buffer in my code and there use function host_buffer_add_remove_at_front to decrease size. It allows to allocate additional spaces later in function wiced_network_send_ethernet_data().
But it looks strage, what do you think?
My second problem is in WWD driver. When all this stuf is working (LwIP <-> My code <-> WWD driver + monitor mode + ad-hoc), WWD driver stalls after several seconds. So I'm able to send several packets between modules but after several second they don't want to send or receive any packets.
I see in debugger that wiced_thread_func (in file wwd_thread.c), where WWD shall send/receive packets, stalls in getting semaphore:
result = host_rtos_get_semaphore( &wiced_transceive_semaphore, (uint32_t) WICED_THREAD_POLL_TIMEOUT, WICED_FALSE );
Do anybody know what I did wrong in the code that could lead to this behaviour?
My boards: SSB-WM-N01
SDK version: 2.4.1