Skip to content

DEV-706 Dock menu for changing S3R USB speed#275

Merged
jyong15 merged 2 commits into
masterfrom
DEV-706_USB_speed_change
May 6, 2026
Merged

DEV-706 Dock menu for changing S3R USB speed#275
jyong15 merged 2 commits into
masterfrom
DEV-706_USB_speed_change

Conversation

@marknolan

Copy link
Copy Markdown
Member

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support structures for controlling S3R USB speed (and related EEPROM-backed settings) via dock/driver capability checks.

Changes:

  • Introduces EepromSensorSettingsDetails to parse/update an EEPROM “sensor settings” page (BT radio state + USB speed bit).
  • Wires the new settings container into ShimmerDevice.
  • Adds isHWAndFWSupportedUsbControl() capability gating for Shimmer3R LogAndStream FW >= 1.0.55.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
ShimmerDriver/src/main/java/com/shimmerresearch/driverUtilities/EepromSensorSettingsDetails.java New EEPROM settings model with parsing and bitfield update logic for radio + USB speed.
ShimmerDriver/src/main/java/com/shimmerresearch/driver/ShimmerDevice.java Adds EEPROM settings member and a new HW/FW support check for USB control; removes prior BT radio state API from this class.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +102 to +107
public void parseEepromSensorSettingsDetails(byte[] byteArray) {
this.mEepromPageArray = byteArray;

radioHwVer = mEepromPageArray[EXP_BOARD_ARRAY_BYTE_INDEX.RADIO_HW_VER.ordinal()] & 0xFF;
baudRate = mEepromPageArray[EXP_BOARD_ARRAY_BYTE_INDEX.BAUD_RATE.ordinal()] & 0xFF;

Copilot AI Apr 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parseEepromSensorSettingsDetails assigns mEepromPageArray directly and then indexes into it without validating byteArray for null and expected length (EXP_BOARD_MEMORY_PAGE_SIZE). This can throw NPE/AIOOBE if callers pass null or a short buffer; consider guarding and/or copying into a properly-sized array (and returning an error/boolean if invalid).

Copilot uses AI. Check for mistakes.
Comment on lines +148 to +156
private void updateEepromPageArray() {
mEepromPageArray[EXP_BOARD_ARRAY_BYTE_INDEX.RADIO_HW_VER.ordinal()] = (byte) radioHwVer;
mEepromPageArray[EXP_BOARD_ARRAY_BYTE_INDEX.BAUD_RATE.ordinal()] = (byte) baudRate;

mEepromPageArray[EXP_BOARD_ARRAY_BYTE_INDEX.SENSOR_OPTIONS1.ordinal()] &= 0xFC; // Clear the existing radio state bits (bits 0 and 1)
mEepromPageArray[EXP_BOARD_ARRAY_BYTE_INDEX.SENSOR_OPTIONS1.ordinal()] |= mRadioState.getBitValue(); // Set the new radio state bits

mEepromPageArray[EXP_BOARD_ARRAY_BYTE_INDEX.SENSOR_OPTIONS1.ordinal()] &= 0xFB; // Clear the existing USB speed bit (bit 2)
mEepromPageArray[EXP_BOARD_ARRAY_BYTE_INDEX.SENSOR_OPTIONS1.ordinal()] |= (mUsbHighSpeed ? USB_SPEED.HIGH_SPEED.getBitValue() : USB_SPEED.FULL_SPEED.getBitValue()); // Set the new USB speed bit

Copilot AI Apr 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateEepromPageArray() assumes mEepromPageArray is already allocated to at least 3 bytes, but it is initialized to an empty array by default. Calling setBtRadioStateFromString/setUsbSpeedStateFromString before parseEepromSensorSettingsDetails will cause an ArrayIndexOutOfBoundsException; consider allocating a default EXP_BOARD_MEMORY_PAGE_SIZE array (and initializing reserved bytes) or no-op/throw until parsed.

Copilot uses AI. Check for mistakes.
Comment on lines +126 to +133
public void setBtRadioStateFromString(String option) {
if(option.equals(BTRADIO_STATE.BT_CLASSIC_BLE_ENABLED.toString())) {
mRadioState = BTRADIO_STATE.BT_CLASSIC_BLE_ENABLED;
}else if (option.equals(BTRADIO_STATE.BT_CLASSIC_ENABLED.toString())) {
mRadioState = BTRADIO_STATE.BT_CLASSIC_ENABLED;
}else if (option.equals(BTRADIO_STATE.BLE_ENABLED.toString())) {
mRadioState = BTRADIO_STATE.BLE_ENABLED;
}

Copilot AI Apr 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setBtRadioStateFromString uses option.equals(...), which will throw if option is null. Elsewhere in the codebase comparisons are typically written as CONSTANT.equals(value) to be null-safe; consider flipping the equals call here and in setUsbSpeedStateFromString.

Copilot uses AI. Check for mistakes.
Comment on lines +126 to +136
public void setBtRadioStateFromString(String option) {
if(option.equals(BTRADIO_STATE.BT_CLASSIC_BLE_ENABLED.toString())) {
mRadioState = BTRADIO_STATE.BT_CLASSIC_BLE_ENABLED;
}else if (option.equals(BTRADIO_STATE.BT_CLASSIC_ENABLED.toString())) {
mRadioState = BTRADIO_STATE.BT_CLASSIC_ENABLED;
}else if (option.equals(BTRADIO_STATE.BLE_ENABLED.toString())) {
mRadioState = BTRADIO_STATE.BLE_ENABLED;
}

updateEepromPageArray();
}

Copilot AI Apr 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setBtRadioStateFromString does not handle the NONE_ENABLED option (it can be produced by BTRADIO_STATE.NONE_ENABLED.toString()), so selecting that value will silently keep the previous state while still updating the EEPROM array. Add an explicit branch (or a default) so all enum values are supported or an invalid option is surfaced.

Copilot uses AI. Check for mistakes.
Comment on lines 209 to 214
protected String mComPort = "";
public transient CommsProtocolRadio mCommsProtocolRadio = null;
public BT_STATE mBluetoothRadioState = BT_STATE.DISCONNECTED;
public DOCK_STATE mDockState = DOCK_STATE.UNDOCKED;
public BTRADIO_STATE mRadioState = BTRADIO_STATE.UNKNOWN;
private boolean mUpdateOnlyWhenStateChanges=false;
public static int EXP_BOARD_MEMORY_LOCATION_FOR_BTRADIO_STATE = 2018;
public enum BTRADIO_STATE{

BT_CLASSIC_BLE_ENABLED("BT Classic and BLE Enabled"),
BT_CLASSIC_ENABLED("BT Classic Enabled"),
BLE_ENABLED("BLE Enabled"),
NONE_ENABLED("None Enabled"),
UNKNOWN("Unknown");
// RECORDING("Recording");

private final String text;

/**
* @param text
*/
private BTRADIO_STATE(final String text) {
this.text = text;
}

/* (non-Javadoc)
* @see java.lang.Enum#toString()
*/
@Override
public String toString() {
return text;
}

}

Copilot AI Apr 22, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ShimmerDevice previously exposed BTRADIO_STATE and mRadioState as public API; removing them is a breaking change for downstream consumers even if the repo itself no longer references them. If external compatibility matters, consider keeping the old enum/field (deprecated) and delegating to mEepromSensorSettingsDetails, or providing an equivalent accessor method.

Copilot uses AI. Check for mistakes.
@jyong15 jyong15 self-requested a review May 6, 2026 05:25

@jyong15 jyong15 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested and looks good

@jyong15 jyong15 merged commit 8465790 into master May 6, 2026
1 check passed
@jyong15 jyong15 deleted the DEV-706_USB_speed_change branch May 6, 2026 05:27
@marknolan marknolan self-assigned this May 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants