diff --git a/ShimmerDriver/src/main/java/com/shimmerresearch/bluetooth/ShimmerBluetooth.java b/ShimmerDriver/src/main/java/com/shimmerresearch/bluetooth/ShimmerBluetooth.java index 1ef3c077..db2beb4d 100644 --- a/ShimmerDriver/src/main/java/com/shimmerresearch/bluetooth/ShimmerBluetooth.java +++ b/ShimmerDriver/src/main/java/com/shimmerresearch/bluetooth/ShimmerBluetooth.java @@ -275,6 +275,7 @@ public String toString() { protected boolean mEnablePCTimeStamps = true; protected BT_CRC_MODE mBtCommsCrcModeCurrent = BT_CRC_MODE.OFF; protected static BT_CRC_MODE DEFAULT_BT_CRC_MODE_IF_SUPPORTED = BT_CRC_MODE.ONE_BYTE_CRC; + public static boolean RN4678_ERROR_DETECTION_ENABLED = false; public enum BT_CRC_MODE { OFF(0), @@ -292,6 +293,11 @@ public int getNumCrcBytes() { } } + public enum SHIMMER_FEATURE { + NONE, + RN4678_ERROR_DETECTION, + } + public static final Map mBtCommandMapOther; static { Map aMap = new LinkedHashMap(); @@ -420,7 +426,8 @@ public int getNumCrcBytes() { aMap.put(UPD_SDLOG_CFG_COMMAND, new BtCommandDetails(UPD_SDLOG_CFG_COMMAND, "UPD_SDLOG_CFG_COMMAND")); aMap.put(SET_CRC_COMMAND, new BtCommandDetails(SET_CRC_COMMAND, "SET_CRC_COMMAND")); aMap.put(SET_RWC_COMMAND, new BtCommandDetails(SET_RWC_COMMAND, "SET_RWC_COMMAND")); - aMap.put(SET_TEST, new BtCommandDetails(SET_TEST, "SET_TEST_COMMAND")); + aMap.put(SET_TEST, new BtCommandDetails(SET_TEST, "SET_TEST_COMMAND")); + aMap.put(SET_FEATURE, new BtCommandDetails(SET_FEATURE, "SET_FEATURE_COMMAND")); mBtSetCommandMap = Collections.unmodifiableMap(aMap); } @@ -2302,6 +2309,9 @@ else if(currentCommand==SET_CRC_COMMAND){ else if(currentCommand==SET_TEST){ InShimmerTest = true; } + else if (currentCommand == SET_FEATURE) { + // TODO: do something? + } else { //unhandled set command printLogDataForDebugging("Unhandled set command: " + btCommandToString(currentCommand)); @@ -2637,6 +2647,10 @@ private void initializeShimmer3or3R(int hardwareVersion){ writeBtCommsCrcMode(DEFAULT_BT_CRC_MODE_IF_SUPPORTED); } + if (RN4678_ERROR_DETECTION_ENABLED && isSupportedRn4678ErrorDetection()) { + writeSetFeatureCommand(SHIMMER_FEATURE.RN4678_ERROR_DETECTION.ordinal(), 1); + } + if (isSetupDeviceWhileConnecting()){ if(mFixedShimmerConfigMode!=null && mFixedShimmerConfigMode!=FIXED_SHIMMER_CONFIG_MODE.NONE){ boolean triggerConfig = setFixedConfigWhenConnecting(); @@ -4631,6 +4645,15 @@ public void writeMemCommand(int command, int address, byte[] infoMemBytes) { writeInstruction(instructionBuffer); } } + + /** + * writeSetFeatureCommand(feature, setting) sets a particular feature on the Shimmer device to the desired setting. + * @param feature is a numeric value defining the feature to be set. + * @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) + */ + public void writeSetFeatureCommand(int feature, int setting){ + writeInstruction(new byte[]{SET_FEATURE, (byte)feature, (byte)setting}); + } //endregion --------- READ/WRITE FUNCTIONS --------- diff --git a/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerDevice.java b/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerDevice.java index 49ef3e0a..c67810d1 100644 --- a/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerDevice.java +++ b/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerDevice.java @@ -2166,6 +2166,15 @@ public static boolean isSupportedNoImuSensors(ShimmerVerObject svo, ExpansionBoa } } + public boolean isSupportedRn4678ErrorDetection() { + if((isShimmerGen3() && getFirmwareIdentifier()==ShimmerVerDetails.FW_ID.LOGANDSTREAM + && mShimmerVerObject.compareVersions(HW_ID.SHIMMER_3, FW_ID.LOGANDSTREAM, 1, 0, 17))){ + return true; + } + return false; + } + + /** * Check each entry in the passed in list to see if the current Shimmer * version information in this instance of ShimmerDevice is compatible with diff --git a/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerObject.java b/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerObject.java index 481f9124..db0905e2 100644 --- a/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerObject.java +++ b/ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerObject.java @@ -476,10 +476,6 @@ public class BTStream { public static final byte PRESSURE_OVERSAMPLING_RATIO_RESPONSE = (byte) 0x53; public static final byte GET_PRESSURE_OVERSAMPLING_RATIO_COMMAND = (byte) 0x54; - public static final byte SET_PRESSURE_SAMPLING_RATE_COMMAND = (byte) 0xB5; - public static final byte PRESSURE_SAMPLING_RATE_RESPONSE = (byte) 0xB6; - public static final byte GET_PRESSURE_SAMPLING_RATE_COMMAND = (byte) 0xB7; - //new BT + SD command to set/rsp/get/update_dump_file all calibration parameters using the new byte array structure public static final byte SET_CALIB_DUMP_COMMAND = (byte) 0x98; public static final byte RSP_CALIB_DUMP_COMMAND = (byte) 0x99; @@ -490,7 +486,10 @@ public class BTStream { public static final byte GET_BT_FW_VERSION_STR_COMMAND = (byte) 0xA1; public static final byte BT_FW_VERSION_STR_RESPONSE = (byte) 0xA2; - public static final byte SET_TEST = (byte) 0xA8; + public static final byte SET_TEST = (byte) 0xA8; + + public static final byte SET_FEATURE = (byte) 0xB7; + 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 public static final int MAX_INQUIRY_PACKET_SIZE = 47; diff --git a/ShimmerDriver/src/main/java/com/shimmerresearch/sensors/bmpX80/SensorBMP390.java b/ShimmerDriver/src/main/java/com/shimmerresearch/sensors/bmpX80/SensorBMP390.java index f2ae9e40..f1ea9258 100644 --- a/ShimmerDriver/src/main/java/com/shimmerresearch/sensors/bmpX80/SensorBMP390.java +++ b/ShimmerDriver/src/main/java/com/shimmerresearch/sensors/bmpX80/SensorBMP390.java @@ -104,16 +104,11 @@ public static final class ObjectClusterSensorName{ public static final byte PRESSURE_CALIBRATION_COEFFICIENTS_RESPONSE = (byte) 0xA6; public static final byte GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND = (byte) 0xA7; - public static final byte SET_PRESSURE_SAMPLING_RATE_COMMAND = (byte) 0xB5; - public static final byte PRESSURE_SAMPLING_RATE_RESPONSE = (byte) 0xB6; - public static final byte GET_PRESSURE_SAMPLING_RATE_COMMAND = (byte) 0xB7; - public static final Map mBtGetCommandMap; static { Map aMap = new LinkedHashMap(); aMap.put(GET_PRESSURE_OVERSAMPLING_RATIO_COMMAND, new BtCommandDetails(GET_PRESSURE_OVERSAMPLING_RATIO_COMMAND, "GET_PRESSURE_OVERSAMPLING_RATIO_COMMAND", PRESSURE_OVERSAMPLING_RATIO_RESPONSE)); aMap.put(GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND, new BtCommandDetails(GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND, "GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND", PRESSURE_CALIBRATION_COEFFICIENTS_RESPONSE)); - aMap.put(GET_PRESSURE_SAMPLING_RATE_COMMAND, new BtCommandDetails(GET_PRESSURE_SAMPLING_RATE_COMMAND, "GET_PRESSURE_SAMPLING_RATE_COMMAND", PRESSURE_SAMPLING_RATE_RESPONSE)); mBtGetCommandMap = Collections.unmodifiableMap(aMap); } @@ -121,7 +116,6 @@ public static final class ObjectClusterSensorName{ static { Map aMap = new LinkedHashMap(); aMap.put(SET_PRESSURE_OVERSAMPLING_RATIO_COMMAND, new BtCommandDetails(SET_PRESSURE_OVERSAMPLING_RATIO_COMMAND, "SET_PRESSURE_OVERSAMPLING_RATIO_COMMAND")); - aMap.put(SET_PRESSURE_SAMPLING_RATE_COMMAND, new BtCommandDetails(SET_PRESSURE_SAMPLING_RATE_COMMAND, "SET_PRESSURE_SAMPLING_RATE_COMMAND")); mBtSetCommandMap = Collections.unmodifiableMap(aMap); } //--------- Bluetooth commands end --------------