PeerDeviceNet

Router API: Tutorials

Introduction   |   Remote intenting   |   Group communication   |   Device connection   |   Java API   |   Tutorials    |   Architecture   |   Contact

The following are simple descriptions of some sample apps which demonstrate how to use PeerDeviceNet APIs to create connected mobile apps. The source code projects of these sample apps are hosted at github. Please follow the links to download them.
  1. Connector using wifi and intenting API (github_project)
This sample connector using Router's ConnectionService intenting api to discover and connect to peer devices. It communicates thru external wifi router or WifiDirect network setup among a group of WifiDirect enabled devices.

It includes Router project as a library project. So it will instantiate a router service directly, running in a separate process.

The README file at github project web site provides more detailed description.
  1. Connector using wifi and AIDL API (github_project)
This sample connector using Router's ConnectionService aidl api to discover and connect to peer devices. It communicates thru external wifi router or WifiDirect network setup among a group of WifiDirect enabled devices.

It doesn't embed router directly, instead invokes an external router's APIs embedded in another app such as Connector_wifi_intent.
  1. Connector using Wifi Direct Hotspot (github_project)
This sample connector using Router's ConnectionService aidl api to discover and connect to peer devices. It uses android WifiP2pManager to create a p2p group with the current device as the group owner. This essentially creates a hotspot that can accept connections from legacy wifi devices as well as other p2p devices.

It doesn't embed router directly, instead invokes an external router's APIs embedded in another app such as Connector_wifi_intent.

The README file at github project web site provides more detailed description.
  1. Chat (github project)
This app demonstrates how to use PeerDeviceNet group communication APIs to implement a simple chat app which connect peer chatters directly without going thru a central server.
PeerDeviceNet provides three kinds of APIs and this app has a separate chat implementation for each API:
ChatActivity.java defines a main menu to allow you choose a specific chat implementation; and allow you start PeerDeviceNet connection manager to connect your devices.

All three chat implementations will talk to each other.
The README file at github project web site provides more detailed description.

  1. Rotate with peers (github project)
This sample is a slight change of android SDK example TouchRotateActivity.  The original TouchRotateActivity allows you rotate a 3D cube thru touch screen.  This sample add PeerDeviceNet group communication to allow several android devices rotate the cube together, a simple demo of multi-player GUI applications.
Group communication is used here to sync the state of this app at connected peer devices. There are two syncing here:
  1. when a device joins the group, it will send a message requesting the rotation "state" of peers already in the group; after receiving responses, it will start its rotation from that state.
  2. when the user of a device rotates the cube, the app will broadcast the rotation changes to all connected peers and peers will change its cube's orientation accordingly.
Users can be actively rotating cubes at multiple devices simultaneously and apps will broadcast rotation values to each other continuously so all apps/devices will keep synced up.
The README file at github project web site provides more detailed description.