Class AntContinuousScanController

java.lang.Object
com.dsi.ant.channel.AntContinuousScanController
All Implemented Interfaces:
android.os.Parcelable

public final class AntContinuousScanController extends Object implements 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
  • Field Details

    • CREATOR

      public static final android.os.Parcelable.Creator<AntContinuousScanController> 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

      public void open() throws android.os.RemoteException, AntCommandFailedException
      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 of AntChannelProvider 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 calling Capabilities.getRfFrequencyMin() and Capabilities.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 a AntCommandFailureReason.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

      public Capabilities getCapabilities() throws android.os.RemoteException
      Gets the Capabilities 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

      public void close() throws android.os.RemoteException, AntCommandFailedException
      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 a MessageFromAntType.CHANNEL_EVENT through IAntChannelEventHandler.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 to EventBufferSettings.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, AntCommandFailedException
      Asks 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.RemoteException
      Clears the handler registered to this callback through setScanChannelEventHandler(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 calling clearScanChannelEventHandler().
      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 calling clearAdapterEventHandler().
      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.RemoteException
      Clears the handler registered to this callback through setAdapterEventHandler(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 interface android.os.Parcelable
    • writeToParcel

      public void writeToParcel(android.os.Parcel dest, int flags)
      Writes value into the provided parcel
      Specified by:
      writeToParcel in interface android.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