remove unneeded code
This commit is contained in:
parent
34fe8d8b60
commit
23e37a8be7
3 changed files with 6 additions and 78 deletions
|
@ -9,10 +9,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
|
||||||
|
@ -29,9 +25,6 @@ public class SerialIOThread extends Thread {
|
||||||
private OutputStream mOutputStream = null;
|
private OutputStream mOutputStream = null;
|
||||||
private BluetoothSocket mRfCommSocket;
|
private BluetoothSocket mRfCommSocket;
|
||||||
|
|
||||||
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
|
|
||||||
private static ScheduledFuture<?> scheduledDisconnection = null;
|
|
||||||
|
|
||||||
private boolean mKeepRunning = true;
|
private boolean mKeepRunning = true;
|
||||||
private byte[] mReadBuff = new byte[0];
|
private byte[] mReadBuff = new byte[0];
|
||||||
|
|
||||||
|
@ -64,7 +57,8 @@ public class SerialIOThread extends Thread {
|
||||||
// process all messages we already got
|
// process all messages we already got
|
||||||
while (mReadBuff.length > 3) { // 3rd byte is packet size. continue only if we an determine packet size
|
while (mReadBuff.length > 3) { // 3rd byte is packet size. continue only if we an determine packet size
|
||||||
byte[] extractedBuff = cutMessageFromBuffer();
|
byte[] extractedBuff = cutMessageFromBuffer();
|
||||||
if (extractedBuff == null) break; // message is not complete in buffer (wrong packet calls disconnection)
|
if (extractedBuff == null)
|
||||||
|
break; // message is not complete in buffer (wrong packet calls disconnection)
|
||||||
|
|
||||||
int command = (extractedBuff[5] & 0xFF) | ((extractedBuff[4] << 8) & 0xFF00);
|
int command = (extractedBuff[5] & 0xFF) | ((extractedBuff[4] << 8) & 0xFF00);
|
||||||
|
|
||||||
|
@ -85,7 +79,6 @@ public class SerialIOThread extends Thread {
|
||||||
synchronized (message) {
|
synchronized (message) {
|
||||||
message.notify();
|
message.notify();
|
||||||
}
|
}
|
||||||
scheduleDisconnection();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -177,23 +170,6 @@ public class SerialIOThread extends Thread {
|
||||||
log.debug("Old firmware detected");
|
log.debug("Old firmware detected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scheduleDisconnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void scheduleDisconnection() {
|
|
||||||
class DisconnectRunnable implements Runnable {
|
|
||||||
public void run() {
|
|
||||||
disconnect("scheduleDisconnection");
|
|
||||||
scheduledDisconnection = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// prepare task for execution in 10 sec
|
|
||||||
// cancel waiting task to prevent sending multiple disconnections
|
|
||||||
if (scheduledDisconnection != null)
|
|
||||||
scheduledDisconnection.cancel(false);
|
|
||||||
Runnable task = new DisconnectRunnable();
|
|
||||||
final int sec = 10;
|
|
||||||
scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(String reason) {
|
public void disconnect(String reason) {
|
||||||
|
|
|
@ -9,10 +9,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
|
@ -30,9 +26,6 @@ public class SerialIOThread extends Thread {
|
||||||
private OutputStream mOutputStream = null;
|
private OutputStream mOutputStream = null;
|
||||||
private BluetoothSocket mRfCommSocket;
|
private BluetoothSocket mRfCommSocket;
|
||||||
|
|
||||||
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
|
|
||||||
private static ScheduledFuture<?> scheduledDisconnection = null;
|
|
||||||
|
|
||||||
private boolean mKeepRunning = true;
|
private boolean mKeepRunning = true;
|
||||||
private byte[] mReadBuff = new byte[0];
|
private byte[] mReadBuff = new byte[0];
|
||||||
|
|
||||||
|
@ -65,7 +58,8 @@ public class SerialIOThread extends Thread {
|
||||||
// process all messages we already got
|
// process all messages we already got
|
||||||
while (mReadBuff.length > 3) { // 3rd byte is packet size. continue only if we an determine packet size
|
while (mReadBuff.length > 3) { // 3rd byte is packet size. continue only if we an determine packet size
|
||||||
byte[] extractedBuff = cutMessageFromBuffer();
|
byte[] extractedBuff = cutMessageFromBuffer();
|
||||||
if (extractedBuff == null) break; // message is not complete in buffer (wrong packet calls disconnection)
|
if (extractedBuff == null)
|
||||||
|
break; // message is not complete in buffer (wrong packet calls disconnection)
|
||||||
|
|
||||||
int command = (extractedBuff[5] & 0xFF) | ((extractedBuff[4] << 8) & 0xFF00);
|
int command = (extractedBuff[5] & 0xFF) | ((extractedBuff[4] << 8) & 0xFF00);
|
||||||
|
|
||||||
|
@ -86,7 +80,6 @@ public class SerialIOThread extends Thread {
|
||||||
synchronized (message) {
|
synchronized (message) {
|
||||||
message.notify();
|
message.notify();
|
||||||
}
|
}
|
||||||
scheduleDisconnection();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -178,23 +171,6 @@ public class SerialIOThread extends Thread {
|
||||||
log.debug("Old firmware detected");
|
log.debug("Old firmware detected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scheduleDisconnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void scheduleDisconnection() {
|
|
||||||
class DisconnectRunnable implements Runnable {
|
|
||||||
public void run() {
|
|
||||||
disconnect("scheduleDisconnection");
|
|
||||||
scheduledDisconnection = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// prepare task for execution in 5 sec
|
|
||||||
// cancel waiting task to prevent sending multiple disconnections
|
|
||||||
if (scheduledDisconnection != null)
|
|
||||||
scheduledDisconnection.cancel(false);
|
|
||||||
Runnable task = new DisconnectRunnable();
|
|
||||||
final int sec = 5;
|
|
||||||
scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(String reason) {
|
public void disconnect(String reason) {
|
||||||
|
|
|
@ -9,10 +9,6 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
|
@ -30,9 +26,6 @@ public class SerialIOThread extends Thread {
|
||||||
private OutputStream mOutputStream = null;
|
private OutputStream mOutputStream = null;
|
||||||
private BluetoothSocket mRfCommSocket;
|
private BluetoothSocket mRfCommSocket;
|
||||||
|
|
||||||
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
|
|
||||||
private static ScheduledFuture<?> scheduledDisconnection = null;
|
|
||||||
|
|
||||||
private boolean mKeepRunning = true;
|
private boolean mKeepRunning = true;
|
||||||
private byte[] mReadBuff = new byte[0];
|
private byte[] mReadBuff = new byte[0];
|
||||||
|
|
||||||
|
@ -65,7 +58,8 @@ public class SerialIOThread extends Thread {
|
||||||
// process all messages we already got
|
// process all messages we already got
|
||||||
while (mReadBuff.length > 3) { // 3rd byte is packet size. continue only if we an determine packet size
|
while (mReadBuff.length > 3) { // 3rd byte is packet size. continue only if we an determine packet size
|
||||||
byte[] extractedBuff = cutMessageFromBuffer();
|
byte[] extractedBuff = cutMessageFromBuffer();
|
||||||
if (extractedBuff == null) break; // message is not complete in buffer (wrong packet calls disconnection)
|
if (extractedBuff == null)
|
||||||
|
break; // message is not complete in buffer (wrong packet calls disconnection)
|
||||||
|
|
||||||
int command = (extractedBuff[5] & 0xFF) | ((extractedBuff[4] << 8) & 0xFF00);
|
int command = (extractedBuff[5] & 0xFF) | ((extractedBuff[4] << 8) & 0xFF00);
|
||||||
|
|
||||||
|
@ -86,7 +80,6 @@ public class SerialIOThread extends Thread {
|
||||||
synchronized (message) {
|
synchronized (message) {
|
||||||
message.notify();
|
message.notify();
|
||||||
}
|
}
|
||||||
scheduleDisconnection();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -178,23 +171,6 @@ public class SerialIOThread extends Thread {
|
||||||
log.debug("Old firmware detected");
|
log.debug("Old firmware detected");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scheduleDisconnection();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void scheduleDisconnection() {
|
|
||||||
class DisconnectRunnable implements Runnable {
|
|
||||||
public void run() {
|
|
||||||
disconnect("scheduleDisconnection");
|
|
||||||
scheduledDisconnection = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// prepare task for execution in 10 sec
|
|
||||||
// cancel waiting task to prevent sending multiple disconnections
|
|
||||||
if (scheduledDisconnection != null)
|
|
||||||
scheduledDisconnection.cancel(false);
|
|
||||||
Runnable task = new DisconnectRunnable();
|
|
||||||
final int sec = 10;
|
|
||||||
scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnect(String reason) {
|
public void disconnect(String reason) {
|
||||||
|
|
Loading…
Reference in a new issue