Skip to content

Commit dc054f1

Browse files
authored
Merge pull request #264 from ShimmerEngineering/DEV-651_new_bt_command_for_RN4678_test
DEV-651 New BT command for factory test of RN4678
2 parents b7cab13 + 36a15e7 commit dc054f1

4 files changed

Lines changed: 37 additions & 12 deletions

File tree

ShimmerDriver/src/main/java/com/shimmerresearch/bluetooth/ShimmerBluetooth.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ public String toString() {
275275
protected boolean mEnablePCTimeStamps = true;
276276
protected BT_CRC_MODE mBtCommsCrcModeCurrent = BT_CRC_MODE.OFF;
277277
protected static BT_CRC_MODE DEFAULT_BT_CRC_MODE_IF_SUPPORTED = BT_CRC_MODE.ONE_BYTE_CRC;
278+
public static boolean RN4678_ERROR_DETECTION_ENABLED = false;
278279

279280
public enum BT_CRC_MODE {
280281
OFF(0),
@@ -292,6 +293,11 @@ public int getNumCrcBytes() {
292293
}
293294
}
294295

296+
public enum SHIMMER_FEATURE {
297+
NONE,
298+
RN4678_ERROR_DETECTION,
299+
}
300+
295301
public static final Map<Byte, BtCommandDetails> mBtCommandMapOther;
296302
static {
297303
Map<Byte, BtCommandDetails> aMap = new LinkedHashMap<Byte, BtCommandDetails>();
@@ -420,7 +426,8 @@ public int getNumCrcBytes() {
420426
aMap.put(UPD_SDLOG_CFG_COMMAND, new BtCommandDetails(UPD_SDLOG_CFG_COMMAND, "UPD_SDLOG_CFG_COMMAND"));
421427
aMap.put(SET_CRC_COMMAND, new BtCommandDetails(SET_CRC_COMMAND, "SET_CRC_COMMAND"));
422428
aMap.put(SET_RWC_COMMAND, new BtCommandDetails(SET_RWC_COMMAND, "SET_RWC_COMMAND"));
423-
aMap.put(SET_TEST, new BtCommandDetails(SET_TEST, "SET_TEST_COMMAND"));
429+
aMap.put(SET_TEST, new BtCommandDetails(SET_TEST, "SET_TEST_COMMAND"));
430+
aMap.put(SET_FEATURE, new BtCommandDetails(SET_FEATURE, "SET_FEATURE_COMMAND"));
424431
mBtSetCommandMap = Collections.unmodifiableMap(aMap);
425432
}
426433

@@ -2302,6 +2309,9 @@ else if(currentCommand==SET_CRC_COMMAND){
23022309
else if(currentCommand==SET_TEST){
23032310
InShimmerTest = true;
23042311
}
2312+
else if (currentCommand == SET_FEATURE) {
2313+
// TODO: do something?
2314+
}
23052315
else {
23062316
//unhandled set command
23072317
printLogDataForDebugging("Unhandled set command: " + btCommandToString(currentCommand));
@@ -2637,6 +2647,10 @@ private void initializeShimmer3or3R(int hardwareVersion){
26372647
writeBtCommsCrcMode(DEFAULT_BT_CRC_MODE_IF_SUPPORTED);
26382648
}
26392649

2650+
if (RN4678_ERROR_DETECTION_ENABLED && isSupportedRn4678ErrorDetection()) {
2651+
writeSetFeatureCommand(SHIMMER_FEATURE.RN4678_ERROR_DETECTION.ordinal(), 1);
2652+
}
2653+
26402654
if (isSetupDeviceWhileConnecting()){
26412655
if(mFixedShimmerConfigMode!=null && mFixedShimmerConfigMode!=FIXED_SHIMMER_CONFIG_MODE.NONE){
26422656
boolean triggerConfig = setFixedConfigWhenConnecting();
@@ -4631,6 +4645,15 @@ public void writeMemCommand(int command, int address, byte[] infoMemBytes) {
46314645
writeInstruction(instructionBuffer);
46324646
}
46334647
}
4648+
4649+
/**
4650+
* writeSetFeatureCommand(feature, setting) sets a particular feature on the Shimmer device to the desired setting.
4651+
* @param feature is a numeric value defining the feature to be set.
4652+
* @param setting is a numeric value defining the desired setting for the feature. Example valid settings values are 0 (Disable feature) and 1 (Enable feature)
4653+
*/
4654+
public void writeSetFeatureCommand(int feature, int setting){
4655+
writeInstruction(new byte[]{SET_FEATURE, (byte)feature, (byte)setting});
4656+
}
46344657

46354658
//endregion --------- READ/WRITE FUNCTIONS ---------
46364659

ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerDevice.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2166,6 +2166,15 @@ public static boolean isSupportedNoImuSensors(ShimmerVerObject svo, ExpansionBoa
21662166
}
21672167
}
21682168

2169+
public boolean isSupportedRn4678ErrorDetection() {
2170+
if((isShimmerGen3() && getFirmwareIdentifier()==ShimmerVerDetails.FW_ID.LOGANDSTREAM
2171+
&& mShimmerVerObject.compareVersions(HW_ID.SHIMMER_3, FW_ID.LOGANDSTREAM, 1, 0, 17))){
2172+
return true;
2173+
}
2174+
return false;
2175+
}
2176+
2177+
21692178
/**
21702179
* Check each entry in the passed in list to see if the current Shimmer
21712180
* version information in this instance of ShimmerDevice is compatible with

ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerObject.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,10 +476,6 @@ public class BTStream {
476476
public static final byte PRESSURE_OVERSAMPLING_RATIO_RESPONSE = (byte) 0x53;
477477
public static final byte GET_PRESSURE_OVERSAMPLING_RATIO_COMMAND = (byte) 0x54;
478478

479-
public static final byte SET_PRESSURE_SAMPLING_RATE_COMMAND = (byte) 0xB5;
480-
public static final byte PRESSURE_SAMPLING_RATE_RESPONSE = (byte) 0xB6;
481-
public static final byte GET_PRESSURE_SAMPLING_RATE_COMMAND = (byte) 0xB7;
482-
483479
//new BT + SD command to set/rsp/get/update_dump_file all calibration parameters using the new byte array structure
484480
public static final byte SET_CALIB_DUMP_COMMAND = (byte) 0x98;
485481
public static final byte RSP_CALIB_DUMP_COMMAND = (byte) 0x99;
@@ -490,7 +486,10 @@ public class BTStream {
490486

491487
public static final byte GET_BT_FW_VERSION_STR_COMMAND = (byte) 0xA1;
492488
public static final byte BT_FW_VERSION_STR_RESPONSE = (byte) 0xA2;
493-
public static final byte SET_TEST = (byte) 0xA8;
489+
public static final byte SET_TEST = (byte) 0xA8;
490+
491+
public static final byte SET_FEATURE = (byte) 0xB7;
492+
494493
public static final int MAX_NUMBER_OF_SIGNALS = 77;//50; //used to be 11 but now 13 because of the SR30 + 8 for 3d orientation
495494
public static final int MAX_INQUIRY_PACKET_SIZE = 47;
496495

ShimmerDriver/src/main/java/com/shimmerresearch/sensors/bmpX80/SensorBMP390.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,24 +104,18 @@ public static final class ObjectClusterSensorName{
104104
public static final byte PRESSURE_CALIBRATION_COEFFICIENTS_RESPONSE = (byte) 0xA6;
105105
public static final byte GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND = (byte) 0xA7;
106106

107-
public static final byte SET_PRESSURE_SAMPLING_RATE_COMMAND = (byte) 0xB5;
108-
public static final byte PRESSURE_SAMPLING_RATE_RESPONSE = (byte) 0xB6;
109-
public static final byte GET_PRESSURE_SAMPLING_RATE_COMMAND = (byte) 0xB7;
110-
111107
public static final Map<Byte, BtCommandDetails> mBtGetCommandMap;
112108
static {
113109
Map<Byte, BtCommandDetails> aMap = new LinkedHashMap<Byte, BtCommandDetails>();
114110
aMap.put(GET_PRESSURE_OVERSAMPLING_RATIO_COMMAND, new BtCommandDetails(GET_PRESSURE_OVERSAMPLING_RATIO_COMMAND, "GET_PRESSURE_OVERSAMPLING_RATIO_COMMAND", PRESSURE_OVERSAMPLING_RATIO_RESPONSE));
115111
aMap.put(GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND, new BtCommandDetails(GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND, "GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND", PRESSURE_CALIBRATION_COEFFICIENTS_RESPONSE));
116-
aMap.put(GET_PRESSURE_SAMPLING_RATE_COMMAND, new BtCommandDetails(GET_PRESSURE_SAMPLING_RATE_COMMAND, "GET_PRESSURE_SAMPLING_RATE_COMMAND", PRESSURE_SAMPLING_RATE_RESPONSE));
117112
mBtGetCommandMap = Collections.unmodifiableMap(aMap);
118113
}
119114

120115
public static final Map<Byte, BtCommandDetails> mBtSetCommandMap;
121116
static {
122117
Map<Byte, BtCommandDetails> aMap = new LinkedHashMap<Byte, BtCommandDetails>();
123118
aMap.put(SET_PRESSURE_OVERSAMPLING_RATIO_COMMAND, new BtCommandDetails(SET_PRESSURE_OVERSAMPLING_RATIO_COMMAND, "SET_PRESSURE_OVERSAMPLING_RATIO_COMMAND"));
124-
aMap.put(SET_PRESSURE_SAMPLING_RATE_COMMAND, new BtCommandDetails(SET_PRESSURE_SAMPLING_RATE_COMMAND, "SET_PRESSURE_SAMPLING_RATE_COMMAND"));
125119
mBtSetCommandMap = Collections.unmodifiableMap(aMap);
126120
}
127121
//--------- Bluetooth commands end --------------

0 commit comments

Comments
 (0)