netconn_new_with_callback - callback never called even though packet is sent [WIFI-2138]

triffid_hunter
Posts: 1
Joined: Wed Apr 08, 2020 3:34 pm

netconn_new_with_callback - callback never called even though packet is sent [WIFI-2138]

Postby triffid_hunter » Wed Apr 08, 2020 3:49 pm

Hi,

I have a project which requires high speed (several megabits/s) non-blocking UDP send.

I usually prefer zero copy for data rates like these.

Poking around in the documentation seems to suggest that netconn is good for this.

However, when I create my socket with netconn_new_with_callback, my callback is never called which means I can't reclaim completed buffers.

My net functions are as follows:

Code: Select all

void net_event_cb(struct netconn* nc, enum netconn_evt evt, u16_t len)
{
	printf("net_event(%d)\n", evt);
	switch (evt)
	{
		case NETCONN_EVT_SENDPLUS: {
			printf("UDP sent %d bytes\n", len);
		}
	}
}

void net_init(void)
{
	netconn_thread_init();

	assert((conn = netconn_new_with_callback(NETCONN_UDP, net_event_cb)) != NULL);

	netconn_set_nonblocking(conn, 1);

	ip_addr_t addr;
	addr.type = ESP_IPADDR_TYPE_V4;
	addr.u_addr.ip4.addr = IPTUPLE_TO_UINT(IPADDR);

	assert(netconn_connect(conn, &addr, PORT) == ERR_OK);
}
and to send a packet I'm doing:

Code: Select all

	assert(netbuf_ref(netbuf, rx_buffer, length) == ERR_OK);
	assert(netconn_send(conn, netbuf) == ERR_OK);
None of the asserts trigger, my packet is sent successfully, but my callback is apparently never called.

How can I work out what's up with the callback?

ESP_Alvin
Posts: 121
Joined: Thu May 17, 2018 2:26 am

Re: netconn_new_with_callback - callback never called even though packet is sent [WIFI-2138]

Postby ESP_Alvin » Thu Apr 09, 2020 3:10 am

Moderator's note: edit the topic title for issue tracking, thanks.

xueyunfei
Posts: 1
Joined: Tue Apr 28, 2020 3:09 am

Re: netconn_new_with_callback - callback never called even though packet is sent [WIFI-2138]

Postby xueyunfei » Tue Apr 28, 2020 3:32 am

hi
I suggest you use socket to send data, because it is invalid to set callback directly under Conn.

Who is online

Users browsing this forum: Baidu [Spider], citoyx and 39 guests