/* This function is called when user wants to receive data from peer host.  */
static int winc1500_recv(struct net_context *context, net_context_recv_cb_t cb, int32_t timeout, void *user_data)
/* This function is called when user wants to receive data from peer host.  */
static int winc1500_recv(struct net_context *context, net_context_recv_cb_t cb, int32_t timeout, void *user_data)
{
	SOCKET socket = (int) context->offload_context;
	int ret;
	w1500_data.socket_data[socket].recv_cb = cb;
	w1500_data.socket_data[socket].recv_user_data = user_data;
	if (!cb) {
		return 0;
	}
	ret = prepare_pkt(&w1500_data.socket_data[socket]);
	if (ret) {
		LOG_ERR("Could not reserve packet buffer");
		return -ENOMEM;
	}
	ret = recv(socket, w1500_data.socket_data[socket].pkt_buf->data,
		   CONFIG_WIFI_WINC1500_MAX_PACKET_SIZE, timeout);
	if (ret) {
		LOG_ERR("recv error %d %s!",
			ret, socket_error_string(ret));
		return ret;
	}
	return 0;
}