OSDN Git Service

Seq番号の更新を見直し、接続の安定性を上げる。
authorMRSa <mrsa@myad.jp>
Mon, 20 May 2019 14:38:07 +0000 (23:38 +0900)
committerMRSa <mrsa@myad.jp>
Mon, 20 May 2019 14:38:07 +0000 (23:38 +0900)
app/src/main/java/net/osdn/gokigen/cameratest/fuji/Communication.java
app/src/main/java/net/osdn/gokigen/cameratest/fuji/Connection.java
app/src/main/java/net/osdn/gokigen/cameratest/fuji/MessageSequence.java
app/src/main/res/drawable/ic_refresh_white_24dp.xml [moved from app/src/main/res/drawable/ic_refresh_black_24dp.xml with 94% similarity]
app/src/main/res/menu/debug_view.xml
app/src/main/res/values/strings.xml
app/src/main/res/xml/preferences_fuji_x.xml

index 3613afd..7b707c8 100644 (file)
@@ -12,6 +12,7 @@ import java.net.Socket;
 class Communication
 {
     private final String TAG = toString();
+    private static final int SEQUENCE_START_NUMBER = 1;
 
     private static final int BUFFER_SIZE = 1024 * 1024 + 8;
     private static final int CONTROL_PORT = 55740;
@@ -22,7 +23,7 @@ class Communication
     private Socket socket = null;
     private DataOutputStream dos = null;
     private BufferedReader bufferedReader = null;
-    private int sequenceNumber = 0x0000000a;
+    private int sequenceNumber = SEQUENCE_START_NUMBER;
 
     private boolean isDumpReceiveLog = true;
 
@@ -80,7 +81,7 @@ class Communication
             e.printStackTrace();
         }
         socket = null;
-        sequenceNumber = 0x0000000a;
+        sequenceNumber = SEQUENCE_START_NUMBER;
         System.gc();
     }
 
index 8f03b10..2cde8c4 100644 (file)
@@ -51,22 +51,33 @@ public class Connection implements IFujiStatusRequest
             dump_bytes(0, rx_bytes);
             Thread.sleep(50);
 
-            // 応答エラーの場合は この値が返ってくるはず  = {0x05, 0x00, 0x00, 0x00, 0x19, 0x20, 0x00, 0x00};
+            // 応答エラーかどうかをチェックする
+            if (rx_bytes.getData().length == 8)
+            {
+                byte[] receiveData = rx_bytes.getData();
+                if ((receiveData[0] == 0x05)&&(receiveData[1] == 0x00)&&(receiveData[2] == 0x00)&&(receiveData[3] == 0x00)&&
+                    (receiveData[4] == 0x19)&&(receiveData[5] == 0x20)&&(receiveData[6] == 0x00)&&(receiveData[7] == 0x00))
+                {
+                    // 応答エラー...
+                    return (false);
+                }
+                return (false);
+            }
 
             // start_messageを送信
-            comm.send_to_camera(sequence.start_message(), false);
+            comm.send_to_camera(sequence.start_message(), true);
             rx_bytes = comm.receive_from_camera();
             dump_bytes(1, rx_bytes);
             Thread.sleep(50);
 
             //  なんだろう?? (送信が必要なようだが)
-            comm.send_to_camera(sequence.start_message2(), false);
+            comm.send_to_camera(sequence.start_message2(), true);
             rx_bytes = comm.receive_from_camera();
             dump_bytes(2, rx_bytes);
             Thread.sleep(50);
 
             // two_part messageを発行 (その1)
-            comm.send_to_camera(sequence.start_message3_1(), false);
+            comm.send_to_camera(sequence.start_message3_1(), true);
             rx_bytes = comm.receive_from_camera();
             dump_bytes(3, rx_bytes);
             Thread.sleep(50);
@@ -78,13 +89,13 @@ public class Connection implements IFujiStatusRequest
             Thread.sleep(50);
 
             // remote mode
-            comm.send_to_camera(sequence.start_message4(), false);
+            comm.send_to_camera(sequence.start_message4(), true);
             rx_bytes = comm.receive_from_camera();
             dump_bytes(5, rx_bytes);
             Thread.sleep(50);
 
             // two_part messageを発行 (その1)
-            comm.send_to_camera(sequence.start_message5_1(), false);
+            comm.send_to_camera(sequence.start_message5_1(), true);
             rx_bytes = comm.receive_from_camera();
             dump_bytes(6, rx_bytes);
             Thread.sleep(50);
@@ -96,25 +107,25 @@ public class Connection implements IFujiStatusRequest
             Thread.sleep(50);
 
             // ????
-            comm.send_to_camera(sequence.start_message6(), false);
+            comm.send_to_camera(sequence.start_message6(), true);
             rx_bytes = comm.receive_from_camera();
             dump_bytes(8, rx_bytes);
             Thread.sleep(50);
 
             // ????
