XOOMの動作状況を聞き処理を変えてみました。 USBケーブルを抜いた際に処理を終了するようにしました。

Dependencies:   mbed

Revision:
3:432e5675d240
Parent:
2:a05c7cbe396f
--- a/AutoEvents.cpp	Thu May 26 19:08:55 2011 +0000
+++ b/AutoEvents.cpp	Fri May 27 18:51:15 2011 +0000
@@ -249,16 +249,16 @@
     char s[128];
     u8 my_mac[6] = {0x00, 0x02, 0x72, 0xAD, 0xF3, 0x5B}; // mac address of my Bluetooth device
 
-/*
-    u8 buf2[6];
+    /*
+        u8 buf2[6];
 
-    buf2[0] = 0x00;
-    buf2[1] = 0x02;
-    buf2[2] = 0x72;
-    buf2[3] = 0xAD;
-    buf2[4] = 0xF3;
-    buf2[5] = 0x5B;
-*/
+        buf2[0] = 0x00;
+        buf2[1] = 0x02;
+        buf2[2] = 0x72;
+        buf2[3] = 0xAD;
+        buf2[4] = 0xF3;
+        buf2[5] = 0x5B;
+    */
 
     for (int i = 1; i < 3; i++) {
         if (GetString(device,i,s,sizeof(s)) < 0)
@@ -266,18 +266,42 @@
         printf("%d: %s\r\n",i,s);
     }
 
+    //for android ADK
+    if ( ( deviceDesc->idVendor != 0x18D1 ||
+            ( deviceDesc->idProduct != 0x2D00 && deviceDesc->idProduct != 0x2D01))
+            &&switchDevice(device)) {
+            
+        printf("  try to change accmode.interfaceDesc->bInterfaceClass=%d\r\n",interfaceDesc->bInterfaceClass);
+        //1th root
+        //accmode_support=true;
+        printf("accessory mode ok.\r\n");
+        return;
+    }
+
+    if (deviceDesc->idVendor == 0x18D1 &&
+            (deviceDesc->idProduct == 0x2D00 || deviceDesc->idProduct == 0x2D01)) {
+        //2th root
+        printf("connecting Android.\r\n");
+        printf("idVender=%x  idProduct=%x  interfaceDesc->bInterfaceClass=%d\r\n",deviceDesc->idVendor,deviceDesc->idProduct,interfaceDesc->bInterfaceClass);
+        AdkUSB _AdkUSB(device,1,0);
+        _AdkUSB.loop();
+        return;
+
+    }
+
+
     switch (interfaceDesc->bInterfaceClass) {
-            /*
-                    case CLASS_MASS_STORAGE:
-                        if (interfaceDesc->bInterfaceSubClass == 0x06 && interfaceDesc->bInterfaceProtocol == 0x50)
-                            OnDiskInsert(device);    // it's SCSI!
-                        break;
-            */
+        case CLASS_MASS_STORAGE:
+            if (interfaceDesc->bInterfaceSubClass == 0x06 && interfaceDesc->bInterfaceProtocol == 0x50)
+                OnDiskInsert(device);    // it's SCSI!
+            break;
+
         case CLASS_WIRELESS_CONTROLLER:
             if (interfaceDesc->bInterfaceSubClass == 0x01 && interfaceDesc->bInterfaceProtocol == 0x01)
                 OnBluetoothInsert(device);    // it's bluetooth!
             break;
         case CLASS_HID:
+
             printf("idVendor = %04X idProduct = %04X \r\n",deviceDesc->idVendor,deviceDesc->idProduct);
             //printf("device = %d configuration = %d interfaceNumber = %d\r\n", device, configuration, interfaceNumber);
             //if (deviceDesc->idVendor == 0x054C &&  deviceDesc->idProduct == 0x0268) StartPS3Event(device,1,0);
@@ -293,22 +317,7 @@
             } else StartAutoEvent(device,1,0);
             break;
 
-        case CLASS_VENDOR_SPECIFIC:
-            if (deviceDesc->idVendor == 0x18D1 &&
-                    (deviceDesc->idProduct == 0x2D00 || deviceDesc->idProduct == 0x2D01)) 
-            {
-
-                printf("accessory mode ok.\r\n");
-                printf("idVender=%x  idProduct=%x  interfaceDesc->bInterfaceClass=%d\r\n",deviceDesc->idVendor,deviceDesc->idProduct,interfaceDesc->bInterfaceClass);
-                AdkUSB _AdkUSB(device,1,0);
-                _AdkUSB.loop();
-          
-            }
-            break;
-
         default:
-            printf("  try to change accmode.interfaceDesc->bInterfaceClass=%d\r\n",interfaceDesc->bInterfaceClass);
-            if (switchDevice(device))break;
 
             printf("Not yet supported \r\n");
             //StartAutoEvent(device,1,0);