/* Run handler function in the netif thread context and wait for function return.  */
void os_hook_dispatch_wait(wifi_task_cb handler, struct params_dispatch *p, void *pv)
/* Run handler function in the netif thread context and wait for function return.  */
void os_hook_dispatch_wait(wifi_task_cb handler, struct params_dispatch *p, void *pv)
{
	hif_msg_t msg;
	if (hif_thread == xTaskGetCurrentTaskHandle()) {
		p->signal_semaphore = 0;
		handler(pv);
	}
	else {
		p->signal_semaphore = 1;
		msg.id = MSG_CMD;
		msg.handler = handler;
		msg.priv = pv;
		xQueueSend(hif_queue, (void *)&msg, portMAX_DELAY);
		xSemaphoreTake(hif_notify_sem, portMAX_DELAY);
	}
}