exitApplication();
return (true);
}
-/*
- if (id == R.id.action_reset)
+ if (id == R.id.action_disconnect)
{
- testTarget.resetConnection();
+ testTarget.disconnect();
return (true);
}
- //noinspection SimplifiableIfStatement
if (id == R.id.action_settings)
{
testTarget.settings();
return (true);
}
+
+/*
+ if (id == R.id.action_reset)
+ {
+ testTarget.resetConnection();
+ return (true);
+ }
+ //noinspection SimplifiableIfStatement
if (id == R.id.action_up_value)
{
testTarget.valueUp();
public void disconnect()
{
+ Log.v(TAG, "Disconnect");
+
+ showMessageText("DISCONNECT");
try
{
- connection.disconnect();
+ Snackbar.make(activity.findViewById(R.id.constraintLayout), R.string.action_disconnect, Snackbar.LENGTH_SHORT).show();
+ Thread thread = new Thread(new Runnable() {
+ @Override
+ public void run() {
+ connection.disconnect();
+ }
+ });
+ thread.start();
}
catch (Exception e)
{
{
e.printStackTrace();
}
-
}
-/*
+
public void settings()
{
- Log.v(TAG, "settings menu");
+ Log.v(TAG, "Show settings menu");
showMessageText("BBBB");
}
+/*
public void valueUp()
{
Log.v(TAG, "value UP");
class Communication
{
private final String TAG = toString();
- private static final int BUFFER_SIZE = 1024 * 1024 + 8;
+ private static final int BUFFER_SIZE = 1024 * 1024 + 8;
private static final int CONTROL_PORT = 55740;
private static final int ASYNC_RESPONSE_PORT = 55741;
private static final int STREAM_PORT = 55742;
private BufferedReader bufferedReader = null;
private int sequenceNumber = 0x0000000a;
+ private boolean isDumpReceiveLog = true;
+
private final FujiStreamReceiver stream;
private final FujiAsyncResponseReceiver response;
void disconnect_socket()
{
- // ストリームを閉じる
+ // ストリームを全部閉じる
try
{
dos.close();
e.printStackTrace();
}
dos = null;
+
try
{
bufferedReader.close();
e.printStackTrace();
}
socket = null;
+ sequenceNumber = 0x0000000a;
System.gc();
}
sendData[9] = (byte) (((0x0000ff00 & sequenceNumber) >>> 8) & 0x000000ff);
sendData[10] = (byte) (((0x00ff0000 & sequenceNumber) >>> 16) & 0x000000ff);
sendData[11] = (byte) (((0xff000000 & sequenceNumber) >>> 24) & 0x000000ff);
-
- Log.v(TAG, "SEQ No. : " + sequenceNumber);
+ if (isDumpReceiveLog)
+ {
+ Log.v(TAG, "SEQ No. : " + sequenceNumber);
+ }
// シーケンス番号を増やす
sequenceNumber++;
// ログに送信メッセージを出力する
dump_bytes("SEND[" + sendData.length + "] ", sendData);
-
// (データを)送信
dos.write(sendData);
dos.flush();
if (is != null)
{
int read_bytes = is.read(byte_array, 0, BUFFER_SIZE);
- Log.v(TAG, "receive_from_camera() : " + read_bytes + " bytes.");
+ if (isDumpReceiveLog)
+ {
+ Log.v(TAG, "receive_from_camera() : " + read_bytes + " bytes.");
+ }
return (new ReceivedDataHolder(byte_array, read_bytes));
}
}
return (new ReceivedDataHolder(new byte[0], 0));
}
+ void dumpReceiveLog(boolean enable)
+ {
+ isDumpReceiveLog = enable;
+ }
+
private void dump_bytes(String header, byte[] data)
{
+ if (!isDumpReceiveLog)
+ {
+ // 受信ログを出さない
+ return;
+ }
+
int index = 0;
StringBuffer message;
message = new StringBuffer();
{
try
{
+ statusChecker.stop();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ try
+ {
comm.stop_stream();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ try
+ {
comm.stop_response();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ try
+ {
comm.disconnect_socket();
}
catch (Exception e)
android:orderInCategory="100"
android:title="@string/action_wifi_settings"
app:showAsAction="never" />
-<!--
<item
- android:id="@+id/action_reset"
+ android:id="@+id/action_settings"
android:orderInCategory="100"
- android:title="@string/action_reset"
+ android:title="@string/action_settings"
app:showAsAction="never" />
<item
- android:id="@+id/action_settings"
+ android:id="@+id/action_disconnect"
android:orderInCategory="100"
- android:title="@string/action_settings"
+ android:title="@string/action_disconnect"
+ app:showAsAction="never" />
+
+<!--
+ <item
+ android:id="@+id/action_reset"
+ android:orderInCategory="100"
+ android:title="@string/action_reset"
app:showAsAction="never" />
+
<item
android:id="@+id/action_up_value"
android:orderInCategory="100"
<string name="action_up">Up</string>
<string name="action_down">Down</string>
<string name="action_reset">Reset Connection</string>
+ <string name="action_disconnect">Disconnect</string>
</resources>