droidcon 2013 ant+ chin

45
Harrison Chin Applications Engineer [email protected]

Upload: droidcon-berlin

Post on 27-Jan-2015

128 views

Category:

Technology


9 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Droidcon 2013 ant+ chin

Harrison Chin Applications Engineer

[email protected]

Page 2: Droidcon 2013 ant+ chin

Thank You!

Page 3: Droidcon 2013 ant+ chin

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

Page 4: Droidcon 2013 ant+ chin
Page 5: Droidcon 2013 ant+ chin

Building ANT Networks…Simply

• Point-to-point M S

Page 6: Droidcon 2013 ant+ chin

Building ANT Networks…Simply

• Point-to-point

• Broadcast one-to-many

M

S

S S

Page 7: Droidcon 2013 ant+ chin

Building ANT Networks…Simply

• Point-to-point

• Broadcast one-to-many

Page 8: Droidcon 2013 ant+ chin

Building ANT Networks…Simply

S

M M

M

S S

• Point-to-point

• Broadcast one-to-many

• Star

Page 9: Droidcon 2013 ant+ chin

Building ANT Networks…Simply

• Point-to-point

• Broadcast one-to-many

• Star

Page 10: Droidcon 2013 ant+ chin

Building ANT Networks…Simply

• Point-to-point

• Broadcast one-to-many

• Star

• Shared

M

S

S

S

S

S

S

Page 11: Droidcon 2013 ant+ chin

Building ANT Networks…Simply

• Point-to-point

• Broadcast one-to-many

• Star

• Shared

• Asynchronous

M

Scan

M M M

Over the Air

Scan

M M

Page 12: Droidcon 2013 ant+ chin

Building ANT Networks…Simply

• Point-to-point

• Broadcast one-to-many

• Star

• Shared

• Asynchronous 1: Is that fun? 2:No idea…

1: Is that fun? 2:No idea…

Page 13: Droidcon 2013 ant+ chin

ANT Networks… Simple to Sophisticated

• Point-to-point

• Broadcast one-to-many

• Star

• Shared

• Asynchronous

• Beyond the star…

Page 14: Droidcon 2013 ant+ chin

Co-existence Management – Time Domain

Page 15: Droidcon 2013 ant+ chin

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, etc

MASTER_2

Background Scanning

MASTER_1

Page 16: Droidcon 2013 ant+ chin

Continuous Scanning Mode

• ‘Always on’ receiver: high power

• Fully Bi-directional Communication

– Channels can be responded to on-demand

• Masters can transmit intermittently

• Potentially hundreds of transmitters to one center node

M

Scan

M

M

M M

MASTER_2

Scanning Mode

MASTER_1

Page 17: Droidcon 2013 ant+ chin

ANT+ Device Profiles

• Open definitions for device-level interoperability

– Channel configuration

– Data format

– Data exchange mechanisms

Page 18: Droidcon 2013 ant+ chin

ANT+ Device Profiles

Page 19: Droidcon 2013 ant+ chin

Control

Bidirectional communication Sensor: status Display: control

Page 20: Droidcon 2013 ant+ chin

Geocache

Hint Next location Visitor count

Page 21: Droidcon 2013 ant+ chin

Bicycle Speed & Cadence Bicycle Power

Cadence Speed Power

Page 22: Droidcon 2013 ant+ chin

Activity Monitor

Access Point

Searching…

Page 23: Droidcon 2013 ant+ chin

Continuous Glucose Monitor

Authenticated sessions Intermittent transmission scheme Live and stored data

Page 24: Droidcon 2013 ant+ chin

ANT+ Interoperability

Page 25: Droidcon 2013 ant+ chin

ANT USB Stick

Android System

Android ANT Layers

Android System

Vendor Specific Library

Combo Connectivity Device

ANT HAL

ANT Radio Service

ANT Firmware

Profiles

App App App

ANT Transport Driver

Physical Transport Driver

ANT HAL Service

Created by:

& Chip Vendor

App App App

Android

Created by:

ANT USB Service

Android USB Host Feature

ANT Firmware

Applications

For Connectivity Chip For ANT USB sticks

Page 26: Droidcon 2013 ant+ chin

