From 6c20a383d2cd2c088ddea132112e84587520be63 Mon Sep 17 00:00:00 2001 From: MRSa Date: Sat, 15 Aug 2020 17:14:56 +0900 Subject: [PATCH] =?utf8?q?pixpro=E5=AE=9F=E8=A3=85=E3=81=AE=E3=83=99?= =?utf8?q?=E3=83=BC=E3=82=B9=E9=83=A8=E5=88=86=E3=82=92=E4=BD=9C=E6=88=90?= =?utf8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 4 +- .../pkremote/camera/CameraInterfaceProvider.java | 69 ++- .../interfaces/control/ICameraConnection.java | 1 + .../vendor/pixpro/IPixproInterfaceProvider.java | 47 ++ .../pixpro/operation/CameraPowerOffPixpro.java | 81 +++ .../pixpro/wrapper/PixproInterfaceProvider.java | 226 ++++++++ .../pixpro/wrapper/command/IPixproCommand.java | 30 ++ .../wrapper/command/IPixproCommandCallback.java | 6 + .../wrapper/command/IPixproCommandPublisher.java | 12 + .../wrapper/command/IPixproCommunication.java | 7 + .../wrapper/command/PixproCommandCommunicator.java | 572 +++++++++++++++++++++ .../wrapper/command/messages/IPixproMessages.java | 30 ++ .../command/messages/PixproCommandBase.java | 58 +++ .../command/messages/PixproCommandReceiveOnly.java | 43 ++ .../connection/PixproConnectSequence01.java | 49 ++ .../connection/PixproConnectSequence02.java | 57 ++ .../connection/PixproConnectSequence03.java | 45 ++ .../connection/PixproConnectSequence04.java | 45 ++ .../connection/PixproConnectSequence05.java | 60 +++ .../connection/PixproConnectSequence06.java | 44 ++ .../connection/PixproConnectSequence07.java | 47 ++ .../connection/PixproConnectSequence08.java | 49 ++ .../connection/PixproConnectSequence09.java | 45 ++ .../connection/PixproConnectSequence10.java | 49 ++ .../connection/PixproConnectSequence11.java | 45 ++ .../connection/PixproCameraConnectSequence.java | 205 ++++++++ .../connection/PixproCameraDisconnectSequence.java | 34 ++ .../wrapper/connection/PixproConnection.java | 256 +++++++++ .../wrapper/playback/PixproPlaybackControl.java | 68 +++ .../wrapper/status/PixproCameraHardwareStatus.java | 52 ++ .../wrapper/status/PixproCameraInformation.java | 25 + .../pixpro/wrapper/status/PixproRunMode.java | 25 + .../pixpro/wrapper/status/PixproStatusChecker.java | 102 ++++ .../pixpro/wrapper/status/PixproStatusHolder.java | 206 ++++++++ .../preference/IPreferencePropertyAccessor.java | 8 +- .../pixpro/PixproPreferenceFragment.java | 378 ++++++++++++++ .../gokigen/pkremote/scene/CameraSceneUpdater.java | 5 + app/src/main/res/values-ja/arrays.xml | 2 + app/src/main/res/values-ja/strings.xml | 21 + app/src/main/res/values/arrays.xml | 2 + app/src/main/res/values/strings.xml | 21 + app/src/main/res/xml/preferences_pixpro.xml | 82 +++ 42 files changed, 3204 insertions(+), 9 deletions(-) create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/IPixproInterfaceProvider.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/operation/CameraPowerOffPixpro.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/PixproInterfaceProvider.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommand.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommandCallback.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommandPublisher.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommunication.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/PixproCommandCommunicator.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/IPixproMessages.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/PixproCommandBase.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/PixproCommandReceiveOnly.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence01.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence02.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence03.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence04.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence05.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence06.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence07.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence08.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence09.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence10.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence11.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/connection/PixproCameraConnectSequence.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/connection/PixproCameraDisconnectSequence.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/connection/PixproConnection.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/playback/PixproPlaybackControl.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproCameraHardwareStatus.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproCameraInformation.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproRunMode.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproStatusChecker.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproStatusHolder.java create mode 100644 app/src/main/java/net/osdn/gokigen/pkremote/preference/pixpro/PixproPreferenceFragment.java create mode 100644 app/src/main/res/xml/preferences_pixpro.xml diff --git a/app/build.gradle b/app/build.gradle index 0daaa6a..c4b4d4f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "net.osdn.gokigen.pkremote" minSdkVersion 14 targetSdkVersion 29 - versionCode 10704 - versionName "1.7.4" + versionCode 10800 + versionName "1.8.0" } buildTypes { release { diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/CameraInterfaceProvider.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/CameraInterfaceProvider.java index a2af6a2..da03f1a 100644 --- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/CameraInterfaceProvider.java +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/CameraInterfaceProvider.java @@ -30,6 +30,7 @@ import net.osdn.gokigen.pkremote.camera.vendor.olympus.IOlympusInterfaceProvider import net.osdn.gokigen.pkremote.camera.vendor.olympus.wrapper.OlympusInterfaceProvider; import net.osdn.gokigen.pkremote.camera.vendor.olympuspen.wrapper.OlympusPenInterfaceProvider; import net.osdn.gokigen.pkremote.camera.vendor.panasonic.wrapper.PanasonicCameraWrapper; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.PixproInterfaceProvider; import net.osdn.gokigen.pkremote.camera.vendor.ptpip.IPtpIpInterfaceProvider; import net.osdn.gokigen.pkremote.camera.vendor.ptpip.wrapper.PtpIpInterfaceProvider; import net.osdn.gokigen.pkremote.camera.vendor.ricoh.wrapper.RicohGr2InterfaceProvider; @@ -57,6 +58,7 @@ public class CameraInterfaceProvider implements IInterfaceProvider private final NikonInterfaceProvider nikon; private final OlympusPenInterfaceProvider olympuspen; private final ThetaInterfaceProvider theta; + private final PixproInterfaceProvider pixpro; private final IInformationReceiver informationReceiver; private final CameraContentsRecognizer cameraContentsRecognizer; private final AppCompatActivity context; @@ -85,6 +87,7 @@ public class CameraInterfaceProvider implements IInterfaceProvider panasonic = new PanasonicCameraWrapper(context, provider, statusListener, informationReceiver, cardSlotSelector); olympuspen = new OlympusPenInterfaceProvider(context, provider); theta = new ThetaInterfaceProvider(context, provider); + pixpro = new PixproInterfaceProvider(context, provider, informationReceiver); this.informationReceiver = informationReceiver; this.cameraContentsRecognizer = new CameraContentsRecognizer(context, this); } @@ -156,6 +159,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getThetaCameraConnection()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getPixproCameraConnection()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getRicohGr2CameraConnection()); @@ -206,6 +213,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getButtonControl()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getButtonControl()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getButtonControl()); @@ -256,6 +267,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getDisplayInjector()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getDisplayInjector()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getDisplayInjector()); @@ -306,6 +321,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getLiveViewControl()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getLiveViewControl()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getLiveViewControl()); @@ -356,6 +375,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getLiveViewListener()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getLiveViewListener()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getLiveViewListener()); @@ -406,6 +429,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getFocusingControl()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getFocusingControl()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getFocusingControl()); @@ -456,6 +483,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getCameraInformation()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getCameraInformation()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getCameraInformation()); @@ -506,6 +537,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getZoomLensControl()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getZoomLensControl()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getZoomLensControl()); @@ -556,6 +591,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getCaptureControl()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getCaptureControl()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getCaptureControl()); @@ -606,6 +645,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getCameraStatusListHolder()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getCameraStatusListHolder()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getCameraStatusListHolder()); @@ -656,6 +699,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getCameraStatusWatcher()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getCameraStatusWatcher()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getCameraStatusWatcher()); @@ -706,6 +753,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getPlaybackControl()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getPlaybackControl()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getPlaybackControl()); @@ -756,6 +807,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getHardwareStatus()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getHardwareStatus()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getHardwareStatus()); @@ -806,6 +861,10 @@ public class CameraInterfaceProvider implements IInterfaceProvider { return (theta.getCameraRunMode()); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + return (pixpro.getCameraRunMode()); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.RICOH) { return (ricohGr2.getCameraRunMode()); @@ -901,16 +960,14 @@ public class CameraInterfaceProvider implements IInterfaceProvider { ret = ICameraConnection.CameraConnectionMethod.THETA; } - else // if (connectionMethod.contains("OPC")) + else if (connectionMethod.contains("PIXPRO")) { - ret = ICameraConnection.CameraConnectionMethod.OPC; + ret = ICameraConnection.CameraConnectionMethod.PIXPRO; } -/* - else if (connectionMethod.contains("SONY")) + else // if (connectionMethod.contains("OPC")) { - ret = ICameraConnection.CameraConnectionMethod.SONY; + ret = ICameraConnection.CameraConnectionMethod.OPC; } -*/ } catch (Exception e) { diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/control/ICameraConnection.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/control/ICameraConnection.java index adef871..bdc54f0 100644 --- a/app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/control/ICameraConnection.java +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/interfaces/control/ICameraConnection.java @@ -20,6 +20,7 @@ public interface ICameraConnection NIKON, OLYMPUS, THETA, + PIXPRO, } enum CameraConnectionStatus diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/IPixproInterfaceProvider.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/IPixproInterfaceProvider.java new file mode 100644 index 0000000..7d526ec --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/IPixproInterfaceProvider.java @@ -0,0 +1,47 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro; + +import net.osdn.gokigen.pkremote.IInformationReceiver; +import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraButtonControl; +import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection; +import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraRunMode; +import net.osdn.gokigen.pkremote.camera.interfaces.control.ICaptureControl; +import net.osdn.gokigen.pkremote.camera.interfaces.control.IFocusingControl; +import net.osdn.gokigen.pkremote.camera.interfaces.control.IZoomLensControl; +import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IDisplayInjector; +import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewControl; +import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewListener; +import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl; +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraHardwareStatus; +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraInformation; +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatus; +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusWatcher; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandPublisher; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommunication; + +public interface IPixproInterfaceProvider +{ + ICameraConnection getPixproCameraConnection(); + ILiveViewControl getLiveViewControl(); + + ILiveViewListener getLiveViewListener(); + IFocusingControl getFocusingControl(); + ICameraInformation getCameraInformation(); + IZoomLensControl getZoomLensControl(); + ICaptureControl getCaptureControl(); + IDisplayInjector getDisplayInjector(); + + ICameraStatusWatcher getCameraStatusWatcher(); + ICameraStatus getCameraStatusListHolder(); + + ICameraButtonControl getButtonControl(); + + IPlaybackControl getPlaybackControl(); + ICameraHardwareStatus getHardwareStatus(); + ICameraRunMode getCameraRunMode(); + + IPixproCommandPublisher getCommandPublisher(); + IPixproCommunication getCommandCommunication(); + + IInformationReceiver getInformationReceiver(); + String getStringFromResource(int resId); +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/operation/CameraPowerOffPixpro.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/operation/CameraPowerOffPixpro.java new file mode 100644 index 0000000..e590d75 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/operation/CameraPowerOffPixpro.java @@ -0,0 +1,81 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.operation; + +import android.content.Context; + +import androidx.preference.Preference; + +import net.osdn.gokigen.pkremote.R; +import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor; +import net.osdn.gokigen.pkremote.scene.ConfirmationDialog; +import net.osdn.gokigen.pkremote.scene.IChangeScene; + +/** + * Preferenceがクリックされた時に処理するクラス + * + */ +public class CameraPowerOffPixpro implements Preference.OnPreferenceClickListener, ConfirmationDialog.Callback +{ + + private final Context context; + private final IChangeScene changeScene; + private String preferenceKey = null; + + /** + * コンストラクタ + * + */ + public CameraPowerOffPixpro(Context context, IChangeScene changeScene) + { + this.context = context; + this.changeScene = changeScene; + } + + /** + * クラスの準備 + * + */ + public void prepare() + { + // 何もしない + } + + /** + * + * + * @param preference クリックしたpreference + * @return false : ハンドルしない / true : ハンドルした + */ + @Override + public boolean onPreferenceClick(Preference preference) + { + if (!preference.hasKey()) + { + return (false); + } + + preferenceKey = preference.getKey(); + if (preferenceKey.contains(IPreferencePropertyAccessor.EXIT_APPLICATION)) + { + + // 確認ダイアログの生成と表示 + ConfirmationDialog dialog = ConfirmationDialog.newInstance(context); + dialog.show(R.string.dialog_title_confirmation, R.string.dialog_message_exit_application, this); + return (true); + } + return (false); + } + + /** + * + * + */ + @Override + public void confirm() + { + if (preferenceKey.contains(IPreferencePropertyAccessor.EXIT_APPLICATION)) + { + // カメラの電源をOFFにしたうえで、アプリケーションを終了する。 + changeScene.exitApplication(); + } + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/PixproInterfaceProvider.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/PixproInterfaceProvider.java new file mode 100644 index 0000000..2cba031 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/PixproInterfaceProvider.java @@ -0,0 +1,226 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper; + +import android.app.Activity; +import android.content.SharedPreferences; +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.preference.PreferenceManager; + +import net.osdn.gokigen.pkremote.IInformationReceiver; +import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraButtonControl; +import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection; +import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraRunMode; +import net.osdn.gokigen.pkremote.camera.interfaces.control.ICaptureControl; +import net.osdn.gokigen.pkremote.camera.interfaces.control.IFocusingControl; +import net.osdn.gokigen.pkremote.camera.interfaces.control.IFocusingModeNotify; +import net.osdn.gokigen.pkremote.camera.interfaces.control.IZoomLensControl; +import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IAutoFocusFrameDisplay; +import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IDisplayInjector; +import net.osdn.gokigen.pkremote.camera.interfaces.liveview.IIndicatorControl; +import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewControl; +import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ILiveViewListener; +import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl; +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraHardwareStatus; +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraInformation; +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatus; +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusReceiver; +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusWatcher; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.IPixproInterfaceProvider; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandPublisher; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommunication; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.PixproCommandCommunicator; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.connection.PixproConnection; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.playback.PixproPlaybackControl; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status.PixproCameraHardwareStatus; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status.PixproCameraInformation; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status.PixproRunMode; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status.PixproStatusChecker; + +import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT; +import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT_DEFAULT_VALUE; +import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.PIXPRO_HOST_IP; +import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.PIXPRO_HOST_IP_DEFAULT_VALUE; + +/** + * + * + */ +public class PixproInterfaceProvider implements IPixproInterfaceProvider, IDisplayInjector +{ + private final String TAG = toString(); + private final Activity activity; + private final PixproCommandCommunicator commandCommunicator; + private final IInformationReceiver informationReceiver; + private final PixproConnection pixproConnection; + private final ICameraHardwareStatus hardwarestatus; + private final PixproPlaybackControl playbackControl; + private final PixproStatusChecker statusChecker; + private final PixproRunMode runMode; + private final ICameraInformation cameraInformation; + + /** + * + * + */ + public PixproInterfaceProvider(@NonNull Activity activity, @NonNull ICameraStatusReceiver provider, @NonNull IInformationReceiver informationReceiver) + { + String ipAddress; + String controlPortStr; + try + { + SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); + ipAddress = preferences.getString(PIXPRO_HOST_IP, PIXPRO_HOST_IP_DEFAULT_VALUE); + controlPortStr = preferences.getString(PIXPRO_COMMAND_PORT, PIXPRO_COMMAND_PORT_DEFAULT_VALUE); + } + catch (Exception e) + { + e.printStackTrace(); + ipAddress = "172.16.0.254"; + controlPortStr = "9175"; + } + int controlPort = parseInt(controlPortStr, 9175); + this.commandCommunicator = new PixproCommandCommunicator(this, ipAddress, controlPort, true, false); + this.informationReceiver = informationReceiver; + this.activity = activity; + this.cameraInformation = new PixproCameraInformation(); + this.statusChecker = new PixproStatusChecker(); + this.pixproConnection = new PixproConnection(activity, provider, this, statusChecker); + this.hardwarestatus = new PixproCameraHardwareStatus(); + this.runMode = new PixproRunMode(); + this.playbackControl = new PixproPlaybackControl(); + } + + private int parseInt(@NonNull String key, int defaultValue) + { + int value = defaultValue; + try + { + value = Integer.parseInt(key); + } + catch (Exception e) + { + e.printStackTrace(); + } + return (value); + } + + public void prepare() + { + Log.v(TAG, "prepare()"); + } + + @Override + public void injectDisplay(IAutoFocusFrameDisplay frameDisplayer, IIndicatorControl indicator, IFocusingModeNotify focusingModeNotify) + { + Log.v(TAG, "injectDisplay()"); + } + + @Override + public ICameraConnection getPixproCameraConnection() + { + return (pixproConnection); + } + + @Override + public ILiveViewControl getLiveViewControl() + { + return (null); + } + + @Override + public ILiveViewListener getLiveViewListener() + { + return (null); + } + + @Override + public IFocusingControl getFocusingControl() + { + return (null); + } + + @Override + public ICameraInformation getCameraInformation() + { + return (cameraInformation); + } + + @Override + public IZoomLensControl getZoomLensControl() + { + return (null); + } + + @Override + public ICaptureControl getCaptureControl() + { + return (null); + } + + @Override + public IDisplayInjector getDisplayInjector() + { + return (this); + } + + @Override + public ICameraStatus getCameraStatusListHolder() + { + return (statusChecker); + } + + @Override + public ICameraButtonControl getButtonControl() + { + return (null); + } + + @Override + public ICameraStatusWatcher getCameraStatusWatcher() + { + return (statusChecker); + } + + @Override + public IPlaybackControl getPlaybackControl() + { + return (playbackControl); + } + + @Override + public ICameraHardwareStatus getHardwareStatus() + { + return (hardwarestatus); + } + + @Override + public ICameraRunMode getCameraRunMode() + { + return (runMode); + } + + @Override + public IPixproCommandPublisher getCommandPublisher() + { + return (commandCommunicator); + } + + @Override + public IPixproCommunication getCommandCommunication() + { + return (commandCommunicator); + } + + @Override + public IInformationReceiver getInformationReceiver() + { + return (informationReceiver); + } + + @Override + public String getStringFromResource(int resId) + { + return (activity.getString(resId)); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommand.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommand.java new file mode 100644 index 0000000..95750e2 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommand.java @@ -0,0 +1,30 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command; + + +public interface IPixproCommand +{ + // メッセージの識別子 + int getId(); + + // コマンドの受信待ち時間(単位:ms) + int receiveDelayMs(); + + // 送信するメッセージボディ + byte[] commandBody(); + + // 送信するメッセージボディ(連続送信する場合) + byte[] commandBody2(); + + // 受信待ち再試行回数 + int maxRetryCount(); + + // コマンドの受信が失敗した場合、再送する(再送する場合は true) + boolean sendRetry(); + + // コマンド送信結果(応答)の通知先 + IPixproCommandCallback responseCallback(); + + // デバッグ用: ログ(logcat)に通信結果を残すかどうか + boolean dumpLog(); + +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommandCallback.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommandCallback.java new file mode 100644 index 0000000..3d1b912 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommandCallback.java @@ -0,0 +1,6 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command; + +public interface IPixproCommandCallback +{ + void receivedMessage(int id, byte[] rx_body); +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommandPublisher.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommandPublisher.java new file mode 100644 index 0000000..2a9a559 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommandPublisher.java @@ -0,0 +1,12 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command; + +import androidx.annotation.NonNull; + +public interface IPixproCommandPublisher +{ + boolean isConnected(); + boolean enqueueCommand(@NonNull IPixproCommand command); + + void start(); + void stop(); +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommunication.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommunication.java new file mode 100644 index 0000000..619f62d --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/IPixproCommunication.java @@ -0,0 +1,7 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command; + +public interface IPixproCommunication +{ + boolean connect(); + void disconnect(); +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/PixproCommandCommunicator.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/PixproCommandCommunicator.java new file mode 100644 index 0000000..a6975c3 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/PixproCommandCommunicator.java @@ -0,0 +1,572 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command; + + +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import net.osdn.gokigen.pkremote.R; +import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.IPixproInterfaceProvider; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.PixproCommandReceiveOnly; + +import java.io.BufferedReader; +import java.io.ByteArrayOutputStream; +import java.io.DataOutputStream; +import java.io.InputStream; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.util.ArrayDeque; +import java.util.Queue; + +import static net.osdn.gokigen.pkremote.camera.utils.SimpleLogDumper.dump_bytes; +import static net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages.SEQ_RECEIVE_ONLY; + +public class PixproCommandCommunicator implements IPixproCommandPublisher, IPixproCommunication +{ + private static final String TAG = PixproCommandCommunicator.class.getSimpleName(); + + private static final int BUFFER_SIZE = 1024 * 1024 + 16; // 受信バッファは 1MB + private static final int COMMAND_SEND_RECEIVE_DURATION_MS = 5; + private static final int COMMAND_SEND_RECEIVE_DURATION_MAX = 3000; + private static final int COMMAND_POLL_QUEUE_MS = 5; + + private final IPixproInterfaceProvider interfaceProvider; + private final String ipAddress; + private final int portNumber; + + private boolean isStart = false; + private boolean tcpNoDelay; + private boolean waitForever; + private Socket socket = null; + private DataOutputStream dos = null; + private BufferedReader bufferedReader = null; + private Queue commandQueue; + + public PixproCommandCommunicator(@NonNull IPixproInterfaceProvider interfaceProvider, @NonNull String ip, int portNumber, boolean tcpNoDelay, boolean waitForever) + { + this.interfaceProvider = interfaceProvider; + this.ipAddress = ip; + this.portNumber = portNumber; + this.tcpNoDelay = tcpNoDelay; + this.waitForever = waitForever; + this.commandQueue = new ArrayDeque<>(); + commandQueue.clear(); + } + + @Override + public boolean isConnected() + { + return (socket != null); + } + + @Override + public boolean connect() + { + try + { + Log.v(TAG, " connect()"); + socket = new Socket(); + socket.setTcpNoDelay(tcpNoDelay); + if (tcpNoDelay) + { + socket.setKeepAlive(false); + socket.setPerformancePreferences(0, 2, 0); + socket.setOOBInline(true); + socket.setReuseAddress(false); + socket.setTrafficClass(0x80); + } + socket.connect(new InetSocketAddress(ipAddress, portNumber), 0); + return (true); + } + catch (Exception e) + { + e.printStackTrace(); + socket = null; + } + return (false); + } + + private void closeOutputStream() + { + try + { + if (dos != null) + { + dos.close(); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + dos = null; + } + + private void closeBufferedReader() + { + try + { + if (bufferedReader != null) + { + bufferedReader.close(); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + bufferedReader = null; + } + + private void closeSocket() + { + try + { + if (socket != null) + { + socket.close(); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + socket = null; + } + + @Override + public void disconnect() + { + // 通信関連のクローズ + closeOutputStream(); + closeBufferedReader(); + closeSocket(); + + isStart = false; + commandQueue.clear(); + System.gc(); + } + + @Override + public void start() + { + if (isStart) + { + // すでにコマンドのスレッド動作中なので抜ける + return; + } + isStart = true; + Log.v(TAG, " start()"); + + Thread thread = new Thread(new Runnable() + { + @Override + public void run() + { + try + { + InputStream is = socket.getInputStream(); + dos = new DataOutputStream(socket.getOutputStream()); + while (isStart) + { + try + { + IPixproCommand command = commandQueue.poll(); + if (command != null) + { + issueCommand(command); + } + Thread.sleep(COMMAND_POLL_QUEUE_MS); + if ((is != null)&&(is.available() > 0)) + { + Log.v(TAG, " --- RECV MSG --- "); + receive_from_camera(new PixproCommandReceiveOnly(SEQ_RECEIVE_ONLY, null)); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + catch (Exception e) + { + Log.v(TAG, "<<<<< IP : " + ipAddress + " port : " + portNumber + " >>>>>"); + e.printStackTrace(); + } + } + }); + try + { + thread.start(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + @Override + public void stop() + { + isStart = false; + commandQueue.clear(); + } + + @Override + public boolean enqueueCommand(@NonNull IPixproCommand command) + { + try + { + //Log.v(TAG, "Enqueue : " + command.getId()); + return (commandQueue.offer(command)); + } + catch (Exception e) + { + e.printStackTrace(); + } + return (false); + } + + private void issueCommand(@NonNull IPixproCommand command) + { + try + { + boolean retry_over = true; + while (retry_over) + { + //Log.v(TAG, "issueCommand : " + command.getId()); + byte[] commandBody = command.commandBody(); + if (commandBody != null) + { + // コマンドボディが入っていた場合には、コマンド送信(入っていない場合は受信待ち) + send_to_camera(command.dumpLog(), commandBody); + byte[] commandBody2 = command.commandBody2(); + if (commandBody2 != null) + { + // コマンドボディの2つめが入っていた場合には、コマンドを連続送信する + send_to_camera(command.dumpLog(), commandBody2); + } + } + retry_over = receive_from_camera(command); + if (retry_over) + { + retry_over = command.sendRetry(); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * カメラにコマンドを送信する(メイン部分) + * + */ + private void send_to_camera(boolean isDumpReceiveLog, @NonNull byte[] byte_array) + { + try + { + if (dos == null) + { + Log.v(TAG, " DataOutputStream is null."); + return; + } + + if (byte_array.length <= 0) + { + // メッセージボディがない。終了する + Log.v(TAG, " SEND BODY IS NOTHING."); + return; + } + + if (isDumpReceiveLog) + { + // ログに送信メッセージを出力する + dump_bytes("SEND[" + byte_array.length + "] ", byte_array); + } + + // (データを)送信 + dos.write(byte_array); + dos.flush(); + } + catch (java.net.SocketException socketException) + { + socketException.printStackTrace(); + try + { + // 回線切断を通知する + detectDisconnect(); + } + catch (Exception ee) + { + ee.printStackTrace(); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + private void detectDisconnect() + { + ICameraConnection connection = interfaceProvider.getPixproCameraConnection(); + if (connection != null) + { + // 回線状態を「切断」にしてダイアログを表示する + connection.forceUpdateConnectionStatus(ICameraConnection.CameraConnectionStatus.DISCONNECTED); + connection.alertConnectingFailed(interfaceProvider.getStringFromResource(R.string.pixpro_command_line_disconnected)); + } + } + + + private void sleep(int delayMs) + { + try + { + Thread.sleep(delayMs); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * カメラからにコマンドの結果を受信する(メイン部分) + * + */ + private boolean receive_from_camera(@NonNull IPixproCommand command) + { + int delayMs = command.receiveDelayMs(); + if ((delayMs < 0)||(delayMs > COMMAND_SEND_RECEIVE_DURATION_MAX)) + { + delayMs = COMMAND_SEND_RECEIVE_DURATION_MS; + } + + // 受信した後、すべてをまとめて「受信したよ」と応答するパターン + return (receive_single(command, delayMs)); + } + + private boolean receive_single(@NonNull IPixproCommand command, int delayMs) + { + boolean isDumpReceiveLog = command.dumpLog(); + int id = command.getId(); + IPixproCommandCallback callback = command.responseCallback(); + try + { + int receive_message_buffer_size = BUFFER_SIZE; + byte[] byte_array = new byte[receive_message_buffer_size]; + InputStream is = socket.getInputStream(); + if (is == null) + { + Log.v(TAG, " InputStream is NULL... RECEIVE ABORTED."); + receivedAllMessage(isDumpReceiveLog, id, null, callback); + return (false); + } + + // 初回データが受信バッファにデータが溜まるまで待つ... + int read_bytes = waitForReceive(is, delayMs, command.maxRetryCount()); + if (read_bytes < 0) + { + // リトライオーバー検出 + Log.v(TAG, " ----- DETECT RECEIVE RETRY OVER... -----"); + return (true); + } + + // 受信したデータをバッファに突っ込む + ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); + while (read_bytes > 0) + { + read_bytes = is.read(byte_array, 0, receive_message_buffer_size); + if (read_bytes <= 0) + { + Log.v(TAG, " RECEIVED MESSAGE FINISHED (" + read_bytes + ")"); + break; + } + byteStream.write(byte_array, 0, read_bytes); + sleep(delayMs); + read_bytes = is.available(); + } + receivedAllMessage(isDumpReceiveLog, id, byteStream.toByteArray(), callback); + System.gc(); + } + catch (Throwable e) + { + e.printStackTrace(); + System.gc(); + } + return (false); + } + + private void receivedAllMessage(boolean isDumpReceiveLog, int id, byte[] body, IPixproCommandCallback callback) + { + Log.v(TAG, " receivedAllMessage() : " + ((body == null) ? 0 : body.length) + " bytes."); + if ((isDumpReceiveLog)&&(body != null)) + { + // ログに受信メッセージを出力する + dump_bytes("RECV[" + body.length + "] ", body); + } + if (checkReceiveStatusMessage(body)) + { + send_secondary_message(isDumpReceiveLog, body); + } + + if (callback != null) + { + callback.receivedMessage(id, body); + } + } + + private void send_secondary_message(boolean isDumpReceiveLog, @Nullable byte[] received_body) + { + if (received_body == null) + { + Log.v(TAG, " send_secondary_message : NULL "); + return; + } + Log.v(TAG, " send_secondary_message : [" + received_body[8] + "] [" + received_body[9] + "] "); + try { + byte[] message_to_send = null; + if ((received_body[8] == (byte) 0xd2) && (received_body[9] == (byte) 0xd7)) { + message_to_send = new byte[]{ + (byte) 0x2e, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, + (byte) 0xd2, (byte) 0x07, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x10, (byte) 0x00, (byte) 0x80, + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (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, (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, (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) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, + }; + } + if ((received_body[8] == (byte) 0xb9) && (received_body[9] == (byte) 0x0b)) { + message_to_send = new byte[]{ + (byte) 0x2e , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00, + (byte) 0xb9 , (byte) 0x0b , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x10 , (byte) 0x00 , (byte) 0x80, + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (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 , (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 , (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) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 + }; + } + if ((received_body[8] == (byte) 0xba) && (received_body[9] == (byte) 0x0b)) { + message_to_send = new byte[] + { + (byte) 0x2e, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, + (byte) 0xba, (byte) 0x0b, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x10, (byte) 0x00, (byte) 0x80, + (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x01, (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, (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, (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) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, + }; + } + if ((received_body[8] == (byte) 0xbb) && (received_body[9] == (byte) 0x0b)) { + message_to_send = new byte[] + { + (byte) 0x2e, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, + (byte) 0xbb, (byte) 0x0b, (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x10, (byte) 0x00, (byte) 0x80, + (byte) 0x1f, (byte) 0x00, (byte) 0x00, (byte) 0x90, (byte) 0x01, (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, (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, (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) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 + }; + } + if ((isDumpReceiveLog)&&(message_to_send != null)) + { + // ログに受信メッセージを出力する + dump_bytes("SND2[" + message_to_send.length + "] ", message_to_send); + } + + if ((dos != null)&&(message_to_send != null)) + { + // (データを)送信 + dos.write(message_to_send); + dos.flush(); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + private boolean checkReceiveStatusMessage(@Nullable byte[] receive_body) + { + boolean isReceivedStatusMessage = false; + try + { + if (receive_body == null) + { + return (false); + } + if (receive_body.length < 16) + { + Log.v(TAG, " BODY SIZE IS SMALL. : " + receive_body.length); + return (false); + } + if (((receive_body[8] == (byte) 0xd2)&&(receive_body[9] == (byte) 0x07))|| + ((receive_body[8] == (byte) 0xb9)&&(receive_body[9] == (byte) 0x0b))|| + ((receive_body[8] == (byte) 0xba)&&(receive_body[9] == (byte) 0x0b))|| + ((receive_body[8] == (byte) 0xbb)&&(receive_body[9] == (byte) 0x0b))) + + { + isReceivedStatusMessage = true; + Log.v(TAG, " >>> RECEIVED HOST PRIMARY MESSAGE. <<<"); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + return (isReceivedStatusMessage); + } + + private int waitForReceive(InputStream is, int delayMs, int retry_count) + { + boolean isLogOutput = true; + int read_bytes = 0; + try + { + while (read_bytes <= 0) + { + // Log.v(TAG, " --- waitForReceive : " + retry_count + " delay : " + delayMs + "ms"); + sleep(delayMs); + read_bytes = is.available(); + if (read_bytes <= 0) + { + if (isLogOutput) + { + Log.v(TAG, " waitForReceive:: is.available() WAIT... : " + delayMs + "ms"); + isLogOutput = false; + } + retry_count--; + if ((!waitForever)&&(retry_count < 0)) + { + return (-1); + } + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + return (read_bytes); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/IPixproMessages.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/IPixproMessages.java new file mode 100644 index 0000000..5ecaf55 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/IPixproMessages.java @@ -0,0 +1,30 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages; + +public interface IPixproMessages +{ + int SEQ_DUMMY = 0; + int SEQ_RECEIVE_ONLY = 1; + + int SEQ_SHUTTER = 10; + int SEQ_FOCUS = 11; + int SEQ_ZOOM = 12; + + + int SEQ_FLASH_OFF = 20; + int SEQ_FLASH_ON = 21; + int SEQ_FLASH_AUTO = 22; + + + int SEQ_CONNECT_01 = 101; + int SEQ_CONNECT_02 = 102; + int SEQ_CONNECT_03 = 103; + int SEQ_CONNECT_04 = 104; + int SEQ_CONNECT_05 = 105; + int SEQ_CONNECT_06 = 106; + int SEQ_CONNECT_07 = 107; + int SEQ_CONNECT_08 = 108; + int SEQ_CONNECT_09 = 109; + int SEQ_CONNECT_10 = 110; + int SEQ_CONNECT_11 = 111; + +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/PixproCommandBase.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/PixproCommandBase.java new file mode 100644 index 0000000..89fc51b --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/PixproCommandBase.java @@ -0,0 +1,58 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages; + + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommand; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; + +import static net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages.SEQ_DUMMY; + +public class PixproCommandBase implements IPixproCommand +{ + @Override + public int getId() + { + return SEQ_DUMMY; + } + + @Override + public int receiveDelayMs() + { + return (30); + } + + @Override + public byte[] commandBody() + { + return (new byte[0]); + } + + @Override + public byte[] commandBody2() + { + return (null); + } + + @Override + public int maxRetryCount() + { + return (50); + } + + @Override + public boolean sendRetry() + { + return (false); + } + + @Override + public IPixproCommandCallback responseCallback() + { + return (null); + } + + @Override + public boolean dumpLog() + { + return (false); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/PixproCommandReceiveOnly.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/PixproCommandReceiveOnly.java new file mode 100644 index 0000000..9449af1 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/PixproCommandReceiveOnly.java @@ -0,0 +1,43 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages; + + +import androidx.annotation.Nullable; + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; + +public class PixproCommandReceiveOnly extends PixproCommandBase +{ + private final IPixproCommandCallback callback; + private final int id; + + public PixproCommandReceiveOnly(int id, @Nullable IPixproCommandCallback callback) + { + this.callback = callback; + this.id = id; + } + + @Override + public IPixproCommandCallback responseCallback() + { + return (callback); + } + + @Override + public int getId() + { + return (id); + } + + @Override + public byte[] commandBody() + { + return (null); + } + + @Override + public boolean dumpLog() + { + return (false); + } + +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence01.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence01.java new file mode 100644 index 0000000..ab40d61 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence01.java @@ -0,0 +1,49 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection; + +import androidx.annotation.Nullable; + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.PixproCommandBase; + +import static net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages.SEQ_CONNECT_01; + +public class PixproConnectSequence01 extends PixproCommandBase +{ + private final IPixproCommandCallback callback; + + public PixproConnectSequence01(@Nullable IPixproCommandCallback callback) + { + this.callback = callback; + } + + @Override + public int getId() + { + return SEQ_CONNECT_01; + } + + @Override + public byte[] commandBody() + { + return (new byte[] + { + // 0xe9 0x03 + (byte) 0x2e , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x30 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xe9 , (byte) 0x03 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x80 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (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 , (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 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x30 , (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 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x02 , (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 , (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 , (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) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 + }); + } + + @Override + public IPixproCommandCallback responseCallback() + { + return (this.callback); + } + +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence02.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence02.java new file mode 100644 index 0000000..8d90045 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence02.java @@ -0,0 +1,57 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection; + +import androidx.annotation.Nullable; + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.PixproCommandBase; + +import static net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages.SEQ_CONNECT_02; + +public class PixproConnectSequence02 extends PixproCommandBase +{ + private final IPixproCommandCallback callback; + + public PixproConnectSequence02(@Nullable IPixproCommandCallback callback) + { + this.callback = callback; + } + + @Override + public int getId() + { + return SEQ_CONNECT_02; + } + + @Override + public byte[] commandBody() + { + return (new byte[] + { + // 0xd1 0x07 + (byte) 0x2e , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x48 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xd1 , (byte) 0x07 , (byte) 0x00 , (byte) 0x00 , (byte) 0x02 , (byte) 0x10 , (byte) 0x00 , (byte) 0x80 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (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 , (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 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x48 , (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 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x47 , (byte) 0x4F , (byte) 0x4B , (byte) 0x49 , (byte) 0x47 , (byte) 0x45 , (byte) 0x4E , (byte) 0x5F , + (byte) 0x61 , (byte) 0x30 , (byte) 0x31 , (byte) 0x53 , (byte) 0x65 , (byte) 0x72 , (byte) 0x69 , (byte) 0x65 , (byte) 0x73 , (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 , (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 , (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 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , + (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , + + // 0xea 0x03 + (byte) 0x2e , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xea , (byte) 0x03 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x80 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (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 , (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 , (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) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 + }); + } + + @Override + public IPixproCommandCallback responseCallback() + { + return (this.callback); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence03.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence03.java new file mode 100644 index 0000000..2158139 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence03.java @@ -0,0 +1,45 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection; + + +import androidx.annotation.Nullable; + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.PixproCommandBase; + +import static net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages.SEQ_CONNECT_03; + +public class PixproConnectSequence03 extends PixproCommandBase +{ + private final IPixproCommandCallback callback; + + public PixproConnectSequence03(@Nullable IPixproCommandCallback callback) + { + this.callback = callback; + } + + @Override + public int getId() + { + return SEQ_CONNECT_03; + } + + @Override + public byte[] commandBody() + { + return (new byte[] + { + // 0xec 0x03 + (byte) 0x2e , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xec , (byte) 0x03 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x80 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (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 , (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 , (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) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 + }); + } + + @Override + public IPixproCommandCallback responseCallback() + { + return (this.callback); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence04.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence04.java new file mode 100644 index 0000000..67b3789 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence04.java @@ -0,0 +1,45 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection; + + +import androidx.annotation.Nullable; + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.PixproCommandBase; + +import static net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages.SEQ_CONNECT_04; + +public class PixproConnectSequence04 extends PixproCommandBase +{ + private final IPixproCommandCallback callback; + + public PixproConnectSequence04(@Nullable IPixproCommandCallback callback) + { + this.callback = callback; + } + + @Override + public int getId() + { + return SEQ_CONNECT_04; + } + + @Override + public byte[] commandBody() + { + return (new byte[] + { + // 0xfc 0x03 + (byte) 0x2e , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xfc , (byte) 0x03 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x80 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (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 , (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 , (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) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 + }); + } + + @Override + public IPixproCommandCallback responseCallback() + { + return (this.callback); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence05.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence05.java new file mode 100644 index 0000000..24990ce --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence05.java @@ -0,0 +1,60 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection; + +import androidx.annotation.Nullable; + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.PixproCommandBase; + +import static net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages.SEQ_CONNECT_05; + +public class PixproConnectSequence05 extends PixproCommandBase +{ + private final IPixproCommandCallback callback; + + public PixproConnectSequence05(@Nullable IPixproCommandCallback callback) + { + this.callback = callback; + } + + @Override + public int getId() + { + return SEQ_CONNECT_05; + } + + @Override + public byte[] commandBody() + { + return (new byte[] + { + // 0xfe 0x03 + (byte) 0x2e , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xe4 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xfe , (byte) 0x03 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x80 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (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 , (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 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xe4 , (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 , (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 , (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 , (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 , (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 , + (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 , (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 , (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 , (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 , (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 , (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 , (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 , (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 , (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 , (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 , (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 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , + (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 + }); + } + + @Override + public IPixproCommandCallback responseCallback() + { + return (this.callback); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence06.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence06.java new file mode 100644 index 0000000..04234ba --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence06.java @@ -0,0 +1,44 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection; + + +import androidx.annotation.Nullable; + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.PixproCommandBase; + +import static net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages.SEQ_CONNECT_06; + +public class PixproConnectSequence06 extends PixproCommandBase +{ + private final IPixproCommandCallback callback; + + public PixproConnectSequence06(@Nullable IPixproCommandCallback callback) + { + this.callback = callback; + } + + @Override + public int getId() + { + return SEQ_CONNECT_06; + } + + @Override + public byte[] commandBody() + { + return (new byte[] + { + (byte) 0x2e , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x05 , (byte) 0x04 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x80 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (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 , (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 , (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) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 + }); + } + + @Override + public IPixproCommandCallback responseCallback() + { + return (this.callback); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence07.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence07.java new file mode 100644 index 0000000..c40520c --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence07.java @@ -0,0 +1,47 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection; + + +import androidx.annotation.Nullable; + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.PixproCommandBase; + +import static net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages.SEQ_CONNECT_07; + +public class PixproConnectSequence07 extends PixproCommandBase +{ + private final IPixproCommandCallback callback; + + public PixproConnectSequence07(@Nullable IPixproCommandCallback callback) + { + this.callback = callback; + } + + @Override + public int getId() + { + return SEQ_CONNECT_07; + } + + @Override + public byte[] commandBody() + { + return (new byte[] + { + // 0xeb 0x03 + (byte) 0x2e , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x08 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xeb , (byte) 0x03 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x80 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (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 , (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 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x08 , (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 , (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) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 + }); + } + + @Override + public IPixproCommandCallback responseCallback() + { + return (this.callback); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence08.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence08.java new file mode 100644 index 0000000..f1878d3 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence08.java @@ -0,0 +1,49 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection; + + +import androidx.annotation.Nullable; + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.PixproCommandBase; + +import static net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages.SEQ_CONNECT_08; + +public class PixproConnectSequence08 extends PixproCommandBase +{ + private final IPixproCommandCallback callback; + + public PixproConnectSequence08(@Nullable IPixproCommandCallback callback) + { + this.callback = callback; + } + + @Override + public int getId() + { + return SEQ_CONNECT_08; + } + + @Override + public byte[] commandBody() + { + return (new byte[] + { + // 0xe9 0x03 + (byte) 0x2e , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x30 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xe9 , (byte) 0x03 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x80 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (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 , (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 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x30 , (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 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x08 , (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 , (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 , (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) 0x03 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 + }); + } + + @Override + public IPixproCommandCallback responseCallback() + { + return (this.callback); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence09.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence09.java new file mode 100644 index 0000000..828f07b --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence09.java @@ -0,0 +1,45 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection; + + +import androidx.annotation.Nullable; + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.PixproCommandBase; + +import static net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages.SEQ_CONNECT_09; + +public class PixproConnectSequence09 extends PixproCommandBase +{ + private final IPixproCommandCallback callback; + + public PixproConnectSequence09(@Nullable IPixproCommandCallback callback) + { + this.callback = callback; + } + + @Override + public int getId() + { + return SEQ_CONNECT_09; + } + + @Override + public byte[] commandBody() + { + return (new byte[] + { + // 0xf1 0x03 + (byte) 0x2e , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xf1 , (byte) 0x03 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x80 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (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 , (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 , (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) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 + }); + } + + @Override + public IPixproCommandCallback responseCallback() + { + return (this.callback); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence10.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence10.java new file mode 100644 index 0000000..5695314 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence10.java @@ -0,0 +1,49 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection; + +import androidx.annotation.Nullable; + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.PixproCommandBase; + +import static net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages.SEQ_CONNECT_10; + + +public class PixproConnectSequence10 extends PixproCommandBase +{ + private final IPixproCommandCallback callback; + + public PixproConnectSequence10(@Nullable IPixproCommandCallback callback) + { + this.callback = callback; + } + + @Override + public int getId() + { + return SEQ_CONNECT_10; + } + + @Override + public byte[] commandBody() + { + return (new byte[] + { + // 0xed 0x03 + (byte) 0x2e , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x20 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xed , (byte) 0x03 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x80 , + (byte) 0x12 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (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 , (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 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x20 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x12 , (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 , (byte) 0x69 , (byte) 0x08 , (byte) 0x00 , (byte) 0x00 , (byte) 0x69 , (byte) 0x08 , (byte) 0x00 , (byte) 0x00 , + (byte) 0x01 , (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 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , + (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 + }); + } + + @Override + public IPixproCommandCallback responseCallback() + { + return (this.callback); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence11.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence11.java new file mode 100644 index 0000000..995606a --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/command/messages/connection/PixproConnectSequence11.java @@ -0,0 +1,45 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection; + + +import androidx.annotation.Nullable; + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.PixproCommandBase; + +import static net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages.SEQ_CONNECT_11; + +public class PixproConnectSequence11 extends PixproCommandBase +{ + private final IPixproCommandCallback callback; + + public PixproConnectSequence11(@Nullable IPixproCommandCallback callback) + { + this.callback = callback; + } + + @Override + public int getId() + { + return SEQ_CONNECT_11; + } + + @Override + public byte[] commandBody() + { + return (new byte[] + { + // 0xec 0x03 + (byte) 0x2e , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0xec , (byte) 0x03 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (byte) 0x00 , (byte) 0x00 , (byte) 0x80 , + (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x01 , (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 , (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 , (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) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0xff , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 , (byte) 0x00 + }); + } + + @Override + public IPixproCommandCallback responseCallback() + { + return (this.callback); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/connection/PixproCameraConnectSequence.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/connection/PixproCameraConnectSequence.java new file mode 100644 index 0000000..7ead46a --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/connection/PixproCameraConnectSequence.java @@ -0,0 +1,205 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.connection; + +import android.app.Activity; +import android.graphics.Color; +import android.util.Log; + +import androidx.annotation.NonNull; + +import net.osdn.gokigen.pkremote.R; +import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection; +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusReceiver; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.IPixproInterfaceProvider; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandPublisher; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.IPixproMessages; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection.PixproConnectSequence01; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection.PixproConnectSequence02; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection.PixproConnectSequence03; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection.PixproConnectSequence04; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection.PixproConnectSequence05; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection.PixproConnectSequence06; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection.PixproConnectSequence07; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection.PixproConnectSequence08; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection.PixproConnectSequence09; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection.PixproConnectSequence10; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.messages.connection.PixproConnectSequence11; + +public class PixproCameraConnectSequence implements Runnable, IPixproCommandCallback, IPixproMessages +{ + private final String TAG = this.toString(); + + private final Activity context; + private final ICameraConnection cameraConnection; + private final ICameraStatusReceiver cameraStatusReceiver; + private final IPixproInterfaceProvider interfaceProvider; + private final IPixproCommandPublisher commandIssuer; + //private final PixproStatusChecker statusChecker; + + PixproCameraConnectSequence(@NonNull Activity context, @NonNull ICameraStatusReceiver statusReceiver, @NonNull final ICameraConnection cameraConnection, @NonNull IPixproInterfaceProvider interfaceProvider) // , @NonNull PixproStatusChecker statusChecker) + { + Log.v(TAG, " KodakCameraConnectSequence"); + this.context = context; + this.cameraConnection = cameraConnection; + this.cameraStatusReceiver = statusReceiver; + this.interfaceProvider = interfaceProvider; + this.commandIssuer = interfaceProvider.getCommandPublisher(); + //this.statusChecker = statusChecker; + } + + @Override + public void run() + { + try + { + // カメラとTCP接続 + IPixproCommandPublisher issuer = interfaceProvider.getCommandPublisher(); + if (!issuer.isConnected()) + { + if (!interfaceProvider.getCommandCommunication().connect()) + { + // 接続失敗... + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.dialog_title_connect_failed_pixpro), false, true, Color.RED); + onConnectError(context.getString(R.string.dialog_title_connect_failed_pixpro)); + return; + } + } + else + { + Log.v(TAG, "SOCKET IS ALREADY CONNECTED..."); + } + // コマンドタスクの実行開始 + issuer.start(); + + // 接続シーケンスの開始 + startConnectSequence(); + + } + catch (Exception e) + { + e.printStackTrace(); + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.dialog_title_connect_failed_pixpro), false, true, Color.RED); + onConnectError(e.getLocalizedMessage()); + } + } + + private void onConnectError(String reason) + { + cameraConnection.alertConnectingFailed(reason); + } + + @Override + public void receivedMessage(int id, byte[] rx_body) + { + switch (id) + { + case SEQ_CONNECT_01: + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.pixpro_connect_connecting1), false, false, 0); + commandIssuer.enqueueCommand(new PixproConnectSequence02(this)); + break; + + case SEQ_CONNECT_02: + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.pixpro_connect_connecting2), false, false, 0); + commandIssuer.enqueueCommand(new PixproConnectSequence03(this)); + break; + + case SEQ_CONNECT_03: + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.pixpro_connect_connecting3), false, false, 0); + commandIssuer.enqueueCommand(new PixproConnectSequence04(this)); + break; + case SEQ_CONNECT_04: + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.pixpro_connect_connecting4), false, false, 0); + // ここで、パスワードの Base64情報を切り出す(FC 03 の応答、 0x0058 ~ 64バイトの文字列を切り出して、Base64エンコードする) + commandIssuer.enqueueCommand(new PixproConnectSequence05(this)); + break; + case SEQ_CONNECT_05: + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.pixpro_connect_connecting5), false, false, 0); + // ここで、パスワードの情報を切り出す (FE 03 の応答、 0x0078 ~ 文字列を切り出す。) + commandIssuer.enqueueCommand(new PixproConnectSequence06(this)); + break; + case SEQ_CONNECT_06: + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.pixpro_connect_connecting6), false, false, 0); + commandIssuer.enqueueCommand(new PixproConnectSequence07(this)); + break; + case SEQ_CONNECT_07: + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.pixpro_connect_connecting7), false, false, 0); + commandIssuer.enqueueCommand(new PixproConnectSequence08(this)); + break; + case SEQ_CONNECT_08: + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.pixpro_connect_connecting8), false, false, 0); + commandIssuer.enqueueCommand(new PixproConnectSequence09(this)); + break; + case SEQ_CONNECT_09: + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.pixpro_connect_connecting9), false, false, 0); + commandIssuer.enqueueCommand(new PixproConnectSequence10(this)); + break; + case SEQ_CONNECT_10: + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.pixpro_connect_connecting10), false, false, 0); + commandIssuer.enqueueCommand(new PixproConnectSequence11(this)); + break; + case SEQ_CONNECT_11: + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connect_finished), false, false, 0); + connectFinished(); + Log.v(TAG, " CONNECT TO CAMERA : DONE."); + break; + default: + Log.v(TAG, " RECEIVED UNKNOWN ID : " + id); + onConnectError(context.getString(R.string.connect_receive_unknown_message)); + break; + } + } + + private void startConnectSequence() + { + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_start), false, false, 0); + cameraStatusReceiver.onStatusNotify(context.getString(R.string.connect_start)); + commandIssuer.enqueueCommand(new PixproConnectSequence01(this)); + } + + private void connectFinished() + { + try + { + // 接続成功のメッセージを出す + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connected), false, false, 0); + + // ちょっと待つ + Thread.sleep(1000); + + //interfaceProvider.getAsyncEventCommunication().connect(); + //interfaceProvider.getCameraStatusWatcher().startStatusWatch(interfaceProvider.getStatusListener()); ステータスの定期確認は実施しない + + // 接続成功!のメッセージを出す + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_connected), false, false, 0); + + onConnectNotify(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + private void onConnectNotify() + { + try + { + final Thread thread = new Thread(new Runnable() + { + @Override + public void run() + { + // カメラとの接続確立を通知する + cameraStatusReceiver.onStatusNotify(context.getString(R.string.connect_connected)); + cameraStatusReceiver.onCameraConnected(); + Log.v(TAG, " onConnectNotify()"); + } + }); + thread.start(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/connection/PixproCameraDisconnectSequence.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/connection/PixproCameraDisconnectSequence.java new file mode 100644 index 0000000..5ca5fda --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/connection/PixproCameraDisconnectSequence.java @@ -0,0 +1,34 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.connection; + +import androidx.annotation.NonNull; + +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.IPixproInterfaceProvider; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommunication; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status.PixproStatusChecker; + +class PixproCameraDisconnectSequence implements Runnable +{ + //private final String TAG = this.toString(); + private final IPixproCommunication command; + private final PixproStatusChecker statusChecker; + + PixproCameraDisconnectSequence(@NonNull IPixproInterfaceProvider interfaceProvider, @NonNull PixproStatusChecker statusChecker) + { + this.command = interfaceProvider.getCommandCommunication(); + this.statusChecker = statusChecker; + } + + @Override + public void run() + { + try + { + statusChecker.stopStatusWatch(); + command.disconnect(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/connection/PixproConnection.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/connection/PixproConnection.java new file mode 100644 index 0000000..3316563 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/connection/PixproConnection.java @@ -0,0 +1,256 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.connection; + +import android.app.Activity; +import android.content.BroadcastReceiver; +import android.content.Context; +import android.content.DialogInterface; +import android.content.Intent; +import android.content.IntentFilter; +import android.net.ConnectivityManager; +import android.net.wifi.WifiInfo; +import android.net.wifi.WifiManager; +import android.provider.Settings; +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AlertDialog; + +import net.osdn.gokigen.pkremote.R; +import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraConnection; +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusReceiver; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.IPixproInterfaceProvider; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status.PixproStatusChecker; + +import java.util.concurrent.Executor; +import java.util.concurrent.Executors; + + +public class PixproConnection implements ICameraConnection +{ + private final String TAG = toString(); + private final Activity context; + private final ICameraStatusReceiver statusReceiver; + private final IPixproInterfaceProvider interfaceProvider; + private final BroadcastReceiver connectionReceiver; + private final Executor cameraExecutor = Executors.newFixedThreadPool(1); + + private ICameraConnection.CameraConnectionStatus connectionStatus = CameraConnectionStatus.UNKNOWN; + + private final PixproCameraConnectSequence connectSequence; + private final PixproCameraDisconnectSequence disconnectSequence; + + /** + * + * + */ + public PixproConnection(@NonNull final Activity context, @NonNull final ICameraStatusReceiver statusReceiver, @NonNull IPixproInterfaceProvider interfaceProvider, @NonNull PixproStatusChecker statusChecker) + { + Log.v(TAG, "KodakConnection()"); + this.context = context; + this.statusReceiver = statusReceiver; + this.interfaceProvider = interfaceProvider; + connectionReceiver = new BroadcastReceiver() + { + @Override + public void onReceive(Context context, Intent intent) + { + onReceiveBroadcastOfConnection(context, intent); + } + }; + connectSequence = new PixproCameraConnectSequence(context, statusReceiver, this, interfaceProvider); // , statusChecker); + disconnectSequence = new PixproCameraDisconnectSequence(interfaceProvider, statusChecker); + } + + /** + * + * + */ + private void onReceiveBroadcastOfConnection(Context context, Intent intent) + { + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_check_wifi), false, false, 0); + statusReceiver.onStatusNotify(context.getString(R.string.connect_check_wifi)); + + Log.v(TAG, context.getString(R.string.connect_check_wifi)); + + String action = intent.getAction(); + if (action == null) + { + Log.v(TAG, "intent.getAction() : null"); + return; + } + + try + { + if (action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) + { + Log.v(TAG, "onReceiveBroadcastOfConnection() : CONNECTIVITY_ACTION"); + + WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE); + if (wifiManager != null) + { + WifiInfo info = wifiManager.getConnectionInfo(); + if (wifiManager.isWifiEnabled() && info != null) + { + if (info.getNetworkId() != -1) + { + Log.v(TAG, "Network ID is -1, there is no currently connected network."); + } + // 自動接続が指示されていた場合は、カメラとの接続処理を行う + connectToCamera(); + } else { + if (info == null) { + Log.v(TAG, "NETWORK INFO IS NULL."); + } else { + Log.v(TAG, "isWifiEnabled : " + wifiManager.isWifiEnabled() + " NetworkId : " + info.getNetworkId()); + } + } + } + } + } + catch (Exception e) + { + Log.w(TAG, "onReceiveBroadcastOfConnection() EXCEPTION" + e.getMessage()); + e.printStackTrace(); + } + } + + @Override + public void startWatchWifiStatus(Context context) + { + Log.v(TAG, "startWatchWifiStatus()"); + try + { + interfaceProvider.getInformationReceiver().updateMessage(context.getString(R.string.connect_prepare), false, false, 0); + statusReceiver.onStatusNotify("prepare"); + + IntentFilter filter = new IntentFilter(); + filter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); + filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); + context.registerReceiver(connectionReceiver, filter); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + @Override + public void stopWatchWifiStatus(@NonNull Context context) + { + Log.v(TAG, "stopWatchWifiStatus()"); + context.unregisterReceiver(connectionReceiver); + disconnect(false); + } + + @Override + public void disconnect(boolean powerOff) + { + Log.v(TAG, "disconnect()"); + disconnectFromCamera(powerOff); + connectionStatus = CameraConnectionStatus.DISCONNECTED; + statusReceiver.onCameraDisconnected(); + } + + @Override + public void connect() + { + Log.v(TAG, "connect()"); + connectToCamera(); + } + + @Override + public void alertConnectingFailed(String message) + { + Log.v(TAG, "alertConnectingFailed() : " + message); + final AlertDialog.Builder builder = new AlertDialog.Builder(context) + .setTitle(context.getString(R.string.dialog_title_connect_failed_pixpro)) + .setMessage(message) + .setPositiveButton(context.getString(R.string.dialog_title_button_retry), new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) + { + disconnect(false); + connect(); + } + }) + .setNeutralButton(R.string.dialog_title_button_network_settings, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) + { + try + { + // Wifi 設定画面を表示する + context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); + } + catch (android.content.ActivityNotFoundException ex) + { + // Activity が存在しなかった...設定画面が起動できなかった + Log.v(TAG, "android.content.ActivityNotFoundException..."); + + // この場合は、再試行と等価な動きとする + connect(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + }); + context.runOnUiThread(new Runnable() + { + @Override + public void run() + { + builder.show(); + } + }); + } + + @Override + public CameraConnectionStatus getConnectionStatus() + { + Log.v(TAG, " getConnectionStatus()"); + return (connectionStatus); + } + + @Override + public void forceUpdateConnectionStatus(CameraConnectionStatus status) + { + Log.v(TAG, " forceUpdateConnectionStatus()"); + connectionStatus = status; + } + + /** + * カメラとの切断処理 + */ + private void disconnectFromCamera(final boolean powerOff) + { + Log.v(TAG, " disconnectFromCamera() : " + powerOff); + try + { + cameraExecutor.execute(disconnectSequence); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * カメラとの接続処理 + */ + private void connectToCamera() + { + Log.v(TAG, " connectToCamera()"); + connectionStatus = CameraConnectionStatus.CONNECTING; + try + { + cameraExecutor.execute(connectSequence); + } + catch (Exception e) + { + Log.v(TAG, " connectToCamera() EXCEPTION : " + e.getMessage()); + e.printStackTrace(); + } + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/playback/PixproPlaybackControl.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/playback/PixproPlaybackControl.java new file mode 100644 index 0000000..197913b --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/playback/PixproPlaybackControl.java @@ -0,0 +1,68 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.playback; + +import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraContentListCallback; +import net.osdn.gokigen.pkremote.camera.interfaces.playback.ICameraFileInfo; +import net.osdn.gokigen.pkremote.camera.interfaces.playback.IContentInfoCallback; +import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentCallback; +import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadContentListCallback; +import net.osdn.gokigen.pkremote.camera.interfaces.playback.IDownloadThumbnailImageCallback; +import net.osdn.gokigen.pkremote.camera.interfaces.playback.IPlaybackControl; + +public class PixproPlaybackControl implements IPlaybackControl +{ + public PixproPlaybackControl() + { + + } + + + @Override + public String getRawFileSuffix() { + return null; + } + + @Override + public void downloadContentList(IDownloadContentListCallback callback) { + + } + + @Override + public void getContentInfo(String path, String name, IContentInfoCallback callback) { + + } + + @Override + public void updateCameraFileInfo(ICameraFileInfo info) { + + } + + @Override + public void downloadContentScreennail(String path, IDownloadThumbnailImageCallback callback) { + + } + + @Override + public void downloadContentThumbnail(String path, IDownloadThumbnailImageCallback callback) { + + } + + @Override + public void downloadContent(String path, boolean isSmallSize, IDownloadContentCallback callback) { + + } + + @Override + public void getCameraContentList(ICameraContentListCallback callback) { + + } + + @Override + public void showPictureStarted() { + + } + + @Override + public void showPictureFinished() { + + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproCameraHardwareStatus.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproCameraHardwareStatus.java new file mode 100644 index 0000000..d4026f2 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproCameraHardwareStatus.java @@ -0,0 +1,52 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status; + +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraHardwareStatus; + +import java.util.Map; + +public class PixproCameraHardwareStatus implements ICameraHardwareStatus +{ + + + @Override + public boolean isAvailableHardwareStatus() + { + return (false); + } + + @Override + public String getLensMountStatus() + { + return (null); + } + + @Override + public String getMediaMountStatus() + { + return (null); + } + + @Override + public float getMinimumFocalLength() + { + return (0); + } + + @Override + public float getMaximumFocalLength() + { + return (0); + } + + @Override + public float getActualFocalLength() + { + return (0); + } + + @Override + public Map inquireHardwareInformation() + { + return (null); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproCameraInformation.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproCameraInformation.java new file mode 100644 index 0000000..02cdeae --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproCameraInformation.java @@ -0,0 +1,25 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status; + +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraInformation; + +public class PixproCameraInformation implements ICameraInformation +{ + + @Override + public boolean isManualFocus() + { + return false; + } + + @Override + public boolean isElectricZoomLens() + { + return false; + } + + @Override + public boolean isExposureLocked() + { + return false; + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproRunMode.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproRunMode.java new file mode 100644 index 0000000..cb3d94d --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproRunMode.java @@ -0,0 +1,25 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status; + +import net.osdn.gokigen.pkremote.camera.interfaces.control.ICameraRunMode; + +public class PixproRunMode implements ICameraRunMode +{ + private boolean runMode = false; + + public PixproRunMode() + { + // + } + + @Override + public void changeRunMode(boolean isRecording) + { + this.runMode = isRecording; + } + + @Override + public boolean isRecordingMode() + { + return (runMode); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproStatusChecker.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproStatusChecker.java new file mode 100644 index 0000000..2006660 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproStatusChecker.java @@ -0,0 +1,102 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status; + +import android.util.Log; + +import androidx.annotation.NonNull; + +import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ICameraStatusUpdateNotify; +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatus; +import net.osdn.gokigen.pkremote.camera.interfaces.status.ICameraStatusWatcher; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.command.IPixproCommandCallback; + +import java.util.ArrayList; +import java.util.List; + +public class PixproStatusChecker implements IPixproCommandCallback, ICameraStatusWatcher, ICameraStatus +{ + private final String TAG = toString(); + private PixproStatusHolder statusHolder; + private boolean whileFetching = false; + private ICameraStatusUpdateNotify notifier = null; + + public PixproStatusChecker() + { + this.statusHolder = new PixproStatusHolder(); + } + + + @Override + public List getStatusList(String key) + { + try + { + if (statusHolder == null) + { + return (new ArrayList<>()); + } + return (statusHolder.getAvailableItemList(key)); + } + catch (Exception e) + { + e.printStackTrace(); + } + return (new ArrayList<>()); + } + + @Override + public String getStatus(String key) + { + try + { + if (statusHolder == null) + { + return (""); + } + return (statusHolder.getItemStatus(key)); + } + catch (Exception e) + { + e.printStackTrace(); + } + return (""); + } + + @Override + public void setStatus(String key, String value) + { + Log.v(TAG, "setStatus(" + key + ", " + value + ")"); + } + + @Override + public void startStatusWatch(@NonNull ICameraStatusUpdateNotify notifier) + { + if (whileFetching) + { + Log.v(TAG, "startStatusWatch() already starting."); + return; + } + try + { + this.notifier = notifier; + whileFetching = true; + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + @Override + public void stopStatusWatch() + { + Log.v(TAG, "stoptStatusWatch()"); + whileFetching = false; + this.notifier = null; + } + + @Override + public void receivedMessage(int id, byte[] rx_body) + { + + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproStatusHolder.java b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproStatusHolder.java new file mode 100644 index 0000000..63fc630 --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/camera/vendor/pixpro/wrapper/status/PixproStatusHolder.java @@ -0,0 +1,206 @@ +package net.osdn.gokigen.pkremote.camera.vendor.pixpro.wrapper.status; + +import android.util.Log; +import android.util.SparseIntArray; + +import androidx.annotation.NonNull; +import androidx.collection.SparseArrayCompat; + +import net.osdn.gokigen.pkremote.camera.interfaces.liveview.ICameraStatusUpdateNotify; + +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; + +class PixproStatusHolder +{ + private final String TAG = toString(); + private SparseIntArray statusHolder; + private SparseArrayCompat statusNameArray; + + PixproStatusHolder() + { + statusHolder = new SparseIntArray(); + statusHolder.clear(); + + statusNameArray = new SparseArrayCompat<>(); + prepareStatusNameArray(); + } + + private void prepareStatusNameArray() + { +/* + statusNameArray.clear(); + statusNameArray.append(BATTERY_LEVEL, BATTERY_LEVEL_STR); + statusNameArray.append(WHITE_BALANCE, WHITE_BALANCE_STR); + statusNameArray.append(APERTURE, APERTURE_STR); + statusNameArray.append(FOCUS_MODE, FOCUS_MODE_STR); + statusNameArray.append(SHOOTING_MODE, SHOOTING_MODE_STR); + statusNameArray.append(FLASH, FLASH_STR); + statusNameArray.append(EXPOSURE_COMPENSATION, EXPOSURE_COMPENSATION_STR); + statusNameArray.append(SELF_TIMER, SELF_TIMER_STR); + statusNameArray.append(FILM_SIMULATION, FILM_SIMULATION_STR); + statusNameArray.append(IMAGE_FORMAT, IMAGE_FORMAT_STR); + statusNameArray.append(RECMODE_ENABLE, RECMODE_ENABLE_STR); + statusNameArray.append(F_SS_CONTROL, F_SS_CONTROL_STR); + statusNameArray.append(ISO, ISO_STR); + statusNameArray.append(MOVIE_ISO, MOVIE_ISO_STR); + statusNameArray.append(FOCUS_POINT, FOCUS_POINT_STR); + statusNameArray.append(DEVICE_ERROR, DEVICE_ERROR_STR); + statusNameArray.append(IMAGE_FILE_COUNT, IMAGE_FILE_COUNT_STR); + statusNameArray.append(SDCARD_REMAIN_SIZE, SDCARD_REMAIN_SIZE_STR); + statusNameArray.append(FOCUS_LOCK, FOCUS_LOCK_STR); + statusNameArray.append(MOVIE_REMAINING_TIME, MOVIE_REMAINING_TIME_STR); + statusNameArray.append(SHUTTER_SPEED, SHUTTER_SPEED_STR); + statusNameArray.append(IMAGE_ASPECT,IMAGE_ASPECT_STR); + statusNameArray.append(BATTERY_LEVEL_2, BATTERY_LEVEL_2_STR); + + statusNameArray.append(UNKNOWN_DF00, UNKNOWN_DF00_STR); + statusNameArray.append(PICTURE_JPEG_COUNT, PICTURE_JPEG_COUNT_STR); + statusNameArray.append(UNKNOWN_D400, UNKNOWN_D400_STR); + statusNameArray.append(UNKNOWN_D401, UNKNOWN_D401_STR); + statusNameArray.append(UNKNOWN_D52F, UNKNOWN_D52F_STR); +*/ + } + + + void updateValue(ICameraStatusUpdateNotify notifier, int id, byte data0, byte data1, byte data2, byte data3) + { + try + { + int value = ((((int) data3) & 0xff) << 24) + ((((int) data2) & 0xff) << 16) + ((((int) data1) & 0xff) << 8) + (((int) data0) & 0xff); + int currentValue = statusHolder.get(id, -1); + Log.v(TAG, "STATUS ID: " + id + " value : " + value + " (" + currentValue + ")"); + statusHolder.put(id, value); + if (currentValue != value) + { + //Log.v(TAG, "STATUS ID: " + id + " value : " + currentValue + " -> " + value); + if (notifier != null) + { + updateDetected(notifier, id, currentValue, value); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + private void updateDetected(@NonNull ICameraStatusUpdateNotify notifier, int id, int previous, int current) + { + try + { + String idName = statusNameArray.get(id, "Unknown"); + Log.v(TAG, String.format(Locale.US,"<< UPDATE STATUS >> id: 0x%04x[%s] 0x%08x(%d) -> 0x%08x(%d)", id, idName, previous, previous, current, current)); + //Log.v(TAG, "updateDetected(ID: " + id + " [" + idName + "] " + previous + " -> " + current + " )"); +/* + if (id == FOCUS_LOCK) + { + if (current == 1) + { + // focus Lock + notifier.updateFocusedStatus(true, true); + } + else + { + // focus unlock + notifier.updateFocusedStatus(false, false); + } + } +*/ + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * 認識したカメラのステータス名称のリストを応答する + * + */ + private List getAvailableStatusNameList() + { + ArrayList selection = new ArrayList<>(); + try + { + for (int index = 0; index < statusHolder.size(); index++) + { + int key = statusHolder.keyAt(index); + selection.add(statusNameArray.get(key, String.format(Locale.US, "0x%04x", key))); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + return (selection); + + } + + List getAvailableItemList(String listKey) + { + if (listKey == null) + { + // アイテム名の一覧を応答する + return (getAvailableStatusNameList()); + } + + ///// 選択可能なステータスの一覧を取得する : でも以下はアイテム名の一覧... ///// + ArrayList selection = new ArrayList<>(); + try + { + for (int index = 0; index < statusHolder.size(); index++) + { + int key = statusHolder.keyAt(index); + selection.add(statusNameArray.get(key)); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + return (selection); + } + + String getItemStatus(String key) + { + try + { + int strIndex = key.indexOf("x"); + Log.v(TAG, "getItemStatus() : " + key + " [" + strIndex + "]"); + if (strIndex >= 1) + { + key = key.substring(strIndex + 1); + try + { + int id = Integer.parseInt(key, 16); + int value = statusHolder.get(id); + Log.v(TAG, "getItemStatus() value : " + value); + return (value + ""); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + for (int index = 0; index < statusNameArray.size(); index++) + { + int id = statusNameArray.keyAt(index); + String strKey = statusNameArray.valueAt(index); + if (key.contentEquals(strKey)) + { + int value = statusHolder.get(id); + return (value + ""); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + return ("? [" + key + "]"); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/preference/IPreferencePropertyAccessor.java b/app/src/main/java/net/osdn/gokigen/pkremote/preference/IPreferencePropertyAccessor.java index 610d1c2..ef715ca 100644 --- a/app/src/main/java/net/osdn/gokigen/pkremote/preference/IPreferencePropertyAccessor.java +++ b/app/src/main/java/net/osdn/gokigen/pkremote/preference/IPreferencePropertyAccessor.java @@ -119,7 +119,13 @@ public interface IPreferencePropertyAccessor String USE_OSC_THETA_V21 = "use_osc_theta_v21"; - /* + String PIXPRO_HOST_IP = "pixpro_host_ip"; + String PIXPRO_HOST_IP_DEFAULT_VALUE = "172.16.0.254"; + + String PIXPRO_COMMAND_PORT = "pixpro_command_port"; + String PIXPRO_COMMAND_PORT_DEFAULT_VALUE = "9175"; + +/* //String GR2_DISPLAY_MODE = "gr2_display_mode"; //String GR2_DISPLAY_MODE_DEFAULT_VALUE = "0"; diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/preference/pixpro/PixproPreferenceFragment.java b/app/src/main/java/net/osdn/gokigen/pkremote/preference/pixpro/PixproPreferenceFragment.java new file mode 100644 index 0000000..60ede1b --- /dev/null +++ b/app/src/main/java/net/osdn/gokigen/pkremote/preference/pixpro/PixproPreferenceFragment.java @@ -0,0 +1,378 @@ +package net.osdn.gokigen.pkremote.preference.pixpro; + +import android.content.Context; +import android.content.Intent; +import android.content.SharedPreferences; +import android.os.Bundle; +import android.provider.Settings; +import android.util.Log; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.fragment.app.FragmentActivity; +import androidx.preference.CheckBoxPreference; +import androidx.preference.ListPreference; +import androidx.preference.Preference; +import androidx.preference.PreferenceFragmentCompat; +import androidx.preference.PreferenceManager; + +import net.osdn.gokigen.pkremote.R; +import net.osdn.gokigen.pkremote.camera.vendor.pixpro.operation.CameraPowerOffPixpro; +import net.osdn.gokigen.pkremote.logcat.LogCatViewer; +import net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor; +import net.osdn.gokigen.pkremote.scene.IChangeScene; + +import java.util.Map; + +import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.DEBUG_INFO; +import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.EXIT_APPLICATION; +import static net.osdn.gokigen.pkremote.preference.IPreferencePropertyAccessor.WIFI_SETTINGS; + +/** + * + * + */ +public class PixproPreferenceFragment extends PreferenceFragmentCompat implements SharedPreferences.OnSharedPreferenceChangeListener, Preference.OnPreferenceClickListener +{ + private final String TAG = toString(); + private AppCompatActivity context = null; + private SharedPreferences preferences = null; + private CameraPowerOffPixpro powerOffController = null; + private LogCatViewer logCatViewer = null; + + /** + * + * + */ + public static PixproPreferenceFragment newInstance(@NonNull AppCompatActivity context, @NonNull IChangeScene changeScene) + { + PixproPreferenceFragment instance = new PixproPreferenceFragment(); + instance.prepare(context, changeScene); + + // パラメータはBundleにまとめておく + Bundle arguments = new Bundle(); + //arguments.putString("title", title); + //arguments.putString("message", message); + instance.setArguments(arguments); + + return (instance); + } + + /** + * + * + */ + private void prepare(@NonNull AppCompatActivity context, @NonNull IChangeScene changeScene) + { + try + { + powerOffController = new CameraPowerOffPixpro(context, changeScene); + powerOffController.prepare(); + + logCatViewer = new LogCatViewer(changeScene); + logCatViewer.prepare(); + + this.context = context; + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * + * + */ + @Override + public void onAttach(@NonNull Context activity) + { + super.onAttach(activity); + Log.v(TAG, "onAttach()"); + + try + { + // Preference をつかまえる + preferences = PreferenceManager.getDefaultSharedPreferences(activity); + + // Preference を初期設定する + initializePreferences(); + + preferences.registerOnSharedPreferenceChangeListener(this); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * Preferenceの初期化... + * + */ + private void initializePreferences() + { + try + { + Map items = preferences.getAll(); + SharedPreferences.Editor editor = preferences.edit(); + + if (!items.containsKey(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA)) + { + editor.putBoolean(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true); + } + if (!items.containsKey(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW)) + { + editor.putBoolean(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, true); + } + if (!items.containsKey(IPreferencePropertyAccessor.CONNECTION_METHOD)) + { + editor.putString(IPreferencePropertyAccessor.CONNECTION_METHOD, IPreferencePropertyAccessor.CONNECTION_METHOD_DEFAULT_VALUE); + } + if (!items.containsKey(IPreferencePropertyAccessor.PIXPRO_HOST_IP)) + { + editor.putString(IPreferencePropertyAccessor.PIXPRO_HOST_IP, IPreferencePropertyAccessor.PIXPRO_HOST_IP_DEFAULT_VALUE); + } + if (!items.containsKey(IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT)) + { + editor.putString(IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT, IPreferencePropertyAccessor.PIXPRO_COMMAND_PORT_DEFAULT_VALUE); + } + editor.apply(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * + * + */ + @Override + public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) + { + Log.v(TAG, "onSharedPreferenceChanged() : " + key); + boolean value; + if (key != null) + { + switch (key) + { + case IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA: + value = preferences.getBoolean(key, true); + Log.v(TAG, " " + key + " , " + value); + break; + + case IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW: + value = preferences.getBoolean(key, true); + Log.v(TAG, " " + key + " , " + value); + break; + + default: + String strValue = preferences.getString(key, ""); + setListPreference(key, key, strValue); + break; + } + } + } + + /** + * + * + */ + @Override + public void onCreatePreferences(Bundle savedInstanceState, String rootKey) + { + Log.v(TAG, "onCreatePreferences()"); + try + { + //super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.preferences_pixpro); + + ListPreference connectionMethod = (ListPreference) findPreference(IPreferencePropertyAccessor.CONNECTION_METHOD); + if (connectionMethod != null) + { + connectionMethod.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { + @Override + public boolean onPreferenceChange(Preference preference, Object newValue) { + preference.setSummary(newValue + " "); + return (true); + } + }); + connectionMethod.setSummary(connectionMethod.getValue() + " "); + } + setOnPreferenceClickListener(findPreference(EXIT_APPLICATION), powerOffController); + setOnPreferenceClickListener(findPreference(DEBUG_INFO), logCatViewer); + setOnPreferenceClickListener(findPreference(WIFI_SETTINGS), this); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * + * + */ + private void setOnPreferenceClickListener(Preference preference, Preference.OnPreferenceClickListener listener) + { + try + { + if (preference == null) + { + return; + } + preference.setOnPreferenceClickListener(listener); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * + * + */ + @Override + public void onResume() + { + super.onResume(); + Log.v(TAG, "onResume() Start"); + + try + { + synchronizedProperty(); + } + catch (Exception e) + { + e.printStackTrace(); + } + + Log.v(TAG, "onResume() End"); + + } + + /** + * + * + */ + @Override + public void onPause() + { + super.onPause(); + Log.v(TAG, "onPause() Start"); + + try + { + // Preference変更のリスナを解除 + preferences.unregisterOnSharedPreferenceChangeListener(this); + } + catch (Exception e) + { + e.printStackTrace(); + } + + Log.v(TAG, "onPause() End"); + } + + /** + * ListPreference の表示データを設定 + * + * @param pref_key Preference(表示)のキー + * @param key Preference(データ)のキー + * @param defaultValue Preferenceのデフォルト値 + */ + private void setListPreference(String pref_key, String key, String defaultValue) + { + try + { + ListPreference pref = (ListPreference) findPreference(pref_key); + String value = preferences.getString(key, defaultValue); + if (pref != null) + { + pref.setValue(value); + pref.setSummary(value); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * BooleanPreference の表示データを設定 + * + * @param pref_key Preference(表示)のキー + * @param key Preference(データ)のキー + * @param defaultValue Preferenceのデフォルト値 + */ + private void setBooleanPreference(String pref_key, String key, boolean defaultValue) + { + try + { + CheckBoxPreference pref = (CheckBoxPreference) findPreference(pref_key); + if (pref != null) { + boolean value = preferences.getBoolean(key, defaultValue); + pref.setChecked(value); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * + * + */ + private void synchronizedProperty() + { + final FragmentActivity activity = getActivity(); + if (activity != null) + { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + try + { + // Preferenceの画面に反映させる + setBooleanPreference(IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, IPreferencePropertyAccessor.AUTO_CONNECT_TO_CAMERA, true); + setBooleanPreference(IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, IPreferencePropertyAccessor.CAPTURE_BOTH_CAMERA_AND_LIVE_VIEW, false); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + }); + } + } + + @Override + public boolean onPreferenceClick(Preference preference) + { + try + { + String preferenceKey = preference.getKey(); + if (preferenceKey.contains(WIFI_SETTINGS)) + { + // Wifi 設定画面を表示する + Log.v(TAG, " onPreferenceClick : " + preferenceKey); + if (context != null) + { + context.startActivity(new Intent(Settings.ACTION_WIFI_SETTINGS)); + } + } + return (true); + } + catch (Exception e) + { + e.printStackTrace(); + } + return (false); + } +} diff --git a/app/src/main/java/net/osdn/gokigen/pkremote/scene/CameraSceneUpdater.java b/app/src/main/java/net/osdn/gokigen/pkremote/scene/CameraSceneUpdater.java index 0424ee8..4ac0d96 100644 --- a/app/src/main/java/net/osdn/gokigen/pkremote/scene/CameraSceneUpdater.java +++ b/app/src/main/java/net/osdn/gokigen/pkremote/scene/CameraSceneUpdater.java @@ -21,6 +21,7 @@ import net.osdn.gokigen.pkremote.preference.nikon.NikonPreferenceFragment; import net.osdn.gokigen.pkremote.preference.olympus.OpcPreferenceFragment; import net.osdn.gokigen.pkremote.preference.olympuspen.OlympusPenPreferenceFragment; import net.osdn.gokigen.pkremote.preference.panasonic.PanasonicPreferenceFragment; +import net.osdn.gokigen.pkremote.preference.pixpro.PixproPreferenceFragment; import net.osdn.gokigen.pkremote.preference.ricohgr2.RicohGr2PreferenceFragment; import net.osdn.gokigen.pkremote.preference.sony.SonyPreferenceFragment; import net.osdn.gokigen.pkremote.preference.theta.ThetaPreferenceFragment; @@ -340,6 +341,10 @@ public class CameraSceneUpdater implements ICameraStatusReceiver, IChangeScene, { preferenceFragment = ThetaPreferenceFragment.newInstance(activity, this); } + else if (connectionMethod == ICameraConnection.CameraConnectionMethod.PIXPRO) + { + preferenceFragment = PixproPreferenceFragment.newInstance(activity, this); + } else // if (connectionMethod == ICameraConnection.CameraConnectionMethod.OPC) { preferenceFragment = OpcPreferenceFragment.newInstance(activity, interfaceProvider, this); diff --git a/app/src/main/res/values-ja/arrays.xml b/app/src/main/res/values-ja/arrays.xml index 2be3ec9..5c069ef 100644 --- a/app/src/main/res/values-ja/arrays.xml +++ b/app/src/main/res/values-ja/arrays.xml @@ -5,6 +5,7 @@ Ricoh Theta(OSC) OPC(Olympus Air) Olympus(OM-D/PEN) + KODAK PIXPRO Fuji X Series Panasonic Sony @@ -17,6 +18,7 @@ THETA OPC OLYMPUS + PIXPRO FUJI_X PANASONIC SONY diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index d9716b7..566c35a 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -274,6 +274,7 @@ アプリ終了 アプリ終了 + アプリ終了 アプリ終了 カメラのAPI一覧を表示します。 @@ -305,6 +306,17 @@ 接続中…(4/5) 接続中…(5/5) + 接続中…(1/10) + 接続中…(2/10) + 接続中…(3/10) + 接続中…(4/10) + 接続中…(5/10) + 接続中…(6/10) + 接続中…(7/10) + 接続中…(8/10) + 接続中…(9/10) + 接続中…(10/10) + 表示画像はスモール画像を使用 すこし時間がかかりますが、画像表示にスモール画像を使用します。 @@ -345,4 +357,13 @@ THETA Web API v2.1の使用 + カメラIPアドレス + 通常、変更は不要です (初期値:172.16.0.254) + + カメラ制御ポート番号 + 通常、変更は不要です (初期値:9175) + + カメラへのコマンド送信回線が切断されました。再試行してください。 + 接続失敗(PIXPRO) + diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 2be3ec9..5c069ef 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -5,6 +5,7 @@ Ricoh Theta(OSC) OPC(Olympus Air) Olympus(OM-D/PEN) + KODAK PIXPRO Fuji X Series Panasonic Sony @@ -17,6 +18,7 @@ THETA OPC OLYMPUS + PIXPRO FUJI_X PANASONIC SONY diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index a3c2d23..49d3944 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -276,6 +276,7 @@ Exit Application Exit Application + Exit Application Exit Application Show available camera apis. @@ -307,6 +308,17 @@ Connecting…(4/5) Connecting…(5/5) + Connecting…(1/10) + Connecting…(2/10) + Connecting…(3/10) + Connecting…(4/10) + Connecting…(5/10) + Connecting…(6/10) + Connecting…(7/10) + Connecting…(8/10) + Connecting…(9/10) + Connecting…(10/10) + Use small image as screen nail Use small size image as @@ -347,4 +359,13 @@ Use THETA Web API v2.1 + Camera IP Address + default: 172.16.0.254 + + Camera Command Port + default: 9175 + + The command communication line is disconnected. (RETRY please.) + Connect failed (PIXPRO) + diff --git a/app/src/main/res/xml/preferences_pixpro.xml b/app/src/main/res/xml/preferences_pixpro.xml new file mode 100644 index 0000000..3de06ac --- /dev/null +++ b/app/src/main/res/xml/preferences_pixpro.xml @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.11.0