Jornada Formativa Qualcomm y Movilforum: Alljoyn

1,791 views

Published on

Published in: Technology
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,791
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
72
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Jornada Formativa Qualcomm y Movilforum: Alljoyn

  1. 1. Open Source. Open Possibilities. Overview of the AllJoyn™ Development Framework Nick Clarey January 11, 2013
  2. 2. Agenda 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&APAGE 2 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  3. 3. Open Source. Open Possibilities. What is AllJoyn?PAGE 3
  4. 4. Why Peer-to-peer (P2P) Is HardP2P Friction Developers Face Today Device Service Discovery Discovery Pairing Platforms Security Radios Ad Hoc Transient Networking DevicesPAGE 4 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  5. 5. AllJoyn Makes Peer-to-peer Frictionless DISCOVER ADAPT MANAGE INTEROPERATE EXCHANGE devices and to apps and transports like Wi-Fi across disparate Information in applications devices and Wi-Fi Direct programming a secure manner around you coming and message routing languages, and going across them operating systems, and bearersPAGE 5 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  6. 6. What Is AllJoyn?Open Source Application Development Framework to EnableAd 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 morePAGE 6 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  7. 7. AllJoyn is a Software Framework Applications Open Sourced (Apache 2.0 License) Third- Multiplayer Party JamJoyn™ Media Social Chat or OEM Gaming Enables Developers to Easily Add P2P Experiences to Their Apps AllJoyn Development Framework S C++ Java JavaScript Objective-C CLR O o p u Application Layer Discovery e r (What services are running on nearby Network Cross- Wireless- devices that are reachable) Discovery Security Pairing n c Management Platform Optimized e Application Layer Security (What information can a service access Wi-Fi Direct Wi-Fi BT on your phone, what’s off limits) Chipset Interoperate Across Different OS and Bearers (Developer does not need to know anything about Wi-Fi, Wi-Fi Direct, Android, Windows, etc.) Tablets Mobiles Televisions Laptop/PCPAGE 7 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  8. 8. What New Experiences Can AllJoyn Enable? ENTERTAINMENT MULTISCREEN COLLABORATIVE & GAMING EXPERIENCES EXPERIENCES EXPERIENCESAllJoyn Ushersin New UserExperiences forSmartphones, Tablets,PCs & TVs GAMES OFFICE SOCIAL IMAGING TV APPS NETWORKING APPS CONNECTIONS PAGE 8 Open Source. Open Possibilities. Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  9. 9. Open Source. Open Possibilities. What About Other P2P Solutions?PAGE 9
  10. 10. What About Existing Protocols? AllJoyn DLNA® UPnP Bonjour Other peer-to-peer Multiple wireless transports platforms focus on Application Centric their own ecosystem Device Centric Could be standards Network management that are slow to change and fixed in design App development framework Media streaming & security AllJoyn is a complete package that works Control plane across different operating systems and programming Discovery languages to provide a complete solution IP TransportPAGE 10 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  11. 11. Open Source. Open Possibilities. AllJoyn FundamentalsPAGE 11
  12. 12. AllJoyn FundamentalsAllJoyn 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 managementBus formation is ad hoc Based on proximal discovery Abstracts multiple discovery mechanismsProtocol is transport independent Supports Wi-Fi currently Working on Wi-Fi DirectPAGE 12 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  13. 13. What Operating Systems and Languages? TODAY LANGUAGE BINDINGS Android Windows® 7 C++ Linux C 2.1 (Éclair) and newer and XP (native implementation) iOS/OS X Windows® RT Windows® 8 Java C# Objective C (Unity) IN DEVELOPMENT/DEMONSTRATED JavaScript C# (General) AllJoyn is open source and available http://www.alljoyn.orgPAGE 13 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  14. 14. AllJoyn Distributed Software Bus Device 1  Conceptually peers are applications not devices. AppX AppY IP or Bluetooth  Applications communicate Local socket with a local daemon Daemon  Daemons handle routing between devices Device 2 Device 3 AppX AppZ AppY AppZ Daemon DaemonPAGE 14 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  15. 15. Ad Hoc Bus Formation Device Device Client App Find-Name Advertise-Name Service App request request Eureka! Daemon Daemon Actual discovery mechanism is transport dependent:  On Wi-Fi a light-weight IP multicast protocol  On Wi-Fi Direct pre-association discoveryPAGE 15 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  16. 16. Ad Hoc Bus Formation Device Device Service Client App App Peer Session Daemon distributed bus Daemon 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 sessionPAGE 16 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  17. 17. Object ModelAllJoyn applications expose their functionality via objects These are typically organized in a hierarchyObjects 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 methodsPAGE 17 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  18. 18. Bus Attachments, Objects, Proxy Objects An application needs Bus Objects implement interfaces Proxy Bus Objects are local a Bus Attachment to  Bus Objects path names look like file representations of remote communicate with the bus paths, e.g. /org/AllJoyn/Games/chess Bus Objects.  Bus Attachments provide a root (/)  Bus Object have methods than can be  Applications use proxy bus for the object hierarchy called remotely objects to make method calls to remote objects  Bus Objects can emit signals Application Application Bus Attachment Bus Attachment Proxy Event Object handler BusPAGE 18 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  19. 19. Connect to the AllJoyn Bus mBus = new BusAttachment(getClass().getName(), BusAttachment.RemoteMessage.Receive); This object represents mBus.useOSLogging(true); the connection to the mBus.setDebugLevel("ALLJOYN_JAVA", 7); bus (daemon) mBus.registerBusListener(new LocalBusListener()); status = mBus.connect(); Connect the if(Status.OK != status) {/*ERROR */} attachment to the bus Application Application Bus Attachment Connect Bus Attachment Bus PAGE 19 Open Source. Open Possibilities. MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc. * Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
  20. 20. Register Bus Objects/* Define an interface that will be your AllJoyn interface for P2P communication */@BusInterface (name = "org.alljoyn.bus.samples.training") Define the Interface thatpublic interface AllJoynTrainingInterface { @BusMethod(signature = "s") represents the methods public void TraningMethod(String arg) throws BusException; of your P2P application}class TrainingService implements AllJoynTrainingInterface, BusObject { Implement the interface public void TraningMethod(String arg) { /* some code */ } and BusObject so we can} register this with the bus Create an object for thetheService = new TrainingService();Status status = mBus.registerBusObject(theService, “/TrainingService”); service and register with if(Status.OK != status) {/*ERROR */} the AllJoyn Bus Application Application Bus Attachment Bus Attachment Bus Bus Connected Object Tree PAGE 20 Open Source. Open Possibilities. MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc. * Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
  21. 21. Register Signal Handler/* Define an interface that will be your AllJoyn interface for P2P communication */@BusInterface (name = "org.alljoyn.bus.samples.training") Define the Interface thatpublic interface AllJoynTrainingInterface { @BusSignal(signature = "s") represents the methods of your public void SignalMethod(String arg) throws BusException; P2P application}/* in the application register the class that implements the SignalMethod handler*/ Let the Bus know what classstatus = mBus.registerSignalHandlers(this); contains the handler for signalsif(Status.OK != status) {/*ERROR */}/* Here is the handler */ This method executes when a@BusSignalHandler(iface = “com.alljoyn.bus.samples.training”, signal = “SignalMethod")public void SignalMethod(String arg) { /* some code */ } signal is sent out assuming device is connected on same session Application Application Bus Attachment Bus Attachment Signal Handler Bus Connected PAGE 21 Open Source. Open Possibilities. MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc. * Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
  22. 22. Advertise Well-Known NameStatus status = mBus.advertiseName(“com.alljoyn.org.samples.training”, SessionOpts.TRANSPORT_ANY);if(Status.OK != status) { Register with the bus that we/*ERROR – Failed to advertise name*/status = mBus.releaseName(“com.alljoyn.org.samples.training”); are going to be aliased the} com.alljoyn.org.samples.training class “com.alljoyn.org.samples.training” Application Application Bus Attachment Advertise Bus Attachment Signal Handler Bus Connected PAGE 22 Open Source. Open Possibilities. MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc. * Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
  23. 23. Discover Well-Known Namesclass LocalBusListener extends BusListener { public void foundAdvertisedName(String name, short transport, String namePrefix) { } public void lostAdvertisedName(String name, short transport, String namePrefix) { Listener class for discovery } public void nameOwnerChanged(String busName, String previousOwner, String newOwner) { events. This is where we are } informed of other services}…...Status status = mBus.findAdvertisedName(“com.alljoyn.org.samples.training”);if(Status.OK != status) {/*ERROR */}…… Look for a com.alljoyn.org.samples.training service “com.alljoyn.org.samples.training” Application Application Bus Attachment findAdvertised Bus Attachment Signal Handler Bus Bus Listener Connected Connected PAGE 23 Open Source. Open Possibilities. MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc. * Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
  24. 24. Create a Sessionclass MySessionPortListener extends SessionPortListener { public boolean acceptSessionJoiner(short sessionPort, String joiner, SessionOpts sessionOpts) { Listener class for session events. return true; } Lets us accept sessions and public void sessionJoined(short sessionPort, final int sessionId, String joiner) { informs when users join. 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; We create the session based onsessionOpts.isMultipoint = true; the Session Options we pass. WesessionOpts.proximity = SessionOpts.PROXIMITY_ANY;sessionOpts.transports = SessionOpts.TRANSPORT_ANY; can specify the transport interfaceStatus status = mBus.bindSessionPort(agreedUponPort, sessionOpts, new MySessionPortListener()); here for the supported typesif(Status.OK != status) { /*ERROR – Could not create a session*/ } Application Application Session Port Bus Attachment Bus Attachment Listener Signal Handler Bus Connected Session Session on port 55 Listener PAGE 24 Open Source. Open Possibilities. MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc. * Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
  25. 25. Join a Sessionshort agreedUponPort = 55; /* value can be 1 to 32767 (max short) */SessionOpts sessionOpts = new SessionOpts();Mutable.IntegerValue sessionId = new Mutable.IntegerValue(); We have already found the nameStatus status = mBus.joinSession(“com.alljoyn.org.sample.training”, agreedUponPort , sessionId, so we now join the session sessionOpts, new MySessionListener());if(Status.OK == status) { /* NOW CONNECTED */} else if(status == Status.ALLJOYN_JOINSESSION_REPLY_ALREADY_JOINED) { /* ALREADY JOINED */ class MySessionListener extends SessionListener {} else { public void sessionLost(int sessionId) { } /* ERROR */ public void sessionMemberAdded(int sessionId, String uniqueName) {}} public void sessionMemberRemoved(int sessionId, String uniqueName) {} } True or False acceptSessionJoiner Status.OK sessionJoined Application joinSession Application Session Port Bus Attachment Bus Attachment Listener Signal Handler Bus Bus Listener Connected Connected Session Session on port 55 Listener PAGE 25 Open Source. Open Possibilities. MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc. * Code snippets licensed under the Apache License, version 2.0 http://www.apache.org/licenses/LICENSE-2.0
  26. 26. Open Source. Open Possibilities. Add AllJoyn to an Android ApplicationPAGE 26
  27. 27. Steps to Add AllJoyn to Existing ApplicationDownload 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-guideFirst: Import AllJoyn libraries Create libs folder that contains:  alljoyn.jar  armeabi/liballjoyn_java.soSecond: Modify manifest to include permissionsThird: Add AllJoyn codePAGE 27 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  28. 28. AllJoyn for Android as a Service 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 NOTE: The service is waiting for AllJoyn callback and does not consume device resources, so battery performance is maintainedPAGE 28 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  29. 29. Open Source. Open Possibilities. Add AllJoyn to a Unity ApplicationPAGE 29
  30. 30. Add AllJoyn Unity Extension to Existing ApplicationSupported platforms Currently supports Android & Windows desktop iOS support in developmentDownload complete documentation here: https://www.alljoyn.org/docs-and-downloads/documentation/alljoyn-unity-setup-quick-start-guideFirst: Import AllJoyn extension Drop the AllJoynAgent prefab into your sceneSecond: Modify manifest to include permissionsThird: Add AllJoyn code Development using Unity Editor w/ C# scriptsPAGE 30 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  31. 31. 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. 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. [10/25/2012]PAGE 31 Open Source. Open Possibilities.MAY CONTAIN U.S. AND INTERNATIONAL EXPORT CONTROLLED INFORMATION. Qualcomm Innovation Center, Inc.
  32. 32. Open Source. Open Possibilities. Questions? Thank you! Follow us on Twitter! AllJoyn. @AllJoyn QDevNet. @Qualcomm_DevPAGE 32

×