Android Components

Applications

ANT Radio Service

Combo Connectivity Device

Android System

ANT HAL

ANT HAL Service

ANT Firmware

ANT+ Profile Plug-in

App

Profiles

ANT+ Profile Plug-in

App App

Page 27: Droidcon 2013 ant+ chin

ANT+ API

Plug-ins

ANT+ Profile Plug-ins Make Implementing ANT+ Applications Easier

Channel API/ANT Radio Service

ANT Channel ANT Channel Provider

Heart Rate PCC Remote Control PCC

Heart Rate Plug-in Control Plug-in

App App

Page 28: Droidcon 2013 ant+ chin

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()

Page 29: Droidcon 2013 ant+ chin

Request Access

public static void requestAccess( Activity userActivity, Context bindToContext, boolean skipPreferredSearch, IPluginAccessResultReceiver<AntPlusHeartRatePcc> resultReceiver, IDeviceStateChangeReceiver stateReceiver)

Page 30: Droidcon 2013 ant+ chin

Device Discovery UI

Page 31: Droidcon 2013 ant+ chin

Result Receiver public void onResultReceived(AntPlusHeartRatePcc result, int resultCode, int initialDeviceStateCode, Object asyncState) { switch(resultCode) { case AntPluginMsgDefines.MSG_REQACC_RESULT_whatSUCCESS: hrPcc = result; subscribeToEvents(); break;

Page 32: Droidcon 2013 ant+ chin

Result Receiver case AntPluginMsgDefines.MSG_REQACC_RESULT_whatDEPENDENCYNOTINSTALLED: AlertDialog.Builder adlgBldr; adlgBldr = new AlertDialog.Builder(Activity_HeartRateSampler.this); adlgBldr.setTitle("Missing Dependency"); adlgBldr.setMessage("The required application\n\"" + AntPlusHeartRatePcc.getMissingDependencyName() + “\"\n is not installed. Do you want to launch the Play Store to search for it?"); ... break;

Page 33: Droidcon 2013 ant+ chin

Subscribing to Events

hrPcc.subscribeHeartRateDataEvent( new IHeartRateDataReceiver() { public void onNewHeartRateData( final int currentMessageCount, final int computedHeartRate, final int heartBeatCounter, final int timestampOfLastBeat_1024s) { //Use data... } } );

Page 34: Droidcon 2013 ant+ chin

State Change Receiver public void onDeviceStateChange(int newDeviceState) { //Handle state change: //(TRACKING, SEARCHING, CLOSED, DEAD) }

Page 35: Droidcon 2013 ant+ chin

Release Access

public static void releaseAccess()

• Releases the connection to the device (the plugin service will automatically shutdown when all apps have released access)

Page 36: Droidcon 2013 ant+ chin

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

Page 37: Droidcon 2013 ant+ chin

General Channel Flow

1. Bind to the ANT Radio Service

2. Get the ANT Channel Provider

3. Acquire Channel(s)

4. Configure Channel(s)

5. Use Channel(s)

6. Release the Channel(s) and Unbind

Page 38: Droidcon 2013 ant+ chin

Bind to the ANT Radio Service

private 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(); } … }

Page 39: Droidcon 2013 ant+ chin

Acquire a Channel

AntChannel acquireChannel() throws ChannelNotAvailableException

{

AntChannel antChannel = null;

if(null != mAntChannelProvider)

{

antChannel = AntChannelProvider.acquireChannel(this, PredefinedNetwork.PUBLIC);

}

return antChannel;

}

Page 40: Droidcon 2013 ant+ chin

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

Page 41: Droidcon 2013 ant+ chin

Handling the Channel

public 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: … } } }

Page 42: Droidcon 2013 ant+ chin

Releasing the Channel

public void close() { if (null != mAntChannel) { mAntChannel.release(); mAntChannel = null; } }

Page 43: Droidcon 2013 ant+ chin

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

Page 44: Droidcon 2013 ant+ chin

What could you do with…

• Extreme network flexibility – Enables large scale

networks for small, coin cell operated devices running for years

– 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

Over the Air

Page 45: Droidcon 2013 ant+ chin

Thank You! Have a Great Droidcon!