OSDN Git Service

Nikonの接続性改善。適当にdelayを入れてみた。
authorMRSa <mrsa@myad.jp>
Mon, 2 Dec 2019 15:13:45 +0000 (00:13 +0900)
committerMRSa <mrsa@myad.jp>
Mon, 2 Dec 2019 15:13:45 +0000 (00:13 +0900)
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/NikonInterfaceProvider.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonFullImageReceiver.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonImageObjectReceiver.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonPlaybackControl.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonSmallImageReceiver.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/nikon/wrapper/playback/NikonStorageContentHolder.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/command/messages/PtpIpCommandGeneric.java
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/command/messages/specific/NikonRegistrationMessage.java [new file with mode: 0644]
app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/connection/NikonCameraConnectSequenceForPlayback.java

index 5c8c535..aba6c5d 100644 (file)
@@ -42,7 +42,6 @@ import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.PtpIpComman
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.connection.NikonConnection;
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.liveview.PtpIpLiveViewControl;
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.status.IPtpIpRunModeHolder;
-import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.status.PtpIpStatusChecker;
 
 import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.NIKON_CAMERA_IP_ADDRESS;
 import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.NIKON_CAMERA_IP_ADDRESS_DEFAULT_VALUE;
index b2a90ec..55e13e5 100644 (file)
@@ -53,7 +53,7 @@ public class NikonFullImageReceiver implements IPtpIpCommandCallback
         this.receivedFirstData = false;
 
         Log.v(TAG, " getPartialObject (id : " + objectId + ", size:" + imageSize + ")");
-        publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, true, 0, 0x101b, 12, objectId, 0, imageSize));  // GetPartialObject (0x101b)
+        publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, 75, true, 0, 0x101b, 12, objectId, 0, imageSize, 0));  // GetPartialObject (0x101b)
     }
 
     @Override
index 680c0a9..984ede1 100644 (file)
@@ -189,7 +189,7 @@ public class NikonImageObjectReceiver implements IPtpIpCommandCallback, NikonSto
             if (publisher != null)
             {
                 // オブジェクト一覧をクリアする
-                publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_ID, isDumpLog, 0, 0x1004));  // GetStorageIDs
+                publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_ID, 50, isDumpLog, 0, 0x1004, 0, 0, 0, 0, 0));  // GetStorageIDs
                 this.callback = callback;
             }
         }
index 0a03b11..74193a5 100644 (file)
@@ -124,7 +124,7 @@ public class NikonPlaybackControl implements IPlaybackControl
                 }
 
                 // 画像を取得する
-                publisher.enqueueCommand(new PtpIpCommandGeneric(new NikonScreennailImageReceiver(activity, callback), objectId, false, 0, 0x90c4, 4, objectId));
+                publisher.enqueueCommand(new PtpIpCommandGeneric(new NikonScreennailImageReceiver(activity, callback), objectId, 75, false, 0, 0x90c4, 4, objectId, 0, 0, 0));
             }
         }
         catch (Exception e)
@@ -168,11 +168,11 @@ public class NikonPlaybackControl implements IPlaybackControl
                         public boolean isReceiveMulti() {
                             return (false);
                         }
-                    }, objectId, false, 0, 0x1008, 4, objectId));  // getObjectInfo
+                    }, objectId, 75, false, 0, 0x1008, 4, objectId, 0, 0, 0));  // getObjectInfo
                 }
 
                 // Log.v(TAG, "downloadContentThumbnail() " + indexStr + " [" + objectId + "] (" + storageId + ")");
-                publisher.enqueueCommand(new PtpIpCommandGeneric(new PtpIpThumbnailImageReceiver(activity, callback), objectId, false, 0, 0x100a, 4, objectId));  // getThumb
+                publisher.enqueueCommand(new PtpIpCommandGeneric(new PtpIpThumbnailImageReceiver(activity, callback), objectId, 75, false, 0, 0x100a, 4, objectId, 0, 0, 0));  // getThumb
             }
         }
         catch (Exception e)
