Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #48

Merged
merged 9 commits into from
Apr 18, 2024
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
18 changes: 12 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 33
namespace 'com.csl.cs108ademoapp'
buildFeatures {
buildConfig true
}

compileSdk 34
defaultConfig {
applicationId "com.csl.cs108ademoapp"
minSdkVersion 19
targetSdkVersion 33
versionCode 38
versionName "2.8.22"
minSdk 21
targetSdk 34
versionCode 41
versionName "2.14.0"
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.google.android.material:material:1.11.0'
implementation project(':cs108library4a')
implementation 'com.google.android.material:material:1.9.0'
implementation project(':cslibrary4a')
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"type": "SINGLE",
"filters": [],
"attributes": [],
"versionCode": 38,
"versionName": "2.8.22",
"versionCode": 39,
"versionName": "2.10.5",
"outputFile": "app-release.apk"
}
],
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.csl.cs108ademoapp">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
Expand All @@ -18,7 +17,7 @@
android:requestLegacyExternalStorage="true"
android:theme="@style/AppTheme">

<service android:name=".CustomIME"
<service android:name="CustomIME"
android:label="@string/app_ime"
android:exported="true"
android:permission="android.permission.BIND_INPUT_METHOD">
Expand All @@ -29,7 +28,7 @@
</service>

<activity
android:name=".MainActivity"
android:name="MainActivity"
android:exported="true"
android:screenOrientation="portrait">
<intent-filter>
Expand Down
47 changes: 31 additions & 16 deletions app/src/main/java/com/csl/cs108ademoapp/AccessTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import android.widget.TextView;
import android.widget.Toast;

import com.csl.cs108library4a.Cs108Library4A;
import com.csl.cslibrary4a.RfidReaderChipData;

import java.util.ArrayList;

Expand All @@ -18,6 +18,7 @@ public enum TaskCancelRReason {
}
public TaskCancelRReason taskCancelReason;
public String accessResult;
public String accessTagEpc;
Handler mHandler = new Handler();
Runnable updateRunnable = null;

