Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 91 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,91 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.externalNativeBuild
# Built application files
*.apk
*.aar
*.ap_
*.aab

# mac specific
.DS_Store

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
# Android Studio 3 in .gitignore file.
.idea/caches
.idea/modules.xml
# Comment next line if keeping position of elements in Navigation Editor is relevant for you
.idea/navEditor.xml

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# Version control
vcs.xml

# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/

# Android Profiling
*.hprof
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "com.csl.cs108ademoapp"
minSdkVersion 19
targetSdkVersion 28
versionCode 24
versionName "1.19.0"
versionCode 25
versionName "1.20.0"
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
Expand Down
93 changes: 80 additions & 13 deletions app/src/main/java/com/csl/cs108ademoapp/AccessTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,35 @@ public enum TaskCancelRReason {
boolean done = false;
boolean ending = false;
private String endingMessaage;
int qValue;
boolean repeat, nextNew;

int qValue=0;
boolean repeat=false, nextNew=false;
boolean bEnableErrorPopWindow=true;

boolean gotInventory;
int batteryCountInventory_old;

public AccessTask(Button button, boolean invalidRequest,
String selectMask, int selectBank, int selectOffset,
String strPassword, int powerLevel, Cs108Connector.HostCommands hostCommand, boolean bEnableErrorPopWindow) {
this.button = button;
this.registerTagGot = registerTagGot;
this.registerVoltageLevel = registerVoltageLevel;

this.invalidRequest = invalidRequest; MainActivity.mCs108Library4a.appendToLog("invalidRequest = " + invalidRequest);
this.selectMask = selectMask;
this.selectBank = selectBank;
this.selectOffset = selectOffset;
this.strPassword = strPassword;
this.powerLevel = powerLevel;
this.hostCommand = hostCommand;
this.bEnableErrorPopWindow = bEnableErrorPopWindow;
if (true) {
total = 0;
tagList.clear();
}
preExecute();
}
public AccessTask(Button button, TextView textViewWriteCount, boolean invalidRequest,
String selectMask, int selectBank, int selectOffset,
String strPassword, int powerLevel, Cs108Connector.HostCommands hostCommand,
Expand Down Expand Up @@ -69,15 +93,15 @@ public AccessTask(Button button, TextView textViewWriteCount, boolean invalidReq
total = 0;
tagList.clear();
}
preExecute();
}

void preExecute() {
accessResult = null;
playerO = MainActivity.sharedObjects.playerO;
playerN = MainActivity.sharedObjects.playerN;
playerN.start();
}
//playerN.start();

@Override
protected void onPreExecute() {
buttonText = button.getText().toString().trim();
String buttonText1 = null; String strLastChar = buttonText.substring(buttonText.length()-1);
if (strLastChar.toUpperCase().matches("E")) {
Expand Down Expand Up @@ -158,7 +182,7 @@ else if (rx000pkgData != null) {
} else if (rx000pkgData.responseType == Cs108Connector.HostCmdResponseTypes.TYPE_18K6C_TAG_ACCESS) {
if (true) {
if (rx000pkgData.decodedError == null) {
if (done == false) { accessResult = rx000pkgData.decodedResult; }
if (done == false) { accessResult = rx000pkgData.decodedResult; MainActivity.mCs108Library4a.appendToLog("HelloA, accResult=" + accessResult);}
done = true;
publishProgress(null, rx000pkgData.decodedResult);
}
Expand Down Expand Up @@ -194,18 +218,19 @@ else if (repeat && (nextNew == false || resultError.length() != 0)) {
String tagInventoried = null;
@Override
protected void onProgressUpdate(String... output) {
if (output[0] != null) {
if (true) progressUpdate(output);
else if (output[0] != null) {
if (output[0].length() == 2) {
if (output[0].contains("TT")) {
gotInventory = true;
if (registerTagGot != null) registerTagGot.setText(output[1]);
boolean matched = false;
for (int i = 0; i < tagList.size(); i++) {
if (output[1].matches(tagList.get(i))) {
matched = true;
break;
}
}
if (registerTagGot != null) registerTagGot.setText(output[1]);
if (matched == false) tagInventoried = output[1];
} else if (output[0].contains("WW")) {
long timePeriod = (System.currentTimeMillis() - startTimeMillis) / 1000;
Expand Down Expand Up @@ -249,6 +274,45 @@ protected void onPostExecute(String result) {
DeviceConnectTask4RegisterEnding();
}

protected void progressUpdate(String... output) {
if (output[0] != null) {
if (output[0].length() == 2) {
if (output[0].contains("TT")) {
gotInventory = true;
boolean matched = false;
for (int i = 0; i < tagList.size(); i++) {
if (output[1].matches(tagList.get(i))) {
matched = true;
break;
}
}
if (registerTagGot != null) registerTagGot.setText(output[1]);
if (matched == false) tagInventoried = output[1];
} else if (output[0].contains("WW")) {
long timePeriod = (System.currentTimeMillis() - startTimeMillis) / 1000;
if (timePeriod > 0) {
if (registerRunTime != null) registerRunTime.setText(String.format("Run time: %d sec", timePeriod));
}
} else if (taskCancelReason == TaskCancelRReason.NULL) {
if (registerVoltageLevel != null) registerVoltageLevel.setText(MainActivity.mCs108Library4a.getBatteryDisplay(true));
}
} else {
resultError += output[0];
if (true)
MainActivity.mCs108Library4a.appendToLog("output[0]: " + output[0] + ", resultError = " + resultError);
}
} else {
if (registerYield != null) {
if (tagInventoried != null) {
tagList.add(tagInventoried);
tagInventoried = null;
}
registerYield.setText("Unique:" + Integer.toString(tagList.size()));
}
if (registerTotal != null) registerTotal.setText("Total:" + Integer.toString(++total));
}
}

void DeviceConnectTask4RegisterEnding() {
String strErrorMessage = "";
if (false) {
Expand All @@ -267,7 +331,7 @@ void DeviceConnectTask4RegisterEnding() {
switch (taskCancelReason) {
case NULL:
if (accessResult == null || (resultError != null && resultError.length() != 0) || (endingMessaage != null && endingMessaage.length() != 0)) strErrorMessage += ("Finish as COMMAND END is received " + (gotInventory ? "WITH" : "WITHOUT") + " tag response");
else Toast.makeText(MainActivity.mContext, R.string.toast_abort_by_SUCCESS, Toast.LENGTH_SHORT).show();
//else Toast.makeText(MainActivity.mContext, R.string.toast_abort_by_SUCCESS, Toast.LENGTH_SHORT).show();
break;
case STOP:
strErrorMessage += "Finish as STOP is pressed. ";
Expand All @@ -290,9 +354,12 @@ void DeviceConnectTask4RegisterEnding() {
if (strErrorMessage.length() != 0) endingMessaage = strErrorMessage;
button.setText(buttonText);
if (endingMessaage != null) {
if (endingMessaage.length() != 0) {
CustomPopupWindow customPopupWindow = new CustomPopupWindow(MainActivity.mContext);
customPopupWindow.popupStart(endingMessaage, false);
if (endingMessaage.length() != 0 || true) {
MainActivity.mCs108Library4a.appendToLog("endingMessage=" + endingMessaage);
if (bEnableErrorPopWindow) {
CustomPopupWindow customPopupWindow = new CustomPopupWindow(MainActivity.mContext);
customPopupWindow.popupStart(endingMessaage, false);
}
}
}
}
Expand Down
Loading