Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

requestAccess

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

There are a number of RequestAccessResult's for a requestAccess(), received in a IPluginAccessResultReceiver.

ALREADY_SUBSCRIBED
1. Will the PCC parameter be set to a valid object when this occurs? (ie. treated the same as a SUCCESS)
2. I tried testing this by calling requestAccess() when the result is SUCCESS, but this results in a SEARCH_TIMEOUT 10 seconds later. In what conditions will an ALREADY_SUBSCRIBED occur?

Thanks.
R      

Signature

blackramlabs.com

RankRankRankRank

Total Posts: 313

Joined 2011-09-12

PM

1) ALREADY_SUBSCRIBED is returned if attempting to connect to an already connected device that already has an active PCC open with the requesting app. This is an error case and does not return a PCC object; you are expected to continue using the already existing one from elsewhere in the app.

2) I just checked ALREADY_SUBSCRIBED is not currently returned by the request by device number methods because it is missing the proper check. I would expect in the future for this to be fixed.

I will add a note to update the javadoc to make this more clear.

ALREADY_SUBSCRIBED indicates an error in your app not releasing previous instances of PCCs, so you shouldn't have to watch for it if you code your app correctly.      

Signature

Dynastream Developer

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

The assumption that a PCC instance would be provided for an ALREADY_SUBSCRIBED error made this much easier to handle. I have searched the ANT+ Sampler source, but can not find anywhere that covers this case (it just triggers a Toast saying "Unrecognized result"). I would like to find the already subscribed instance, but onResultReceived() does not provided any device details, so I do not see a way to do this. What is the recommended approach to handling this error?

As this is not currently triggered by the request by device number methods, which methods do trigger this error?

Thanks.
R      

Signature

blackramlabs.com

RankRankRankRank

Total Posts: 313

Joined 2011-09-12

PM

Any of the other request access methods will trigger the error. As I said, ALREADY_SUBSCRIBED indicates an error with your app code, most likely leaking a PCC obtained previously. If you code your app correctly you should not have to handle this error. The correct response to this error is to look at your app code and determine where you are leaking the previous PCC without releasing it. The ANT+ sampler does not show handling this code, because it always closes its PCCs and never triggers it.      

Signature

Dynastream Developer

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

Then this is actually a runtime exception? So the correct handling of this code would be to make the app crash with:
case ALREADY_SUBSCRIBED:
  throw new 
RuntimeException("PCC already subscribed");
  break; 
     

Signature

blackramlabs.com

RankRankRankRank

Total Posts: 313

Joined 2011-09-12

PM

If you would like to crash your app to know this has occurred it is up to you.      

Signature

Dynastream Developer

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

That sounds like this is not the preferred approach. What is?

Thanks.
R      

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

bump.      

Signature

blackramlabs.com

RankRankRankRank

Total Posts: 313

Joined 2011-09-12

PM

The preferred approach is whatever you choose it to be. As I said, this return code is used to indicate a programming error in your code. It is not intended to be seen at runtime.      

Signature

Dynastream Developer