Chat here about code rewrites, mods, etc... with respect to the github project https://github.com/esp8266/Arduino

Moderator: igrr

User avatar
By Rodrigo Miranda
#47530
lethe wrote:
Rodrigo Miranda wrote:By the way, is that the way it is usually done? For example in those commercial electronic products such as wifi led spotlights...

There's no standard method, there are several, each with their own advantages & drawbacks...
mDNS is a popular & standardized method, but has probably more overhead than others (needs additional UDP socket).
An alternative would be to implement custom UDP broadcast/multicast messages. If you are using UDP anyway, you can get away with only using a single socket for everything.
Some manufacturers only communicate through a cloud server (with the obvious disadvantage of your device being as useful as a paperweight without internet access, but with internet it works world-wide).


Can you explain me with more detail how to make a UDP broadcast? For what I have found i have to send the message to 198.162.255.255, I tried that but did not work, do I have to set the nodemcu to listen to a specific message or something?
User avatar
By lethe
#47536
Rodrigo Miranda wrote:Can you explain me with more detail how to make a UDP broadcast? For what I have found i have to send the message to 198.162.255.255, I tried that but did not work, do I have to set the nodemcu to listen to a specific message or something?

198.162.255.255 only works, if it is the valid broadcast address for your network (i.e. if your network is 192.168.0.0/16 see https://en.wikipedia.org/wiki/Broadcast ... networking). In most cases you should use the global broadcast IP 255.255.255.255.
When sending broadcasts from the ESP, you also need to choose the interface, where broadcasts will be sent to (defaults to SoftAP interface only, see wifi_set_broadcast_if() in SDK API doc).

To send broadcasts from a PC/phone, you probably need to enable the broadcast flag on that socket (if/how depends on OS & programming API).
User avatar
By mrburnette
#50514 I have a fairly simple one-to-many UDP broadcast project that has 9 months of actual stability in a hostile environment (attic- exposed to wild temperature and humidity changes.)

http://www.hackster.io/rayburne/tardis-time-esp8266-ap-webserver-gps-6b5d2a

Ray