import net.osdn.gokigen.a01d.camera.olympus.wrapper.OlympusInterfaceProvider;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ICameraStatusReceiver;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.ICameraPowerOn;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.PowerOnCamera;
import net.osdn.gokigen.a01d.liveview.IStatusViewDrawer;
import net.osdn.gokigen.a01d.liveview.LiveViewFragment;
* A01d ;
*
*/
-public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver, IChangeScene, PowerOnCamera.PowerOnCameraCallback
+public class A01dMain extends AppCompatActivity implements ICameraStatusReceiver, IChangeScene, ICameraPowerOn.PowerOnCameraCallback
{
private final String TAG = toString();
private IOlympusInterfaceProvider interfaceProvider = null;
// BLEでカメラの電源をONにする設定だった時
try
{
- // カメラの電源ONクラスを呼び出しておく
- PowerOnCamera powerOnCamera = new PowerOnCamera(this);
- powerOnCamera.wakeup();
+ // カメラの電源ONクラスを呼び出しておく (電源ONができたら、コールバックをもらう)
+ interfaceProvider.getCameraPowerOn().wakeup(this);
}
catch (Exception e)
{
import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraInformation;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.ICameraRunMode;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.ILiveViewControl;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.ICameraPowerOn;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
*/
public interface IOlympusInterfaceProvider
{
+ ICameraPowerOn getCameraPowerOn();
IOlyCameraConnection getOlyCameraConnection();
ICameraHardwareStatus getHardwareStatus();
IOlyCameraPropertyProvider getCameraPropertyProvider();
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ICameraStatusReceiver;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.IOlyCameraConnection;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.OlyCameraConnection;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.ICameraPowerOn;
+import net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble.PowerOnCamera;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.IOlyCameraPropertyProvider;
import net.osdn.gokigen.a01d.camera.olympus.wrapper.property.OlyCameraPropertyProxy;
import net.osdn.gokigen.a01d.liveview.IAutoFocusFrameDisplay;
private final OlyCameraHardwareStatus hardwareStatus;
private final OLYCameraPropertyListenerImpl propertyListener;
private final OlyCameraZoomLensControl zoomLensControl;
+ private final ICameraPowerOn cameraPowerOn;
private OlyCameraFocusControl focusControl = null;
private OlyCameraCaptureControl captureControl = null;
this.hardwareStatus = new OlyCameraHardwareStatus(this.wrapper.getOLYCamera());
this.propertyListener = new OLYCameraPropertyListenerImpl(this.wrapper.getOLYCamera());
this.zoomLensControl = new OlyCameraZoomLensControl(context, this.wrapper.getOLYCamera());
+ this.cameraPowerOn = new PowerOnCamera(this.wrapper.getOLYCamera());
}
@Override
}
@Override
+ public ICameraPowerOn getCameraPowerOn()
+ {
+ return (cameraPowerOn);
+ }
+
+ @Override
public IOlyCameraConnection getOlyCameraConnection()
{
return (connection);
--- /dev/null
+package net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble;
+
+
+public interface ICameraPowerOn
+{
+ // カメラ起動指示
+ void wakeup(PowerOnCameraCallback callback);
+
+ // 実行終了時のコールバックのインタフェース
+ interface PowerOnCameraCallback
+ {
+ void wakeupExecuted(boolean isExecute);
+ }
+}
package net.osdn.gokigen.a01d.camera.olympus.wrapper.connection.ble;
+import android.bluetooth.BluetoothDevice;
+import android.content.Context;
import android.util.Log;
+import jp.co.olympus.camerakit.OACentralConfiguration;
+import jp.co.olympus.camerakit.OLYCamera;
+
/**
* BLE経由でカメラの電源を入れるクラス
*
*/
-public class PowerOnCamera
+public class PowerOnCamera implements ICameraPowerOn
{
private final String TAG = toString();
- private final PowerOnCameraCallback callback;
+ private final OLYCamera camera;
+ private String btName;
+ private String btCode;
- public PowerOnCamera(PowerOnCameraCallback callback)
+ /**
+ *
+ */
+ public PowerOnCamera(OLYCamera camera)
{
Log.v(TAG, "PowerOnCamera()");
-
- this.callback = callback;
+ this.camera = camera;
}
- public void wakeup()
+ public void wakeup(PowerOnCameraCallback callback)
{
+ boolean isWakeup = true;
Log.v(TAG, "PowerOnCamera::wakeup()");
-
+ btName = "";
+ btCode = "";
+ try
+ {
+ OACentralConfiguration oa_central = OACentralConfiguration.load();
+ btName = oa_central.getBleName();
+ btCode = oa_central.getBleCode();
+ Log.v(TAG, "Bluetooth BtName : '" + btName + "' btCode : '" + btCode + "' ");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+/*
+ try
+ {
+ BluetoothDevice btDevice = null;
+ camera.setBluetoothDevice(btDevice);
+ camera.setBluetoothPassword(btCode);
+ camera.wakeup();
+ isWakeup = true;
+ }
+ catch (Exception e)
+ {
+ // 例外受信
+ e.printStackTrace();
+ isWakeup = false;
+ }
+*/
// 今は暫定で返しちゃう
- callback.wakeupExecuted(true);
+ callback.wakeupExecuted(isWakeup);
}
- /**
- * 実行終了時のコールバックのインタフェース
- *
- */
- public interface PowerOnCameraCallback
- {
- void wakeupExecuted(boolean isExecute);
+
+
+/*
+private BluetoothAdapter.LeScanCallback mLeScanCallback = new BluetoothAdapter.LeScanCallback(){
+ @Override
+ public void onLeScan(final BluetoothDevice device, int rssi, byte[] scanRecord){
+ if (btName.equals(device.getName())){
+ btAdapter.stopLeScan(this);
+ btDevice = device;
+ try {
+ camera.setBluetoothDevice(btDevice);
+ camera.setBluetoothPassword(btCode);
+ camera.wakeup();
+ camera.connect(OLYCamera.ConnectionType.BluetoothLE);
+ } catch (OLYCameraKitException e) {
+ Log.w(TAG, "To connect to the camera is failed: " + e.getMessage());
+ }
+ }
}
+};
+*/
+
}
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal"
+ >
+ <TextView
+ android:layout_width="0px"
+ android:layout_height="0px"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="5pt"
+ android:tag="id"
+ />
+ <Button xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:tag="button"
+ android:text="@string/save_props"
+ />
+ <EditText xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:hint="@string/hint_save_bt_name"
+ android:textSize="8pt"
+ android:tag="bt_name"
+ />
+ <EditText xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:hint="@string/hint_save_bt_passcode"
+ android:inputType="textPassword"
+ android:password="true"
+ android:textSize="8pt"
+ android:tag="bt_passcode"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="4pt"
+ android:tag="info"
+ />
+</LinearLayout>
android:layout_weight="1"
android:gravity="start"
android:clickable="true"
+ android:focusable="true"
android:text="@string/blank"
android:textColor="@color/background_dark"
android:textSize="14sp" />
android:layout_gravity="end"
android:visibility="invisible"
android:clickable="true"
+ android:focusable="true"
android:scaleType="center"
android:contentDescription="@string/configuration"
android:src="@drawable/ic_save_black_24dp" />
android:layout_gravity="end"
android:visibility="invisible"
android:clickable="true"
+ android:focusable="true"
android:scaleType="center"
android:contentDescription="@string/configuration"
android:src="@drawable/ic_refresh_black_24dp" />
android:layout_gravity="end"
android:visibility="visible"
android:clickable="true"
+ android:focusable="true"
android:scaleType="center"
android:contentDescription="@string/restore"
android:src="@drawable/ic_restore_page_black_24dp" />
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+ android:orientation="horizontal"
+ >
+ <TextView
+ android:layout_width="0px"
+ android:layout_height="0px"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="5pt"
+ android:tag="id"
+ />
+ <Button xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:tag="button"
+ android:text="@string/save_props"
+ />
+ <EditText xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:hint="@string/hint_save_bt_name"
+ android:textSize="8pt"
+ android:tag="bt_name"
+ />
+ <EditText xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:hint="@string/hint_save_bt_passcode"
+ android:inputType="textPassword"
+ android:password="true"
+ android:textSize="8pt"
+ android:tag="bt_passcode"
+ />
+ <TextView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:textSize="4pt"
+ android:tag="info"
+ />
+</LinearLayout>
android:layout_weight="1"
android:gravity="start"
android:clickable="true"
+ android:focusable="true"
android:text="@string/blank"
android:textColor="@color/background_dark"
android:textSize="14sp" />
android:layout_gravity="end"
android:visibility="invisible"
android:clickable="true"
+ android:focusable="true"
android:scaleType="center"
android:contentDescription="@string/configuration"
android:src="@drawable/ic_save_black_24dp" />
android:layout_gravity="end"
android:visibility="invisible"
android:clickable="true"
+ android:focusable="true"
android:scaleType="center"
android:contentDescription="@string/configuration"
android:src="@drawable/ic_refresh_black_24dp" />
android:layout_gravity="end"
android:visibility="visible"
android:clickable="true"
+ android:focusable="true"
android:scaleType="center"
android:contentDescription="@string/restore"
android:src="@drawable/ic_restore_page_black_24dp" />
<string name="hint_save_props">ラベル</string>
<string name="saved_my_props">設定を保存しました。 : </string>
+
+ <string name="hint_save_bt_name">名前</string>
+ <string name="hint_save_bt_passcode">パスコード</string>
+
<string name="auto_save_props">(自動保存)</string>
<string name="title_tab_title_load">設定反映</string>
<string name="title_tab_title_save">設定保存</string>
<string name="title_tab_title_save">Save</string>
<string name="title_my_settings">Favorite Camera Properties</string>
+ <string name="hint_save_bt_name">Name</string>
+ <string name="hint_save_bt_passcode">Passcode</string>
+
+
<string name="connect_start">start</string>
<string name="connect_check_wifi">check WIFI</string>
<string name="connect_connect">connecting</string>