Skip to content

Commit

Permalink
Changed Corsense fix to compile the regex. Fixed Lint warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethEvans committed Sep 9, 2018
1 parent 9d8bf7e commit 9c84bbe
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,20 @@

import android.bluetooth.BluetoothGattCharacteristic;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class HeartRateValues implements IConstants {
private long date;
private int hr = INVALID_INT;
private int sensorContact = INVALID_INT;
private int ee = INVALID_INT;
private String rr = INVALID_STRING;
private String info;
private static Pattern corsenseFixPattern = Pattern.compile("^[0-6]" +
"(\\s+|$)");

public HeartRateValues(BluetoothGattCharacteristic characteristic, long
HeartRateValues(BluetoothGattCharacteristic characteristic, long
date) {
this.date = date;
if (!characteristic.getUuid().equals(UUID_HEART_RATE_MEASUREMENT)) {
Expand Down Expand Up @@ -58,17 +63,20 @@ public HeartRateValues(BluetoothGattCharacteristic characteristic, long
// There may be more than 1 R-R value
int iVal;
String rrString = "";
StringBuilder sb = new StringBuilder();
while (offset < len) {
iVal = characteristic.getIntValue(
BluetoothGattCharacteristic.FORMAT_UINT16, offset);
offset += 2;
rrString += " " + iVal;
sb.append(" ");
sb.append(iVal);
}
rr = rrString.trim();
rr = sb.toString().trim();
if (USE_CORSENSE_FIX) {
// Take out first value if 0-6
//String rr1 = rr;
rr = rr.replaceFirst("^[0-6](\\s+|$)", "");
Matcher matcher = corsenseFixPattern.matcher(rr);
rr = matcher.replaceFirst("");
//Log.d(TAG, "|" + rr1 + "|->|" + rr + "| |");
}
string += "\nR-R: " + rrString;
Expand Down

0 comments on commit 9c84bbe

Please sign in to comment.