4
votes

I have an Arduino Uno R3 with a WiFi shield. The WiFi shield has the most current firmware (V1.1.0). In short, I am trying to communicate with the Arduino from an Android smartphone. I have successfully been able to do this locally by using local IPs assigned by the router; however, now I am wanting to extend this by not having the Android on the same network. For example, communicating with the Arduino from anywhere in the world on the Android device. I know I can do this by simply going to my router configurations and setting up a port forward to the Arduino; however, I would like to get around this by using Universal Plug and Play (UPnP). In order to be able to locate an Internet Gateway Device on the network, I must be able to send a UDP message using the multicast address 239.255.255.250:1900. This is where my problem occurs. It seems as if the WiFi shield isn't capable of sending a UDP packet via the multicast address with the latest WiFi library. Is there a way to modify the WiFi library such that this could be possible?

Note: I can successfully send and receive UDP packets using unicast addresses on the Arduino, just not using multicast.

Also, there is a library that does this via Arduino and Ethernet shield located at: https://github.com/deverick/Arduino-Upnp-PortMapping. I have attempted to modify this library to work for the WiFi shield. I assume that the Ethernet library is capable of sending UDP packets using the multicast address since this library does exactly that.

EDIT: When I said the WiFi shield "isn't capable", I meant that as in I am not able to send a UDP packet using the multicast address. I receive no errors that I am aware of; the code runs without error other than the fact that it doesn't actually send a packet. I am using the latest WiFi library for Arduino on GitHub: https://github.com/arduino/Arduino/tree/master/libraries/WiFi. I simply begin a packet with 239.255.255.250 and port 1900, write a string to the socket, and then end the packet to send it. The packet never actually gets transmitted. If I send a packet to my PC using it's local IP, it works like a charm. It appears that the WiFi library doesn't support the ability to send a packet using the multicast address.

1
Can you update to explain what you mean by "isn't capable" Do you have code that does not run, or do you have code that should work, but fails to open the port.jdr5ca
I posted an update. Hopefully this is more helpful. I can post code if need be.StayPuff
Second 235. is typo yes? You meant 239. How I would troubleshoot: Try changing the address to 255.255.255.255. Then I expect you will see(w Wireshark or similar) the packet correctly broadcast on your network. Then 239.255.255.255, and you should still see broadcast. When you change to .250, no more. That would confirm the multicast address is the issue.jdr5ca
Yes, sorry. I fixed it. I meant 239. I'll try this out. Maybe I can come up with a work around. Thanks!StayPuff
While testing some things, I found that the UPNP library above doesn't actually use multicast. The W5100 on standard ethernet shield will substitute the MAC of the gateway when you send to an IP outside your subnet. For many people, the router is the gateway. So that code works by mistake. If the router UPNP implementation was strict, it might refuse to respond to such malformed packets.jdr5ca

1 Answers

0
votes

Sketch Arduino and PIC firmware for Wifly RN-XV modem configuration without Wifly library and with front-end: https://dl.dropboxusercontent.com/u/101922388/WiflySanUSB.zip Type in browser address bar: 192.168.1.195/YT to toggle Led and open a HTML page. The microcontroller can be, with this firmware and Wifly, a server (switching the led signal through 192.168.1.195/YT in adress bar) or also client (the AD converter value is inserted in google databank).