Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Problem with requestAccess for combined bike speed and cadence devices

Rank

Total Posts: 8

Joined 2013-10-06

PM

In my app, I'm want to support combined bike speed and cadence
devices but when I try to connect to a combined bike speed and
cadence device via the AntPlusBikeCadencePcc.requestAccess(...)
and AntPlusBikeSpeedDistancePcc.requestAccess(...) the following
problem appears.

After initializing, I request access to the cadence sensor via
AntPlusBikeCadencePcc.requestAccess(mContext, deviceNumber, 0, combinedSensor, new MyResultReceiver<AntPlusBikeCadencePcc>(), new MyDeviceStateChangeReceiver());
and similarly for the speedAndDistance data.

After some time (when the device is found), the method
MyResultReceiver<AntPlusBikeCadencePcc>.onResultReceived(...) is
called (with resultCode=SUCCESS, initialDeviceState=TRACKING).
Within this method, I subscribe for the new cadence data via
cadencePcc.subscribeCalculatedCadenceEvent(new
ICalculatedCadenceReceiver() {...}); Unfortunately, when doing
so, I find the following error in the LogCat: Tag:AntPluginPcc,
Text: BBD20000: Subscribing to event 301 failed with code -3

When subscribing to other Events, I get the same error message
but with other event codes.

Interestingly, the same code works well for a stand alon cadence sensors, i.e, when combinedSensor==false.

I have the same problem with the AntPlusBikeSpeedDistancePcc.requestAccess(...).

To be more precise, the AntPlusBikeCadencePcc.requestAccess(...)
and AntPlusBikeSpeedDistancePcc.requestAccess(...) are called
shortly afterwards. I also observed that only one of these
searches becomes successfull, the other ends with a
SEARCH_TIMEOUT.
     
RankRankRankRank

Total Posts: 313

Joined 2011-09-12

PM

-3 means the event doesn't exist on the target device, but 301 (calculated cadence) should always be available on any cadence device, combined sensor or not. It looks like you have found some type of bug where you are getting the plugin service to attach your cadence PCC to a bike speed and distance sensor device type which doesn't have those events.

I need a little more information to look into this. What are the deviceNumber and combinedSensor parameters set to in all your requestAccess calls? How many requestAccess calls are you making (just two for one speed and one cadence or more?), in what order, and which ones are possibly active at the same time?      

Signature

Dynastream Developer

Rank

Total Posts: 8

Joined 2013-10-06

PM


Thanks for helping me with this problem.

Unfortunately, I am currently not in front of the code, so the
following answers are based on my memory of some previous tests.
As soon as I get back to the code, I will do some more tests and
give more precise answers.

I observed this problem only when connecting to a combined biek
speed and cadence sensor. As already stated it also appears with
the AntPlusBikeSpeedDistancePcc.requestAccess(...) call.

