Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

Know that an Async Scan has started?

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

requestAsyncScanController() "Sends a request to the plugin to start an asynchronous search for available devices". An AsyncScanController<AntPlusBikePowerPcc> is returned from the request, which only lets you requestDeviceAccess(). If there is an error AsyncScanController.IAsyncScanResultReceiver.onSearchStopped(RequestAccessResult) is called.

How do I know that the scan has started?      

Signature

blackramlabs.com

Avatar
RankRankRankRank

Total Posts: 745

Joined 2012-09-14

PM

A scan has started if the requestAsyncScanController() method does not return null.

Cheers      
Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

Thanks Harrison.

I tried this on a device with no ANT+, but the ANT USB Service installed. requestAsyncScanController() returns an AsyncScanController, but onSearchStopped() occurs straight away with CHANNEL_NOT_AVAILABLE.

I want to not return from my start scan request method until I know that scanning is happening, or return a failure (so that my scan UI is not shown while there is no scan). How can I do this?      

Signature

blackramlabs.com

RankRankRankRank

Total Posts: 313

Joined 2011-09-12

PM

Using AsyncScanController or the new MultiDeviceSearch you would need to block your code until the receiver either receives the first result or a stopped code/failure code.      

Signature

Dynastream Developer

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

This can take up to 10 seconds (search timeout), which is too long for a UI update without crashing the app.      

Signature

blackramlabs.com

RankRankRankRank

Total Posts: 313

Joined 2011-09-12

PM

If you are blocking on your UI thread, then I suggest you show some type of wait dialog. Even in the search failing case it can take several seconds to determine the search is failed (because of things like initializing the chip, allocating channels, etc.), that's why these are async calls in the first place.      

Signature

Dynastream Developer

Avatar
RankRankRankRank

Total Posts: 149

Joined 2014-04-02

PM

In a related question; can I get a list of already connected devices without having to start a search?      

Signature

blackramlabs.com

RankRankRankRank

Total Posts: 313

Joined 2011-09-12

PM

No, currently not, hmmm, never thought of doing that. I can see why that might be useful. In the current implementation you can count on receiving the already connected devices immediately after the search connects, but there is some overhead and it isn't necessarily deterministic to tell when you have received all of them. Let me check over the next week what we can do to expose the already connected device list, no promises this ends up in the final release, it might be next release.      

Signature

Dynastream Developer