1

What is the proper way to connect an app to a device? At the moment, I have a raspberry pi 3 that controls something about electricity and an iPhone app I created. Every time the app goes to foreground, it sends a UDP broadcast message, when the app receives a response from the raspberry pi, it uses that IP address (in the IP header) to consume the web services I created in the hub. This UDP process is done all the time you run the app. Is this what IOT devices usually do? I assume the raspberry pi IP will change sooner or later.

A colleague of mine told me another way: After the first time I get the IP address, instead of using UDP broadcast messages every time the app runs, use ICMP to ping the previously saved IP address to see if it is responding. In that case, I use the web services with that IP address, otherwise, use the UPD broadcast message again.

I don't see the point of that. Basically because the system is not faster using ICMP. (a UDP request is more or less as fast as an ICMP request). Moreover, maybe, another device started using that IP address now (like a smart TV or a smart plug) and for that reason, it is not going to reply to the network requests sent by the app. In that case, the app cannot recover, because it thinks it is already connected to the proper device. As far as I understand, ICMP is a protocol use for diagnosis, not for devices discovery.

What do you think? What's the process used by devices like Alexa, Philips Hue, Smart plugs... to solve the problem of discovering the devices by their apps? It seems Philips HUE is using SSDP, which under the hood uses a UDP broadcast message. Is it used every time you run the app to discover the IP address? (I am going to check this later with wireshark)

Thanks for suggestions.

Ricardo
  • 2,831
  • 4
  • 29
  • 42
  • Just a side note: Your discussion seem to discuss the issue in closed networks, e.g. home network. The alternatives you discuss can be used in that environment. However, they cannot and should not be used in the open Internet. In the open Internet, the IoT devices should not be addressable IP endpoints for security reasons (see attacks to Jeep, Web Cams, etc.) – Stefan Vaillant Mar 22 '19 at 12:37
  • @StefanVaillant Yes,I am talking about a LAN, not interested on Internet right now. – Ricardo Mar 24 '19 at 09:43

1 Answers1

1

You can enable the hostname of your Raspberry Pi to be accessible on your local network through:

http://raspberrypi.local

To enable it, you need to install Bonjour support on your Raspberry Pi by installing the Avahi mDNS daemon (implements Apple's Zeroconf architecture):

$ sudo apt-get install avahi-daemon

Update boot startup:

$ sudo insserv avahi-daemon

Restart to apply the new configuration:

$ sudo /etc/init.d/avahi-daemon restart
Ryan Amaral
  • 4,059
  • 1
  • 41
  • 39