I also thought, the problem might be related to parallel
searches. So I limited the search to the combined device
only (still AntPlusBikeSpeedDistancePcc.requestAccess(...) and
AntPlusBikeCadencePcc.requestAccess(...) shortly after each
other. Unfortunately, I don't know the order) but this did not
help.
I once also limited to only one requestAccess(...) call (but do
not remember which one it was) but this did not solve the problem.

As already stated, I get the same error also for the subscription
to the other Events like subscribeBatteryStatusEvent(...),
subscribeManufacturerIdentificationEvent(...),
subscribeProductInformationEvent(...) but with other numbers.


The deviceNumber is found by an AsynScan, where
AntPlusBikeSpdCadCommonPcc.BikeSpdCadAsyncScanResultDeviceInfo.isSpdAndCadComboSensor
is checked and then stored in a database. When searching for
devices, I get the deviceNumber from this database.


I hope, these answers help you to find the problem. As soon as I
am back on the code, I can do some more tests to get more precise
ansers.      
Rank

Total Posts: 8

Joined 2013-10-06

PM

Now, I did a test where I only search for one device at each
time. More precisely, only for the cadence or speed part of the
combined speed and cadence device.


I get the problem when I only search for the cadence part, i.e., via
AntPlusBikeCadencePcc.requestAccess(context, deviceNumber, 0, true, new MyResultReceiver<AntPlusBikeCadencePcc>(), new MyDeviceStateChangeReceiver());
Thereby, I observe the following problems:
When calling subscribeCumulativeOperatingTimeEvent(), I get BBD20000: Subscribing to event 204 failed with code -3.
When calling subscribeManufacturerAndSerialEvent(), I get BBD20000: Subscribing to event 205 failed with code -3.
When calling subscribeVersionAndModelEvent(), I get BBD20000: Subscribing to event 206 failed with code -3.

Interestingly, when only searching for the speed part, i.e., via
AntPlusBikeSpeedDistancePcc.requestAccess(context, deviceNumber, 0, true, new MyResultReceiver<AntPlusBikeSpeedDistancePcc>(), new MyDeviceStateChangeReceiver());
there are no problems with the subscribeCalculatedSpeedEvent() and subscribeCalculatedAccumulatedDistanceEvent() calls.

However, for the other calls, I get:
When calling subscribeCumulativeOperatingTimeEvent(), I get BBD20000: Subscribing to event 204 failed with code -3.
When calling subscribeManufacturerAndSerialEvent(), I get BBD20000: Subscribing to event 205 failed with code -3.
When calling subscribeVersionAndModelEvent(), I get BBD20000: Subscribing to event 206 failed with code -3.

     
Rank

Total Posts: 8

Joined 2013-10-06

PM

Oh, In my previous post, I oversaw that calling
subscribeCalculatedCadenceEvent() now works. However, I still
get the messages for the other subscriptions.
     
Rank

Total Posts: 8

Joined 2013-10-06

PM

Now, I did one more test/experiment.
When searching for both parts, the order seems to be relevant.

When first searching for the speed and then for the cadence part,
the speed part is indeed first found and I get for the calls of
the speed part:
subscribeCalculatedSpeedEvent => BBD20000: Subscribing to event 201 failed with code -3
subscribeCalculatedAccumulatedDistanceEvent => BBD20000: Subscribing to event 202 failed with code -3
subscribeCumulativeOperatingTimeEvent => BBD20000: Subscribing to event 204 failed with code -3
subscribeManufacturerAndSerialEvent => BBD20000: Subscribing to event 205 failed with code -3
subscribeVersionAndModelEvent => BBD20000: Subscribing to event 206 failed with code -3

The search for the cadence part ends with resultCode=SEARCH_TIMEOUT, initialDeviceState=DEAD


When first searching for the cadence and then for the speed part,
the cadence part is indeed first found and I get for the calls of
the cadende part:
subscribeCalculatedCadenceEvent() => BBD20000: Subscribing to event 301 failed with code -3
subscribeCumulativeOperatingTimeEvent() => BBD20000: Subscribing to event 204 failed with code -3
subscribeManufacturerAndSerialEvent() => BBD20000: Subscribing to event 205 failed with code -3
subscribeVersionAndModelEvent() => BBD20000: Subscribing to event 206 failed with code -3

The search for the speed part ends with resultCode=SEARCH_TIMEOUT, initialDeviceState=DEAD


Hope that helps.      
RankRankRankRank

Total Posts: 313

Joined 2011-09-12

PM

From post #3, it looks like everything is working as expected when you do the searches one at a time. The combined speed and distance sensor only outputs the speed and distance events, the other data like version, manf, battery, etc. are unavailable as defined in the profile. So when you subscribe to those events they don't exist (-3 return).

In post #5 it definitely looks like doing the search at both times is messing things up. I will look into this and get it fixed.

However, if you already know you are trying to connect to the two halves of a single combined sensor, it is proper to do them one at a time. When you call search in parallel it will open two ANT channels and attempt two simultaneous searches for the same device, only one can find the device and the other will timeout. Instead, you should wait until one of the searches successfully connects then requestAccess to the other half of it at that point. In this case, since the device is already connected the second requestAccess command will immediately see the already connected device and connect without doing another ANT search.

You can look at the PluginSampler app in the SDK which does this approach for thew speed or cadence examples when it connects to a combined sensor.      

Signature

Dynastream Developer

Rank

Total Posts: 8

Joined 2013-10-06

PM

Ok, I now search for one part after the other and everything works as it should.
So thanks for your help.