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 @@ -745,11 +745,17 @@ protected void clearSingleDataPacketFromBuffers(byte[] bufferTemp, int packetSiz
}

}

@Override
protected void processPacket() {
setIamAlive(true);
byte[] allBytes = mByteArrayOutputStream.toByteArray();
//consolePrintLn("Byte Array Size: " + allBytes.length);
if (mByteArrayOutputStream.size()>10000){
mByteArrayOutputStream.reset();
mListofPCTimeStamps.clear();
consolePrintLn("Byte Array Size (reset): " + mByteArrayOutputStream.size());
return;
}
byte[] bufferTemp = new byte[getPacketSizeWithCrc()+2];
System.arraycopy(allBytes,0,bufferTemp,0,bufferTemp.length);
//Data packet followed by another data packet
Expand Down Expand Up @@ -864,6 +870,7 @@ protected void processInstreamResponse() {
consolePrintLn("In-stream received = " + btCommandToString(inStreamResponseCommand));

if (inStreamResponseCommand == DIR_RESPONSE) {
printLogDataForDebugging("IN STREAM: DIR_RESPONSE");
//byte[] responseData = readBytes(1, inStreamResponseCommand);
bufferTemp = getDataFromArrayOutputStream(5);
if (bufferTemp != null) {
Expand All @@ -880,6 +887,7 @@ protected void processInstreamResponse() {
clearSingleDataPacketFromBuffers(bufferTemp, bufferTemp.length + mBtCommsCrcModeCurrent.getNumCrcBytes());
}
} else if (inStreamResponseCommand == STATUS_RESPONSE) {
printLogDataForDebugging("IN STREAM: STATUS_RESPONSE");
bufferTemp = getDataFromArrayOutputStream(5);
if (bufferTemp != null) {
byte[] responseData = new byte[1];
Expand All @@ -903,6 +911,7 @@ protected void processInstreamResponse() {
}
}
} else if (inStreamResponseCommand == VBATT_RESPONSE) {
printLogDataForDebugging("IN STREAM: VBATT_RESPONSE");
bufferTemp = getDataFromArrayOutputStream(7);
if (bufferTemp != null) {
byte[] responseData = new byte[3];
Expand All @@ -922,6 +931,8 @@ protected void processInstreamResponse() {
} else {
discardFirstBufferByte();
}
} else {
printLogDataForDebugging("IN STREAM: buffer temp is null, byte array output stream size is " + mByteArrayOutputStream.size());
}
}
}
Expand All @@ -932,7 +943,10 @@ protected void processWhileStreaming() {
byte[] byteBuffer = readBytes(availableBytes());
if(byteBuffer!=null){
try {
mByteArrayOutputStream.write(byteBuffer);
if (byteBuffer.length>0) {
//consolePrintLn("Byte Array Size put in : " + byteBuffer.length);
mByteArrayOutputStream.write(byteBuffer);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -948,11 +962,18 @@ protected void processWhileStreaming() {
}

//If there is a full packet and the subsequent sequence number of following packet
if(mByteArrayOutputStream.size()>=getPacketSizeWithCrc()+2){ // +2 because there are two acks
int size = mByteArrayOutputStream.size();
while(mByteArrayOutputStream.size()>=getPacketSizeWithCrc()+2){ // +2 because there are two acks
processPacket();
int newSize = mByteArrayOutputStream.size();
if (size == newSize){
consolePrintLn("processWhileStreaming: Leaving while loop");
break;
}
}
}


/**this is to clear the buffer
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ public void startStreaming(View v) {
setupCSV();
//Disable PC timestamps for better performance. Disabling this takes the timestamps on every full packet received instead of on every byte received.
shimmer.enablePCTimeStamps(false);
//Disable timers for better performance.
shimmer.stopAllTimers();
//Enable the arrays data structure. Note that enabling this will disable the Multimap/FormatCluster data structure
shimmer.enableArraysDataStructure(true);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,12 @@ public boolean onOptionsItemSelected(MenuItem item) {
if(selectedDeviceAddress != null) {

ShimmerDevice mDevice = mService.getShimmer(selectedDeviceAddress);
if (mDevice instanceof ShimmerBluetooth) {
//Disable PC timestamps for better performance. Disabling this takes the timestamps on every full packet received instead of on every byte received.
((ShimmerBluetooth) mDevice).enablePCTimeStamps(false);
//Disable timers for better performance.
((ShimmerBluetooth) mDevice).stopAllTimers();
}
try {
mDevice.startStreaming();
mViewPager.setCurrentItem(mDevice instanceof VerisenseDevice ? 5 : 4);
Expand Down