Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand Down Expand Up @@ -289,6 +290,10 @@ else if (selectedShimmer instanceof Shimmer4sdk) {
}


public void setVerbose(boolean verbose){
mVerbose = verbose;
}

/** Use setFixedConfigWhenConnecting instead
*
* @param device
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,6 +38,15 @@ public class ShimmerJavaClass {
private final ConcurrentHashMap<String, Queue<Object[]>> dataQueues = new ConcurrentHashMap<>();
private List<float[]> 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;

Expand All @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -251,4 +271,14 @@ protected void processMsgFromCallback(ShimmerMsg shimmerMSG) {
}
}
}
}
public class MatlabConnectionEvent {
public String state;
public String comPort;

public MatlabConnectionEvent(String state, String comPort) {
this.state = state;
this.comPort = comPort;
}
}

}
Loading