whitecatboard / Lua-RTOS-ESP32

Lua RTOS for ESP32
Other
1.18k stars 221 forks source link

Communication protocol #341

Closed Azzeccagarbugli closed 4 years ago

Azzeccagarbugli commented 4 years ago

Hi everybody!

First of all I would like to say thanks to the all the developers of this project for their awesome job.

I'm actually trying to develop a really interesting pattern using the capabilities of this software and I just found out an issue that I don't know really how to solve.

In my system I'm using more than one Whitecat ESP32N2 board, all with Lua-RTOS on board, and I would be able to create a communication protocol that would let me to find out which boards are connected to the same network and create a share list of theme in a peer-to-peer scheme so that each one of them knows how many are available in the house.

A really similar solution is adopted by the Cisco's team with the Cisco Discovery Protocol that allows the user to find out which platform are connected to the same network and share information about each other.

Another really close example could be the one about the discovery service of DHCP.

Do you know how could I implement this in Lua or is there already a similar working solution out there?

I hope that I was clear enough.

Thanks to everybody, cheers!

the0ne commented 4 years ago

Hi @Azzeccagarbugli you should be able to use mdns ("bonjour") for this. Not sure if it is enabled in the default builds, though.

Azzeccagarbugli commented 4 years ago

Hi @the0ne,

Thanks a lot for the quick answer, anyway I tried to look for this protocol that you suggested and the only useful link that I found was the one specified in the Wiki section, to be more precise this one.

As soon as I found it I thought that all my problems would disappear but unfortunately was not like this.

image

Indeed, I tried more than once the procedure described in the Wiki but without success because each time that I try to run the following command:

net.service.mdns.start("ESP32")

The board gives me this error:

stdin:1: attempt to index a nil value (field 'mdns')
stack traceback:
        stdin:1: in main chunk
        [C]: in ?

I really don't understand why this is happening. Could you explain me why?

Thanks!

the0ne commented 4 years ago

This message comes up because mdns is not enabled in the build you are using. You need to compile your own build.

Azzeccagarbugli commented 4 years ago

This message comes up because mdns is not enabled in the build you are using.

Ah ok, now I get it and I assume that each type of message like this is coming up because I'm running a build that doesn't support that feature, right?

You need to compile your own build.

The question comes naturally then, how can I build my own build that support this type of functionality?

the0ne commented 4 years ago

I'm currently abroad with no computer available, so as a short answer, see https://github.com/whitecatboard/Lua-RTOS-ESP32/blob/master/README.md#method-2-build-by-yourself

Azzeccagarbugli commented 4 years ago

So the pre-compiled version is not ok for this purpose? I really had no idea.

I will try to compile the build from my self and hope that everything will be working.

P.S: How do I know which feature are not available in the pre-compiled version? I though that there weren't differences between the two methods described in the README

the0ne commented 4 years ago

After the initial build you will need to open newly created file named sdkconfig. Change LUA_RTOS_LUA_USE_MDNS= to LUA_RTOS_LUA_USE_MDNS=y. Then rebuild and flash.

stexniolo commented 4 years ago

Hello @the0ne, i'm a friend of @Azzeccagarbugli and i'm also trying to configure mdns on my whitecat board. First of all, thanks for your time and i hope you help us once again. I changed LUA_RTOS_LUA_USE_MDNS= to LUA_RTOS_LUA_USE_MDNS=y as you said, but when i try to rebuild my board i run into this error: Errore xtensa

My questions are: 1) Did i miss any command? Is it enough to write "source ./env" and then "make flash" to rebuild my board? 2) In the error message it seems that i miss something called "xtensa-esp32-elf-gcc". How can i solve it?

Thanks again!

the0ne commented 4 years ago

See https://docs.espressif.com/projects/esp-idf/en/latest/get-started-legacy/linux-setup.html#toolchain-setup in how to install the xtensa gcc for esp32 on your pc.

stexniolo commented 4 years ago

Hello @the0ne , sorry for the delay. @Azzeccagarbugli and i have successfully configured mdns on our boards. Thank you very much for your support. Hope this protocol will be useful for our purpose!