-            comm.send_to_camera(sequence.start_message7(), false);
+            comm.send_to_camera(sequence.start_message7(), true);
             rx_bytes = comm.receive_from_camera();
             dump_bytes(9, rx_bytes);
             Thread.sleep(50);
 
             // ????
-            comm.send_to_camera(sequence.start_message8(), false);
+            comm.send_to_camera(sequence.start_message8(), true);
             rx_bytes = comm.receive_from_camera();
             dump_bytes(10, rx_bytes);
             Thread.sleep(50);
 
             // ????
-            comm.send_to_camera(sequence.start_message9(), false);
+            comm.send_to_camera(sequence.start_message9(), true);
 
             // 応答OKの場合は、8バイト ({0x03, 0x00, 0x01, 0x20} + {0x10, 0x02, 0x00, 0x00} )が応答されるはず
             rx_bytes = comm.receive_from_camera();
index 763cad0..b61b782 100644 (file)
@@ -25,12 +25,12 @@ class MessageSequence
                 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
 
 /**/
-                // device_name 'GOKIGEN____012345'
+                // device_name 'GOKIGEN____012345678'
                 (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)0x5f, (byte)0x00, (byte)0x5f, (byte)0x00, (byte)0x5f, (byte)0x00, (byte)0x30, (byte)0x00,
                 (byte)0x31, (byte)0x00, (byte)0x32, (byte)0x00, (byte)0x33, (byte)0x00, (byte)0x34, (byte)0x00,
-                (byte)0x35, (byte)0x00, (byte)0x36, (byte)0x00, (byte)0x37, (byte)0x00, (byte)0x00, (byte)0x00,
+                (byte)0x35, (byte)0x00, (byte)0x36, (byte)0x00, (byte)0x37, (byte)0x00, (byte)0x38, (byte)0x00,
                 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
                 (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00, (byte)0x00,
 /**/
@@ -56,14 +56,6 @@ class MessageSequence
         return (new byte[] { (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, });
     }
 
-    byte[] hello_message()
-    {
-        return (new byte[] {
-                // HELLO (0x0000)
-                0x00, 0x00,
-        });
-    }
-
     byte[] start_message()
     {
         return (new byte[] {
@@ -135,7 +127,6 @@ class MessageSequence
         });
     }
 
-
     byte[] start_message4()
     {
         return (new byte[] {
@@ -325,7 +316,6 @@ class MessageSequence
         });
     }
 
-
     byte[] execute_focus_unlock()
     {
         return (new byte[] {
@@ -1,4 +1,5 @@
 <vector xmlns:android="http://schemas.android.com/apk/res/android"
+        android:tint="#e0e0e0"
         android:width="24dp"
         android:height="24dp"
         android:viewportWidth="24.0"
index 731369b..a1806a1 100644 (file)
@@ -5,7 +5,7 @@
     <item
         android:id="@+id/action_refresh"
         compat:showAsAction="always"
-        android:icon="@drawable/ic_refresh_black_24dp"
+        android:icon="@drawable/ic_refresh_white_24dp"
         android:title="@string/action_refresh"
         android:visible="true" />
 
index f8b2244..f2fb73a 100644 (file)
@@ -34,6 +34,8 @@
     <string name="pref_degug_info">Debug Information</string>
     <string name="pref_summary_debug_info">LogCat Information</string>
 
+    <string name="pref_special_thanks">Special Thanks to : fuji-cam-wifi-tool</string>
+
 
     <string name="dialog_title_confirmation">Confirmation</string>
     <string name="dialog_positive_execute">OK</string>
index 30c2483..18998ff 100644 (file)
 
     <PreferenceCategory
         android:title="@string/pref_cat_others">
-
+        <Preference
+            android:key="special_thanks"
+            android:title="@string/pref_special_thanks"
+            android:summary="https://github.com/hkr/fuji-cam-wifi-tool"
+            android:selectable="true">
+            <intent android:action="android.intent.action.VIEW"
+                android:data="https://github.com/hkr/fuji-cam-wifi-tool" />
+        </Preference>
 
     </PreferenceCategory>
 
         <Preference
             android:key="instruction_link"
             android:title="@string/pref_instruction_manual"
-            android:summary="https://osdn.net/projects/gokigen/wiki/GR2Control"
+            android:summary="https://osdn.net/projects/gokigen/wiki/A01d"
             android:selectable="true">
             <intent android:action="android.intent.action.VIEW"
-                android:data="https://osdn.net/projects/gokigen/wiki/GR2Control" />
+                android:data="https://osdn.net/projects/gokigen/wiki/A01d" />
         </Preference>
 
         <Preference