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 @@ -1111,9 +1111,15 @@ protected void processInstreamResponse(boolean shouldClearCrcFromBuffer) {
}
}
else if(inStreamResponseCommand==STATUS_RESPONSE){
byte[] responseData = readBytes(1, inStreamResponseCommand);
int statusBytesToRead = 0;
if(isSupportedUSBPluggedInStatus()) {
statusBytesToRead = 2;
}else {
statusBytesToRead = 1;
}
byte[] responseData = readBytes(statusBytesToRead, inStreamResponseCommand);
if(responseData!=null){
parseStatusByte(responseData[0]);
parseStatusByte(responseData);

if(!isSupportedRtcStateInStatus()){
if(!mIsSensing && !isInitialised()){
Expand Down Expand Up @@ -2396,26 +2402,26 @@ protected byte[] readBytes(int numBytes, byte btCommand) {
/**
* @param statusByte
*/
protected void parseStatusByte(byte statusByte){
protected void parseStatusByte(byte[] statusByte){
Boolean savedDockedState = isDocked();

setIsDocked(((statusByte & (0x01 << 0)) > 0)? true:false);
setIsSensing(((statusByte & (0x01 << 1)) > 0)? true:false);
setIsDocked(((statusByte[0] & (0x01 << 0)) > 0)? true:false);
setIsSensing(((statusByte[0] & (0x01 << 1)) > 0)? true:false);
//reserved(((statusByte & (0x01 << 2)) > 0)? true:false);
if(isSupportedRtcStateInStatus()){
mIsRtcSet = ((statusByte & (0x01 << 2)) > 0)? true:false;
mIsRtcSet = ((statusByte[0] & (0x01 << 2)) > 0)? true:false;
}
setIsSDLogging(((statusByte & (0x01 << 3)) > 0)? true:false);
setIsStreaming(((statusByte & (0x01 << 4)) > 0)? true:false);
setIsSDLogging(((statusByte[0] & (0x01 << 3)) > 0)? true:false);
setIsStreaming(((statusByte[0] & (0x01 << 4)) > 0)? true:false);
if(isSupportedSdInfoInStatus()){
setIsSDPresent(((statusByte & (0x01 << 5)) > 0)? true:false);
setIsSDError(((statusByte & (0x01 << 6)) > 0)? true:false);
setIsSDPresent(((statusByte[0] & (0x01 << 5)) > 0)? true:false);
setIsSDError(((statusByte[0] & (0x01 << 6)) > 0)? true:false);
}
if(isSupportedRedLedStateInStatus()){
mIsRedLedOn = ((statusByte & (0x01 << 7)) > 0)? true:false;
mIsRedLedOn = ((statusByte[0] & (0x01 << 7)) > 0)? true:false;
}
consolePrintLn("\nStatus Response = \n" + UtilShimmer.byteToHexStringFormatted(statusByte)

consolePrintLn("\nStatus Response = \n" + UtilShimmer.byteToHexStringFormatted(statusByte[0])
+ "\t" + "IsDocked = " + isDocked()
+ "\t" + "IsSensing = " + mIsSensing
+ "\t" + "IsRtcSet = " + mIsRtcSet
Expand All @@ -2425,6 +2431,14 @@ protected void parseStatusByte(byte statusByte){
+ "\t" + "mIsSdPresent = " + isSDPresent()
+ "\t" + "mIsRedLedOn = " + mIsRedLedOn);

if(statusByte.length > 1) {
setIsUsbPluggedIn(((statusByte[1] & (0x01 << 0)) > 0)? true:false);

consolePrintLn("\nStatus Response = \n" + UtilShimmer.byteToHexStringFormatted(statusByte[1])
+ "\t" + "IsUsbPluggedIn = " + isUsbPluggedIn());

}

if(savedDockedState!=isDocked()){
dockedStateChange();
}
Expand All @@ -2442,6 +2456,10 @@ public boolean isSupportedSdInfoInStatus() {
return isThisVerCompatibleWith(FW_ID.LOGANDSTREAM, 0, 7, 12);
}

public boolean isSupportedUSBPluggedInStatus() {
return isThisVerCompatibleWith(HW_ID.SHIMMER_3R, FW_ID.LOGANDSTREAM, 1,0, 24);
}

protected boolean isSupportedInStreamCmds() {
if((getFirmwareIdentifier()==FW_ID.LOGANDSTREAM
|| isThisVerCompatibleWith(FW_ID.BTSTREAM, 0, 8, 1))&& getHardwareVersion()!=HW_ID.SHIMMER_2R){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public abstract class ShimmerDevice extends BasicProcessWithCallBack implements
protected boolean mIsStreaming = false; // This is used to monitor whether the device is in streaming mode
protected boolean mIsInitialised = false;
private boolean mIsDocked = false;
private boolean mIsUsbPluggedIn= false;
protected boolean mHaveAttemptedToReadConfig = false;

//BSL related start
Expand Down Expand Up @@ -1048,6 +1049,16 @@ public boolean setIsDocked(boolean docked) {
}
return changed;
}

public boolean setIsUsbPluggedIn(boolean usbPluggedIn) {
boolean changed=false;
if (mIsUsbPluggedIn!=usbPluggedIn){
changed = true;
}
mIsUsbPluggedIn = usbPluggedIn;
return changed;

}

public void stateHandler(Object obj){

Expand All @@ -1059,6 +1070,10 @@ public void stateHandler(Object obj){
public boolean isDocked() {
return mIsDocked;
}

public boolean isUsbPluggedIn() {
return mIsUsbPluggedIn;
}

public void setIsConnected(boolean state) {
mIsConnected = state;
Expand Down
Loading