|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.dsi.ant.AntInterface
public class AntInterface
AntInterface is a proxy object for communicating with the ANT Radio Service. It is recommended you have only one instance, managed from within a local long-running service (to prevent any conflicts during ANT configuration).
Detailed documentation is available in the "ANT Message Protocol and Usage" document under the Developers Zone on http://www.thisisant.com.
Missing ANT Message functions (can be implemented with ANTTxMessage()
):
Unsupported ANT Message functions (on phone ANT hardware):
Nested Class Summary | |
---|---|
static interface |
AntInterface.ServiceListener
An interface for notifying AntInterface clients when they have been connected to the ANT Radio Service. |
Field Summary | |
---|---|
static java.lang.String |
TAG
The Log Tag. |
Constructor Summary | |
---|---|
AntInterface()
Instantiates a new ANT Interface. |
Method Summary | |
---|---|
void |
ANTAddChannelId(byte channelNumber,
short deviceNumber,
byte deviceType,
byte txType,
byte listIndex)
Add channel IDs to the inclusion/exclusion list. |
void |
ANTAssignChannel(byte channelNumber,
byte channelType,
byte networkNumber)
Assign the a channel. |
void |
ANTCloseChannel(byte channelNumber)
Close a channel that has been previously opened. |
void |
ANTConfigEventBuffering(short screenOnFlushTimerInterval,
short screenOnFlushBufferThreshold,
short screenOffFlushTimerInterval,
short screenOffFlushBufferThreshold)
ANT config event buffering. |
void |
ANTConfigList(byte channelNumber,
byte listSize,
byte exclude)
Configure the inclusion/exclusion list. |
void |
ANTDisableEventBuffering()
ANT disable event buffering. |
void |
ANTOpenChannel(byte channelNumber)
Open a channel that has been previously assigned and configured. |
void |
ANTRequestMessage(byte channelNumber,
byte messageID)
Request a specific information message from the device. |
void |
ANTResetSystem()
This message is sent to the module to reset the system and put it in a known, low-power state. |
void |
ANTSendAcknowledgedData(byte channelNumber,
byte[] txBuffer)
Send an acknowledged packet on a channel. |
void |
ANTSendBroadcastData(byte channelNumber,
byte[] txBuffer)
Send a broadcast packet on a channel. |
int |
ANTSendBurstTransfer(byte channelNumber,
byte[] txBuffer)
Transmits the given data on a channel as a burst message. |
void |
ANTSendBurstTransferPacket(byte control,
byte[] txBuffer)
Send a burst packet on a channel (8 bytes). |
int |
ANTSendPartialBurst(byte channelNumber,
byte[] txBuffer,
int initialPacket,
boolean containsEndOfBurst)
ANT send partial burst. |
void |
ANTSetChannelId(byte channelNumber,
short deviceNumber,
byte deviceType,
byte txType)
Configures the channel ID for a specific channel. |
void |
ANTSetChannelPeriod(byte channelNumber,
short channelPeriod)
Configures the messaging period of a specific channel. |
void |
ANTSetChannelRFFreq(byte channelNumber,
byte radioFrequency)
Set the RF frequency for a particular channel. |
void |
ANTSetChannelSearchTimeout(byte channelNumber,
byte searchTimeout)
Configure the length of time that the receiver will search for a channel before timing out. |
void |
ANTSetChannelTxPower(byte channelNumber,
byte txPower)
Set the transmit power level for a specified channel. |
void |
ANTSetLowPriorityChannelSearchTimeout(byte channelNumber,
byte searchTimeout)
Configure the duration the receiver will search for a channel in low priority mode before switching to high priority mode. |
void |
ANTSetProximitySearch(byte channelNumber,
byte searchThreshold)
This function enables a one-time proximity requirement for searching. |
void |
ANTTxMessage(byte[] message)
Write a raw message (8 bytes) to the ANT chip. |
void |
ANTUnassignChannel(byte channelNumber)
Unassign a channel. |
boolean |
claimInterface()
Take control of the ANT Radio. |
boolean |
destroy()
Deprecated. Use a single instance and start/stop connection to ANT Radio Service with initService()/releaseService(). |
void |
disable()
Disable ANT. |
void |
enable()
Enable ANT. |
static AntInterface |
getInstance(Context context,
AntInterface.ServiceListener listener)
Deprecated. Use constructor to create a new instance and initService() to tell it to start connection to the ANT Radio Service. |
int |
getServiceLibraryVersionCode()
Returns the version code (eg. |
java.lang.String |
getServiceLibraryVersionName()
Returns the version name (eg "1.0") of ANTLib used by the ANT Radio Service |
static void |
goToMarket(Context pContext)
Go to market. |
static boolean |
hasAntSupport(Context pContext)
Check if this device has support for ANT. |
boolean |
hasClaimedInterface()
Check if the calling application has control of the ANT Radio. |
boolean |
initService(Context context,
AntInterface.ServiceListener listener)
Binds this activity to the ANT Radio Service. |
boolean |
isEnabled()
Checks if ANT is enabled. |
boolean |
isServiceConnected()
True if this activity can communicate with the ANT Radio Service. |
boolean |
releaseInterface()
Give up control of the ANT Radio. |
void |
releaseService()
Unbinds this activity from the ANT Radio Service. |
boolean |
requestForceClaimInterface(java.lang.String appName)
Claims the interface if it is available. |
boolean |
stopRequestForceClaimInterface()
Clears the notification asking the user if they would like to seize control of the ANT Radio. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String TAG
Constructor Detail |
---|
public AntInterface()
Method Detail |
---|
@Deprecated public static AntInterface getInstance(Context context, AntInterface.ServiceListener listener)
Note, since version 3.0 this will always create a new instance.
context
- the context used to bind to the remote service.listener
- the listener to be notified of status changes.
public static void goToMarket(Context pContext)
pContext
- the contextpublic boolean initService(Context context, AntInterface.ServiceListener listener)
java.lang.IllegalArgumentException
- if context is not provided.public void releaseService()
public boolean isServiceConnected()
@Deprecated public boolean destroy()
public void enable() throws AntInterfaceException
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void disable() throws AntInterfaceException
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public boolean isEnabled() throws AntInterfaceException
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTTxMessage(byte[] message) throws AntInterfaceException
Only use this fucntion if the message you want has not been implemented in the API.
See the ANT Message Protocol and Usage document for details.
message
- the message to send.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public int ANTSendPartialBurst(byte channelNumber, byte[] txBuffer, int initialPacket, boolean containsEndOfBurst) throws AntInterfaceException
channelNumber
- the channel numbertxBuffer
- the data to transmitinitialPacket
- the initial packetcontainsEndOfBurst
- the contains end of burst
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTUnassignChannel(byte channelNumber) throws AntInterfaceException
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTAssignChannel(byte channelNumber, byte channelType, byte networkNumber) throws AntInterfaceException
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTSetChannelId(byte channelNumber, short deviceNumber, byte deviceType, byte txType) throws AntInterfaceException
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTSetChannelPeriod(byte channelNumber, short channelPeriod) throws AntInterfaceException
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTSetChannelSearchTimeout(byte channelNumber, byte searchTimeout) throws AntInterfaceException
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTSetChannelRFFreq(byte channelNumber, byte radioFrequency) throws AntInterfaceException
A frequency in the 2402 MHz to 2480 MHz range is recommended.
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTAddChannelId(byte channelNumber, short deviceNumber, byte deviceType, byte txType, byte listIndex) throws AntInterfaceException
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTConfigList(byte channelNumber, byte listSize, byte exclude) throws AntInterfaceException
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTSetChannelTxPower(byte channelNumber, byte txPower) throws AntInterfaceException
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTSetLowPriorityChannelSearchTimeout(byte channelNumber, byte searchTimeout) throws AntInterfaceException
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTSetProximitySearch(byte channelNumber, byte searchThreshold) throws AntInterfaceException
Only ANT devices within the set proximity bin can be acquired. Search threshold values are not correlated to specific distances as this will be dependent to the system design.
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTResetSystem() throws AntInterfaceException
Execution of this command terminates all channels. All information previously configured in the system can no longer be considered valid.
After a Reset System command has been issued, the application should wait 500ms to ensure that ANT is in the proper, “after-reset” state before any further commands are issued from the host.
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTOpenChannel(byte channelNumber) throws AntInterfaceException
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTCloseChannel(byte channelNumber) throws AntInterfaceException
The host will initially receive a RESPONSE_NO_ERROR message indicating the message was successfully received by ANT. The actual closing of the channel will be indicated by an EVENT_CHANNEL_CLOSED, and the host should wait for this message before performing any other operations on the channel.
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTRequestMessage(byte channelNumber, byte messageID) throws AntInterfaceException
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTSendBroadcastData(byte channelNumber, byte[] txBuffer) throws AntInterfaceException
Note, data payload for a broadcast message is 8 bytes. The host application shall always define the full 8 bytes of the data packet and set unused bytes appropriately. If an application requires less than 8 bytes of data to be transmitted over the air, the remaining unused bytes shall be set to a predefined “unused” value (for example, ANT+ device profiles specify unused byte values, such as 0x00 or 0xFF).
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTSendAcknowledgedData(byte channelNumber, byte[] txBuffer) throws AntInterfaceException
Note, data payload for an acknowledged message is 8 bytes. The host application shall always define the full 8 bytes of the data packet and set unused bytes appropriately. If an application requires less than 8 bytes of data to be transmitted over the air, the remaining unused bytes shall be set to a predefined “unused” value (for example, ANT+ device profiles specify unused byte values, such as 0x00 or 0xFF).
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public int ANTSendBurstTransfer(byte channelNumber, byte[] txBuffer) throws AntInterfaceException
See the
ANT Message Protocol and Usage document for details.
NumDataPackets is not required, as this will be calculated.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTSendBurstTransferPacket(byte control, byte[] txBuffer) throws AntInterfaceException
When a single packet burst is sent, it behaves identically to an acknowledged message, there are no retries associated with a single packet burst.
See the ANT Message Protocol and Usage document for details.
NOTE: Sending individual burst packets will most likely result in a failure due to the data not arriving at the chip quickly enough for it to continue the burst.
control
- Is the combination of sequence number and channel number.txBuffer
- Must be 8 bytes of data to transmit as a bust packet.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTConfigEventBuffering(short screenOnFlushTimerInterval, short screenOnFlushBufferThreshold, short screenOffFlushTimerInterval, short screenOffFlushBufferThreshold) throws AntInterfaceException
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public void ANTDisableEventBuffering() throws AntInterfaceException
See the ANT Message Protocol and Usage document for details.
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public int getServiceLibraryVersionCode() throws AntInterfaceException
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public java.lang.String getServiceLibraryVersionName() throws AntInterfaceException
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public boolean claimInterface() throws AntInterfaceException
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public boolean releaseInterface() throws AntInterfaceException
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public boolean requestForceClaimInterface(java.lang.String appName) throws AntInterfaceException
appName
- The name if this application, to show to the user.
java.lang.IllegalArgumentException
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public boolean stopRequestForceClaimInterface() throws AntInterfaceException
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public boolean hasClaimedInterface() throws AntInterfaceException
AntInterfaceException
AntServiceNotConnectedException
AntRemoteException
public static boolean hasAntSupport(Context pContext)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |