HubFeed

The hubFeed feature of AnalogIn and AnalogOut makes it possible to send data from one device to another. For example, an application running on an iPad can broadcast its accelerometer data to  a computer which might use it to scrub through a video, and an iPhone that uses it to control the volume of a sound. More info after the video.

How it Works

Sending Data

The device that’s generating the data sends it out using AnalogOut with the controller parameter set to “hubFeed” and the hubFeedName parameter set to a unique name for that data feed. The data sent via the AnalogOut is then feed to a local or remote Hub.

If the application needs send more than one number in the data, it can either use multiple AnalogOut widgets, each with a different hubFeedName, or use code to send out sets of data in a single feed by using the sendOutput() function call with a string that contains space delimited numbers: e.g. analogOutInstance.sendOutput(“10 45 8.5”);

Receiving Data

Any other device can then subscribe to a data feed by using an AnalogIn widget also set to hubFeed for the controller, and using a matching name for hubFeedName, and setting the remoteHubIP to the IP address of the computer running the “master” Hub designated as the one where all hubFeed communications are pointed.

To receive multiple feeds, the receiving device could use multiple AnalogIns, each using a different hubFeedName string. Or, if the sending device uses the sendOutput() example from above with multiple parameters, the receiving device can use a single AnalogIn, and use the multiInput code technique described on the AnalogIn page.

The “master” Hub IP

In all of these examples, it’s important that all devices are talking to the same Hub for sending and receiving any hubFeed data. The IP address of the computer running this “master” hub is then used in remoteHubIP of any widgets that need access to hubFeed.

If two computers are involved, one of them would set the remoteHubIP parameter in AnalogIn or AnalogOut to the default of the local host (127.0.0.1), in effect setting that computer as the master. Any other computers would set remoteHubIP to the IP of the first, “master” computer. E.g. the IP of the master computer might be 10.0.1.9 on a local network.

In the case of mobile devices like an iPad, the MobileControl widget should be set to the IP of the computer that is the “master” location of the Hub.


Last modified April 3rd, 2012