Post on 08-May-2015
transcript
Open Source. Open Possibilities.
Overview of the AllJoyn™ Development Framework
Nick Clarey
January 11, 2013
PAGE 2 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
What is AllJoyn?
What About Other Peer-to-peer Solutions?
AllJoyn Fundamentals
Add AllJoyn to an Android Application
Add AllJoyn to a Unity Application
Q&A
Agenda
Open Source. Open Possibilities.
PAGE 3
What is AllJoyn?
PAGE 4 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Why Peer-to-peer (P2P) Is Hard
P2P Friction Developers Face Today
Ad Hoc Networking
Transient Devices
Platforms
Radios
Service Discovery
Device Discovery
Security
Pairing
PAGE 5 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
AllJoyn Makes Peer-to-peer Frictionless
EXCHANGE Information in
a secure manner
ADAPT to apps and
devices
coming
and going
MANAGE transports like Wi-Fi
and Wi-Fi Direct
and message routing
across them
DISCOVER devices and
applications
around you
INTEROPERATE across disparate
programming
languages,
operating systems,
and bearers
PAGE 6 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
What Is AllJoyn? Open Source Application Development Framework to Enable Ad Hoc, Proximity-based, Peer-to-peer Networking
AllJoyn brings proximity awareness to mobile apps, unleashing a whole new set
of user experiences to smartphones, tablets, PCs, TVs and more
PAGE 7 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
AllJoyn is a Software Framework
Third-Party
or OEM
Tablets
O
p
e
n
S
o
u
r
c
e
JamJoyn™ Media Multiplayer
Gaming Social Chat
Applications
C++ Java JavaScript Objective-C CLR
Discovery Security Network
Management Pairing
Cross-Platform
Wireless-Optimized
AllJoyn Development Framework
Wi-Fi Direct Wi-Fi BT
Chipset
Mobiles Televisions Laptop/PC
Open Sourced (Apache 2.0 License)
Enables Developers to Easily Add P2P Experiences to Their Apps
Application Layer Discovery (What services are running on nearby devices that are reachable)
Application Layer Security (What information can a service access on your phone, what’s off limits)
Interoperate Across Different OS and Bearers (Developer does not need to know anything about Wi-Fi, Wi-Fi Direct, Android, Windows, etc.)
PAGE 8 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
What New Experiences Can AllJoyn Enable?
ENTERTAINMENT & GAMING EXPERIENCES
MULTISCREEN EXPERIENCES
COLLABORATIVE EXPERIENCES
GAMES OFFICE APPS
SOCIAL NETWORKING
IMAGING APPS
TV CONNECTIONS
AllJoyn Ushers in New User Experiences for Smartphones, Tablets, PCs & TVs
PAGE 8 Open Source. Open Possibilities.
Open Source. Open Possibilities.
PAGE 9
What About Other P2P Solutions?
PAGE 10 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
What About Existing Protocols?
Other peer-to-peer platforms focus on their own ecosystem
AllJoyn DLNA® UPnP Bonjour
Multiple wireless transports
Application Centric
Device Centric
Network management
App development
framework
Media streaming & security
Control plane
Discovery
IP Transport
Could be standards that are slow to change and fixed in design
AllJoyn is a complete package that works across different operating systems and programming languages to provide a complete solution
Open Source. Open Possibilities.
PAGE 11
AllJoyn Fundamentals
PAGE 12 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
AllJoyn Fundamentals
AllJoyn is a distributed software bus
Each device runs a bus daemon
Applications communicate directly only with the daemon
Daemons on each device communicate with daemons on other devices
Daemons do message routing and namespace management
Bus formation is ad hoc
Based on proximal discovery
Abstracts multiple discovery mechanisms
Protocol is transport independent
Supports Wi-Fi currently
Working on Wi-Fi Direct
PAGE 13 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
C# (Unity)
C++ (native implementation)
Java iOS/OS X Windows® RT
Windows® 7 and XP
Linux Android 2.1 (Éclair) and newer
What Operating Systems and Languages?
AllJoyn is open source and available
http://www.alljoyn.org
LANGUAGE BINDINGS TODAY
IN DEVELOPMENT/DEMONSTRATED
C# (General)
C
JavaScript
Objective C Windows® 8
PAGE 14 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
AllJoyn Distributed Software Bus
IP or Bluetooth
Local socket
Conceptually peers are applications not devices.
Applications communicate with a local daemon
Daemons handle routing between devices
Device 3
Daemon
AppY AppZ
Device 2
Daemon
AppX
Device 1
Daemon
AppX AppY
AppZ
PAGE 15 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Device Device
Ad Hoc Bus Formation
Daemon
Service
App
Daemon
Client App Find-Name
request Advertise-Name
request
Eureka!
Actual discovery mechanism is transport dependent:
On Wi-Fi a light-weight IP multicast protocol
On Wi-Fi Direct pre-association discovery
PAGE 16 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Device Device
Ad Hoc Bus Formation
Daemon Daemon distributed bus
Peer Session
Once connected daemons form a single bus with a shared namespace
Peers can discover when other peers join or leave the bus
Peers can make RPC calls and send and receive events
Session reference counting keeps device-to-device connections alive
Multicast events can be sent to all peers in the session
Service
App Client App
PAGE 17 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Object Model
AllJoyn applications expose their functionality via objects
These are typically organized in a hierarchy
Objects implement interfaces (one or more)
Interfaces are composed of members, which fall into three categories
Methods – classic OO object interaction
Signals – asynchronous event notification
Can be broadcast, multicast, or point-to-point
Properties – data members
These are accessed by built-in get/set methods
PAGE 18 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Bus Attachments, Objects, Proxy Objects
An application needs a Bus Attachment to communicate with the bus
Bus Attachments provide a root (/) for the object hierarchy
Bus Objects implement interfaces
Bus Objects path names look like file paths, e.g. /org/AllJoyn/Games/chess
Bus Object have methods than can be called remotely
Bus Objects can emit signals
Proxy Bus Objects are local representations of remote Bus Objects.
Applications use proxy bus objects to make method calls to remote objects
Bus
Bus Attachment Bus Attachment
Application
Proxy
Object Event
handler
Application
PAGE 19 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Connect to the AllJoyn Bus
This object represents
the connection to the
bus (daemon)
Connect the
attachment to the bus
mBus = new BusAttachment(getClass().getName(), BusAttachment.RemoteMessage.Receive);
mBus.useOSLogging(true);
mBus.setDebugLevel("ALLJOYN_JAVA", 7);
mBus.registerBusListener(new LocalBusListener());
status = mBus.connect();
if(Status.OK != status) {/*ERROR */}
Bus Attachment Bus Attachment
Bus
Connect
Application Application
* Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
PAGE 20 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Register Bus Objects /* Define an interface that will be your AllJoyn interface for P2P communication */
@BusInterface (name = "org.alljoyn.bus.samples.training")
public interface AllJoynTrainingInterface {
@BusMethod(signature = "s")
public void TraningMethod(String arg) throws BusException;
}
class TrainingService implements AllJoynTrainingInterface, BusObject {
public void TraningMethod(String arg) { /* some code */ }
}
theService = new TrainingService();
Status status = mBus.registerBusObject(theService, “/TrainingService”);
if(Status.OK != status) {/*ERROR */}
Bus Attachment Bus Attachment
Bus
Define the Interface that
represents the methods
of your P2P application
Implement the interface
and BusObject so we can
register this with the bus
Create an object for the
service and register with
the AllJoyn Bus
Connected
Application Application
Bus
Object
Tree
* Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
PAGE 21 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Register Signal Handler /* Define an interface that will be your AllJoyn interface for P2P communication */
@BusInterface (name = "org.alljoyn.bus.samples.training")
public interface AllJoynTrainingInterface {
@BusSignal(signature = "s")
public void SignalMethod(String arg) throws BusException;
}
/* in the application register the class that implements the SignalMethod handler*/
status = mBus.registerSignalHandlers(this);
if(Status.OK != status) {/*ERROR */}
/* Here is the handler */
@BusSignalHandler(iface = “com.alljoyn.bus.samples.training”, signal = “SignalMethod")
public void SignalMethod(String arg) { /* some code */ }
Bus Attachment Bus Attachment
Bus Connected
Signal
Handler
Define the Interface that
represents the methods of your
P2P application
Let the Bus know what class
contains the handler for signals
This method executes when a
signal is sent out assuming device
is connected on same session
Application Application
* Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
PAGE 22 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Advertise Well-Known Name Status status = mBus.advertiseName(“com.alljoyn.org.samples.training”, SessionOpts.TRANSPORT_ANY);
if(Status.OK != status) {
/*ERROR – Failed to advertise name*/
status = mBus.releaseName(“com.alljoyn.org.samples.training”);
}
Bus Attachment Bus Attachment
Bus Connected
Register with the bus that we
are going to be aliased the
com.alljoyn.org.samples.training class
Advertise
“com.alljoyn.org.samples.training”
Signal
Handler
Application Application
* Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
PAGE 23 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Discover Well-Known Names class LocalBusListener extends BusListener {
public void foundAdvertisedName(String name, short transport, String namePrefix) {
}
public void lostAdvertisedName(String name, short transport, String namePrefix) {
}
public void nameOwnerChanged(String busName, String previousOwner, String newOwner) {
}
}
…
...
Status status = mBus.findAdvertisedName(“com.alljoyn.org.samples.training”);
if(Status.OK != status) {/*ERROR */}
…
…
Listener class for discovery
events. This is where we are
informed of other services
Look for a com.alljoyn.org.samples.training service
Bus Attachment Bus Attachment
Bus Connected
“com.alljoyn.org.samples.training”
Connected
findAdvertised
Bus
Listener Signal
Handler
Application Application
* Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
PAGE 24 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Create a Session class MySessionPortListener extends SessionPortListener {
public boolean acceptSessionJoiner(short sessionPort, String joiner, SessionOpts sessionOpts) {
return true;
}
public void sessionJoined(short sessionPort, final int sessionId, String joiner) {
mBus.setSessionListener(sessionId, new MySessionListener());
}
}
--------------
Mutable.ShortValue agreedUponPort = new Mutable.ShortValue(55); /* value can be 1 to 32767 (max short) */
SessionOpts sessionOpts = new SessionOpts();
sessionOpts.traffic = SessionOpts.TRAFFIC_MESSAGES;
sessionOpts.isMultipoint = true;
sessionOpts.proximity = SessionOpts.PROXIMITY_ANY;
sessionOpts.transports = SessionOpts.TRANSPORT_ANY;
Status status = mBus.bindSessionPort(agreedUponPort, sessionOpts, new MySessionPortListener());
if(Status.OK != status) { /*ERROR – Could not create a session*/ }
* Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
Listener class for session events.
Lets us accept sessions and
informs when users join.
Bus Attachment Bus Attachment
Bus Connected
Signal
Handler
We create the session based on
the Session Options we pass. We
can specify the transport interface
here for the supported types
Session
Port
Listener
Session
Listener Session on port 55
Application Application
PAGE 25 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Join a Session short agreedUponPort = 55; /* value can be 1 to 32767 (max short) */
SessionOpts sessionOpts = new SessionOpts();
Mutable.IntegerValue sessionId = new Mutable.IntegerValue();
Status status = mBus.joinSession(“com.alljoyn.org.sample.training”, agreedUponPort , sessionId,
sessionOpts, new MySessionListener());
if(Status.OK == status) {
/* NOW CONNECTED */
} else if(status == Status.ALLJOYN_JOINSESSION_REPLY_ALREADY_JOINED) {
/* ALREADY JOINED */
} else {
/* ERROR */
}
We have already found the name
so we now join the session
Bus Attachment Bus Attachment
Connected
Signal
Handler Connected
Bus
Listener Bus
Session
Port
Listener
Session
Listener Session on port 55
joinSession
acceptSessionJoiner
True or False
sessionJoined Status.OK
Application Application
* Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
class MySessionListener extends SessionListener {
public void sessionLost(int sessionId) { }
public void sessionMemberAdded(int sessionId, String uniqueName) {}
public void sessionMemberRemoved(int sessionId, String uniqueName) {}
}
Open Source. Open Possibilities.
PAGE 26
Add AllJoyn to an Android Application
PAGE 27 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Steps to Add AllJoyn to Existing Application
Download complete documentation here:
https://www.alljoyn.org/docs-and-downloads/documentation/guide-alljoyn-development-using-java-sdk
https://www.alljoyn.org/docs-and-downloads/documentation/alljoyn-android-environment-setup-guide
First: Import AllJoyn libraries
Create libs folder that contains:
alljoyn.jar
armeabi/liballjoyn_java.so
Second: Modify manifest to include permissions
Third: Add AllJoyn code
PAGE 28 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
AllJoyn for Android as a Service
NOTE: The service is waiting for AllJoyn callback and does not consume device resources, so battery performance is maintained
When an Activity implements AllJoyn the connection does not persist unless the activity is active
This can be used but is not recommended
A Service can startup on device power on
Complex AllJoyn interactions or delays will block a UI thread
Depending on AllJoyn interface design remote devices can communicate to show notifications or toasts
Open Source. Open Possibilities.
PAGE 29
Add AllJoyn to a Unity Application
PAGE 30 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Add AllJoyn Unity Extension to Existing Application
Supported platforms
Currently supports Android & Windows desktop
iOS support in development
Download complete documentation here:
https://www.alljoyn.org/docs-and-downloads/documentation/alljoyn-unity-setup-quick-start-guide
First: Import AllJoyn extension
Drop the AllJoynAgent prefab into your scene
Second: Modify manifest to include permissions
Third: Add AllJoyn code
Development using Unity Editor w/ C# scripts
PAGE 31 Open Source. Open Possibilities.
MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. 5775 Morehouse Drive
San Diego, CA. 92121-1714
U.S.A.
Copyright © 2012 Qualcomm Innovation Center, Inc.
All rights reserved.
Not to be used, copied, reproduced in whole or in part, nor its contents revealed in any manner to others without the express written permission of Qualcomm Innovation Center, Inc.
This technical data may be subject to U.S. and international export, re-export, or transfer ("export") laws. Diversion contrary to U.S. and international law is strictly prohibited.
AllJoyn, JamJoyn, QuIC and the QuIC logo are trademarks of Qualcomm Innovation Center, Inc. Other product and brand names may be trademarks or registered trademarks of their
respective owners.
[10/25/2012]
Nothing in these materials is an offer to sell any of the components or devices referenced herein. Certain components for use in the U.S. are available only through licensed suppliers. Some
components are not available for use in the U.S.
Open Source. Open Possibilities.
PAGE 32
Questions?
Thank you!
Follow us on Twitter!
AllJoyn. @AllJoyn
QDevNet.
@Qualcomm_Dev