ESP-IDF UDP

Kaisha
Posts: 42
Joined: Thu Mar 05, 2020 8:59 pm

ESP-IDF UDP

Postby Kaisha » Thu Mar 05, 2020 9:54 pm

I was looking to use UDP for communication between multiple ESP32 chips. The only example I could find was the lwip/sockets one, which seems like a lot of overhead/resources for some very small/simple UDP packets. Is there any lower level/simpler API that could be used instead?

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: ESP-IDF UDP

Postby PeterR » Sat Mar 07, 2020 2:34 am

Whats not to love about:

Code: Select all

socket(AF_INET, SOCK_DGRAM, 0);
?
What else do you have going on that would stop you using Berkley sockets?
Socket storage is not huge. Buffer allocation may be an issue though.
re: Resource utilisation: You used to be able to change the Ethernet RX/TX buffers in 3.x. Not found/confirmed that option in 4.x.
You can change Wifi buffers in 3.x and 4.x. I know that Ethernet buffers changes wear well (for my application which has multiple sockets), not so sure about wifi.
It does depend what you are doing but are you really resource constrained?
EDIT: To be clear, you do get a big RAM hit when you first use the lwip stack on Ethernet. This includes some large static stuctures and larger dynamic buffers, the latter you can control through menuconfig (3.x). Wifi uses even more memory for Wifi functions and also dynamic wifi buffers. It is Wifi's nature (regardless of processor) I am afraid to trash your memory.
& I also believe that IDF CAN should be fixed.

Kaisha
Posts: 42
Joined: Thu Mar 05, 2020 8:59 pm

Re: ESP-IDF UDP

Postby Kaisha » Tue Mar 10, 2020 12:32 pm

I just don't like sockets or LWIP. I've used both before, they often have hard to find errors and quirks and the spaghetti code mess that is their implementation makes it near impossible to debug.

I'd prefer to manage my own buffers.

Sadly it seems that it is not supported :(

PeterR
Posts: 621
Joined: Mon Jun 04, 2018 2:47 pm

Re: ESP-IDF UDP

Postby PeterR » Wed Mar 11, 2020 11:11 am

Well, that is a point of view I guess.
I am guessing however that n thousand people using, testing and perhaps contributing to lwip would produce a better result than you or I.
The raw emac & phy interfaces are open to all '/components/ethernet' and so you can bypass lwip & sockets should you wish.
& I also believe that IDF CAN should be fixed.

Kaisha
Posts: 42
Joined: Thu Mar 05, 2020 8:59 pm

Re: ESP-IDF UDP

Postby Kaisha » Sat Mar 14, 2020 1:48 pm

Thank-you, I'll take a look.

Who is online

Users browsing this forum: ok-home and 107 guests