Expand All @@ -27,7 +28,7 @@ public enum TaskCancelRReason {
boolean invalidRequest;
String selectMask; int selectBank, selectOffset;
String strPassword; int powerLevel;
Cs108Library4A.HostCommands hostCommand;
RfidReaderChipData.HostCommands hostCommand;

CustomMediaPlayer playerO, playerN;

Expand All @@ -46,10 +47,11 @@ public enum TaskCancelRReason {

boolean gotInventory;
int batteryCountInventory_old;
boolean bSkipClearFilter = false;

public AccessTask(Button button, boolean invalidRequest,
String selectMask, int selectBank, int selectOffset,
String strPassword, int powerLevel, Cs108Library4A.HostCommands hostCommand,
String strPassword, int powerLevel, RfidReaderChipData.HostCommands hostCommand,
boolean bEnableErrorPopWindow, Runnable updateRunnable) {
this.button = button;
this.registerTagGot = registerTagGot;
Expand All @@ -72,10 +74,9 @@ public AccessTask(Button button, boolean invalidRequest,
}
public AccessTask(Button button, TextView textViewWriteCount, boolean invalidRequest,
String selectMask, int selectBank, int selectOffset,
String strPassword, int powerLevel, Cs108Library4A.HostCommands hostCommand,
int qValue, int repeat, boolean resetCount,
TextView registerRunTime, TextView registerTagGot, TextView registerVoltageLevel,
TextView registerYieldView, TextView registerTotalView) {
String strPassword, int powerLevel, RfidReaderChipData.HostCommands hostCommand,
int qValue, int repeat, boolean resetCount, boolean bSkipClearFilter,
TextView registerRunTime, TextView registerTagGot, TextView registerVoltageLevel, TextView registerYieldView, TextView registerTotalView) {
this.button = button;
this.registerTotal = textViewWriteCount;
this.registerRunTime = registerRunTime;
Expand All @@ -94,6 +95,7 @@ public AccessTask(Button button, TextView textViewWriteCount, boolean invalidReq
this.qValue = qValue;
if (repeat > 255) repeat = 255;
this.repeat = repeat;
this.bSkipClearFilter = bSkipClearFilter;
if (resetCount) {
total = 0;
tagList.clear();
Expand All @@ -105,7 +107,7 @@ public void setRunnable(Runnable updateRunnable) {
}

void preExecute() {
accessResult = null;
accessResult = null; MainActivity.csLibrary4A.appendToLog("accessResult is set null");
playerO = MainActivity.sharedObjects.playerO;
playerN = MainActivity.sharedObjects.playerN;
//playerN.start();
Expand Down Expand Up @@ -135,7 +137,7 @@ void preExecute() {

if (invalidRequest == false) {
if (strPassword.length() != 8) { invalidRequest = true; MainActivity.csLibrary4A.appendToLog("strPassword.length = " + strPassword.length() + " (not 8)."); }
else if (hostCommand == Cs108Library4A.HostCommands.CMD_18K6CKILL) {
else if (hostCommand == RfidReaderChipData.HostCommands.CMD_18K6CKILL) {
if (MainActivity.csLibrary4A.setRx000KillPassword(strPassword) == false) {
invalidRequest = true; MainActivity.csLibrary4A.appendToLog("setRx000KillPassword is failed");
}
Expand All @@ -149,14 +151,21 @@ else if (hostCommand == Cs108Library4A.HostCommands.CMD_18K6CKILL) {
invalidRequest = true; MainActivity.csLibrary4A.appendToLog("setAccessRetry is failed");
}
}
MainActivity.csLibrary4A.appendToLog("setSelectCriteria: invalidRequest = " + invalidRequest + ", repeat = " + repeat + ", bSkipClearFilter = " + bSkipClearFilter + ", powerLevel = " + powerLevel + ", skipSelect = " + skipSelect);
if (invalidRequest == false) {
if (DEBUG) MainActivity.csLibrary4A.appendToLog("AccessTask(): powerLevel = " + powerLevel);
int matchRep = 1;
if (repeat > 1) matchRep = repeat;
if (bSkipClearFilter == false) {
MainActivity.csLibrary4A.appendToLog("Going to setSelectCriteria disable");
MainActivity.csLibrary4A.setSelectCriteriaDisable(-1);
}
if (powerLevel < 0 || powerLevel > 330) invalidRequest = true;
else if (skipSelect) { }
else if (MainActivity.csLibrary4A.setSelectedTag(selectMask, selectBank, selectOffset, powerLevel, qValue, matchRep) == false) {
invalidRequest = true; MainActivity.csLibrary4A.appendToLog("setSelectedTag is failed with selectMask = " + selectMask + ", selectBank = " + selectBank + ", selectOffset = " + selectOffset + ", powerLevel = " + powerLevel);
else if (skipSelect == false) {
MainActivity.csLibrary4A.appendToLog("setSelectCriteria: Going to setSelectTag");
if (MainActivity.csLibrary4A.setSelectedTag(selectMask, selectBank, selectOffset, powerLevel, qValue, matchRep) == false) {
invalidRequest = true; MainActivity.csLibrary4A.appendToLog("setSelectedTag is failed with selectMask = " + selectMask + ", selectBank = " + selectBank + ", selectOffset = " + selectOffset + ", powerLevel = " + powerLevel);
}
}
}
gotInventory = false;
Expand All @@ -173,10 +182,13 @@ else if (MainActivity.csLibrary4A.setSelectedTag(selectMask, selectBank, selectO
}
}

boolean accessCompleteReceived = false;

@Override
protected String doInBackground(Void... a) {
boolean ending = false;
int iTimeOut = 5000;
accessCompleteReceived = false;

while (MainActivity.csLibrary4A.isBleConnected() && isCancelled() == false && ending == false) {
int batteryCount = MainActivity.csLibrary4A.getBatteryCount();
Expand All @@ -189,12 +201,13 @@ protected String doInBackground(Void... a) {
publishProgress("WW");
}
byte[] notificationData = MainActivity.csLibrary4A.onNotificationEvent();
Cs108Library4A.Rx000pkgData rx000pkgData = MainActivity.csLibrary4A.onRFIDEvent();
RfidReaderChipData.Rx000pkgData rx000pkgData = MainActivity.csLibrary4A.onRFIDEvent();
if (MainActivity.csLibrary4A.mrfidToWriteSize() != 0) timeMillis = System.currentTimeMillis();
else if (rx000pkgData != null) {
if (rx000pkgData.responseType == null) {
publishProgress("null response");
} else if (rx000pkgData.responseType == Cs108Library4A.HostCmdResponseTypes.TYPE_18K6C_TAG_ACCESS) {
} else if (rx000pkgData.responseType == RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_TAG_ACCESS) {
accessCompleteReceived = true;
MainActivity.csLibrary4A.appendToLog("rx000pkgData.dataValues = " + MainActivity.csLibrary4A.byteArrayToString(rx000pkgData.dataValues));
if (rx000pkgData.decodedError == null) {
if (done == false) {
Expand All @@ -207,7 +220,8 @@ else if (rx000pkgData != null) {
done = true;
} else publishProgress(rx000pkgData.decodedError);
iTimeOut = 1000;
} else if (rx000pkgData.responseType == Cs108Library4A.HostCmdResponseTypes.TYPE_COMMAND_END) {
} else if (rx000pkgData.responseType == RfidReaderChipData.HostCmdResponseTypes.TYPE_COMMAND_END) {
if (hostCommand == RfidReaderChipData.HostCommands.CMD_18K6CKILL && accessCompleteReceived == false) accessResult = "";
MainActivity.csLibrary4A.appendToLog("BtData: repeat = " + repeat + ", decodedError = " + rx000pkgData.decodedError + ", resultError = " + resultError);
if (rx000pkgData.decodedError != null) { endingMessaage = rx000pkgData.decodedError; ending = true; }
else if (repeat > 0 && resultError.length() == 0) {
Expand All @@ -218,7 +232,8 @@ else if (repeat > 0 && resultError.length() == 0) {
endingMessaage = "";
ending = true;
}
} else if (rx000pkgData.responseType == Cs108Library4A.HostCmdResponseTypes.TYPE_18K6C_INVENTORY) {
} else if (rx000pkgData.responseType == RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_INVENTORY) {
accessTagEpc = MainActivity.csLibrary4A.byteArrayToString(rx000pkgData.decodedEpc);
done = false;
publishProgress("TT", MainActivity.csLibrary4A.byteArrayToString(rx000pkgData.decodedEpc));
} else {
Expand Down
31 changes: 20 additions & 11 deletions app/src/main/java/com/csl/cs108ademoapp/AccessTask1.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import android.widget.Button;
import android.widget.Toast;

import com.csl.cs108library4a.Cs108Library4A;
import com.csl.cslibrary4a.RfidReaderChipData;

public class AccessTask1 {
Button button;
Expand All @@ -14,24 +14,24 @@ public class AccessTask1 {
int selectBank, selectOffset;
String strPassword;
int powerLevel;
Cs108Library4A.HostCommands hostCommand;
RfidReaderChipData.HostCommands hostCommand;
Runnable updateRunnable = null;

AccessTask accessTask;
public AccessTask1(Button button, boolean invalidRequest,
int accBank, int accOffset, int accSize, int accBlockCount, String accWriteData,
String selectMask, int selectBank, int selectOffset,
String strPassword, int powerLevel, Cs108Library4A.HostCommands hostCommand, Runnable updateRunnable) {
String strPassword, int powerLevel, RfidReaderChipData.HostCommands hostCommand, Runnable updateRunnable) {
this.button = button;
this.invalidRequest = invalidRequest;
MainActivity.csLibrary4A.appendToLog("HelloK: invalidRequest=" + invalidRequest);
this.accBank = accBank;
this.accOffset = accOffset;
if (hostCommand == Cs108Library4A.HostCommands.CMD_18K6CWRITE) { if (accBlockCount > 16) accBlockCount = 16; }
if (hostCommand == RfidReaderChipData.HostCommands.CMD_18K6CWRITE) { if (accBlockCount > 16) accBlockCount = 16; }
else if (accBlockCount > 255) accBlockCount = 255;
this.accBlockCount = accBlockCount;
if (accWriteData == null) accWriteData = "";
if (hostCommand == Cs108Library4A.HostCommands.CMD_18K6CWRITE) {
if (hostCommand == RfidReaderChipData.HostCommands.CMD_18K6CWRITE) {
MainActivity.csLibrary4A.appendToLog("strOut: accWriteData=" + accWriteData);
accWriteData = deformatWriteAccessData(accWriteData);
if (accWriteData.length() < accSize * 4) {
Expand Down Expand Up @@ -96,7 +96,7 @@ else if (accessTask.getStatus() != AsyncTask.Status.FINISHED) { }
else if (button.getText().toString().indexOf("ING") > 0) { }
else if (isResultReady == false) {
String strAccessResult = "";
if (hostCommand != Cs108Library4A.HostCommands.CMD_18K6CREAD || accBank != 3) strAccessResult = accessTask.accessResult;
if (hostCommand != RfidReaderChipData.HostCommands.CMD_18K6CREAD || accBank != 3) strAccessResult = accessTask.accessResult;
else {
int word4line = 7;
for (int i = 0; i < accSizeNow; i=i+word4line) {
Expand Down Expand Up @@ -144,10 +144,19 @@ else if (isResultReady == false) {
}
public String accessResult;
public String getResult() {
MainActivity.csLibrary4A.appendToLog("HelloA: accessResult=" + accessResult);
if (accessTask == null) return null;
if (accessTask.getStatus() != AsyncTask.Status.FINISHED) return null;
if (button.getText().toString().indexOf("ING") > 0) return null;
MainActivity.csLibrary4A.appendToLog("HelloA: accessResult = " + accessResult);
if (accessTask == null) {
MainActivity.csLibrary4A.appendToLog("accessTask is null");
return null;
}
if (accessTask.getStatus() != AsyncTask.Status.FINISHED) {
MainActivity.csLibrary4A.appendToLog("accessTask.getStatus is not finished");
return null;
}
if (button.getText().toString().indexOf("ING") > 0) {
MainActivity.csLibrary4A.appendToLog("button is still ing");
return null;
}
return accessResult;
}

Expand Down Expand Up @@ -178,7 +187,7 @@ void setup() {
}
}
}
if (invalidRequest == false && hostCommand == Cs108Library4A.HostCommands.CMD_18K6CWRITE) {
if (invalidRequest == false && hostCommand == RfidReaderChipData.HostCommands.CMD_18K6CWRITE) {
if (accWriteData.length() > accSizeNow * 4) accWriteDataNow = accWriteData.substring(0, accSizeNow*4);
else accWriteDataNow = accWriteData;
if (MainActivity.csLibrary4A.setAccessWriteData(accWriteDataNow) == false) {
Expand Down
17 changes: 9 additions & 8 deletions app/src/main/java/com/csl/cs108ademoapp/CustomIME.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import android.view.View;
import android.view.inputmethod.InputConnection;

import com.csl.cs108library4a.Cs108Library4A;
import com.csl.cslibrary4a.RfidReaderChipData;

import java.util.ArrayList;

Expand All @@ -29,9 +29,9 @@ public View onCreateInputView() {
super.onCreateInputView();;
mHandler.post(serviceRunnable);
KeyboardView keyboardView = null;
if (false) {
if (true) {
keyboardView = (KeyboardView) getLayoutInflater().inflate(R.layout.keyboard_view, null);
Keyboard keyboard = new Keyboard(this, R.xml.number_pad);
Keyboard keyboard = new Keyboard(this, R.xml.number_pad1);
keyboardView.setKeyboard(keyboard);
//keyboardView.setOnKeyboardActionListener(this);
}
Expand All @@ -51,8 +51,9 @@ public void onDestroy() {
@Override
public void run() {
String strCurrentIME = Settings.Secure.getString(getContentResolver(), Settings.Secure.DEFAULT_INPUT_METHOD);
appendToLog("CustomIME Debug 0 with " + strCurrentIME);
if (strCurrentIME.contains("com.csl.cs108ademoapp") == false) return;
String strCompare = getPackageName();
appendToLog("CustomIME Debug 0 with strCurrentIME = " + strCurrentIME + ", strCompare = " + strCompare);
if (strCurrentIME.contains(strCompare) == false) return;

mHandler.postDelayed(serviceRunnable, 1000);
if (MainActivity.sharedObjects == null) return;
Expand Down Expand Up @@ -86,8 +87,8 @@ public void run() {
if (matched == false && strEpc != null) {
epcArrayList.add(strEpc);
InputConnection ic = getCurrentInputConnection();
strEpc = (MainActivity.wedgePrefix != null ? MainActivity.wedgePrefix : "") + strEpc
+ (MainActivity.wedgeSuffix != null ? MainActivity.wedgeSuffix : "");
if (MainActivity.wedgePrefix != null) strEpc = MainActivity.wedgePrefix + strEpc;
if (MainActivity.wedgeSuffix != null) strEpc += MainActivity.wedgeSuffix;
switch (MainActivity.wedgeDelimiter) {
default:
strEpc += "\n";
Expand Down Expand Up @@ -124,7 +125,7 @@ void startStopHandler() {
if ((started && MainActivity.csLibrary4A.getTriggerButtonStatus()) || (started == false && MainActivity.csLibrary4A.getTriggerButtonStatus() == false)) return;
if (started == false) {
appendToLog("CustomIME Debug 11");
MainActivity.csLibrary4A.startOperation(Cs108Library4A.OperationTypes.TAG_INVENTORY);
MainActivity.csLibrary4A.startOperation(RfidReaderChipData.OperationTypes.TAG_INVENTORY);
inventoryRfidTask = new InventoryRfidTask();
inventoryRfidTask.execute();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public void popupStart(String message, boolean wait) {
popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.showAtLocation(popupView, Gravity.CENTER, 0, 0);
TextView textViewDismiss = (TextView)popupView.findViewById(R.id.dismissMessage);
int iLenghtMax = 300;
if (message.length() > iLenghtMax) message = message.substring(0, iLenghtMax) + " .....";
//int iLenghtMax = 300;
//if (message.length() > iLenghtMax) message = message.substring(0, iLenghtMax) + " .....";
csLibrary4A.appendToLog("SaveList2ExternalTask: popupStart message = " + message);
textViewDismiss.setText(message);
Button btnDismiss = (Button)popupView.findViewById(R.id.dismiss);
Expand Down
Loading