Package com.dsi.ant.channel
Class AntContinuousScanController
java.lang.Object
com.dsi.ant.channel.AntContinuousScanController
- All Implemented Interfaces:
android.os.Parcelable
The ANT Continuous Scan controller on any piece of ANT hardware. It is the
communication link used when a single ANT node must receive, and possibly
process, data from multiple nodes. This controller prevents other channels
from being opened and it is created in assigned state. Also, as the RF is
continually active, this node draws significant power (peak Rx current)
and therefore continuous scanning mode should not be used for devices
that have tight power constraints.
See the ANT
Message Protocol and Usage document for more details.
This class is parcelable and can therefore be passed between processes.
In this case care must be taken that
setScanChannelEventHandler(IAntChannelEventHandler)
and
clearScanChannelEventHandler()
are used properly.- Since:
- 4.11.1
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface android.os.Parcelable
android.os.Parcelable.ClassLoaderCreator<T>, android.os.Parcelable.Creator<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final android.os.Parcelable.Creator<AntContinuousScanController>
Creates an AntContinuousScanController from a ParcelFields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the handler registered to this callback throughsetAdapterEventHandler(IAntAdapterEventHandler)
and closes its associated resources.void
Clears the handler registered to this callback throughsetScanChannelEventHandler(IAntChannelEventHandler)
and closes its associated resources.void
close()
Closes the controller.int
Gets theCapabilities
of this controller.void
open()
Opens continuous scan.void
readFromParcel
(android.os.Parcel source) Set values to those in the provided Parcelvoid
release()
Does the opposite ofAntChannelProvider
acquireContinuousScanController(), tearing down this controller instance.Asks the controller for its status information.void
setAdapterEventHandler
(IAntAdapterEventHandler eventHandler) Sets up the handler to be used for event callbacks from the adapter this controller is on.void
setChannelId
(ChannelId channelId) Configures the channel ID for this channel.void
setEventBuffer
(EventBufferSettings eventBufferSettings) Enables event buffering to buffer messages and deliver them when the buffer time expires, or the buffer is full.void
setRfFrequency
(int radioFrequencyOffset) Sets the RF frequency for this channel by a frequency offset, e.g.void
setScanChannelEventHandler
(IAntChannelEventHandler eventHandler) Sets up the handler to be used for event callbacks from this controller.void
writeToParcel
(android.os.Parcel dest, int flags) Writes value into the provided parcel
-
Field Details
-
CREATOR
Creates an AntContinuousScanController from a Parcel- Since:
- 4.11.1
-
-
Method Details
-
setChannelId
public void setChannelId(ChannelId channelId) throws android.os.RemoteException, AntCommandFailedException Configures the channel ID for this channel. Note: a value of 0 here signifies using a wild card for that parameter when finding a match.See the ANT Message Protocol and Usage document for more details.
- Parameters:
channelId
- The device number, device type and transmission type to identify this channel.- Throws:
android.os.RemoteException
- If you receive this exception then the channel should be considered dead. In this circumstance you can attempt to acquire a replacement channel.AntCommandFailedException
- If the service reported a failure.- Since:
- 4.11.1
-
open
Opens continuous scan. The controller is already in assigned state when it was acquired.See the ANT Message Protocol and Usage document for more details.
- Throws:
android.os.RemoteException
- If you receive this exception then the channel should be considered dead. In this circumstance you can attempt to acquire a replacement channel.AntCommandFailedException
- If the service reported a failure.- Since:
- 4.11.1
-
release
public void release()Does the opposite ofAntChannelProvider
acquireContinuousScanController(), tearing down this controller instance. It cannot be used after calling this method. This signals the ANT Radio service to reclaim the channel resources for other applications to use.- Since:
- 4.11.1
-
setRfFrequency
public void setRfFrequency(int radioFrequencyOffset) throws android.os.RemoteException, AntCommandFailedException Sets the RF frequency for this channel by a frequency offset, e.g. 50 MHz offset = 2450 MHz. The valid range for the offset can be found by getting the channel's capabilities (getCapabilities()
) and callingCapabilities.getRfFrequencyMin()
andCapabilities.getRfFrequencyMax()
. A frequency offset of 57 MHz (2457 MHz) is not allowed and is reserved for use by the ANT+ Plugin API, which must be used to connect to ANT+ devices. An attempt to set a frequency outside of these allowed values will fail with aAntCommandFailureReason.INVALID_REQUEST
. See the ANT Message Protocol and Usage document for more details.- Parameters:
radioFrequencyOffset
- The radio frequency to use for this channel's communication as an offset in MHz from 2400MHz (2.4GHz).- Throws:
android.os.RemoteException
- If you receive this exception then the channel should be considered dead. In this circumstance you can attempt to acquire a replacement channel.AntCommandFailedException
- If the service reported a failure.- Since:
- 4.11.1
-
getCapabilities
Gets theCapabilities
of this controller. These are based on the adapter (hardware) the controller is running on.- Returns:
- The capabilities of this controller.
- Throws:
android.os.RemoteException
- If you receive this exception then the controller should be considered dead. In this circumstance you can attempt to acquire a replacement controller.- Since:
- 4.11.1
-
close
Closes the controller.Note: This method returns when the close command itself is successful, but not the actual event of the controller completing the close routines. To synchronize on the actual closing of the channel wait for the response event
EventCode.CHANNEL_CLOSED
in aMessageFromAntType.CHANNEL_EVENT
throughIAntChannelEventHandler.onReceiveMessage(MessageFromAntType, AntMessageParcel)
.See the ANT Message Protocol and Usage document for more details.
- Throws:
android.os.RemoteException
- If you receive this exception then the channel should be considered dead. In this circumstance you can attempt to acquire a replacement channel.AntCommandFailedException
- If the service reported a failure.- Since:
- 4.11.1
-
setEventBuffer
public void setEventBuffer(EventBufferSettings eventBufferSettings) throws android.os.RemoteException, AntCommandFailedException Enables event buffering to buffer messages and deliver them when the buffer time expires, or the buffer is full. The Continuous Scan Mode controller turns off event buffering by default, but re-enabling it toEventBufferSettings.DEFAULT_BUFFER_TIME_MILLISECONDS
can substantially increase power savings in cases where that is required. See the ANT Message Protocol and Usage document for details.- Parameters:
eventBufferSettings
- Indicates the specific event buffer values to be requested- Throws:
android.os.RemoteException
- If you receive this exception then the channel should be considered dead. In this circumstance you can attempt to acquire a replacement channel.AntCommandFailedException
- If the service reported a failure.- Since:
- 4.11.1
-
requestChannelStatus
public ChannelStatusMessage requestChannelStatus() throws android.os.RemoteException, AntCommandFailedExceptionAsks the controller for its status information.- Returns:
- This controller's ChannelStatus.
- Throws:
android.os.RemoteException
- If you receive this exception then the controller should be considered dead. In this circumstance you can attempt to acquire a replacement controller.AntCommandFailedException
- If the service reported a failure.- Since:
- 4.11.1
-
clearScanChannelEventHandler
public void clearScanChannelEventHandler() throws android.os.RemoteExceptionClears the handler registered to this callback throughsetScanChannelEventHandler(IAntChannelEventHandler)
and closes its associated resources.- Throws:
android.os.RemoteException
- If you receive this exception then the controller should be considered dead. In this circumstance you can attempt to acquire a replacement controller.- Since:
- 4.11.1
-
setScanChannelEventHandler
public void setScanChannelEventHandler(IAntChannelEventHandler eventHandler) throws android.os.RemoteException Sets up the handler to be used for event callbacks from this controller. Setting a handler clears any handler previously registered. The handler can be cleared by callingclearScanChannelEventHandler()
.- Parameters:
eventHandler
- The handler to receive the channel events.- Throws:
android.os.RemoteException
- If you receive this exception then the controller should be considered dead. In this circumstance you can attempt to acquire a replacement controller.- Since:
- 4.11.1
- See Also:
-
setAdapterEventHandler
public void setAdapterEventHandler(IAntAdapterEventHandler eventHandler) throws android.os.RemoteException Sets up the handler to be used for event callbacks from the adapter this controller is on. Events are triggered for any configuration changes that impact the controller. Setting a handler clears any handler previously registered. The handler can be cleared by callingclearAdapterEventHandler()
.- Parameters:
eventHandler
- The handler to receive the adapter events.- Throws:
android.os.RemoteException
- If you receive this exception then the controller should be considered dead. In this circumstance you can attempt to acquire a replacement controller.- Since:
- 4.11.1
- See Also:
-
clearAdapterEventHandler
public void clearAdapterEventHandler() throws android.os.RemoteExceptionClears the handler registered to this callback throughsetAdapterEventHandler(IAntAdapterEventHandler)
and closes its associated resources.- Throws:
android.os.RemoteException
- If you receive this exception then the controller should be considered dead. In this circumstance you can attempt to acquire a replacement controller.- Since:
- 4.11.1
-
describeContents
public int describeContents()- Specified by:
describeContents
in interfaceandroid.os.Parcelable
-
writeToParcel
public void writeToParcel(android.os.Parcel dest, int flags) Writes value into the provided parcel- Specified by:
writeToParcel
in interfaceandroid.os.Parcelable
- Since:
- 4.11.1
-
readFromParcel
public void readFromParcel(android.os.Parcel source) Set values to those in the provided Parcel- Parameters:
source
- Parceled version of an ServiceResultParcel.- Since:
- 4.11.1
-