Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

Commit

Permalink
Integrated commands and button settings for the RevE boards into the …
Browse files Browse the repository at this point in the history
…app.
  • Loading branch information
maxieds committed May 12, 2018
1 parent 894160a commit 02d2924
Show file tree
Hide file tree
Showing 21 changed files with 249 additions and 98 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ android {
applicationId "com.maxieds.chameleonminilivedebugger"
minSdkVersion 21
targetSdkVersion 27
versionCode 40
versionName "0.4.0"
versionCode 41
versionName "0.4.1"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toolbar;

Expand Down Expand Up @@ -105,6 +106,7 @@ public class LiveLoggerActivity extends AppCompatActivity {
public static SpinnerAdapter spinnerLButtonLongAdapter;
public static SpinnerAdapter spinnerLEDRedAdapter;
public static SpinnerAdapter spinnerLEDGreenAdapter;
public static SpinnerAdapter spinnerButtonMyAdapter;
public static SpinnerAdapter spinnerLogModeAdapter;
public static SpinnerAdapter spinnerCmdShellAdapter;
public static MenuItem selectedThemeMenuItem;
Expand Down Expand Up @@ -595,6 +597,12 @@ public UsbSerialDevice configureSerialPort(UsbSerialDevice serialPort, UsbSerial
int deviceVID = device.getVendorId();
int devicePID = device.getProductId();
if(deviceVID == ChameleonIO.CMUSB_VENDORID && devicePID == ChameleonIO.CMUSB_PRODUCTID) {
ChameleonIO.REVE_BOARD = false;
connection = usbManager.openDevice(device);
break;
}
else if(deviceVID == ChameleonIO.CMUSB_REVE_VENDORID && devicePID == ChameleonIO.CMUSB_REVE_PRODUCTID) {
ChameleonIO.REVE_BOARD = true;
connection = usbManager.openDevice(device);
break;
}
Expand Down Expand Up @@ -740,22 +748,30 @@ public void actionButtonRestorePeripheralDefaults(View view) {
R.id.LButtonSpinner,
R.id.LButtonLongSpinner,
R.id.LEDRedSpinner,
R.id.LEDGreenSpinner
R.id.LEDGreenSpinner,
R.id.ButtonMyRevEBoardSpinner
};
String[] queryCmds = {
"RBUTTON?",
"RBUTTON_LONG?",
"LBUTTON?",
"LBUTTON_LONG?",
"LEDRED?",
"LEDGREEN?"
"LEDGREEN?",
"buttonmy?"
};
for (int i = 0; i < spinnerIDs.length; i++) {
Log.i(TAG, queryCmds[i]);
Spinner curSpinner = (Spinner) LiveLoggerActivity.runningActivity.findViewById(spinnerIDs[i]);
String deviceSetting = getSettingFromDevice(LiveLoggerActivity.serialPort, queryCmds[i]);
curSpinner.setSelection(((ArrayAdapter<String>) curSpinner.getAdapter()).getPosition(deviceSetting));
}
// handle FIELD and READ-ONLY switches:
String fieldSetting = getSettingFromDevice(LiveLoggerActivity.serialPort, "FIELD?");
((Switch) findViewById(R.id.fieldOnOffSwitch)).setChecked(fieldSetting.equals("0") ? false : true);
String roQueryCmd = ChameleonIO.REVE_BOARD ? "readonlymy?" : "READONLY?";
String roSetting = getSettingFromDevice(LiveLoggerActivity.serialPort, roQueryCmd);
((Switch) findViewById(R.id.readonlyOnOffSwitch)).setChecked(roSetting.equals("0") ? false : true);
}

}
Expand Down Expand Up @@ -847,17 +863,26 @@ else if(createCmd.equals("SNIFFER")) {
return;
}
else if(createCmd.equals("ULTRALIGHT")) {
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=MF_ULTRALIGHT", ChameleonIO.TIMEOUT);
if(!ChameleonIO.REVE_BOARD)
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=MF_ULTRALIGHT", ChameleonIO.TIMEOUT);
else
ChameleonIO.executeChameleonMiniCommand(serialPort, "configmy=MF_ULTRALIGHT", ChameleonIO.TIMEOUT);
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
return;
}
else if(createCmd.equals("CLASSIC-1K")) {
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=MF_CLASSIC_1K", ChameleonIO.TIMEOUT);
if(!ChameleonIO.REVE_BOARD)
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=MF_CLASSIC_1K", ChameleonIO.TIMEOUT);
else
ChameleonIO.executeChameleonMiniCommand(serialPort, "configmy=MF_CLASSIC_1K", ChameleonIO.TIMEOUT);
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
return;
}
else if(createCmd.equals("CLASSIC-4K")) {
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=MF_CLASSIC_4K", ChameleonIO.TIMEOUT);
if(!ChameleonIO.REVE_BOARD)
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=MF_CLASSIC_4K", ChameleonIO.TIMEOUT);
else
ChameleonIO.executeChameleonMiniCommand(serialPort, "configmy=MF_CLASSIC_4K", ChameleonIO.TIMEOUT);
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
return;
}
Expand Down Expand Up @@ -887,21 +912,25 @@ else if(createCmd.equals("MFU-EV1-164B")) {
return;
}
else if(createCmd.equals("CFGNONE")) {
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=NONE", ChameleonIO.TIMEOUT);
if(!ChameleonIO.REVE_BOARD)
ChameleonIO.executeChameleonMiniCommand(serialPort, "CONFIG=NONE", ChameleonIO.TIMEOUT);
else
ChameleonIO.executeChameleonMiniCommand(serialPort, "configmy=NONE", ChameleonIO.TIMEOUT);
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
return;
}
else if(createCmd.equals("RESET")) { // need to re-establish the usb connection:
ChameleonIO.executeChameleonMiniCommand(serialPort, "RESET", ChameleonIO.TIMEOUT);
else if(createCmd.equals("RESET") || createCmd.equals("resetmy")) { // need to re-establish the usb connection:
ChameleonIO.executeChameleonMiniCommand(serialPort, createCmd, ChameleonIO.TIMEOUT);
ChameleonIO.deviceStatus.statsUpdateHandler.removeCallbacks(ChameleonIO.deviceStatus.statsUpdateRunnable);
closeSerialPort(serialPort);
configureSerialPort(null, usbReaderCallback);
ChameleonIO.deviceStatus.updateAllStatusAndPost(true);
return;
}
else if(createCmd.equals("RANDOM UID")) {
String uidCmd = ChameleonIO.REVE_BOARD ? "uidmy=" : "UID=";
byte[] randomBytes = Utils.getRandomBytes(ChameleonIO.deviceStatus.UIDSIZE);
String sendCmd = "UID=" + Utils.bytes2Hex(randomBytes).replace(" ", "");
String sendCmd = uidCmd + Utils.bytes2Hex(randomBytes).replace(" ", "");
ChameleonIO.executeChameleonMiniCommand(serialPort, sendCmd, ChameleonIO.TIMEOUT);
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
}
Expand All @@ -924,7 +953,8 @@ else if(createCmd.equals("ONCLICK")) {
msgParam = "SYSTICK Millis := " + getSettingFromDevice(serialPort, "SYSTICK?");
}
else if(createCmd.equals("GETUID")) {
String rParam = getSettingFromDevice(serialPort, "GETUID");
String queryCmd = ChameleonIO.REVE_BOARD ? "uidmy?" : "GETUID";
String rParam = getSettingFromDevice(serialPort, queryCmd);
msgParam = "GETUID: " + rParam;
}
else if(createCmd.equals("SEND") || createCmd.equals("SEND_RAW")) {
Expand Down Expand Up @@ -1071,7 +1101,8 @@ else if(uidAction.equals("SHIFT_LEFT")){
System.arraycopy(uid, 0, nextUID, 1, uid.length - 1);
uid = nextUID;
}
getSettingFromDevice(serialPort, String.format(Locale.ENGLISH, "UID=%s", Utils.bytes2Hex(uid).replace(" ", "")));
String uidCmd = ChameleonIO.REVE_BOARD ? "uidmy" : "UID";
getSettingFromDevice(serialPort, String.format(Locale.ENGLISH, "%s=%s", uidCmd, Utils.bytes2Hex(uid).replace(" ", "")));
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
appendNewLog(LogEntryMetadataRecord.createDefaultEventRecord("UID", "Next device UID set to " + Utils.bytes2Hex(uid).replace(" ", ":")));
}
Expand Down Expand Up @@ -1327,8 +1358,10 @@ public void actionButtonExportLogDownload(View view) {
ExportTools.downloadByXModem("LOGDOWNLOAD", "devicelog", false);
else if(action.equals("LOGDOWNLOAD2LIVE"))
ExportTools.downloadByXModem("LOGDOWNLOAD", "devicelog", true);
else if(action.equals("DOWNLOAD"))
ExportTools.downloadByXModem("DOWNLOAD", "carddata-" + ChameleonIO.deviceStatus.CONFIG, false);
else if(action.equals("DOWNLOAD")) {
String dldCmd = ChameleonIO.REVE_BOARD ? "downloadmy" : "DOWNLOAD";
ExportTools.downloadByXModem(dldCmd, "carddata-" + ChameleonIO.deviceStatus.CONFIG, false);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ else if(tabNumber == TAB_TOOLS && LiveLoggerActivity.spinnerRButtonLongAdapter =
connectPeripheralSpinnerAdapter(view, R.id.LButtonLongSpinner, R.array.LButtonLongOptions, LiveLoggerActivity.spinnerLButtonLongAdapter, "LBUTTON_LONG?");
connectPeripheralSpinnerAdapter(view, R.id.LEDRedSpinner, R.array.LEDRedOptions, LiveLoggerActivity.spinnerLEDRedAdapter, "LEDRED?");
connectPeripheralSpinnerAdapter(view, R.id.LEDGreenSpinner, R.array.LEDGreenOptions, LiveLoggerActivity.spinnerLEDGreenAdapter, "LEDGREEN?");
connectPeripheralSpinnerAdapter(view, R.id.ButtonMyRevEBoardSpinner, R.array.ButtonMyRevEBoards, LiveLoggerActivity.spinnerButtonMyAdapter, "buttonmy?");
connectPeripheralSpinnerAdapter(view, R.id.LogModeSpinner, R.array.LogModeOptions, LiveLoggerActivity.spinnerLogModeAdapter, "LOGMODE?");
connectCommandListSpinnerAdapter(view, R.id.FullCmdListSpinner, R.array.FullCommandList, LiveLoggerActivity.spinnerCmdShellAdapter, "");

Expand Down Expand Up @@ -283,7 +284,8 @@ public void onStopTrackingTouch(SeekBar seekBar) {
@Override
public void onScrollStateChange(NumberPicker numberPicker, int scrollState) {
if (scrollState == NumberPicker.OnScrollListener.SCROLL_STATE_IDLE) {
LiveLoggerActivity.getSettingFromDevice(LiveLoggerActivity.serialPort, "SETTING=" + numberPicker.getValue());
String settingCmd = ChameleonIO.REVE_BOARD ? "settingmy=" : "SETTING=";
LiveLoggerActivity.getSettingFromDevice(LiveLoggerActivity.serialPort, settingCmd + numberPicker.getValue());
ChameleonIO.deviceStatus.updateAllStatusAndPost(false);
}
}
Expand Down
Binary file added app/src/main/res/drawable/apdubullet16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/buttonmy24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/clearmy24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/copysquare16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/fingerprint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/reset24v2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/rssimy24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/signalbars1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/signalbars2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/signalbars3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/signalbars4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/src/main/res/drawable/signalbars5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/uididentifier16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/versionmy24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 02d2924

Please sign in to comment.