Filed under Junction
NFC Brings our Devices Together
Recently, many of us in the Stanford MobiSocial lab have grown very excited about the prospect of having NFC in smartphones. NFC, or near-field communication, allows two devices to interact simply by bringing them close together. NFC readers read in data called “tags”, which are a collection of records with well-defined formats. Records can be urls, business cards, or other domain-specific data type.
It appears that NFC may become standard in the next generation of smartphones, largely driven by the promise of mobile payments, a new revenue stream for companies in the mobile space. Beyond payments, other promising applications of NFC include ticketing for events and transportation, contact information exchange, quickly looking up product information, and more.
NFC supports different modes of operation– a reader (such as a smartphone) can scan a tag to pull data from it. These tags are cheap and small, and can be stuck just about anywhere, providing a digital identity for some thing or some place. NFC also supports P2P transactions, allowing two devices to pass data back and forth. With NFC available on future smartphones, this opens up exciting new possibilities.
NFC on Google’s Nexus S
When Google and Samsung announced the Nexus S, it marked the first time that NFC would appear on an Android phone. However, it was revealed that support for NFC would be limited to simply reading tags in the Gingerbread release. Not many people have NFC tags yet, so this was a bit of a let-down. But it was discovered that the limitations were purely in software, and so we anxiously awaited news of further development of the NFC stack.
That was, until we were fortunate enough to get our hands on a pair of Nexus S phones to play with. We were inspired to look into the state of NFC on Android a bit more in depth to see if it’d be possible to push our own P2P applications.
As it turns out, P2P mode wasn’t completely ignored in the Gingerbread cycle. After looking through some of the commits for Gingerbread (long live open source!), we found an initial implementation of P2P in Android. And, with a bit of work, we were able to run P2P mode successfully between our two devices.
The initial implementation was called MyTag, and allowed a phone to present an NFC tag to another phone. Note that although NFC has a mode for “card emulation”, this implementation uses a true P2P connection to send a tag between phones, with a socket established between the MyTagServer and MyTagClient.
Most of our changes for enabling P2P mode were in the Nfc package. And since this package is a bundled part of Gingerbread, the applications we built using P2P mode require a custom version of the Android OS. So our applications remain proof-of-concepts for now.
Using NFC and Junction
We have written a few basic demonstrations of NFC in Android. We use our own custom NFC api to achieve them, and can only hope that Android’s api will eventually allow these types of interactions in the near future. Running these demonstrations currently requires a custom build of the Android OS. We also make use of the Junction platform (discussed below), which allows an application to be run across phones, even if a joining phone doesn’t yet have the application being used.
Our first demonstration shows how a file can be transferred between two phones, here a photo from the Gallery application. We modified the built-in Gallery application to allow a picture to be shared simply by opening it on one phone and touching it to another. The receiver is then prompted to download the file.
Note that in our implementation, the actual file is transferred between phones over HTTP. We simply use NFC to share a URL representing the image. NFC is not the speediest transfer protocol and requires the devices to remain in contact for the duration of the transfer, so we simply use it to kick off our transfer.
Our next demonstration is of a shared application– a collaborative whiteboard. Again, we use NFC to simply transfer a URL and Junction does the rest. The URL contains enough information to tell the joining device (a) which application is being used, and (b) which application session to join. Junction also tells joining parties where the software can be found if it’s not yet available on the device.
Note that Junction applications are truly multiparty, and we could join even more phones by simply touching an interested party to any device that’s already in the session.
Junction and Device-Spanning Applications
We’ve been working on a platform called Junction, with the goal of making device-spanning applications easy to write and easy to use. We’ve written games like poker that work across phones and TVs, secure authentication between a desktop browser and a phone, and the whiteboard application shown above, which can be run across an array of devices including PCs, tablets, and phones.
A key challenge in making these applications usable is having applications discover each other across devices. We quickly learned that there’s no silver bullet to accomplish this; Network discover such as SSDP (used in UPnP) work well when the applications are on the same network, but don’t support web applications or phones with 3G connections. QR codes can be used when connecting a device with a screen to another device with a camera. Bluetooth beaconing works well for devices in proximity, when the devices all have programmable access to Bluetooth.
Because Junction has a focus on mobile platforms (with support for Android and iPhone/iPad), we’ve been excited about NFC. NFC potentially allows a device to share its context without interrupting the user experience. The whiteboard is still running in full-screen while being shared with another phone.
Junction applications share just enough information to identify the application being run, and identify the application session to join. Junction also supports a process by which an application can be downloaded if it is not yet available on the participant’s platform.
Junction and NFC complement each other well for launching applications across devices. NFC provides the bootstrapping necessary to start the application, and Junction allows the application to run across devices. As we said, we have no knowledge of what the future of NFC apis will look like in smartphones, but hope that these types of interactions will be possible. But you can start building Junction applications now.