Package 

Class CyclingSpeedAndCadenceMeasurementResponse

  • All Implemented Interfaces:
    android.os.Parcelable , no.nordicsemi.android.ble.callback.DataReceivedCallback , no.nordicsemi.android.ble.callback.profile.ProfileDataCallback , no.nordicsemi.android.ble.common.profile.csc.CyclingSpeedAndCadenceCallback , no.nordicsemi.android.ble.common.profile.csc.CyclingSpeedAndCadenceMeasurementCallback

    
    public final class CyclingSpeedAndCadenceMeasurementResponse
    extends CyclingSpeedAndCadenceMeasurementDataCallback implements Parcelable
                        

    Response class that could be used as a result of a synchronous request. The data received are available through getters, instead of a callback.

    Usage example:

    try {
        CyclingSpeedAndCadenceResponse response = waitForNotification(characteristic)
              .awaitValid(CyclingSpeedAndCadenceResponse.class);
        float totalDistance = response.getTotalDistance(2340.0f);
        ...
    } catch (RequestFailedException e) {
        Log.w(TAG, "Request failed with status " + e.getStatus(), e);
    } catch (InvalidDataException e) {
        Log.w(TAG, "Invalid data received: " + e.getResponse().getRawData());
    }
    
    • Constructor Detail

      • CyclingSpeedAndCadenceMeasurementResponse

        CyclingSpeedAndCadenceMeasurementResponse()
    • Method Detail

      • onWheelMeasurementReceived

         void onWheelMeasurementReceived(@NonNull() BluetoothDevice device, long wheelRevolutions, int lastWheelEventTime)

        Method called when the data received had wheel revolution data present.The default implementation calculates the total distance, distance since connection andcurrent speed and calls onDistanceChanged.

        Parameters:
        device - the target device.
        wheelRevolutions - cumulative wheel revolutions since the CSC device was reset (UINT32).
        lastWheelEventTime - the last wheel event time in 1/1024 s (UINT16).
      • onCrankMeasurementReceived

         void onCrankMeasurementReceived(@NonNull() BluetoothDevice device, int crankRevolutions, int lastCrankEventTime)

        Method called when the data received had crank revolution data present.The default implementation calculates the crank cadence and gear ratio andcalls onCrankDataChanged

        Parameters:
        device - the target device.
        crankRevolutions - cumulative crank revolutions since the CSC device was reset (UINT16).
        lastCrankEventTime - the last crank event time in 1/1024 s (UINT16).
      • onDistanceChanged

         void onDistanceChanged(@NonNull() BluetoothDevice device, float totalDistance, float distance, float speed)

        Callback called when the traveled distance and speed has changed.The distance and speed calculations are based on the wheel circumference obtainedwith getWheelCircumference. Make sure it returns the correct value.

        Parameters:
        device - the target device.
        totalDistance - the total distance traveled since the measuring device was reset, in meters.
        distance - the distance traveled since the phone connected to the CSC device, in meters.
        speed - current speed, in meters per second.
      • onCrankDataChanged

         void onCrankDataChanged(@NonNull() BluetoothDevice device, float crankCadence, float gearRatio)

        Callback called when the crank data (cadence or gear ratio) has changed.

        Parameters:
        device - the target device.
        crankCadence - new crank cadence, in revolutions per minute.
        gearRatio - new gear ratio.
      • getTotalDistance

         float getTotalDistance(float wheelCircumference)

        Returns the total distance since the device was reset.

        Parameters:
        wheelCircumference - the wheel circumference in millimeters.
      • getDistance

         float getDistance(float wheelCircumference, CyclingSpeedAndCadenceMeasurementResponse previous)

        Returns the distance traveled since the given response was received.

        Parameters:
        wheelCircumference - the wheel circumference in millimeters.
        previous - a previous response.
      • getSpeed

         float getSpeed(float wheelCircumference, CyclingSpeedAndCadenceMeasurementResponse previous)

        Returns the average speed since the previous response was received.

        Parameters:
        wheelCircumference - the wheel circumference in millimeters.
        previous - a previous response.