Hello everyone. I am working on a project that sends and receives UDP Multicast messages through my Arduino Mega with the Ethernet Shield.
Background:
The purpose is to detect any devices on my home network. I am trying to implement this by sending an M-SEARCH request to receive NOTIFY advertisements from the devices as seen in the Universal Plug and Play protocol document below:
In order to implement this I found a library from a user's post claiming to enable the multicast feature on the Ethernet Shield W5100 chip. The post link is:
Arduino: 1.6.2 (Windows 8.1), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
Build options changed, rebuilding all
NOTIFY_SSDP_RECEIVE_UPNP_UDP.ino: In function 'void setup()':
NOTIFY_SSDP_RECEIVE_UPNP_UDP.ino:31:2: error: 'Udp' was not declared in this scope
NOTIFY_SSDP_RECEIVE_UPNP_UDP.ino: In function 'void loop()':
NOTIFY_SSDP_RECEIVE_UPNP_UDP.ino:38:20: error: 'Udp' was not declared in this scope
Error compiling.
Why is Udp not "detected" by the compiler ?? The library is installed and it shows up on the library list. I would greatly appreciate your help in debugging the code:
As I responded to your other post, the file names have changed. There is no Udp.h file. It is now EthernetUdp.h.
I recommend modifying the new library. Add the multicast functions to it.
edit: I downloaded that library, and it appears to have one prototype in Udp.h that you should be able to add to EthernetUdp.h and Udp.h, and one function to add to EthernetUdp.cpp. Maybe I will try it.
I can see the changes in the library file names. Ive included a screenshot. The window on the left is the new downloaded library that is supposed to enable multicast. The window on the right is the pre-installed Ethernet library in Arduino
That is the library. It took a bit of modification to get it to compile. Don't know if it works tho.
edit: What is your goal? The w5100 will not monitor a different IP than assigned. It will broadcast on a broadcast IP, but must listen on the IP assigned by dhcp or a static assignment. The code shows it waits for a packet, then sends one, but that won't do any good. Your code must send a broadcast packet and wait for a response packet. This code: https://tkkrlab.nl/wiki/Arduino_UDP_multicast
My hope is to use the new library to write my own sketch that sends a UDP M-Search Multicast message and waits for the corresponding responses from the devices on the network. (Later I want to save the responses on an SD card and transmit them via Bluetooth to an Android app that I am also creating, but that's not an issue right now.)
Before I do that, I want to make sure the new library doesn't give errors as I compile the Arduino sketch in (TkkrLab)
Because I did not write this new library, I would like to first make sure it enables multicast on the W5100 and that it works for sending and receiving UDP multicast packets.
If the sketch on the link above compiles, then I will go ahead and attempt to use the new library to send the M-Search requests and responses.