Welcome Guest,Register Now
Log In

ANT Forum

Welcome guest, please Login or Register

   

ANT USB Service on Google Nexus 7 Tablet, goes into weird state.

Rank

Total Posts: 5

Joined 2012-12-05

PM

Hello,
I am using ANT USB Stick with OTG Cable connected to Google Nexus 7" tab. Using Body Composition scale to measure Body Composition details. In general it works great. However I am facing following problem, have you ever come across similar problems? Were you able to fix this?
Preconditions:
ANT Radio Service, ANT USB service installed on Google Nexus Tab. Connected to ANT USB Stick, using OTG cable. Able to measure Body Composiition data. Leave the tablet stand by for sever minutes to an hour.
Here is what the description of the problem:
Is seems like the ANT USB Service is went to weird state, the service seems paused, if I go and check Setteing->Apps->Running->ANT Radio Service, one Service (com.dsi.ant.service.AntRadioService) and One Process is running (com.dsi.ant.service.socket).
And one more process, ANT USB Service/Process (com.dsi.ant.usbservice) should be listed as well. But this is not listed.
As result when I try connecting to BC Scale, the UI is stuck at "Openning Channel..." state, never advances to "Searching..." state.

One easy fix for this, is if I disconnect the OTG cable and connect it back, this works fine.

Now the question is, is there a way to bring down the ANT USB Service programatically? And restart using
stopService(Intent)
startService(Intent)
Where the Intent is built based on ANT USB Service name? Not sure what is the name of the Service here?
This is proably not com.dsi.ant.usbservice or com.dsi.ant.chip.remote.usb.UsbAntChipDetector

Thanks in advance.      
Rank

Total Posts: 5

Joined 2012-12-05

PM

I forgot to mention the following statement form Google PLay store, of ANT USB service:

* Some tablets (eg Motorola XOOM, Gateway TP-A60/Acer Iconia A500) will suspend the USB when the screen turns off, which will kill any ANT connections.

Is there a way to prevent this?      
Avatar
RankRankRankRank

Total Posts: 129

Joined 2010-11-30

PM

Ram - 08 May 2013 04:57 PM
Leave the tablet stand by for sever minutes to an hour.
Ram - 08 May 2013 05:26 PM
* Some tablets (eg Motorola XOOM, Gateway TP-A60/Acer Iconia A500) will suspend the USB when the screen turns off, which will kill any ANT connections.

Is there a way to prevent this?

These two comments are probably related. You should acquire a partial wake lock from the PowerManager if the user of your app is on a device which suspends the USB on screen off.
Ram - 08 May 2013 04:57 PM
Is seems like the ANT USB Service is went to weird state, the service seems paused, if I go and check Setteing->Apps->Running->ANT Radio Service, one Service (com.dsi.ant.service.AntRadioService) and One Process is running (com.dsi.ant.service.socket).
And one more process, ANT USB Service/Process (com.dsi.ant.usbservice) should be listed as well. But this is not listed.

This may not actually be because the service is not running. I can run an application that is using ANT, and after connecting an ANT USB stick make neither the ANT Radio Service or ANT USB Service show as 'in use' by the app in Settings - although the ANT connection is still working fine.
Ram - 08 May 2013 04:57 PM
As result when I try connecting to BC Scale, the UI is stuck at "Openning Channel..." state, never advances to "Searching..." state.

If the USB has been suspended, then your channel configuration would have been lost. An attempt to open the channel will result in a Channel In Wrong State response as you must assign and reconfigure again.
Ram - 08 May 2013 04:57 PM
Now the question is, is there a way to bring down the ANT USB Service programatically?

The ANT USB Service will run only while the ANT Radio Service is running. Anytime you connect an ANT USB Stick an activity is automatically started to get the user permissions for the ANT USB Service to use the stick, but that activity is stopped immediately after the user responds.      
Rank

Total Posts: 5

Joined 2012-12-05

PM

Hi Rohan,

Thanks a lot for your timely reply.

>> You should acquire a partial wake lock from the PowerManager if the user of your app is on a device which suspends the USB on screen off.


Yes, I am already using wake lock as follows:
((PowerManager)getSystemService(POWER_SERVICE)).newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "TAG").acquire();
However, in practice what is happening is, some users of the service is pressing the hard button to keep Tablet to sleep. So the above code is not quite helping.

>> . I can run an application that is using ANT, and after connecting an ANT USB stick make neither the ANT Radio Service or ANT USB Service show as 'in use' by the app in Settings - although the ANT connection is still working fine.

Kindly allow me to reiterate my observations, When I connect the USB stick, both the services are started and works like a charm, ANT+ devices are communicated to Android application, quite normal.
During this phase, when you go to Settings -> APPS -> Running, here are the state of the ANT Radio+Usb Services:
ANT Radio Service, 2 processes and 1 Service
ANT USB Service, running.
One more observation, Settings -> APPS, select each of the Services, you have "Force Stop" button active indicating the service is running....

Then what happens when the screen goes blank, after a period of time out.... Here is the state of each of the ANT radio + usb services:
ANT Radio Service, still works, with 1 Service and 1 Process.
ANT USB Service, still indicates running...
Which means, Settings -> APPS, select each of the Services, you have "Force Stop" button active indicating the both service is running....

Here is what I believe ANT Radio Service, is not recognizing ANT USB Service any more. If I manually force stop the ANT USB Service, and programmatic when I stop and start the ANT Radio Service. then every things works great!!

>> If the USB has been suspended, then your channel configuration would have been lost. An attempt to open the channel will result in a Channel In Wrong State response as you must assign and reconfigure again.

Actually I am assigning and reconfiguration the Channel for each attempt. I sincerely believe the above state is not recoverable, unless you do one of the following two:
1) Unplug the OTG cable (USB Stick) and reconnect it.
2) Force stop ANT USB Service.


>> The ANT USB Service will run only while the ANT Radio Service is running. Anytime you connect an ANT USB Stick an activity is automatically started to get the user permissions for the ANT USB Service to use the stick, but that activity is stopped immediately after the user responds.

So is there any way to Force Stop the ANT USB Service programatically? Using Context.stopservice(Intent) API call?

Much appreciate your active engagement in helping solve the problem.

Ram      
Avatar
RankRankRankRank

Total Posts: 129

Joined 2010-11-30

PM

Firstly I need to point out that you should not be using startService and stopService on a service for which you do not know if other applications need the service to stay running. Also, the ANT Radio Service does not run as a Started Service anyway, just a Bound Service. In this way it will only run when required by an app, and will stop itself. In your case you only require unbinding. stopService will not do anything.

You must hold a partial wake lock (a screen dim wake lock is not sufficient). From http://developer.android.com/reference/android/os/PowerManager.html:
*If you hold a partial wake lock, the CPU will continue to run, regardless of any display timeouts or the state of the screen and even after the user presses the power button. In all other wake locks, the CPU will run, but the user can still put the device to sleep using the power button.

I have not been able to reproduce the issue you have encountered. Please provide more details on the environment, such as Android version and ANT Radio Service/ANT USB Service versions. Does the ANT+ Demo also stop showing updating data? Does the new ANT Radio Service v4.0 still exhibit the same behaviour?

-Rohan