Package com.dsi.ant.plugins.antplus.pcc
Class AntPlusWeightScalePcc
java.lang.Object
com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc
com.dsi.ant.plugins.antplus.pccbase.AntPlusCommonPcc
com.dsi.ant.plugins.antplus.pcc.AntPlusWeightScalePcc
Enables communication between a client and the WeightScale plugin service.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Represents the data contained in an advanced measurement from a scalestatic enum
The status of the body weight value.static enum
Defines codes for the gender of the user of the weight scalestatic interface
Receiver for the AdvancedMeasurementFinished event, which is: Receives the result of an advanced measurement request.static interface
Receiver for the BasicMeasurementFinished event, which is: Receives the result of a basic measurement request.static interface
Receiver for the BodyWeightBroadcast event, which is: The weight value currently broadcast by the weight scale.static interface
Receiver for the CapabilitiesRequestFinished event, which is: Receives the result of a capabilities request.static interface
Receiver for the DownloadAllHistoryFinished event, which is: Receives the result of arequestDownloadAllHistory(IDownloadAllHistoryFinishedReceiver, IFitFileDownloadedReceiver, IAntFsProgressUpdateReceiver)
command.class
Defines the keys and values used to communicate between the PCC and plugin.static class
Represents data specific to the user of the weight scalestatic enum
Defines the status code results sent on the result receiver for requests to the plugin.Nested classes/interfaces inherited from class com.dsi.ant.plugins.antplus.pccbase.AntPlusCommonPcc
AntPlusCommonPcc.CommonDataPage, AntPlusCommonPcc.IBatteryStatusReceiver, AntPlusCommonPcc.IManufacturerIdentificationReceiver, AntPlusCommonPcc.IManufacturerSpecificDataReceiver, AntPlusCommonPcc.IProductInformationReceiver, AntPlusCommonPcc.IRequestFinishedReceiver, AntPlusCommonPcc.IRssiReceiver
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.AntPlusCommonPcc
mRequestFinishedReceiver
Fields inherited from class com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc
mReleaseHandle, mStateChangeReceiver, PATH_ANTPLUS_PLUGINS_PKG, reportedServiceVersion, supportsRssiEvent
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
protected int
protected android.content.Intent
protected void
handlePluginEvent
(android.os.Message eventMsg) requestAccess
(android.app.Activity userActivity, android.content.Context bindToContext, boolean skipPreferredSearch, int searchProximityThreshold, AntPluginPcc.IPluginAccessResultReceiver<AntPlusWeightScalePcc> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver) Sends a request to the plugin to access a device and receive a live PCC instance.requestAccess
(android.app.Activity userActivity, android.content.Context bindToContext, AntPluginPcc.IPluginAccessResultReceiver<AntPlusWeightScalePcc> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver) Sends a request to the plugin to access a device and receive a live PCC instance.requestAccess
(android.content.Context bindToContext, int antDeviceNumber, int searchProximityThreshold, AntPluginPcc.IPluginAccessResultReceiver<AntPlusWeightScalePcc> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver) Sends a request to the plugin to access a device and receive a live PCC instance.boolean
requestAdvancedMeasurement
(AntPlusWeightScalePcc.IAdvancedMeasurementFinishedReceiver advancedMeasurementFinishedReceiver, AntPlusWeightScalePcc.UserProfile userProfile) Requests advanced weight measurements for the given user from the scale.requestAsyncScanController
(android.content.Context bindToContext, int searchProximityThreshold, AsyncScanController.IAsyncScanResultReceiver scanResultReceiver) Sends a request to the plugin to start an asynchronous search for available devices.boolean
requestBasicMeasurement
(AntPlusWeightScalePcc.IBasicMeasurementFinishedReceiver basicMeasurementFinishedReceiver) Requests a basic weight measurement from the scale.boolean
requestCapabilities
(AntPlusWeightScalePcc.ICapabilitiesRequestFinishedReceiver capabilitiesReceiver) Requests the capabilities of weight scale and the identifier of the currently 'selected' user profile, if any.boolean
requestDownloadAllHistory
(AntPlusWeightScalePcc.IDownloadAllHistoryFinishedReceiver downloadAllHistoryFinishedReceiver, FitFileCommon.IFitFileDownloadedReceiver fitFileDownloadedReceiver, AntFsCommon.IAntFsProgressUpdateReceiver antFsProgressUpdateRecevier) Requests a download of all of the history data from the device.void
subscribeBodyWeightBroadcastEvent
(AntPlusWeightScalePcc.IBodyWeightBroadcastReceiver BodyWeightBroadcastReceiver) Subscribe to receive BodyWeightBroadcast events, which contain: The weight value currently broadcast by the weight scale.Methods inherited from class com.dsi.ant.plugins.antplus.pccbase.AntPlusCommonPcc
requestCommonDataPage, requestManufacturerSpecificDataPage, sendManufacturerSpecificDataPage, sendRequestCommand, sendRequestCommand, sendRequestCommand, sendRequestCommand, subscribeBatteryStatusEvent, subscribeManufacturerIdentificationEvent, subscribeManufacturerSpecificDataEvent, subscribeProductInformationEvent, subscribeRssiEvent, supportsRssi
Methods inherited from class com.dsi.ant.plugins.antplus.pccbase.AntPluginPcc
bindAndRequest, closePluginConnection, createCmdMsg, getAntDeviceNumber, getCurrentDeviceState, getDeviceName, getInstalledPluginsVersionNumber, getInstalledPluginsVersionString, getMissingDependencyName, getMissingDependencyPackageName, 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
-
Method Details
-
getRequiredServiceVersionForBind
protected int getRequiredServiceVersionForBind()- Specified by:
getRequiredServiceVersionForBind
in classAntPluginPcc
-
requestAccess
public static PccReleaseHandle<AntPlusWeightScalePcc> requestAccess(android.app.Activity userActivity, android.content.Context bindToContext, boolean skipPreferredSearch, int searchProximityThreshold, AntPluginPcc.IPluginAccessResultReceiver<AntPlusWeightScalePcc> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver) 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:
userActivity
- 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
- It is recommended to always use -1 to use the user's default settings unless your application has a specific reason to do otherwise. 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.
-
requestAccess
public static PccReleaseHandle<AntPlusWeightScalePcc> requestAccess(android.app.Activity userActivity, android.content.Context bindToContext, AntPluginPcc.IPluginAccessResultReceiver<AntPlusWeightScalePcc> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver) 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. This overload callsrequestAccess(Activity, Context, boolean, int, IPluginAccessResultReceiver, IDeviceStateChangeReceiver)
with skipPreferrredSearch=false and searchProximityThreshold=-1(user default).
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:
userActivity
- 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.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.
-
requestAccess
public static PccReleaseHandle<AntPlusWeightScalePcc> requestAccess(android.content.Context bindToContext, int antDeviceNumber, int searchProximityThreshold, AntPluginPcc.IPluginAccessResultReceiver<AntPlusWeightScalePcc> resultReceiver, AntPluginPcc.IDeviceStateChangeReceiver stateReceiver) 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:
bindToContext
- 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.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.
-
requestAsyncScanController
public static AsyncScanController<AntPlusWeightScalePcc> requestAsyncScanController(android.content.Context bindToContext, int searchProximityThreshold, AsyncScanController.IAsyncScanResultReceiver scanResultReceiver) Sends a request to the plugin to start an asynchronous search for available devices. Using the returned AsyncScanController you can view available devices (including devices already connected to the plugin by other applications), receive user saved info and preferences for available devices, and eventually request access to a device you desire to connect to.
Note: The scan is started automatically, and must be stopped by your application to avoid resource leaks. (See the controller documentation for more details:AsyncScanController
.- Parameters:
bindToContext
- The context to which the plugin will be bound. Used for plugin lifecycle management.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 rating from 1-10 where 1 is the strongest (ie: closest) and 10 is the lowest(ie: farthest away). 0 = don't use proximity search.scanResultReceiver
- The receiver to receive the info for available devices and status of the scan.- Returns:
- The controller object for the asynchronous controller. Note: The scan is started automatically,
and must be stopped by your application to avoid resource leaks.
(See the controller documentation for more details:
AsyncScanController
.
-
getServiceBindIntent
protected android.content.Intent getServiceBindIntent()- Specified by:
getServiceBindIntent
in classAntPluginPcc
-
getPluginPrintableName
- Specified by:
getPluginPrintableName
in classAntPluginPcc
-
handlePluginEvent
protected void handlePluginEvent(android.os.Message eventMsg) - Overrides:
handlePluginEvent
in classAntPlusCommonPcc
-
requestBasicMeasurement
public boolean requestBasicMeasurement(AntPlusWeightScalePcc.IBasicMeasurementFinishedReceiver basicMeasurementFinishedReceiver) Requests a basic weight measurement from the scale.- Parameters:
basicMeasurementFinishedReceiver
- Receives the body weight measurement.- Returns:
- True if request was submitted successfully and you are guaranteed a result on the result receiver.
-
requestAdvancedMeasurement
public boolean requestAdvancedMeasurement(AntPlusWeightScalePcc.IAdvancedMeasurementFinishedReceiver advancedMeasurementFinishedReceiver, AntPlusWeightScalePcc.UserProfile userProfile) Requests advanced weight measurements for the given user from the scale. The advanced measurements will only be calculated when a valid user profile is available to the weight scale; this requires a scale that supports device profiles, and for a user profile to be provided in this function or for the scale to have a user profile already 'selected'.
Note: If you specify a user profile for this request and the weight scale supports user profiles, it should set the given profile as the new 'selected' profile.- Parameters:
advancedMeasurementFinishedReceiver
- Receiver for the body weight measurement, or null if the request was unsuccessful.userProfile
- The user details to calculate the advanced body measurement information, or null to use the current profile set on the weight scale. If this is set to null and the weight scale does not have a 'selected' profile or the weight scale does not support user profiles then the scale will not calculate any advanced information.- Returns:
- True if request was submitted successfully and you are guaranteed a result on the result receiver.
-
requestCapabilities
public boolean requestCapabilities(AntPlusWeightScalePcc.ICapabilitiesRequestFinishedReceiver capabilitiesReceiver) Requests the capabilities of weight scale and the identifier of the currently 'selected' user profile, if any.- Parameters:
capabilitiesReceiver
- Receives the capabilities of the weight scale.- Returns:
- True if request was submitted successfully and you are guaranteed a result on the result receiver.
-
requestDownloadAllHistory
public boolean requestDownloadAllHistory(AntPlusWeightScalePcc.IDownloadAllHistoryFinishedReceiver downloadAllHistoryFinishedReceiver, FitFileCommon.IFitFileDownloadedReceiver fitFileDownloadedReceiver, AntFsCommon.IAntFsProgressUpdateReceiver antFsProgressUpdateRecevier) Requests a download of all of the history data from the device.- Parameters:
downloadAllHistoryFinishedReceiver
- The receiver to receive the status of the file download.fitFileDownloadedReceiver
- The receiver to receive each downloaded file from the device as it is downloaded over ANT-FS.antFsProgressUpdateRecevier
- Optional. The receiver to receive the state updates of the ANT-FS connection or null.- Returns:
- True if request was submitted successfully and you are guaranteed a result on the result receiver.
-
subscribeBodyWeightBroadcastEvent
public void subscribeBodyWeightBroadcastEvent(AntPlusWeightScalePcc.IBodyWeightBroadcastReceiver BodyWeightBroadcastReceiver) Subscribe to receive BodyWeightBroadcast events, which contain: The weight value currently broadcast by the weight scale. This event is useful for dynamic value scale and specialized scenarios, but most applications should preferably use the request methods for greater convenience. This function can also be used to unsubscribe from an event, by passing null as the receiver.- Parameters:
BodyWeightBroadcastReceiver
- receiver to receive events (or null to unsubscribe from this event).
-