linuxnetwork-programmingwifiupnpplug-and-play

Simple Universal Plug and Play ( uPNP ) to find Raspberry Pi on Network


I have a RaspberryPi connected to my home network via WiFi with a dynamic ip address. I then have my iPhone connected to the same network also via WiFi. The Pi has a lightweight c++ HTTP server running on it that can execute commands. I now want to write an Objective-C app that can find the Pi on the network, regardless of it's ip address, and send it commands. So, Universal Plug and Play seems like the logical solution - but everything I find on Google is dealing with Media players and streaming audio/video content.

I just want the Pi to somehow simply broadcast on my network - "Hey, I'm RasberryPi and my IP Address is 192.168.0.5!".

Can somebody please suggest a package or solution to this problem? Thanks!


Solution

  • For the RPi side I would suggest GUPnP as long as you can fulfill the dependency requirements. It's a very modular framework so you don't need to load or use any of the multimedia related things if you don't need them. It's based on glib and libsoup and allows you to fairly easily define and implement your own UPnP services. Take a look at the BinaryLight example: It implements a BinaryLight Device that contains a SwitchPower service with several methods and two state variables (properties). You should be able to hit the ground running if you start with that. There's documentation on how to write a server.

    The components you are going to need/want:

    Also possibly for testing (this on a desktop linux machine since it requires gtk):

    EDIT: If you really don't want to implement any UPnP functionality, it's possible you could just use GSSDP for the IP discovery. This could be very simple: see test-publish example.