diff --git a/ShimmerBluetoothManager/src/main/java/com/shimmerresearch/managers/bluetoothManager/ShimmerBluetoothManager.java b/ShimmerBluetoothManager/src/main/java/com/shimmerresearch/managers/bluetoothManager/ShimmerBluetoothManager.java index 0aff1993..3d2fcb3a 100644 --- a/ShimmerBluetoothManager/src/main/java/com/shimmerresearch/managers/bluetoothManager/ShimmerBluetoothManager.java +++ b/ShimmerBluetoothManager/src/main/java/com/shimmerresearch/managers/bluetoothManager/ShimmerBluetoothManager.java @@ -38,6 +38,7 @@ public abstract class ShimmerBluetoothManager{ + protected boolean mVerbose = true; protected boolean directConnectUnknownShimmer=false; /** Key is the COM port in PC and BT address for Android*/ @@ -289,6 +290,10 @@ else if (selectedShimmer instanceof Shimmer4sdk) { } + public void setVerbose(boolean verbose){ + mVerbose = verbose; + } + /** Use setFixedConfigWhenConnecting instead * * @param device @@ -474,6 +479,7 @@ protected void putShimmerBtConnectedMap(ShimmerDevice shimmerDevice){ String connectionHandle = shimmerDevice.getBtConnectionHandle(); ShimmerDevice existingShimmer = getShimmerDeviceBtConnected(connectionHandle); if (existingShimmer==null){ + shimmerDevice.mVerboseMode = this.mVerbose; System.err.println("Putting Shimmer in BT connected map with connectionHandle:" + (connectionHandle.isEmpty()? "EMPTY":connectionHandle)); mMapOfBtConnectedShimmers.put(connectionHandle, shimmerDevice); } diff --git a/ShimmerDriverPC/src/main/java/com/shimmerresearch/tools/matlab/ShimmerJavaClass.java b/ShimmerDriverPC/src/main/java/com/shimmerresearch/tools/matlab/ShimmerJavaClass.java index ad56ab32..721b169a 100644 --- a/ShimmerDriverPC/src/main/java/com/shimmerresearch/tools/matlab/ShimmerJavaClass.java +++ b/ShimmerDriverPC/src/main/java/com/shimmerresearch/tools/matlab/ShimmerJavaClass.java @@ -27,6 +27,8 @@ import com.shimmerresearch.pcDriver.ShimmerPC; import com.shimmerresearch.tools.bluetooth.BasicShimmerBluetoothManagerPc; import com.shimmerresearch.algorithms.*; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; public class ShimmerJavaClass { private String comPort; @@ -36,6 +38,15 @@ public class ShimmerJavaClass { private final ConcurrentHashMap> dataQueues = new ConcurrentHashMap<>(); private List collectedData = new ArrayList<>(); + private PropertyChangeSupport pcs = new PropertyChangeSupport(this); + + public void addPropertyChangeListener(PropertyChangeListener listener) { + pcs.addPropertyChangeListener(listener); + } + + public void removePropertyChangeListener(PropertyChangeListener listener) { + pcs.removePropertyChangeListener(listener); + } private boolean mDebug = true; @@ -53,6 +64,10 @@ public ShimmerJavaClass() { } } + public void setDebugMode(boolean debug) { + mDebug = debug; + } + public static void main(String[] args) { ShimmerJavaClass example = new ShimmerJavaClass(); example.createAndShowGUI(); @@ -220,9 +235,14 @@ protected void processMsgFromCallback(ShimmerMsg shimmerMSG) { System.out.println(channel); } } + System.out.println("Device State Change: CONNECTED"); + pcs.firePropertyChange("ConnectedState", null, new MatlabConnectionEvent("CONNECTED", callbackObject.mComPort)); + } else if (callbackObject.mState == BT_STATE.DISCONNECTED || callbackObject.mState == BT_STATE.CONNECTION_LOST) { System.out.println("Device State Change: " + callbackObject.mState); System.out.flush(); + System.out.println("Device State Change: DISCONNECTED"); + pcs.firePropertyChange("ConnectedState", null, new MatlabConnectionEvent("DISCONNECTED", callbackObject.mComPort)); } } else if (ind == ShimmerPC.MSG_IDENTIFIER_NOTIFICATION_MESSAGE) { @@ -251,4 +271,14 @@ protected void processMsgFromCallback(ShimmerMsg shimmerMSG) { } } } -} \ No newline at end of file + public class MatlabConnectionEvent { + public String state; + public String comPort; + + public MatlabConnectionEvent(String state, String comPort) { + this.state = state; + this.comPort = comPort; + } + } + +}