Can't start the service app without reconnect the IOIO to my Android?

486 views
Skip to first unread message

Majid ff

unread,
Sep 27, 2014, 6:48:43 PM9/27/14
to ioio-...@googlegroups.com
I am using the service example "HelloIOIOService", whenever it is start it is work fine but when I stop it and try to start it again it doesn't work unless plug out and plugin the usb cable between the IOIO and the device again.
Even this way doesn't succeed all time, some time work some time not! and it shows "No installed apps work with this USB accessory........"

My IOIO has the following info: Hardware ID: SPRK0020 Bootloader ID: IOIO0400 Firmware ID: IOIO0500


The connection is look like not reliable, what is the wrong? is it the app itself or hardware issue?
In Eclipse LogCat, it is continue shows the following even the IOIO is already connected physically:
09-28 00:13:41.708: D/IOIOImpl(21259): Physical disconnect.
09-28 00:13:41.708: D/IOIOImpl(21259): Connection lost / aborted
09-28 00:13:41.708: D/IOIOImpl(21259): Waiting for IOIO connection
09-28 00:13:41.713: V/IOIOImpl(21259): Waiting for underlying connection




I have already followed the instruction in the link github.com/ytai/ioio/wiki/ADK and my Manifest file as below (I also create the file accessory_filter.xml in the directory /res/xml:


AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
   
package="ioio.examples.hello_service" android:versionCode="1"
   
android:versionName="1.0">

   
<uses-sdk android:minSdkVersion="14"
             
android:targetSdkVersion="16" />
   
<application android:icon="@drawable/ic_launcher"
       
android:label="@string/app_name">
       
<uses-library android:name="com.android.future.usb.accessory"
           
android:required="false" />
       
<service android:name="HelloIOIOService">
           
<intent-filter>
               
<action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
           
</intent-filter>
           
<intent-filter>
               
<action android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED" />
           
</intent-filter>
           
<meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
               
android:resource="@xml/accessory_filter" />
           
<meta-data android:name="android.hardware.usb.action.USB_DEVICE_ATTACHED"
               
android:resource="@xml/device_filter" />

       
</service>
       
<activity android:label="@string/app_name" android:name="MainActivity"
           
android:launchMode="singleTask">
           
<intent-filter>
               
<action android:name="android.intent.action.MAIN" />
               
<category android:name="android.intent.category.LAUNCHER" />
           
</intent-filter>
           
<meta-data android:resource="@xml/accessory_filter" android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"/>
       
</activity>
   
</application>
</manifest>



HelloIOIOService.java
public class HelloIOIOService extends IOIOService {
   
@Override
   
protected IOIOLooper createIOIOLooper() {
       
return new BaseIOIOLooper() {
           
private DigitalOutput led_;

           
@Override
           
protected void setup() throws ConnectionLostException,
                   
InterruptedException {
                led_
= ioio_.openDigitalOutput(IOIO.LED_PIN);
           
}

           
@Override
           
public void loop() throws ConnectionLostException,
                   
InterruptedException {
                led_
.write(false);
               
Thread.sleep(500);
                led_
.write(true);
               
Thread.sleep(500);
           
}
       
};
   
}

   
@Override
   
public void onStart(Intent intent, int startId) {
       
super.onStart(intent, startId);
       
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
       
if (intent != null && intent.getAction() != null
               
&& intent.getAction().equals("stop")) {
           
// User clicked the notification. Need to stop the service.
            nm
.cancel(0);
            stopSelf
();
       
} else {
           
// Service starting. Create a notification.
           
Notification notification = new Notification(
                    R
.drawable.ic_launcher, "IOIO service running",
                   
System.currentTimeMillis());
            notification
                   
.setLatestEventInfo(this, "IOIO Service", "Click to stop",
                           
PendingIntent.getService(this, 0, new Intent(
                                   
"stop", null, this, this.getClass()), 0));
            notification
.flags |= Notification.FLAG_ONGOING_EVENT;
            nm
.notify(0, notification);
       
}
   
}

   
@Override
   
public IBinder onBind(Intent arg0) {
       
return null;
   
}

}



MainActivity.java
public class MainActivity extends Activity {
   
@Override
   
protected void onCreate(Bundle savedInstanceState) {
       
super.onCreate(savedInstanceState);
        startService
(new Intent(this, HelloIOIOService.class));
        finish
();
   
}
}



AF

unread,
Sep 28, 2014, 11:46:56 AM9/28/14
to ioio-...@googlegroups.com
Hey Majid,

In AndroidManifest, move the code between "<service>" and "</service>" tags to between "<activity>" and "</activity>" tags. Or, instead of moving it, just copy it and paste it between these two last tags.

            notification
.flags |= Notification.<span style
...

Majid ff

unread,
Sep 28, 2014, 2:20:02 PM9/28/14
to ioio-...@googlegroups.com

Hi AF, thanks for reply, I actually already did that before with no successes, I still have to unplug and then plug in the usb cable to make the app work again.
It seem that using USB Accessory method still need more development by Android staff or my be the IOIO Firmware itself, I do not know!

So right now I am using the USB debugging methode which it is more reliable but I must keep the Android USB debugger switch on all the time, so I can start, stop and then start  HelloIOIOService again without needed to unplug and plug the USB cable again.

AF

unread,
Sep 28, 2014, 7:22:46 PM9/28/14
to ioio-...@googlegroups.com
What configuration are you using? I mean "smartphone, debugging mode on or off, cable used, ioio H/A switch position, external supply yes or not"? Also see if the Service App version you are running is correct (it shoud be v5.0 because you have ioio app firmware v5.0).
And if you are already using the correct configuration do this: turn the ioio trimpot a bit more to the right.

Majid ff

unread,
Sep 29, 2014, 12:56:28 PM9/29/14
to ioio-...@googlegroups.com
I am using Samsung Galaxy S2, Android 4.1.2, I tried with debugging both mode on and off. I am using the oreginal cable that comes with the IOIO (micro-A connected to the IOIO). I tested both positions H and A, I am also use external 5V power supply to the IOIO.
I am using the app that come with firmware v5.0 as well.
I have already turned the IOIO trim pot to the end clockwise!

But still same problem.

Ytai Ben-Tsvi

unread,
Oct 3, 2014, 12:33:04 AM10/3/14
to ioio-...@googlegroups.com
There are some issues with how Accessory and Service interact. The end result is that I haven't found a good way to detect a re-connection of the accessory when the service is running.
To separate issues, please try the precompiled HelloIOIO first and check that everything is reliable in accessory mode. Then, move to the precompiled HelloIOIOService and note the behavior. Only then move to your own code. Feel free to try to look into how IOIOService is implemented and come up with suggestions. The key issue is that there is apparently no way to register a Service to listen for an Accessory connection, so you may need to start an activity and delegate the Intent to the service.

--
You received this message because you are subscribed to the Google Groups "ioio-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ioio-users+...@googlegroups.com.
To post to this group, send email to ioio-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.

Ole Tetzschner

unread,
Aug 6, 2015, 5:39:28 AM8/6/15
to ioio-users
Hey Ytai

Any progress on this AOA Service-problem? Do you by chance have an updated HelloIOIOservice-example? The HelloIOIO-activity works like a champ (AOA) on all my android-devices, but the HelloIOIO-services does not :/

With kind regards, Ole

Ytai Ben-Tsvi

unread,
Aug 6, 2015, 10:19:29 AM8/6/15
to ioio-...@googlegroups.com

Yes. This has been fixed, but not yet released. You can check out the latest code from the master branch on GitHub for the time being.

Ole Tetzschner

unread,
Aug 6, 2015, 10:40:40 AM8/6/15
to ioio-...@googlegroups.com
thanks Ytai

is it only an android-app issue or do I need to update android-ioio-lib and/or ioio-firmware as well?

kind regards, Ole

--
You received this message because you are subscribed to a topic in the Google Groups "ioio-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ioio-users/YSEBH7lwe-A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ioio-users+...@googlegroups.com.

To post to this group, send email to ioio-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ioio-users.
For more options, visit https://groups.google.com/d/optout.



--
Med venlig hilsen

Ole Tetzschner

Ytai Ben-Tsvi

unread,
Aug 6, 2015, 10:58:14 AM8/6/15
to ioio-...@googlegroups.com

App and library. No need to touch the firmware if you have a v5.x installed.

Ole Tetzschner

unread,
Aug 7, 2015, 9:01:59 AM8/7/15
to ioio-...@googlegroups.com
Ytai, you are a champ :)

Would be nice if the startet IOIOService auto-reconnected, every time the IOIO-board was connected/restarted. But restarting the IOIOService (when using AOA) is working. In BT-mode the auto-reconnect is working fine.

Kind regards, Ole

Ytai Ben-Tsvi

unread,
Aug 7, 2015, 11:17:13 AM8/7/15
to ioio-...@googlegroups.com

The fact that the accesory connection intent has to go through an activity to the service is, as far as I know, the only way to do this in Android. If you find a better way to do this let me know.

Reply all
Reply to author
Forward
0 new messages