Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

RequestAccess calls not receiving results during service initialization

RankRankRankRank

Total Posts: 313

Joined 2011-09-12

PM

There is a bug in the ANT+ Plugins Service versions previous to 3.3.0 which results in all but one of the requestAccess message sent during a certain window of the initialization phase to be dropped without processing them. This is usually seen when an app starts up and tries to send multiple access requests for devices one after another without waiting for each result, then only one receives a response.

I thought I would share several possible workarounds to avoid this bug:

/Option 1/ Send requests one at a time. If you wait for the result of each request you send to be received before you send the next one, you will completely avoid the problem. This will probably be slower in a lot of cases, but it is deterministic and fairly simple to manage (You could even optimize this solution by taking advantage of the fact that after the first SUCCESS or TIMEOUT result you receive then the conditions for the bug are no longer present, so after the first result you could send all the rest of the requests without waiting)

/Option 2/ Delay subsequent request access calls by a fixed time. From our testing, it appears to take <500ms after the first request access before the condition is resolved. While this solution is not 100% deterministic, if you delayed subsequent requests for 1s after the first you would likely never see the problem.

/Option 2/ Make your first search a wildcard search, i.e. requestAccess for device number 0. In this case you would still rely on receiving the RequestAccess SUCCESS result to determine when to send subsequent requests, but if you use a wildcard search you would likely avoid getting a timeout when there are devices nearby. Once you get a wildcard result, check if the device number matches one of the ones you want. If not, release it after you start your next request.

/Option 4/ If you use PluginLib >= v3.3.0, you can open a multi search of any type and wait for the SearchCallbacks.onSearchStarted() call, once you see the callback you can send all your access requests then close the multi search. The reason to use this one would be the onSearchStarted callback will occur much faster than a request access result because it doesn't need to connect to a device before the callback will occur.
     

Signature

Dynastream Developer