Wahoo Fitness API  3.6.1
Documentation for the iPhone version of the Wahoo Fitness API.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
WFWeightScaleConnection Class Reference

Represents a connection to an ANT+ or BTLE Weight Scale sensor. More...

#import <WFWeightScaleConnection.h>

+ Inheritance diagram for WFWeightScaleConnection:
+ Collaboration diagram for WFWeightScaleConnection:

Instance Methods

(BOOL- assignUserId:toHistoryRecordWithTimestamp:
 Assigns the specified userId to the history record from the scale which has a timestamp matching the parameter timestamp More...
 
(BOOL- clearAllHistory
 Instructs the sensor to clear its entire weight history. More...
 
(BOOL- clearAllUserRecords
 Instructs the sensor to clear all user records from memory. More...
 
(BOOL- clearHistoryRecordWithTimestamp:
 Deletes the latest history record from the scale which has a timestamp matching the parameter timestamp More...
 
(BOOL- clearUserRecordWithId:
 Clears the user record with id matching the parameter userId from the scale. More...
 
(void) - disconnect
 Disconnects the sensor. More...
 
(void) - disconnect:
 Disconnects the sensor and for BTLE peripheral, ensures the BTLE connection is closed. More...
 
(WFSensorData *) - getData
 Retrieves the most current data available from the sensor. More...
 
(NSTimeInterval) - getLastSyncTime
 Returns the date and time of this device's last known history download from the scale. More...
 
(WFSensorData *) - getRawData
 Retrieves the most current raw data available from the sensor. More...
 
(WFWeightScaleData *) - getWeightScaleData
 Returns the latest data available from the sensor. More...
 
(BOOL- hasData
 Returns a boolean value indicating whether new data is available. More...
 
(BOOL- requestAllHistory
 Requests all weight history from a BTLE weight scale sensor. More...
 
(BOOL- requestAllUserRecords
 Requests all user records from the sensor. More...
 
(BOOL- requestHistorySinceLastSync
 Requests all weight history from a BTLE weight scale sensor since the last sync with device. More...
 
(BOOL- requestHistorySinceTimestamp:
 Requests all weight history from the BTLE sensor having a timestamp greater than or equal to the timestamp parameter. More...
 
(WFBTLEServiceProcessor *) - serviceProcessorForSensorType:
 Returns a WFBTLEService derived instance which handles BTLE service processing for the specified sensor type. More...
 
(BOOL- setDisplayUnitType:
 Sets the units displayed on the scale LCD to Metric or Imperial . More...
 
(BOOL- setWeightScaleUserProfile:
 Sends a user profile message to the Weight Scale sensor with the user profile data specified in the WFWeightScaleUserProfile_t structure. More...
 
(float) - signalEfficiency
 Returns the signal efficiency for the connected sensor. More...
 
(BOOL- storeUserRecord:
 Creates a user record of type WFBTLEWeightScaleUser and stores it on the weight scale. More...
 
(void) - wsConnection:didAddNewUserRecord:
 After a new user profile has been successfully added to the scale and assigned an ID, this method will be called with the completed WFBTLEWeightScaleUser object as a parameter. More...
 
(void) - wsConnection:didReceiveUserId:
 Invoked when the WFWeightScaleConnection receives response from new user id request. More...
 
(void) - wsConnection:didReceiveUserRecords:
 Invoked when the WFWeightScaleConnection receives user records from the device. More...
 
(void) - wsConnection:didReceiveWeightHistory:
 Invoked when the WFWeightScaleConnection receives weight history from the device. More...
 
(void) - wsConnection:userProfileRejected:forOverlappingWith:
 Invoked when a user profile which has been added contains overlapping weight ranges with and existing profile on the scale. More...
 

Class Methods

(BOOL+ configureConditionalConnection:lastSyncDate:
 

Protected Attributes

WFBTLEWeightScaleUser_userRecordWaitingForId
 
BOOL _waitingForUserId
 

Properties

WFSensorConnectionStatus_t connectionStatus
 Gets the current connection status. More...
 
id< WFSensorConnectionDelegatedelegate
 Specifies the WFSensorConnectionDelegate instance which will handle callback methods for this WFSensorConnection. More...
 
NSString * deviceIDString
 Returns the Device ID of the connected sensor for both ANT and BTLE. More...
 
WFDeviceInformationdeviceInformation
 
USHORT deviceNumber
 Gets the ANT device ID of the connected sensor. More...
 
NSString * deviceUUIDString
 Specifies the BTLE Device UUID String. More...
 
BOOL didTimeout
 Gets a boolean value indicating whether a connection timeout occurred. More...
 
WFSensorConnectionError_t error
 Get the error status for the connection. More...
 
BOOL hasAntBridgeSupport
 Gets a boolean value indicating whether this WFSensorConnection instance is connected to a device which supports the Wahoo Fitness ANT Bridge. More...
 
BOOL hasError
 TRUE if an error has occured, otherwise FALSE. More...
 
BOOL hasValidParams
 Gets a boolean value indicating whether this WFSensorConnection has valid connection parameters. More...
 
BOOL hasWildcardParams
 Gets a boolean value indicating whether the connection parameters for this WFSensorConnection indicate a wildcard search. More...
 
BOOL isANTConnection
 TRUE if the sensor is a ANT device, otherwise FALSE. More...
 
BOOL isBTLEConnection
 TRUE if the sensor is a BTLE device, otherwise FALSE. More...
 
BOOL isConnected
 TRUE if the sensor is currently connected, otherwise FALSE. More...
 
BOOL isValid
 Gets a boolean value indicating whether this WFSensorConnection instance is valid. More...
 
WFNetworkType_t networkType
 Specifies the network type of this WFSensorConnection (ANT+, BTLE, etc). More...
 
WFSensorSubType_t sensorSubType
 Gets the sensor sub type for this WFSensorConnection. More...
 
WFSensorType_t sensorType
 Gets the sensor type for this WFSensorConnection. More...
 
NSTimeInterval timeSinceLastMessage
 Gets the time since the last ANT message was received (in seconds). More...
 
UCHAR transmissionType
 Gets the ANT transmission type of the connected sensor. More...
 
id< WFWeightScaleDelegatewsDelegate
 Specifies the WFWeightScaleDelegate instance which will handle callback methods for this WFWeightScaleConnection. More...
 

Detailed Description

Represents a connection to an ANT+ or BTLE Weight Scale sensor.

Method Documentation

- (BOOL) assignUserId: (int)  userId
toHistoryRecordWithTimestamp: (NSTimeInterval)  timestamp 

Assigns the specified userId to the history record from the scale which has a timestamp matching the parameter timestamp

Returns
TRUE if the command was sent successfully, otherwise FALSE.
Parameters
userIdThe integer value to be written to the history record's user id field
timestampA NSTimeInterval matching the timestamp of the history record to clear. Timestamp is time since Apple referecne date.
- (BOOL) clearAllHistory

Instructs the sensor to clear its entire weight history.

Returns
TRUE if the command was sent successfully, otherwise FALSE.
- (BOOL) clearAllUserRecords

Instructs the sensor to clear all user records from memory.

Returns
TRUE if the command was sent successfully, otherwise FALSE.
- (BOOL) clearHistoryRecordWithTimestamp: (NSTimeInterval)  timestamp

Deletes the latest history record from the scale which has a timestamp matching the parameter timestamp

Returns
TRUE if the command was sent successfully, otherwise FALSE.
Parameters
timestampA NSTimeInterval matching the timestamp of the history record to clear. Timestamp is time since Apple reference date.

sets scale to

- (BOOL) clearUserRecordWithId: (int)  userId

Clears the user record with id matching the parameter userId from the scale.

Returns
TRUE if the command was sent successfully, otherwise FALSE.
Parameters
userIdThe unique user id of the record to be deleted
+ (BOOL) configureConditionalConnection: (WFConnectionParams *)  params
lastSyncDate: (NSDate *)  syncDate 
- (void) disconnect

Disconnects the sensor.

- (void) disconnect: (BOOL bKillPeripheralConnection

Disconnects the sensor and for BTLE peripheral, ensures the BTLE connection is closed.

BTLE peripheral connections are held in a "peripheral pool" to facilitate multiple logical connections to the same physical device. Normally, when the last logical connection (WFSensorConnection) is disconnected, the BTLE connection will be held in the pool briefly to reduce the overhead of any subsequent connection requests from the application. To override this behaviour, the disconnect: method may be invoked with the bKillPeripheralConnection parameter set to TRUE. In this case, if the WFSensorConnection requesting the disconnect is the last logical connection to the BTLE peripheral, the BTLE peripheral connection will be closed immediately and the BTLE peripheral will be removed from the pool.

Note
For ANT+ devices, this method behaves exactly the same as the disconnect method, regardless of the value of the bKillPeripheralConnection parameter.
Parameters
bKillPeripheralConnectionTRUE if the underlying BTLE connection should be closed immediately, otherwise FALSE.
- (WFSensorData*) getData

Retrieves the most current data available from the sensor.

Note
WFSensorData is an abstract base class for all sensor data types. The specific type will be determined by the type of sensor. The instance returned must be cast to the specific type in order to be useful.
Returns
A WFSensorData derived instance containing data if available, otherwise nil.
- (NSTimeInterval) getLastSyncTime

Returns the date and time of this device's last known history download from the scale.

Returns
NSTimeInterval seconds since Apple Reference Date of last sync time.
- (WFSensorData*) getRawData

Retrieves the most current raw data available from the sensor.

Note
This method will return raw (unformatted) data from the sensor. It is made available for applications which require processing of data as close to the original measured values a possible. There may be other rarely used data available via this method as well. For most applications, the getData method should be used instead.

WFSensorData is an abstract base class for all sensor data types. The specific type will be determined by the type of sensor. The instance returned must be cast to the specific type in order to be useful.
Returns
A WFSensorData derived instance containing data if available, otherwise nil.
- (WFWeightScaleData*) getWeightScaleData

Returns the latest data available from the sensor.

Note that this is for ANT+ weight scale sensors only.

See also
- getData (WFSensorConnection)
Returns
A WFWeightScaleData instance containing data if available, otherwise nil.
- (BOOL) hasData

Returns a boolean value indicating whether new data is available.

Returns
TRUE if new data is available since the last time getData was invoked, otherwise FALSE.
- (BOOL) requestAllHistory

Requests all weight history from a BTLE weight scale sensor.

Returns
TRUE if the command was sent successfully, otherwise FALSE.
- (BOOL) requestAllUserRecords

Requests all user records from the sensor.

Returns
TRUE if the command was sent successfully, otherwise FALSE.
- (BOOL) requestHistorySinceLastSync

Requests all weight history from a BTLE weight scale sensor since the last sync with device.

Returns
TRUE if the command was sent successfully, otherwise FALSE.
- (BOOL) requestHistorySinceTimestamp: (NSTimeInterval)  timestamp

Requests all weight history from the BTLE sensor having a timestamp greater than or equal to the timestamp parameter.

Parameters
timestampNSTimeInterval since Apple reference date
Returns
TRUE if the command was sent successfully, otherwise FALSE.
- (WFBTLEServiceProcessor*) serviceProcessorForSensorType: (WFSensorType_t eSensorType

Returns a WFBTLEService derived instance which handles BTLE service processing for the specified sensor type.

Parameters
eSensorTypeThe sensor type.
Returns
A WFBTLEService derived instance if successful, otherwise nil.
- (BOOL) setDisplayUnitType: (WFBTLEWeightScaleUnitType_t unitType

Sets the units displayed on the scale LCD to Metric or Imperial .

Note that the units stored on the scale and transmitted through the API will always be in Metric - this is for scale display purposes only.

Parameters
unitTypeA WFBTLEWeightScaleUnitType_t which can indicate imperial (english) or metric.
Returns
TRUE if the command was sent successfully, otherwise FALSE.
- (BOOL) setWeightScaleUserProfile: (WFWeightScaleUserProfile_t *)  pstData

Sends a user profile message to the Weight Scale sensor with the user profile data specified in the WFWeightScaleUserProfile_t structure.

Note that this is for ANT+ weight scale sensors only.

Parameters
pstDataA WFWeightScaleUserProfile_t structure containing the user profile information to be sent to the sensor.
Returns
TRUE if the user profile message was sent successfully, otherwise FALSE.
- (float) signalEfficiency

Returns the signal efficiency for the connected sensor.

Returns
For ANT connections, this property represents the ratio of messages received from the sensor over the number of messages expected (range [0, 1.0]). This value should give a good indication of the reception quality for the sensor. For BTLE connections, this property represents the RSSI (in dBm). If the sensor is not currently connected, the return value is -1.
- (BOOL) storeUserRecord: (WFBTLEWeightScaleUser *)  userRecord

Creates a user record of type WFBTLEWeightScaleUser and stores it on the weight scale.

Will send a WFBTLEWeightScaleUser object to the delegate once it has been created and assigned a userId locally on the scale. If the provided weight range overlaps with an existing user the delegate will be notified that there was a conflict.

Parameters
userRecordThe WFBTLEWeightScaleUser instance to store on the scale.
Returns
TRUE if the command was sent successfully, otherwise FALSE.
- (void) wsConnection: (WFWeightScaleConnection *)  wsConn
didAddNewUserRecord: (WFBTLEWeightScaleUser *)  user 

After a new user profile has been successfully added to the scale and assigned an ID, this method will be called with the completed WFBTLEWeightScaleUser object as a parameter.

Parameters
wsConnThe WFWeightScaleConnection instance.
userNewly added WFWeightScaleUser object.
- (void) wsConnection: (WFWeightScaleConnection *)  wsConn
didReceiveUserId: (int)  userId 
optionalinherited

Invoked when the WFWeightScaleConnection receives response from new user id request.

Parameters
wsConnThe WFWeightScaleConnection instance.
userIdinteger representing the next available userId.
- (void) wsConnection: (WFWeightScaleConnection *)  wsConn
didReceiveUserRecords: (NSArray *)  users 

Invoked when the WFWeightScaleConnection receives user records from the device.

Parameters
wsConnThe WFWeightScaleConnection instance.
usersAn NSArray of WFWeightScaleUser objects.
- (void) wsConnection: (WFWeightScaleConnection *)  wsConn
didReceiveWeightHistory: (NSArray *)  history 

Invoked when the WFWeightScaleConnection receives weight history from the device.

Parameters
wsConnThe WFWeightScaleConnection instance.
historyAn NSArray of WFWeightScaleData objects.
- (void) wsConnection: (WFWeightScaleConnection *)  wsConn
userProfileRejected: (WFBTLEWeightScaleUser *)  rejectedProfile
forOverlappingWith: (WFBTLEWeightScaleUser *)  overlappedProfile 

Invoked when a user profile which has been added contains overlapping weight ranges with and existing profile on the scale.

Parameters
wsConnThe WFWeightScaleConnection instance.
rejectedProfileThe profile sent by the user to be stored
overlappedProfileThe existing profile with which it overlaps

Member Data Documentation

- (WFBTLEWeightScaleUser*) _userRecordWaitingForId
protected
- (BOOL) _waitingForUserId
protected

Property Documentation

- (WFSensorConnectionStatus_t) connectionStatus
readnonatomicassigninherited

Gets the current connection status.

- (id<WFSensorConnectionDelegate>) delegate
readwritenonatomicretaininherited

Specifies the WFSensorConnectionDelegate instance which will handle callback methods for this WFSensorConnection.

- (NSString*) deviceIDString
readnonatomicassigninherited

Returns the Device ID of the connected sensor for both ANT and BTLE.

- (WFDeviceInformation*) deviceInformation
readnonatomicretaininherited
- (USHORT) deviceNumber
readnonatomicassigninherited

Gets the ANT device ID of the connected sensor.

- (NSString*) deviceUUIDString
readnonatomicassigninherited

Specifies the BTLE Device UUID String.

- (BOOL) didTimeout
readnonatomicassigninherited

Gets a boolean value indicating whether a connection timeout occurred.

- (WFSensorConnectionError_t) error
readnonatomicassigninherited

Get the error status for the connection.

- (BOOL) hasAntBridgeSupport
readnonatomicassigninherited

Gets a boolean value indicating whether this WFSensorConnection instance is connected to a device which supports the Wahoo Fitness ANT Bridge.

See also
- enableAntBridge: (WFHardwareConnector)
WFConnectorSettings::isAntBridgeAutoEnabled
- (BOOL) hasError
readnonatomicassigninherited

TRUE if an error has occured, otherwise FALSE.

- (BOOL) hasValidParams
readnonatomicassigninherited

Gets a boolean value indicating whether this WFSensorConnection has valid connection parameters.

When the WFSensorConnection is initiated as a wildcard search, the connection parameters (WFSensorConnection::deviceNumber, WFSensorConnection::transmissionType, etc.) are not set to a specific device. Once the sensor connection is established, the connection parameters will contain values which uniquely identify the connected sensor. At this point the connection parameters may be persisted and used in the future to establish a connection with this same sensor (pairing).

The value of this property is TRUE when the connection parameters are suitable for uniquely identifying a specific sensor. Otherwise, the value is FALSE.

See also
WFSensorConnection::hasWildcardParams
- (BOOL) hasWildcardParams
readnonatomicassigninherited

Gets a boolean value indicating whether the connection parameters for this WFSensorConnection indicate a wildcard search.

See also
WFSensorConnection::hasValidParams
- (BOOL) isANTConnection
readnonatomicassigninherited

TRUE if the sensor is a ANT device, otherwise FALSE.

- (BOOL) isBTLEConnection
readnonatomicassigninherited

TRUE if the sensor is a BTLE device, otherwise FALSE.

- (BOOL) isConnected
readnonatomicassigninherited

TRUE if the sensor is currently connected, otherwise FALSE.

- (BOOL) isValid
readnonatomicassigninherited

Gets a boolean value indicating whether this WFSensorConnection instance is valid.

The WFSensorConnection is invalidated when the sensor is disconnected, or when the API is reset.

Note
The WFSensorConnection instance returned via the requestSensorConnection: (WFHardwareConnector) method should be retained by the application for retrieving data and managing the connection. The Wahoo API will also maintain a reference to this instance (it may be retrieved by the getSensorConnections: (WFHardwareConnector) method). When the sensor is disconnected, the WFSensorConnection instance is invalidated. At this point, the Wahoo API will release its reference to the instance. Once this happens, the instance may not be used to retrieve data, and any properties of the instance will contain spurious values, and should not be used. An application may check for this state with the WFSensorConnection::isValid property.
- (WFNetworkType_t) networkType
readnonatomicassigninherited

Specifies the network type of this WFSensorConnection (ANT+, BTLE, etc).

- (WFSensorSubType_t) sensorSubType
readnonatomicassigninherited

Gets the sensor sub type for this WFSensorConnection.

- (WFSensorType_t) sensorType
readnonatomicassigninherited

Gets the sensor type for this WFSensorConnection.

- (NSTimeInterval) timeSinceLastMessage
readnonatomicassigninherited

Gets the time since the last ANT message was received (in seconds).

WF_INVALID_DATA_TIME if unknown or invalid.

- (UCHAR) transmissionType
readnonatomicassigninherited

Gets the ANT transmission type of the connected sensor.

- (id< WFWeightScaleDelegate >) wsDelegate
readwritenonatomicretain

Specifies the WFWeightScaleDelegate instance which will handle callback methods for this WFWeightScaleConnection.