index 2e3d6d1..1baa4d0 100644 (file)
@@ -52,7 +52,7 @@ public class NikonSmallImageReceiver implements IPtpIpCommandCallback
         this.receivedFirstData = false;
         //Log.v(TAG, " getPartialObject (id : " + objectId + ", size:" + imageSize + ")");
         //publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, true, 0, 0x101b, 12, objectId, 0, imageSize));  // GetPartialObject 0x101b
-        publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, true, 0, 0x90c4, 4, objectId));  // GetLargeThumb
+        publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_PARTIAL_OBJECT, 75, true, 0, 0x90c4, 4, objectId, 0, 0, 0));  // GetLargeThumb
     }
 
     @Override
index 1e46030..4db7331 100644 (file)
@@ -43,7 +43,7 @@ public class NikonStorageContentHolder  implements IPtpIpCommandCallback
         {
             isObjectReceived = false;
             IPtpIpCommandPublisher publisher = provider.getCommandPublisher();
-            publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_HANDLE1, isDumpLog, 0, 0x1007, 12, storageId, 0x00003001, 0xffffffff));
+            publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_HANDLE1, 35, isDumpLog, 0, 0x1007, 12, storageId, 0x00003001, 0xffffffff, 0));
             imageObjectList.clear();
         }
         catch (Exception e)
@@ -96,7 +96,7 @@ public class NikonStorageContentHolder  implements IPtpIpCommandCallback
                 for (int subDirectory : directoriesList)
                 {
                     Log.v(TAG, "  STORAGE ID : " + storageId + "  DIRECTORY ID : " + subDirectory);
-                    publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_HANDLE2, isDumpLog, 0, 0x1007, 12, storageId, 0x00000000, subDirectory)); //
+                    publisher.enqueueCommand(new PtpIpCommandGeneric(this, GET_STORAGE_HANDLE2, 35, isDumpLog, 0, 0x1007, 12, storageId, 0x00000000, subDirectory, 0)); //
                 }
                 return;
             }
@@ -139,7 +139,7 @@ public class NikonStorageContentHolder  implements IPtpIpCommandCallback
                         public boolean isReceiveMulti() {
                             return false;
                         }
