Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Bike Power: Get crank parameters

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

The Android ANT+ plugins API has:
AntPlusBikePowerPcc.requestCrankParameters(IRequestFinishedReceiver requestFinishedReceiver)

AntPlusBikePowerPcc.requestCrankParameters(IRequestFinishedReceiver requestFinishedReceiverICrankParametersReceiver crankParametersReceiver)

AntPlusBikePowerPcc.subscribeCrankParametersEvent(ICrankParametersReceiver CrankParametersReceiver

The documentation for requestCrankParameters(ICrankParametersReceiver) states that:
Any receiver passed here will overwrite any pre-existing receiver subscription, except from subscribeCalibrationMessageEvent(ICalibrationMessageReceiver)
but I believe this is a bug and should say "subscribeCrankParametersEvent".

If you can "overwrite any pre-existing receiver subscription" except the one from the subscribe method, does this mean that the ICrankParametersReceiver I set in requestCrankParameters(ICrankParametersReceiver) will be called if I then do a requestCrankParameters() any time in the future?

What if another app sets the crank parameters to a new value?

If I have also done subscribeCrankParametersEvent(), will the ICrankParametersReceiver be called twice?      

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 745

Joined 2012-09-14

PM

Thanks for the bug report, this will be fixed in a future release.

The receiver will not be called again if you call requestCrankParameters(). The requestCrankParameters(ICrankParametersReceiver) method automatically removes the receiver after the crank parameters have been received, as the request methods are intended to be 'once and done' compared to the subscription methods which are 'listen forever'.

If another app or device changes the crank parameters on the power sensor, you will not know that they have been changed unless the bike power sensor sends the crank parameters page (which it should only do on request according to the Bike Power profile).

If you have also subscribed to the subscribeCrankParametersEvent(), then which ever receiver you passed into that and requestCrankParameters() will also be called whenever you receive a crank parameters page from the bike power sensor. If you passed the same receiver into both methods then it will be called twice.

Cheers      
Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

What is the unit of measurement for the BigDecimal "full crank length"? This applies to both AntPlusBikePowerPcc.requestSetCrankParameters(fullCrankLength) and CrankParameters.getFullCrankLength() (documented as 0.5mm resolution, but no units).

There was another post (about distance) stating that "Generally all calculated values are in SI units, in this case it would be metres"; does that apply here?

Thankyou,
R      

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 745

Joined 2012-09-14

PM

Hi R,

The units are in mm which I believe is present in the online Javadoc at least.

Cheers      
Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

Thankyou harrison. Units is missing from requestSetCrankParameters() javadoc, but is included for CrankParameters (but not in the summary where I had looked).      

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

I can't seem to get crank parameters from the ANT+ Sensor Simulator.

I am running a Crank Torque Sensor Type, and can successfully set crank length and it shows up in the simulator. I have tried both manually set and auto set crank length, but I can't get it to my phone.

Running the ANT+ Plugin Sample, when I press "Request Crank Parameters" I see a "Request Successfully Sent" toast, but the Crank Parameters section only contains "---".

My app behaves the same way. AntPlusBikePowerPcc.IRequestFinishedReceiver is called, but AntPlusBikePowerPcc.ICrankParametersReceiver is not.

Am I missing something in the simulator setup?

Update: The PC ANT+ Sensor Simulator can correctly get the crank parameters. This looks to be a bug with the Android API.      

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

Using the services in the ANT+ P.B1 SDK, it is now possible to get crank parameters, but with some problems.

a) I have seen this a few times:
E/AntPlusBikePowerPcc(10467): BBD20000: Cmd requestSetCrankParameters failed with code -3
D/AndroidRuntime(10467): Shutting down VM
W/dalvikvm(10467): threadid=1: thread exiting with uncaught exception (group=0x2b542210)
E/AndroidRuntime(10467): FATAL EXCEPTION: main
E/AndroidRuntime(10467): java.lang.RuntimeException: requestSetCrankParameters cmd failed internally
E/AndroidRuntime(10467): at com.dsi.ant.plugins.antplus.pcc.AntPlusBikePowerPcc.requestSetCrankParameters(AntPlusBikePowerPcc.java:2909)


Testing with SimulANT+
b) Whenever I set the crank length, it gets updated, but the status changes to INVALID. This is using my app and the ANT+ Plugin Sampler.      

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 745

Joined 2012-09-14

PM

Hi R,

a) Code -3 indicates a bad parameter error which the PluginService should have logged earlier in LogCat. We will be changing this to throw an IllegalArgumentException instead in the PCC to make it clearer.

b) SimulANT+ does not automatically change the status properly, instead it is reflecting what the request sent (0x00) which is defined in the profile for Display -> Sensor. We can look into adding this functionality using a script, or we may add it to the default behavior of SimulANT+.

Cheers      
Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

Hi harrison,

a) What classifies as a bad parameter?

b) Are you saying this is a bug with SimulANT+? When I request auto crank length, the status in SimulANT+ correctly updates to AUTO.

Thanks      

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 745

Joined 2012-09-14

PM

a)
1) The CrankLengthSetting may not be null.
2) If the CrankLengthSetting is set to MANUAL_CRANK_LENGTH then the fullCrankLength value may not be null.
3) If MANUAL_CRANK_LENGTH is being set then the fullCrankLength must not exceed 236.5mm or be lesser than 110.0mm.

Unfortunately this information was missed and will be copied from the Profile to the Javadoc in a future release.

b) Yes this is a SimulANT+ bug, the display has no ability to set the sensor status directly, it must be set by the sensor. So in this case SimulANT+ is treating valid manual crank length's as "INVALID".