Class AntPlusBikeSpdCadCommonPcc
java.lang.Object
com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc
com.dsi.ant.plugins.antplus.pccbase.AntPlusLegacyCommonPcc
com.dsi.ant.plugins.antplus.pccbase.AntPlusBikeSpdCadCommonPcc
- Direct Known Subclasses:
AntPlusBikeCadencePcc
,AntPlusBikeSpeedDistancePcc
Base class for bike speed sensors and bike cadence sensors implementing request access to handle combined bike and speed sensors.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Controls a scan for devices available to connect to, and requesting access to one of those available devices.static class
Contains the data describing a device detected by the scan.static interface
Receiver for the BatteryStatus event, which is: Information about the battery status.static interface
Receives results and failures of an async scan.class
Defines the keys and values used to communicate between the PCC and plugin.static class
Search Result InformationNested classes/interfaces inherited from class com.dsi.ant.plugins.antplus.pccbase.AntPlusLegacyCommonPcc
AntPlusLegacyCommonPcc.ICumulativeOperatingTimeReceiver, AntPlusLegacyCommonPcc.IManufacturerAndSerialReceiver, AntPlusLegacyCommonPcc.IVersionAndModelReceiver
Nested classes/interfaces inherited from class com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc
AntPluginPcc.IDeviceStateChangeReceiver, AntPluginPcc.IPluginAccessResultReceiver<T extends AntPluginPcc>, AntPluginPcc.RequestAccessResultHandler<T extends AntPluginPcc>, AntPluginPcc.RequestAccessResultHandler_AsyncSearchByDevNumber<T extends AntPluginPcc>, AntPluginPcc.RequestAccessResultHandler_UI<T extends AntPluginPcc>, AntPluginPcc.StandardReleaseHandle<T extends AntPluginPcc>
-
Field Summary
Fields inherited from class com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc
mReleaseHandle, mStateChangeReceiver, PATH_ANTPLUS_PLUGINS_PKG, reportedServiceVersion, supportsRssiEvent
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AntPlusBikeSpdCadCommonPcc
(boolean isInstanceCadencePcc) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected android.os.Message
createCmdMsg
(int cmdCode, android.os.Bundle msgData) protected int
protected void
handlePluginEvent
(android.os.Message eventMsg) boolean
Indicates if this sensor is a speed and cadence combined sensor.protected static <T extends AntPlusBikeSpdCadCommonPcc>
PccReleaseHandle<T>requestAccessBSC_helper
(boolean isCadence, android.app.Activity userActivity, android.content.Context bindToContext, boolean skipPreferredSearch, int searchProximityThreshold, AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver, T potentialRetObj) Sends a request to the plugin to access a device and receive a live PCC instance.protected static <T extends AntPlusBikeSpdCadCommonPcc>
PccReleaseHandle<T>requestAccessBSC_helper
(boolean isCadence, android.content.Context bindToContext, int antDeviceNumber, int searchProximityThreshold, boolean isSpdCadCombinedSensor, AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver, T potentialRetObj) Sends a request to the plugin to access a device and receive a live PCC instance.protected static <T extends AntPlusBikeSpdCadCommonPcc>
AntPlusBikeSpdCadCommonPcc.BikeSpdCadAsyncScanController<T>requestAccessBSC_Helper_AsyncScanController
(boolean isCadence, android.content.Context bindingContext, int searchProximityThreshold, T retPccObject, AntPlusBikeSpdCadCommonPcc.IBikeSpdCadAsyncScanResultReceiver scanResultReceiver) protected void
setIsSpeedAndCadence
(boolean isSpeedAndCadence) boolean
subscribeBatteryStatusEvent
(AntPlusBikeSpdCadCommonPcc.IBatteryStatusReceiver batteryStatusReceiver) Subscribe to receive BatteryStatus events, which contain: Information about the battery status.Methods inherited from class com.dsi.ant.plugins.antplus.pccbase.AntPlusLegacyCommonPcc
subscribeCumulativeOperatingTimeEvent, subscribeManufacturerAndSerialEvent, subscribeRssiEvent, subscribeVersionAndModelEvent, supportsRssi
Methods inherited from class com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc
bindAndRequest, closePluginConnection, getAntDeviceNumber, getCurrentDeviceState, getDeviceName, getInstalledPluginsVersionNumber, getInstalledPluginsVersionString, getMissingDependencyName, getMissingDependencyPackageName, getPluginPrintableName, getServiceBindIntent, handleNonCmdPluginMessage, isUserPreferredDeviceForPlugin, isUserRecognizedDevice, releaseAccess, requestAccess_Helper_AsyncScanController, requestAccess_Helper_AsyncSearchByDevNumber, requestAccess_Helper_Main, requestAccess_Helper_SearchActivity, requestAccess_Helper_SubMain, requestAsyncScan_Helper_SubMain, sendPluginCommand, sendPluginCommand, startPluginManagerActivity, subscribeToEvent, unsubscribeFromEvent
-
Constructor Details
-
AntPlusBikeSpdCadCommonPcc
protected AntPlusBikeSpdCadCommonPcc(boolean isInstanceCadencePcc) Constructor- Parameters:
isInstanceCadencePcc
- true if constructing a BikeCadencePcc
-
-
Method Details
-
getRequiredServiceVersionForBind
protected int getRequiredServiceVersionForBind()- Specified by:
getRequiredServiceVersionForBind
in classAntPluginPcc
-
requestAccessBSC_helper
protected static <T extends AntPlusBikeSpdCadCommonPcc> PccReleaseHandle<T> requestAccessBSC_helper(boolean isCadence, android.app.Activity userActivity, android.content.Context bindToContext, boolean skipPreferredSearch, int searchProximityThreshold, AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver, T potentialRetObj) Sends a request to the plugin to access a device and receive a live PCC instance. If the minimum version of the desired plugin is installed, this will start a search for a device to connect to and return the result on the provided result receiver. This method displays a search dialog UI while the search is in progress.
If the user has a preferred device set for this plugin and skipPreferredSearch is not set true, this request will attempt to connect to that device first. Then if the search for the preferred device times-out, the user can choose to retry, cancel, or search for other devices. If there is no preferred device configured or skipPreferredSearch is set to true, the search will begin directly at searching for other devices.During the search for other devices, a list of devices detected in range is presented to the user. Any time during the search the user can select a device from the list to connect to, and can optionally save a name for that device and set it as the preferred device for future searches.
Regardless of how the search proceeds, as soon as a device is connected or if an error occurs or the user cancels then the result will be posted to the supplied result receiver.
Note: During the search this function will display UI elements to display the progress of the search to the user and allow them to interact and control the search. If this is not acceptable to the calling application, then do not use this version of requestAccess().- Parameters:
isCadence
- True if caller is the cadence PCC, false if SpdDstuserActivity
- The current foreground activity. Used to display search progress and results.bindToContext
- The context to which the plugin will be bound. Used for plugin lifecycle management.skipPreferredSearch
- True = Don't automatically connect to user's preferred device, but always go to search for other devices.searchProximityThreshold
- This value represents the signal strength 'proximity' requirement on finding matches during searching, if a device does not meet the requirements it will not show up in the search at all. The value is a generic signal strength threshold from 1-10 where 1 is the strongest (ie: closest) and 10 is the lowest(ie: farthest away). 0 = don't use proximity search and -1 = use plugin user-specified default.resultReceiver
- The receiver to receive the results of the request. Possible returns include:stateReceiver
- The receiver to receive the state updates of the accessed device, assuming the request is successful. This receiver will receive notifications of all state changes to the device that occur subsequent to the initial state returned in the result receiver.- Returns:
- A release handle for the device. This can be used to guarantee the device is properly shutdown and cleaned up, even before the device is actually received through the result receiver.
-
requestAccessBSC_helper
protected static <T extends AntPlusBikeSpdCadCommonPcc> PccReleaseHandle<T> requestAccessBSC_helper(boolean isCadence, android.content.Context bindToContext, int antDeviceNumber, int searchProximityThreshold, boolean isSpdCadCombinedSensor, AntPluginPcc.IPluginAccessResultReceiver<T> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver, T potentialRetObj) Sends a request to the plugin to access a device and receive a live PCC instance. If the minimum version of the desired plugin is installed, this will start an asynchronous search for a device to connect to and return the result on the provided result receiver.
The plugin will attempt to connect to a device with the provided deviceNumber and return a result when the device is connected or the search fails. The search will timeout after 10s, if you wish to keep searching you can call this method again.
Note: If you set deviceNumber to 0 it will connect to the first available/found device.- Parameters:
isCadence
- True if caller is the cadence PCC, false if SpdDstbindToContext
- The context to which the plugin will be bound. Used for plugin lifecycle management.antDeviceNumber
- DeviceNumber to attempt to connect to. A deviceNumber of 0 indicates a desire to connect to first available device.searchProximityThreshold
- This value represents the signal strength 'proximity' requirement on finding matches during searching, if a device does not meet the requirements it will not show up in the search at all. The value is a generic signal strength threshold from 1-10 where 1 is the strongest (ie: closest) and 10 is the lowest(ie: farthest away). 0 = don't use proximity search.isSpdCadCombinedSensor
- Set to true if the deviceNumber specified belongs to a combined speed and cadence sensor. For a wildcard search (when device ID is 0), true indicates to search for only a combined speed and cadence sensor, false indicates to search for any type speed sensor. Note: You can determine if a sensor is a combined one or not by callingisSpeedAndCadenceCombinedSensor()
. You could then choose to connect to the additional sensor output of speed and distance usingrequestAccessBSC_helper(boolean, Context, int, int, boolean, IPluginAccessResultReceiver, IDeviceStateChangeReceiver, AntPlusBikeSpdCadCommonPcc)
.resultReceiver
- The receiver to receive the results of the request. Possible returns include:stateReceiver
- The receiver to receive the state updates of the accessed device, assuming the request is successful. This receiver will receive notifications of all state changes to the device that occur subsequent to the initial state returned in the result receiver.- Returns:
- A release handle for the device. This can be used to guarantee the device is properly shutdown and cleaned up, even before the device is actually received through the result receiver.
-
requestAccessBSC_Helper_AsyncScanController
protected static <T extends AntPlusBikeSpdCadCommonPcc> AntPlusBikeSpdCadCommonPcc.BikeSpdCadAsyncScanController<T> requestAccessBSC_Helper_AsyncScanController(boolean isCadence, android.content.Context bindingContext, int searchProximityThreshold, T retPccObject, AntPlusBikeSpdCadCommonPcc.IBikeSpdCadAsyncScanResultReceiver scanResultReceiver) -
setIsSpeedAndCadence
protected void setIsSpeedAndCadence(boolean isSpeedAndCadence) -
isSpeedAndCadenceCombinedSensor
public boolean isSpeedAndCadenceCombinedSensor()Indicates if this sensor is a speed and cadence combined sensor.- Returns:
- True if this device is a speed and cadence combined sensor
-
createCmdMsg
protected android.os.Message createCmdMsg(int cmdCode, android.os.Bundle msgData) - Overrides:
createCmdMsg
in classAntPluginPcc
-
handlePluginEvent
protected void handlePluginEvent(android.os.Message eventMsg) - Overrides:
handlePluginEvent
in classAntPlusLegacyCommonPcc
-
subscribeBatteryStatusEvent
public boolean subscribeBatteryStatusEvent(AntPlusBikeSpdCadCommonPcc.IBatteryStatusReceiver batteryStatusReceiver) Subscribe to receive BatteryStatus events, which contain: Information about the battery status. This function can also be used to unsubscribe from an event, by passing null as the receiver.- Parameters:
batteryStatusReceiver
- receiver to receive events (or null to unsubscribe from this event).- Returns:
- true if successful
- Since:
- 2.1.8; requires Plugin Service 2.2.8+
-