-                    }, GET_STORAGE_HANDLE3, isDumpLog, 0, 0x1007, 12, storageId, 0x00000000, subDirectory));
+                    }, GET_STORAGE_HANDLE3, 35, isDumpLog, 0, 0x1007, 12, storageId, 0x00000000, subDirectory, 0));
 
 /*
                     //  ストレージ名称。。。ここでは利用できない
index 1d8cfa7..4e5f3fc 100644 (file)
@@ -14,6 +14,8 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
     private final int holdId;
     private final int estimatedObjectSize;
 
+    private final int delayMs;
+
     private final byte opCode0;
     private final byte opCode1;
 
@@ -43,6 +45,7 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
         this.bodySize = 0;
         this.isDumpLog = isDumpLog;
         this.estimatedObjectSize = -1;
+        this.delayMs = 15;
 
         this.id = id;
         this.holdId = holdId;
@@ -76,6 +79,7 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
         this.bodySize = bodySize;
         this.isDumpLog = isDumpLog;
         this.estimatedObjectSize = -1;
+        this.delayMs = 15;
 
         this.id = id;
         this.holdId = holdId;
@@ -109,6 +113,7 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
         this.bodySize = bodySize;
         this.isDumpLog = isDumpLog;
         this.estimatedObjectSize = -1;
+        this.delayMs = 15;
 
         this.id = id;
         this.holdId = holdId;
@@ -142,6 +147,7 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
         this.bodySize = bodySize;
         this.isDumpLog = isDumpLog;
         this.estimatedObjectSize = -1;
+        this.delayMs = 15;
 
         this.id = id;
         this.holdId = holdId;
@@ -176,6 +182,41 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
         this.bodySize = bodySize;
         this.isDumpLog = isDumpLog;
         this.estimatedObjectSize = -1;
+        this.delayMs = 15;
+
+        this.id = id;
+        this.holdId = holdId;
+        opCode0 = ((byte) (0x000000ff & opcode));
+        opCode1 = ((byte)((0x0000ff00 & opcode) >> 8));
+
+        data0 = ((byte) (0x000000ff & value));
+        data1 = ((byte)((0x0000ff00 & value) >> 8));
+        data2 = ((byte)((0x00ff0000 & value) >> 16));
+        data3 = ((byte)((0xff000000 & value) >> 24));
+
+        data4 = ((byte) (0x000000ff & value2));
+        data5 = ((byte)((0x0000ff00 & value2) >> 8));
+        data6 = ((byte)((0x00ff0000 & value2) >> 16));
+        data7 = ((byte)((0xff000000 & value2) >> 24));
+
+        data8 = ((byte) (0x000000ff & value3));
+        data9 = ((byte)((0x0000ff00 & value3) >> 8));
+        dataA = ((byte)((0x00ff0000 & value3) >> 16));
+        dataB = ((byte)((0xff000000 & value3) >> 24));
+
+        dataC = ((byte) (0x000000ff & value4));
+        dataD = ((byte)((0x0000ff00 & value4) >> 8));
+        dataE = ((byte)((0x00ff0000 & value4) >> 16));
+        dataF = ((byte)((0xff000000 & value4) >> 24));
+    }
+
+    public PtpIpCommandGeneric(@NonNull IPtpIpCommandCallback callback, int id, int delayMs, boolean isDumpLog, int holdId, int opcode, int bodySize, int value, int value2, int value3, int value4)
+    {
+        this.callback = callback;
+        this.bodySize = bodySize;
+        this.isDumpLog = isDumpLog;
+        this.estimatedObjectSize = -1;
+        this.delayMs = delayMs;
 
         this.id = id;
         this.holdId = holdId;
@@ -350,6 +391,12 @@ public class PtpIpCommandGeneric extends PtpIpCommandBase
     }
 
     @Override
+    public int receiveDelayMs()
+    {
+        return (delayMs);
+    }
+
+    @Override
     public int getHoldId()
     {
         return (holdId);
diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/command/messages/specific/NikonRegistrationMessage.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/ptpip/wrapper/command/messages/specific/NikonRegistrationMessage.java
new file mode 100644 (file)
index 0000000..3b3d879
--- /dev/null
@@ -0,0 +1,89 @@
+package net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.specific;
+
+import androidx.annotation.NonNull;
+
+import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpCommandCallback;
+import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.PtpIpCommandBase;
+
+import java.nio.ByteBuffer;
+import java.util.UUID;
+
+public class NikonRegistrationMessage extends PtpIpCommandBase
+{
+    private final IPtpIpCommandCallback callback;
+
+    public NikonRegistrationMessage(@NonNull IPtpIpCommandCallback callback)
+    {
+        this.callback = callback;
+    }
+
+    @Override
+    public IPtpIpCommandCallback responseCallback()
+    {
+        return (callback);
+    }
+
+    @Override
+    public int getId()
+    {
+        return (SEQ_REGISTRATION);
+    }
+
+    @Override
+    public boolean receiveAgainShortLengthMessage()
+    {
+        return (false);
+    }
+
+    @Override
+    public boolean useSequenceNumber()
+    {
+        return (false);
+    }
+
+    @Override
+    public boolean isIncrementSeqNumber()
+    {
+        return (false);
+    }
+
+    @Override
+    public int receiveDelayMs()
+    {
+        return (50);
+    }
+
+    @Override
+    public byte[] commandBody()
+    {
+        int uuid = UUID.randomUUID().hashCode();
+
+        byte[] typeArray = {
+                (byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00,
+        };
+
+        byte[] uuidArray = {
+                (byte)0xad, (byte)0xa5, (byte)0x48, (byte)0x5d, (byte)0x87, (byte)0xb2, (byte)0x7f, (byte)0x0b,
+                (byte)0xd3, (byte)0xd5, (byte)0xde, (byte)0xd0, (byte)0x12, (byte)0x44, (byte)0x99, (byte)0x32,
+        };
+
+        byte[] deviceNameArray = {
+                // device_name 'GOKIGEN_a01'
+                (byte)0x47, (byte)0x00, (byte)0x4f, (byte)0x00, (byte)0x4b, (byte)0x00, (byte)0x49, (byte)0x00,
+                (byte)0x47, (byte)0x00, (byte)0x45, (byte)0x00, (byte)0x4e, (byte)0x00, (byte)0x5f, (byte)0x00,
+                (byte)0x61, (byte)0x00, (byte)0x30, (byte)0x00, (byte)0x31, (byte)0x00, (byte)0x00, (byte)0x00,
+        };
+        byte[] versionArray = {
+                //
+                (byte)0x00, (byte)0x00, (byte)0x01, (byte)0x00,
+        };
+
+        ByteBuffer byteBuffer = ByteBuffer.allocate(4 + 16 + 24 + 4);
+        byteBuffer.put(typeArray);
+        byteBuffer.put(uuidArray);
+        byteBuffer.put(deviceNameArray);
+        byteBuffer.put(versionArray);
+
+        return (byteBuffer.array());
+    }
+}
index 3fe8be1..dc16f73 100644 (file)
@@ -15,8 +15,7 @@ import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpComma
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpCommandPublisher;
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.IPtpIpMessages;
 import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.PtpIpCommandGeneric;
-import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.specific.CanonRegistrationMessage;
-import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.status.PtpIpStatusChecker;
+import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.command.messages.specific.NikonRegistrationMessage;
 
 public class NikonCameraConnectSequenceForPlayback implements Runnable, IPtpIpCommandCallback, IPtpIpMessages
 {
@@ -114,7 +113,7 @@ public class NikonCameraConnectSequenceForPlayback implements Runnable, IPtpIpCo
                 if (checkEventInitialize(rx_body))
                 {
                     interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting1), false, false, 0);
-                    commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_OPEN_SESSION, isDumpLog, 0, 0x1002, 4, 0x41));  // OpenSession
+                    commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_OPEN_SESSION, 50, isDumpLog, 0, 0x1002, 4, 0x41, 0, 0, 0));  // OpenSession
                 }
                 else
                 {
@@ -124,7 +123,7 @@ public class NikonCameraConnectSequenceForPlayback implements Runnable, IPtpIpCo
 
             case SEQ_OPEN_SESSION:
                 interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.canon_connect_connecting2), false, false, 0);
-                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_INIT_SESSION, isDumpLog, 0, 0x1001));  // GetDeviceInfo
+                commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_INIT_SESSION, 50, isDumpLog, 0, 0x1001, 0, 0, 0, 0, 0));  // GetDeviceInfo
                 break;
 
             case SEQ_INIT_SESSION:
@@ -149,7 +148,7 @@ public class NikonCameraConnectSequenceForPlayback implements Runnable, IPtpIpCo
     {
         interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_start), false, false, 0);
         cameraStatusReceiver.onStatusNotify(context.getString(R.string.connect_start));
-        commandIssuer.enqueueCommand(new CanonRegistrationMessage(this));
+        commandIssuer.enqueueCommand(new NikonRegistrationMessage(this));
     }
 
     private void sendInitEventRequest(byte[] receiveData)
@@ -165,7 +164,7 @@ public class NikonCameraConnectSequenceForPlayback implements Runnable, IPtpIpCo
             statusChecker.setEventConnectionNumber(eventConnectionNumber);
             interfaceProvider.getCameraStatusWatcher().startStatusWatch(null);
 
-            commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_OPEN_SESSION, isDumpLog, 0, 0x1002, 4, 0x41));
+            commandIssuer.enqueueCommand(new PtpIpCommandGeneric(this, SEQ_OPEN_SESSION, 50, isDumpLog, 0, 0x1002, 4, 0x41, 0, 0, 0));
         }
         catch (Exception e)
         {