Droidcon 2013 ant+ chin


Published on

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Droidcon 2013 ant+ chin

  1. 1. Harrison Chin Applications Engineerharrison.chin@thisisant.com
  2. 2. Thank You!
  3. 3. What is ANT or ANT+?• ANT is an ultra low power 2.4GHz wireless protocol – Shipped over 60+ Million devices so far – Can communicate for years using a single coin cell battery – Hundreds of transmitters can co-exist on the same RF channel without collision – Simple logical channels can be used separately or combined into complex topologies – Highly compact stack and common API across vendors – 8 byte Payload Broadcast and Acknowledged packets • Up to 24 byte Burst message packets• ANT+ is a set of mutually agreed upon definitions for what the information sent over ANT represents
  4. 4. Building ANT Networks…Simply• Point-to-point M S
  5. 5. Building ANT Networks…Simply• Point-to-point• Broadcast one-to-many M S S S
  6. 6. Building ANT Networks…Simply• Point-to-point• Broadcast one-to-many
  7. 7. Building ANT Networks…Simply• Point-to-point• Broadcast one-to-many S• Star M S S M M
  8. 8. Building ANT Networks…Simply• Point-to-point• Broadcast one-to-many• Star
  9. 9. Building ANT Networks…Simply• Point-to-point• Broadcast one-to-many• Star• Shared S S S M S S S
  10. 10. Building ANT Networks…Simply• Point-to-point• Broadcast one-to-many• Star …• Shared M M M … M• Asynchronous Over the Air Scan Scan M M
  11. 11. Building ANT Networks…Simply• Point-to-point• Broadcast one-to-many• Star• Shared• Asynchronous 1: Is 1: Is that that fun? fun? 2:No 2:No idea… idea…
  12. 12. ANT Networks… Simple to Sophisticated• Point-to-point• Broadcast one-to-many• Star• Shared• Asynchronous• Beyond the star…
  13. 13. Co-existence Management – Time Domain
  14. 14. Background Scanning Channel • Background scanning channel is receive only • Allows independent channels to stay open on the same physical radio • Useful to create asynchronous topologies, monitor messages, RSSI pairing schemes, etcMASTER_1MASTER_2BackgroundScanning
  15. 15. Continuous Scanning Mode • ‘Always on’ receiver: high power M M • Fully Bi-directional Communication Scan M – Channels can be responded to on-demand M M • Masters can transmit intermittently • Potentially hundreds of transmitters to one center nodeMASTER_1MASTER_2ScanningMode
  16. 16. ANT+ Device Profiles• Open definitions for device-level interoperability – Channel configuration – Data format – Data exchange mechanisms
  17. 17. ANT+ Device Profiles
  18. 18. Control Bidirectional communication Sensor: status Display: control
  19. 19. GeocacheHintNext locationVisitor count
  20. 20. Bicycle Speed & Cadence Bicycle PowerCadenceSpeedPower
  21. 21. Activity Monitor Access Searching… Point
  22. 22. Continuous Glucose Monitor Authenticated sessions Intermittent transmission scheme Live and stored data
  23. 23. ANT+ Interoperability
  24. 24. Android ANT Layers App App App App App AppCreated by: Profiles ANT Radio Service For Connectivity Chip For ANT USB sticks ANT HAL Service ANT USB Service Applications ANT HALCreated by: ANT Transport Driver & Chip Physical Transport Driver Android USB Host Feature Vendor Vendor Specific Library Android System Android Android System ANT Firmware ANT Firmware Combo Connectivity Device ANT USB Stick
  25. 25. Android ComponentsApp App App Profiles ANT+ Profile ANT+ Profile Plug-in Plug-in ANT Radio Service Applications ANT HAL Service ANT HAL Android System ANT Firmware Combo Connectivity Device
  26. 26. ANT+ Profile Plug-ins Make Implementing ANT+ Applications Easier App App Heart Rate PCC Remote Control PCC ANT+ API Heart Rate Plug-in Control Plug-in Plug-insANT Channel Provider ANT Channel Channel API/ANT Radio Service
  27. 27. Plug-in Communicator Class• A simple class which provides access to the ANT+ Plug-in• Methods include… public static void requestAccess(…) public String getDeviceName() public int getAntDeviceID() public int getCurrentDeviceState() public void subscribeTo<EventName>(...) public void releaseAccess()
  28. 28. Request Accesspublic static void requestAccess( Activity userActivity, Context bindToContext, boolean skipPreferredSearch, IPluginAccessResultReceiver<AntPlusHeartRatePcc> resultReceiver, IDeviceStateChangeReceiver stateReceiver)
  29. 29. Device Discovery UI
  30. 30. Result Receiverpublic void onResultReceived(AntPlusHeartRatePcc result, int resultCode, int initialDeviceStateCode, Object asyncState){switch(resultCode){case AntPluginMsgDefines.MSG_REQACC_RESULT_whatSUCCESS: hrPcc = result; subscribeToEvents(); break;
  31. 31. Result Receivercase AntPluginMsgDefines.MSG_REQACC_RESULT_whatDEPENDENCYNOTINSTALLED: AlertDialog.Builder adlgBldr; adlgBldr = new AlertDialog.Builder(Activity_HeartRateSampler.this); adlgBldr.setTitle("Missing Dependency"); adlgBldr.setMessage("The required applicationn"" + AntPlusHeartRatePcc.getMissingDependencyName() + “"n is not installed. Do you want to launch the Play Store to search for it?");...break;
  32. 32. Subscribing to EventshrPcc.subscribeHeartRateDataEvent( new IHeartRateDataReceiver() { public void onNewHeartRateData( final int currentMessageCount, final int computedHeartRate, final int heartBeatCounter, final int timestampOfLastBeat_1024s) { //Use data... } } );
  33. 33. State Change Receiverpublic void onDeviceStateChange(int newDeviceState){ //Handle state change: //(TRACKING, SEARCHING, CLOSED, DEAD)}
  34. 34. Release Access public static void releaseAccess()• Releases the connection to the device (the plugin service will automatically shutdown when all apps have released access)
  35. 35. Channel Interface• Used for non-ANT+ applications• Development of Beta ANT+ profiles• Provides channels from all connected chips• Gives full access to individual ANT channel capabilities – Background scanning – Shared channels – Decimated receive rates
  36. 36. General Channel Flow1. Bind to the ANT Radio Service2. Get the ANT Channel Provider3. Acquire Channel(s)4. Configure Channel(s)5. Use Channel(s)6. Release the Channel(s) and Unbind
  37. 37. Bind to the ANT Radio Serviceprivate AntService mAntRadioService = null;private AntChannelProvider mAntChannelProvider = null;private ServiceConnection mAntRadioServiceConnection =new ServiceConnection(){ @Override public void onServiceConnected(ComponentName name, IBinder service) { mAntRadioService = new AntService(service); mAntChannelProvider = mAntRadioService.getChannelProvider(); } …}
  38. 38. Acquire a ChannelAntChannel acquireChannel() throws ChannelNotAvailableException{ AntChannel antChannel = null; if(null != mAntChannelProvider) { antChannel = AntChannelProvider.acquireChannel(this, PredefinedNetwork.PUBLIC); } return antChannel;}
  39. 39. Configuring an ANT Channel…• setAdapterWideLibConfig(LibConfig libConfig)• setChannelId(ChannelId channelId)• setPeriod(int period_32768unitsPerSecond)• setTransmitPower(int outputPowerLevelSetting)• setProximityThreshold(int searchThreshold)• setRfFreqency(int radioFrequencyOffset)• setSearchTimeout (LowPrioritySearchTimeout lowPrioritySearchTimeout)• …and more representing standard ANT Message Commands
  40. 40. Handling the Channelpublic class ChannelCallback implements AntChannelMessageHandler{ @Override public void handleMessage(AntMessageFromAnt antMessage) { switch(antMessage.getMessageType()) { case BROADCAST_DATA: case ACKNOWLEDGED_DATA: // Rx Data DataMessage rxMessage = (DataMessage)antMessage; processData(rxMessage.getPayload()); break; case CHANNEL_EVENT: … } }}
  41. 41. Releasing the Channelpublic void close(){ if (null != mAntChannel) { mAntChannel.release(); mAntChannel = null; }}
  42. 42. What could you do with…• Simplicity – ANT+ Android Plug-ins handle discovery and profile interpretation for the developer – Unified ANT API across multiple vendors minimizes support costs – Small stack size and TDMA style coexistence reduces memory and computational costs – Individual logical channels are easy to work with
  43. 43. What could you do with…• Extreme network flexibility – Enables large scale networks for small, coin cell operated devices Over the running for years Air – Hubs, phones, access points, etc can gather data and communicate concurrently – Scatternets, meshes, trees, etc, can be dynamically created and closed – Simple channels are the building blocks
  44. 44. Thank You!Have a Great Droidcon!