diff --git a/app/build.gradle b/app/build.gradle index 83e4bf1..35ab697 100755 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,8 +6,8 @@ android { applicationId "com.csl.cs108ademoapp" minSdkVersion 19 targetSdkVersion 26 - versionCode 18 - versionName "1.13.0" + versionCode 19 + versionName "1.14.0" } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 diff --git a/app/release/cs108ademo-181018-v1.12.1-app-release.zip b/app/release/cs108ademo-181018-v1.12.1-app-release.zip deleted file mode 100755 index 32904b3..0000000 Binary files a/app/release/cs108ademo-181018-v1.12.1-app-release.zip and /dev/null differ diff --git a/app/release/cs108ademo-181022-v1.12.2-app-release.apk b/app/release/cs108ademo-181022-v1.12.2-app-release.apk deleted file mode 100755 index 190dd59..0000000 Binary files a/app/release/cs108ademo-181022-v1.12.2-app-release.apk and /dev/null differ diff --git a/app/release/cs108ademo-181022-v1.12.2-app-release.zip b/app/release/cs108ademo-181022-v1.12.2-app-release.zip deleted file mode 100755 index 85256b6..0000000 Binary files a/app/release/cs108ademo-181022-v1.12.2-app-release.zip and /dev/null differ diff --git a/app/release/cs108ademo-181022-v1.12.3-app-release.zip b/app/release/cs108ademo-181022-v1.12.3-app-release.zip deleted file mode 100755 index ae636c6..0000000 Binary files a/app/release/cs108ademo-181022-v1.12.3-app-release.zip and /dev/null differ diff --git a/app/release/cs108ademo-181218-v1.12.4-app-release.zip b/app/release/cs108ademo-181218-v1.12.4-app-release.zip deleted file mode 100755 index b098fd0..0000000 Binary files a/app/release/cs108ademo-181218-v1.12.4-app-release.zip and /dev/null differ diff --git a/app/release/cs108ademo-181219-v1.12.5-app-release.zip b/app/release/cs108ademo-181219-v1.12.5-app-release.zip deleted file mode 100755 index d1926d5..0000000 Binary files a/app/release/cs108ademo-181219-v1.12.5-app-release.zip and /dev/null differ diff --git a/app/release/cs108ademo-181219-v1.12.6-app-release.zip b/app/release/cs108ademo-181219-v1.12.6-app-release.zip deleted file mode 100755 index c5ffd2e..0000000 Binary files a/app/release/cs108ademo-181219-v1.12.6-app-release.zip and /dev/null differ diff --git a/app/release/cs108ademo-190102-v1.13.0-app-release.zip b/app/release/cs108ademo-190102-v1.13.0-app-release.zip deleted file mode 100755 index 225cbad..0000000 Binary files a/app/release/cs108ademo-190102-v1.13.0-app-release.zip and /dev/null differ diff --git a/app/release/cs108ademo-181219-v1.12.5-app-release.apk b/app/release/cs108ademo-190116-v1.13.1-app-release.apk similarity index 57% rename from app/release/cs108ademo-181219-v1.12.5-app-release.apk rename to app/release/cs108ademo-190116-v1.13.1-app-release.apk index 1f5ed13..d914bc4 100755 Binary files a/app/release/cs108ademo-181219-v1.12.5-app-release.apk and b/app/release/cs108ademo-190116-v1.13.1-app-release.apk differ diff --git a/app/release/cs108ademo-190116-v1.13.1-app-release.zip b/app/release/cs108ademo-190116-v1.13.1-app-release.zip new file mode 100755 index 0000000..8e134b8 Binary files /dev/null and b/app/release/cs108ademo-190116-v1.13.1-app-release.zip differ diff --git a/app/release/cs108ademo-181018-v1.12.1-app-release.apk b/app/release/cs108ademo-190117-v1.13.2-app-release.apk similarity index 57% rename from app/release/cs108ademo-181018-v1.12.1-app-release.apk rename to app/release/cs108ademo-190117-v1.13.2-app-release.apk index fe47ae5..cf1f04d 100755 Binary files a/app/release/cs108ademo-181018-v1.12.1-app-release.apk and b/app/release/cs108ademo-190117-v1.13.2-app-release.apk differ diff --git a/app/release/cs108ademo-190117-v1.13.2-app-release.zip b/app/release/cs108ademo-190117-v1.13.2-app-release.zip new file mode 100755 index 0000000..3279e2d Binary files /dev/null and b/app/release/cs108ademo-190117-v1.13.2-app-release.zip differ diff --git a/app/release/cs108ademo-190118-v1.13.3-app-release.apk b/app/release/cs108ademo-190118-v1.13.3-app-release.apk new file mode 100755 index 0000000..c948546 Binary files /dev/null and b/app/release/cs108ademo-190118-v1.13.3-app-release.apk differ diff --git a/app/release/cs108ademo-190118-v1.13.3-app-release.zip b/app/release/cs108ademo-190118-v1.13.3-app-release.zip new file mode 100755 index 0000000..0570b0f Binary files /dev/null and b/app/release/cs108ademo-190118-v1.13.3-app-release.zip differ diff --git a/app/release/cs108ademo-181022-v1.12.3-app-release.apk b/app/release/cs108ademo-190122-v1.13.4-app-release.apk similarity index 57% rename from app/release/cs108ademo-181022-v1.12.3-app-release.apk rename to app/release/cs108ademo-190122-v1.13.4-app-release.apk index 4178ad6..2825c9e 100755 Binary files a/app/release/cs108ademo-181022-v1.12.3-app-release.apk and b/app/release/cs108ademo-190122-v1.13.4-app-release.apk differ diff --git a/app/release/cs108ademo-190122-v1.13.4-app-release.zip b/app/release/cs108ademo-190122-v1.13.4-app-release.zip new file mode 100755 index 0000000..f671c6b Binary files /dev/null and b/app/release/cs108ademo-190122-v1.13.4-app-release.zip differ diff --git a/app/release/cs108ademo-181218-v1.12.4-app-release.apk b/app/release/cs108ademo-190124-v1.13.5-app-release.apk similarity index 57% rename from app/release/cs108ademo-181218-v1.12.4-app-release.apk rename to app/release/cs108ademo-190124-v1.13.5-app-release.apk index 3580213..d6b3489 100755 Binary files a/app/release/cs108ademo-181218-v1.12.4-app-release.apk and b/app/release/cs108ademo-190124-v1.13.5-app-release.apk differ diff --git a/app/release/cs108ademo-190124-v1.13.5-app-release.zip b/app/release/cs108ademo-190124-v1.13.5-app-release.zip new file mode 100755 index 0000000..9925909 Binary files /dev/null and b/app/release/cs108ademo-190124-v1.13.5-app-release.zip differ diff --git a/app/release/cs108ademo-190124-v1.13.6-app-release.apk b/app/release/cs108ademo-190124-v1.13.6-app-release.apk new file mode 100755 index 0000000..79aea29 Binary files /dev/null and b/app/release/cs108ademo-190124-v1.13.6-app-release.apk differ diff --git a/app/release/cs108ademo-190124-v1.13.6-app-release.zip b/app/release/cs108ademo-190124-v1.13.6-app-release.zip new file mode 100755 index 0000000..1f046ac Binary files /dev/null and b/app/release/cs108ademo-190124-v1.13.6-app-release.zip differ diff --git a/app/release/cs108ademo-190102-v1.13.0-app-release.apk b/app/release/cs108ademo-190125-v1.13.7-app-release.apk similarity index 57% rename from app/release/cs108ademo-190102-v1.13.0-app-release.apk rename to app/release/cs108ademo-190125-v1.13.7-app-release.apk index 0e1a387..0e11de9 100755 Binary files a/app/release/cs108ademo-190102-v1.13.0-app-release.apk and b/app/release/cs108ademo-190125-v1.13.7-app-release.apk differ diff --git a/app/release/cs108ademo-190125-v1.13.7-app-release.zip b/app/release/cs108ademo-190125-v1.13.7-app-release.zip new file mode 100755 index 0000000..b817e79 Binary files /dev/null and b/app/release/cs108ademo-190125-v1.13.7-app-release.zip differ diff --git a/app/release/cs108ademo-190214-v1.13.7A-app-release.apk b/app/release/cs108ademo-190214-v1.13.7A-app-release.apk new file mode 100755 index 0000000..ce3e6aa Binary files /dev/null and b/app/release/cs108ademo-190214-v1.13.7A-app-release.apk differ diff --git a/app/release/cs108ademo-190214-v1.13.7A-app-release.zip b/app/release/cs108ademo-190214-v1.13.7A-app-release.zip new file mode 100755 index 0000000..73769bb Binary files /dev/null and b/app/release/cs108ademo-190214-v1.13.7A-app-release.zip differ diff --git a/app/release/cs108ademo-190215-v1.13.8-app-release.apk b/app/release/cs108ademo-190215-v1.13.8-app-release.apk new file mode 100755 index 0000000..abdd720 Binary files /dev/null and b/app/release/cs108ademo-190215-v1.13.8-app-release.apk differ diff --git a/app/release/cs108ademo-190215-v1.13.8-app-release.zip b/app/release/cs108ademo-190215-v1.13.8-app-release.zip new file mode 100755 index 0000000..f41aa81 Binary files /dev/null and b/app/release/cs108ademo-190215-v1.13.8-app-release.zip differ diff --git a/app/release/cs108ademo-181219-v1.12.6-app-release.apk b/app/release/cs108ademo-190220-v1.14.0-app-release.apk similarity index 57% rename from app/release/cs108ademo-181219-v1.12.6-app-release.apk rename to app/release/cs108ademo-190220-v1.14.0-app-release.apk index e546ad0..b2c193f 100755 Binary files a/app/release/cs108ademo-181219-v1.12.6-app-release.apk and b/app/release/cs108ademo-190220-v1.14.0-app-release.apk differ diff --git a/app/release/cs108ademo-190220-v1.14.0-app-release.zip b/app/release/cs108ademo-190220-v1.14.0-app-release.zip new file mode 100755 index 0000000..bb3ac5b Binary files /dev/null and b/app/release/cs108ademo-190220-v1.14.0-app-release.zip differ diff --git a/app/release/output.json b/app/release/output.json index 899a14b..ee83254 100755 --- a/app/release/output.json +++ b/app/release/output.json @@ -1 +1 @@ -[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":18,"versionName":"1.13.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file +[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":19,"versionName":"1.14.0","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release"},"path":"app-release.apk","properties":{}}] \ No newline at end of file diff --git a/app/src/main/java/com/csl/cs108ademoapp/AccessTask.java b/app/src/main/java/com/csl/cs108ademoapp/AccessTask.java index 0115d30..59d0420 100755 --- a/app/src/main/java/com/csl/cs108ademoapp/AccessTask.java +++ b/app/src/main/java/com/csl/cs108ademoapp/AccessTask.java @@ -10,7 +10,8 @@ import java.util.ArrayList; public class AccessTask extends AsyncTask { - final boolean DEBUG = false; + final boolean DEBUG = true; + final boolean skipSelect = false; public enum TaskCancelRReason { NULL, INVALD_REQUEST, DESTORY, STOP, BUTTON_RELEASE, TIMEOUT } @@ -37,6 +38,7 @@ public enum TaskCancelRReason { private String endingMessaage; int qValue; boolean repeat, nextNew; + boolean gotInventory; int batteryCountInventory_old; public AccessTask(Button button, TextView textViewWriteCount, boolean invalidRequest, @@ -53,7 +55,7 @@ public AccessTask(Button button, TextView textViewWriteCount, boolean invalidReq this.registerYield = registerYieldView; this.registerTotal = registerTotalView; - this.invalidRequest = invalidRequest; + this.invalidRequest = invalidRequest; MainActivity.mCs108Library4a.appendToLog("invalidRequest = " + invalidRequest); this.selectMask = selectMask; this.selectBank = selectBank; this.selectOffset = selectOffset; @@ -115,14 +117,17 @@ else if (hostCommand == Cs108Connector.HostCommands.CMD_18K6CKILL) { int matchRep = 0; if (repeat == false || nextNew) matchRep = 1; if (powerLevel < 0 || powerLevel > 330) invalidRequest = true; + else if (skipSelect) { } else if (MainActivity.mCs108Library4a.setSelectedTag(null, selectMask, selectBank, selectOffset, powerLevel, qValue, matchRep) == false) { invalidRequest = true; MainActivity.mCs108Library4a.appendToLog("setSelectedTag is failed with selectMask = " + selectMask + ", selectBank = " + selectBank + ", selectOffset = " + selectOffset + ", powerLevel = " + powerLevel); } } + gotInventory = false; taskCancelReason = TaskCancelRReason.NULL; if (invalidRequest) { cancel(true); taskCancelReason = TaskCancelRReason.INVALD_REQUEST; + MainActivity.mCs108Library4a.appendToLog("invalidRequest A= " + invalidRequest); } else { if (MainActivity.mCs108Library4a.checkHostProcessorVersion(MainActivity.mCs108Library4a.getMacVer(), 2, 6, 8)) { MainActivity.mCs108Library4a.setInvModeCompact(false); @@ -192,6 +197,7 @@ protected void onProgressUpdate(String... output) { 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++) { @@ -260,7 +266,7 @@ void DeviceConnectTask4RegisterEnding() { strErrorMessage = ""; switch (taskCancelReason) { case NULL: - if (accessResult == null || (resultError != null && resultError.length() != 0) || (endingMessaage != null && endingMessaage.length() != 0)) strErrorMessage += "Finish as COMMAND END is received"; + 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(); break; case STOP: diff --git a/app/src/main/java/com/csl/cs108ademoapp/DrawerListContent.java b/app/src/main/java/com/csl/cs108ademoapp/DrawerListContent.java index 97c7353..e7538c0 100755 --- a/app/src/main/java/com/csl/cs108ademoapp/DrawerListContent.java +++ b/app/src/main/java/com/csl/cs108ademoapp/DrawerListContent.java @@ -57,7 +57,7 @@ public static DrawerPositions toDrawerPosition(int x) { addItem(new DrawerItem("8", "Security", R.drawable.dl_access)); addItem(new DrawerItem("9", "Register Tag", R.drawable.dl_rr)); addItem(new DrawerItem("10", "Cold Chain CS8300", R.drawable.dl_loc)); - addItem(new DrawerItem("11", "RFMicron Temperature", R.drawable.dl_loc)); + addItem(new DrawerItem("11", "RFMicron", R.drawable.dl_loc)); addItem(new DrawerItem("12", "UCODE DNA", R.drawable.dl_loc)); addItem(new DrawerItem("13", "Wedge", R.drawable.dl_rr)); } diff --git a/app/src/main/java/com/csl/cs108ademoapp/InventoryRfidTask.java b/app/src/main/java/com/csl/cs108ademoapp/InventoryRfidTask.java index ecd78bd..f48b0bf 100755 --- a/app/src/main/java/com/csl/cs108ademoapp/InventoryRfidTask.java +++ b/app/src/main/java/com/csl/cs108ademoapp/InventoryRfidTask.java @@ -257,6 +257,7 @@ else if (output[0].contains("WW")) { String strEpc = MainActivity.mCs108Library4a.byteArrayToString(rx000pkgData.decodedEpc); String strExtra2 = null; if (rx000pkgData.decodedData2 != null) strExtra2 = MainActivity.mCs108Library4a.byteArrayToString(rx000pkgData.decodedData2); String strExtra1 = null; if (rx000pkgData.decodedData1 != null) strExtra1 = MainActivity.mCs108Library4a.byteArrayToString(rx000pkgData.decodedData1); + String strAddresss = strEpc; // strEpc, strEpc + strExtra1 + strExtra2 String strCrc16 = null; if (rx000pkgData.decodedCrc != null) strCrc16 = MainActivity.mCs108Library4a.byteArrayToString(rx000pkgData.decodedCrc); if (strExtra1 != null && strExtra1Filter != null) { MainActivity.mCs108Library4a.appendToLog("strEpc = " + strEpc + ", strExtra1 = " + strExtra1 + ", strExtra1Filter = " + strExtra1Filter + ", strExtra2 = " + strExtra2 ); @@ -300,7 +301,7 @@ else if (output[0].contains("WW")) { // MainActivity.mCs108Library4a.appendToLog("Matching Epc = " + strEpc); iMatchItem = -1; if (true) { - int index = Collections.binarySearch(MainActivity.sharedObjects.tagsIndexList, new SharedObjects.TagsIndex(strEpc+strExtra1+strExtra2, 0)); + int index = Collections.binarySearch(MainActivity.sharedObjects.tagsIndexList, new SharedObjects.TagsIndex(strAddresss, 0)); if (index >= 0) { iMatchItem = MainActivity.sharedObjects.tagsIndexList.size() - 1 - MainActivity.sharedObjects.tagsIndexList.get(index).getPosition(); // MainActivity.mCs108Library4a.appendToLog("Binary matched index = " + index + ", iMatchItem = " + iMatchItem + ", Epc = " + tagsList.get(iMatchItem).getAddress()); @@ -322,6 +323,8 @@ else if (output[0].contains("WW")) { readerDevice.setRssi(rssi); readerDevice.setPhase(phase); readerDevice.setChannel(chidx); + readerDevice.setExtra1(strExtra1, extra1Bank, data1_offset); + MainActivity.mCs108Library4a.appendToLog("setExtra1 with strExtra1 = " + strExtra1); tagsList.set(iMatchItem, readerDevice); match = true; updated = true; @@ -342,7 +345,7 @@ else if (output[0].contains("WW")) { 1, rssi, phase, chidx); if (bAdd2End) tagsList.add(readerDevice); else tagsList.add(0, readerDevice); - SharedObjects.TagsIndex tagsIndex = new SharedObjects.TagsIndex(strEpc+strExtra1+strExtra2, tagsList.size()-1); MainActivity.sharedObjects.tagsIndexList.add(tagsIndex); Collections.sort(MainActivity.sharedObjects.tagsIndexList); + SharedObjects.TagsIndex tagsIndex = new SharedObjects.TagsIndex(strAddresss, tagsList.size()-1); MainActivity.sharedObjects.tagsIndexList.add(tagsIndex); Collections.sort(MainActivity.sharedObjects.tagsIndexList); if (serverConnectValid && ALLOW_RTSAVE && true) { try { // saveExternalTask = new SaveList2ExternalTask(); diff --git a/app/src/main/java/com/csl/cs108ademoapp/adapters/MicronAdapter.java b/app/src/main/java/com/csl/cs108ademoapp/adapters/MicronAdapter.java index 33aaca1..7d141e0 100755 --- a/app/src/main/java/com/csl/cs108ademoapp/adapters/MicronAdapter.java +++ b/app/src/main/java/com/csl/cs108ademoapp/adapters/MicronAdapter.java @@ -16,12 +16,13 @@ public class MicronAdapter extends FragmentStatePagerAdapter { public Fragment getItem(int index) { Fragment fragment = null; switch (index) { - case 0: + case 1: fragment = new AccessMicronFragment(); fragment0 = fragment; break; - case 1: - fragment = InventoryRfidiMultiFragment.newInstance(true,"E28240", false); + case 0: + String mDid = "E282403"; //"E28240", "E282403" + fragment = InventoryRfidiMultiFragment.newInstance(true, mDid, false); fragment1 = fragment; break; default: diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessMicronFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessMicronFragment.java index 8aec60b..98656ba 100755 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessMicronFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessMicronFragment.java @@ -1,5 +1,6 @@ package com.csl.cs108ademoapp.fragments; +import android.graphics.Color; import android.os.AsyncTask; import android.os.Bundle; import android.view.LayoutInflater; @@ -105,11 +106,6 @@ public void onClick(View v) { public void onDestroy() { if (accessTask != null) accessTask.cancel(true); MainActivity.mCs108Library4a.setSameCheck(true); - if (changedSelectIndex) { - MainActivity.mCs108Library4a.setInvSelectIndex(1); - MainActivity.mCs108Library4a.setSelectCriteria(false, 0, 0, 0, 0, ""); - MainActivity.mCs108Library4a.setInvSelectIndex(0); - } MainActivity.mCs108Library4a.restoreAfterTagSelect(); super.onDestroy(); } @@ -147,6 +143,27 @@ void setupTagID() { bSelected = true; if (editTextRWTagID != null) editTextRWTagID.setText(tagSelected.getAddress()); + if (setModelCode(tagSelected.getTid())) textViewModelCode.setText(tagSelected.getTid().substring(4)); + else if (tagSelected.getRes() != null && tagSelected.getUser() != null) { modelCode = 3; textViewModelCode.setText("403"); } + else { + CheckBox checkBoxModelCode = (CheckBox) getActivity().findViewById(R.id.accesMNModelCodeTitle); + checkBoxModelCode.setVisibility(View.VISIBLE); + TextView textViewModelCode = (TextView) getActivity().findViewById(R.id.accesMNModelCodeTitle1); + textViewModelCode.setVisibility(View.GONE); + } + if (setCalibrationVersion(tagSelected.getUser()) == false) { + CheckBox checkBoxCalibrationData = (CheckBox) getActivity().findViewById(R.id.accesMNCalibrationTitle); + checkBoxCalibrationData.setVisibility(View.VISIBLE); + TextView textViewCalibrationData = (TextView) getActivity().findViewById(R.id.accesMNCalibrationTitle1); + textViewCalibrationData.setVisibility(View.GONE); + } + if (tagSelected.getRes() == null) { + CheckBox checkBoxRssiCode = (CheckBox) getActivity().findViewById(R.id.accesMNRssiCodeTitle); + checkBoxRssiCode.setVisibility(View.VISIBLE); + TextView textViewRssiCodeTitle = (TextView) getActivity().findViewById(R.id.accesMNRssiCodeTitle1); + textViewRssiCodeTitle.setVisibility(View.GONE); + } else setRssiCode(tagSelected.getRes()); + stringDetail = tagSelected.getDetails(); indexUser = stringDetail.indexOf("USER="); if (indexUser != -1) { @@ -165,12 +182,13 @@ void startAccessTask() { if (DEBUG) MainActivity.mCs108Library4a.appendToLog("startAccessTask()"); if (updating == false) { updating = true; bankProcessing = 0; - checkBoxConfig.setChecked(true); MainActivity.mCs108Library4a.setInvSelectIndex(0); + checkProcessing = 0; mHandler.removeCallbacks(updateRunnable); mHandler.post(updateRunnable); } } boolean updating = false; int bankProcessing = 0; + int checkProcessing = 0; private final Runnable updateRunnable = new Runnable() { @Override public void run() { @@ -238,6 +256,44 @@ String getTemperatue(String stringInput) { return stringValue; } + boolean setModelCode(String strTid) { + if (strTid == null) return false; + if (strTid.length() <= 7) return false; + if (strTid.substring(0, 7).matches("E282401")) { + modelCode = 1; return true; + } else if (strTid.substring(0, 7).matches("E282402")) { + modelCode = 2; return true; + } else if (strTid.substring(0, 7).matches("E282403")) { + modelCode = 3; return true; + } + return false; + } + boolean setCalibrationVersion(String strUser) { + if (strUser == null) return false; + if (strUser.length() < 16) return false; + int crc = Integer.parseInt(strUser.substring(0, 4), 16); + calCode1 = Integer.parseInt(strUser.substring(4, 7), 16); + calTemp1 = Integer.parseInt(strUser.substring(7, 10), 16); calTemp1 >>= 1; + calCode2 = Integer.parseInt(strUser.substring(9, 13), 16); calCode2 >>= 1; calCode2 &= 0xFFF; + calTemp2 = Integer.parseInt(strUser.substring(12, 16), 16); calTemp2 >>= 2; calTemp2 &= 0x7FF; + calVer = Integer.parseInt(strUser.substring(15, 16),16); calVer &= 0x3; + MainActivity.mCs108Library4a.appendToLog("crc = " + crc + ", code1 = " + calCode1 + ", temp1 = " + calTemp1 + ", code2 = " + calCode2 + ", temp2 = " + calTemp2 + ", ver = " + calVer); + textViewCalibrationVersion.setText(strUser); //String.valueOf(calVer) + return true; + } + boolean setRssiCode(String strData) { + if (strData == null) return false; + if (strData.length() < 4) return false; + int iTemp = Integer.parseInt(strData.substring(2,4), 16); iTemp &= 0x1F; + textViewRssiCode.setText(String.format("%d", iTemp)); //"%02X" + EditText editText = (EditText) getActivity().findViewById(R.id.accessMNRssiLowerLimit); + int iTempLower = Integer.parseInt(editText.getText().toString()); + editText = (EditText) getActivity().findViewById(R.id.accessMNRssiUpperLimit); + int iTempUpper = Integer.parseInt(editText.getText().toString()); + if (iTemp >= iTempLower && iTemp <= iTempUpper) textViewRssiCode.setTextColor(Color.BLACK); + else textViewRssiCode.setTextColor(Color.RED); + return true; + } // int accessBank, accSize, accOffset; // int restartCounter = 0; int restartAccessBank = -1; boolean processResult() { @@ -245,50 +301,46 @@ boolean processResult() { if (accessTask == null) return false; else if (accessTask.getStatus() != AsyncTask.Status.FINISHED) return false; else { + MainActivity.mCs108Library4a.setInvSelectIndex(1); + MainActivity.mCs108Library4a.setSelectCriteria(false, 0, 0, 0, 0, ""); MainActivity.mCs108Library4a.appendToLog("setSelectCriteria 1 = FALSE"); + MainActivity.mCs108Library4a.setInvSelectIndex(0); if (DEBUG) MainActivity.mCs108Library4a.appendToLog("AccessTask FINISHED"); accessResult = accessTask.accessResult; if (accessResult == null) { if (readWriteTypes == ReadWriteTypes.MODELCODE) { textViewConfigOk.setText("E"); - checkBoxConfig.setChecked(false); + // checkBoxConfig.setChecked(false); } else if (readWriteTypes == ReadWriteTypes.CALIBRATION) { textViewCalibrationOk.setText("E"); - checkBoxCalibration.setChecked(false); + // checkBoxCalibration.setChecked(false); } else if (readWriteTypes == ReadWriteTypes.SENSORCODE) { - textViewSensorCodeOk.setText("E"); checkBoxSensorCode.setChecked(false); + textViewSensorCodeOk.setText("E"); + //checkBoxSensorCode.setChecked(false); } else if (readWriteTypes == ReadWriteTypes.RSSICODE) { - textViewRssiCodeOk.setText("E"); checkBoxRssiCode.setChecked(false); + textViewRssiCodeOk.setText("E"); + // checkBoxRssiCode.setChecked(false); } else if (readWriteTypes == ReadWriteTypes.TEMPERATURECODE) { - textViewTemperatureCodeOk.setText("E"); checkBoxTemperatureCode.setChecked(false); + textViewTemperatureCodeOk.setText("E"); + // checkBoxTemperatureCode.setChecked(false); } } else { if (DEBUG) MainActivity.mCs108Library4a.appendToLog("accessResult = " + accessResult); if (readWriteTypes == ReadWriteTypes.MODELCODE) { textViewConfigOk.setText("O"); - checkBoxConfig.setChecked(false); + // checkBoxConfig.setChecked(false); readWriteTypes = ReadWriteTypes.NULL; - boolean valid = false; - if (accessResult.length() > 7) { - if (accessResult.substring(0, 7).matches("E282401")) { modelCode = 1; valid = true; } - else if (accessResult.substring(0, 7).matches("E282402")) { modelCode = 2; valid = true; } - else if (accessResult.substring(0, 7).matches("E282403")) { modelCode = 3; valid = true; } - } - if (valid) { textViewModelCode.setText(accessResult.substring(4)); checkBoxCalibration.setChecked(true); } + boolean valid = setModelCode(accessResult); + if (valid) textViewModelCode.setText(accessResult.substring(4)); else Toast.makeText(MainActivity.mContext, "This is not Micron 40X tag !!!", Toast.LENGTH_SHORT).show(); } else if (readWriteTypes == ReadWriteTypes.CALIBRATION) { - textViewCalibrationOk.setText("O"); checkBoxCalibration.setChecked(false); readWriteTypes = ReadWriteTypes.NULL; - if (accessResult.length() >= 16) { - int crc = Integer.parseInt(accessResult.substring(0, 4), 16); - calCode1 = Integer.parseInt(accessResult.substring(4, 7), 16); - calTemp1 = Integer.parseInt(accessResult.substring(7, 10), 16); calTemp1 >>= 1; - calCode2 = Integer.parseInt(accessResult.substring(9, 13), 16); calCode2 >>= 1; calCode2 &= 0xFFF; - calTemp2 = Integer.parseInt(accessResult.substring(12, 16), 16); calTemp2 >>= 2; calTemp2 &= 0x7FF; - calVer = Integer.parseInt(accessResult.substring(15, 16),16); calVer &= 0x3; - MainActivity.mCs108Library4a.appendToLog("crc = " + crc + ", code1 = " + calCode1 + ", temp1 = " + calTemp1 + ", code2 = " + calCode2 + ", temp2 = " + calTemp2 + ", ver = " + calVer); - textViewCalibrationVersion.setText(String.valueOf(calVer)); - } + textViewCalibrationOk.setText("O"); + // checkBoxCalibration.setChecked(false); + readWriteTypes = ReadWriteTypes.NULL; + setCalibrationVersion(accessResult); } else if (readWriteTypes == ReadWriteTypes.SENSORCODE) { - textViewSensorCodeOk.setText("O"); checkBoxSensorCode.setChecked(false); readWriteTypes = ReadWriteTypes.NULL; + textViewSensorCodeOk.setText("O"); + // checkBoxSensorCode.setChecked(false); + readWriteTypes = ReadWriteTypes.NULL; int iTemp = 0; if (accessResult.length() >= 4) { if (modelCode == 3) { @@ -300,13 +352,14 @@ boolean processResult() { } } } else if (readWriteTypes == ReadWriteTypes.RSSICODE) { - textViewRssiCodeOk.setText("O"); checkBoxRssiCode.setChecked(false); readWriteTypes = ReadWriteTypes.NULL; - if (accessResult.length() >= 4) { - int iTemp = Integer.parseInt(accessResult.substring(2,4), 16); iTemp &= 0x1F; - textViewRssiCode.setText(String.format("%02X", iTemp)); - } + textViewRssiCodeOk.setText("O"); + // checkBoxRssiCode.setChecked(false); + readWriteTypes = ReadWriteTypes.NULL; + setRssiCode(accessResult); } else if (readWriteTypes == ReadWriteTypes.TEMPERATURECODE) { - textViewTemperatureCodeOk.setText("O"); checkBoxTemperatureCode.setChecked(false); readWriteTypes = ReadWriteTypes.NULL; + textViewTemperatureCodeOk.setText("O"); + // checkBoxTemperatureCode.setChecked(false); + readWriteTypes = ReadWriteTypes.NULL; if (accessResult.length() >= 4) { float fTemperature = Integer.parseInt(accessResult.substring(0,4), 16); fTemperature = ((float)calTemp2 - (float)calTemp1) * (fTemperature - (float) calCode1); @@ -322,35 +375,36 @@ boolean processResult() { return true; } } + int processedTick = 0; boolean processTickItems() { boolean invalidRequest1 = false; int accBank = 0, accSize = 0, accOffset = 0; String writeData = ""; if (editTextRWTagID.getText().toString().length() == 0) invalidRequest1 = true; - else if (checkBoxConfig.isChecked() == true) { - accBank = 2; accOffset = 0; accSize = 2; readWriteTypes = ReadWriteTypes.MODELCODE; + else if (checkBoxConfig.isChecked() == true && checkProcessing < 1) { + accBank = 2; accOffset = 0; accSize = 2; readWriteTypes = ReadWriteTypes.MODELCODE; checkProcessing = 1; textViewConfigOk.setText(""); textViewModelCode.setText(""); modelCode = -1; - } else if (checkBoxCalibration.isChecked() == true) { - accBank = 3; accOffset = 8; accSize = 4; readWriteTypes = ReadWriteTypes.CALIBRATION; + } else if (checkBoxCalibration.isChecked() == true && checkProcessing < 2) { + accBank = 3; accOffset = 8; accSize = 4; readWriteTypes = ReadWriteTypes.CALIBRATION; checkProcessing = 2; textViewCalibrationOk.setText(""); textViewCalibrationVersion.setText(""); calVer = -1; - } else if (checkBoxSensorCode.isChecked() == true && modelCode != -1) { + } else if (checkBoxSensorCode.isChecked() == true && modelCode != -1 && checkProcessing < 3) { accBank = 0; if (modelCode == 1) accBank = 3; accOffset = 11; if (modelCode == 3) accOffset = 12; - accSize = 1; readWriteTypes = ReadWriteTypes.SENSORCODE; + accSize = 1; readWriteTypes = ReadWriteTypes.SENSORCODE; checkProcessing = 3; textViewSensorCodeOk.setText(""); textViewSensorCode.setText(""); - } else if (checkBoxRssiCode.isChecked() == true && modelCode != -1) { + } else if (checkBoxRssiCode.isChecked() == true && modelCode != -1 && checkProcessing < 4) { MainActivity.mCs108Library4a.setInvSelectIndex(0); - MainActivity.mCs108Library4a.setSelectCriteria(true, 4, 0, 3, (modelCode == 3 ? 0xD0 : 0xA0), "1F"); + MainActivity.mCs108Library4a.setSelectCriteria(true, 4, 0, 3, (modelCode == 3 ? 0xD0 : 0xA0), "1F"); MainActivity.mCs108Library4a.appendToLog("setSelectCriteria 0 = TRUE"); MainActivity.mCs108Library4a.setInvSelectIndex(1); changedSelectIndex = true; accBank = 0; accOffset = 13; if (modelCode == 1) { accBank = 3; accOffset = 9; } - accSize = 1; readWriteTypes = ReadWriteTypes.RSSICODE; + accSize = 1; readWriteTypes = ReadWriteTypes.RSSICODE; checkProcessing = 4; textViewRssiCodeOk.setText(""); textViewRssiCode.setText(""); - } else if (checkBoxTemperatureCode.isChecked() == true && modelCode == 3 && calVer != -1) { + } else if (checkBoxTemperatureCode.isChecked() == true && modelCode == 3 && calVer != -1 && checkProcessing < 5) { MainActivity.mCs108Library4a.setInvSelectIndex(0); - MainActivity.mCs108Library4a.setSelectCriteria(true, 4, 0, 3, 0xE0, ""); + MainActivity.mCs108Library4a.setSelectCriteria(true, 4, 0, 3, 0xE0, ""); MainActivity.mCs108Library4a.appendToLog("setSelectCriteria 0 = TRUE"); MainActivity.mCs108Library4a.setInvSelectIndex(1); changedSelectIndex = true; - accBank = 0; accOffset = 14; accSize = 1; readWriteTypes = ReadWriteTypes.TEMPERATURECODE; + accBank = 0; accOffset = 14; accSize = 1; readWriteTypes = ReadWriteTypes.TEMPERATURECODE; checkProcessing = 5; textViewTemperatureCodeOk.setText(""); textViewTemperatureCode.setText(""); } else { invalidRequest1 = true; diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessReadWriteFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessReadWriteFragment.java index 9131136..f6a56f5 100755 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessReadWriteFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessReadWriteFragment.java @@ -16,12 +16,15 @@ import android.widget.Toast; import com.csl.cs108ademoapp.AccessTask; +import com.csl.cs108ademoapp.CustomPopupWindow; import com.csl.cs108ademoapp.GenericTextWatcher; import com.csl.cs108library4a.Cs108Connector; import com.csl.cs108ademoapp.MainActivity; import com.csl.cs108ademoapp.R; import com.csl.cs108library4a.ReaderDevice; +import static com.csl.cs108ademoapp.MainActivity.mContext; + public class AccessReadWriteFragment extends CommonFragment { Spinner spinnerSelectBank; EditText editTextRWSelectOffset, editTextRWTagID, editTextAccessRWAccPassword, editTextAccessRWKillPwd, editTextAccessRWAccPwd, editTextAccPc, editTextAccessRWEpc, editTExtAccessRWXpc; @@ -30,10 +33,11 @@ public class AccessReadWriteFragment extends CommonFragment { private Button buttonRead; private Button buttonWrite; Handler mHandler = new Handler(); + String strPCValueRef; - String accPcValue = ""; String accEpcValue = ""; String accXpcValue = ""; String accTidValue = ""; String accUserValue = ""; + String accEpcValue = ""; String accXpcValue = ""; String accTidValue = ""; String accUserValue = ""; enum ReadWriteTypes { - NULL, RESERVE, EPC, XPC, TID, USER, EPC1 + NULL, RESERVE, PC, EPC, XPC, TID, USER, EPC1 } boolean operationRead = false; ReadWriteTypes readWriteTypes; @@ -119,19 +123,12 @@ public void onClick(View v) { ReaderDevice tagSelected = MainActivity.tagSelected; if (tagSelected != null) { if (tagSelected.getSelected() == true) { - String strEpcValue = tagSelected.getAddress(); editTextRWTagID.setText(strEpcValue); + String strEpcValue = tagSelected.getAddress(); String detail = tagSelected.getDetails(); String header = "PC="; int index = detail.indexOf(header) + header.length(); - String strPCValue = detail.substring(index, index + 4); - if (true) { - updatePCEpc(strPCValue, strEpcValue); - } else { - editTextAccPc.setText(strPCValue); - textViewEpcLength.setText("EPC has " + 4 * strEpcValue.length() + " bits"); - editTextAccessRWEpc.setText(strEpcValue); - editTextAccessRWEpc.addTextChangedListener(new GenericTextWatcher(editTextAccessRWEpc, strEpcValue.length())); - } + strPCValueRef = detail.substring(index, index + 4); + updatePCEpc(strPCValueRef, strEpcValue); } } MainActivity.mCs108Library4a.setSameCheck(false); @@ -149,11 +146,77 @@ public AccessReadWriteFragment() { super("AccessReadWriteFragment"); } + int getPC2EpcWordCount(String detail) { + String detail2 = detail.substring(0, 1); + int number2 = Integer.valueOf(detail2, 16) * 2; + String detail3 = detail.substring(1, 2); + int number3 = Integer.valueOf(detail3, 16); + if ((number3 / 8) != 0) number2 += 1; + return number2; + } void updatePCEpc(String strPCValue, String strEpcValue) { - editTextAccPc.setText(strPCValue); - textViewEpcLength.setText("EPC has " + 4 * strEpcValue.length() + " bits"); - editTextAccessRWEpc.setText(strEpcValue); - editTextAccessRWEpc.addTextChangedListener(new GenericTextWatcher(editTextAccessRWEpc, strEpcValue.length())); + if (false) { + int iWordCount = 0; + if (strPCValue != null) { + if (strPCValue.length() != 0) editTextAccPc.setText(strPCValue); + iWordCount = getPC2EpcWordCount(strPCValue); + textViewEpcLength.setText("EPC has " + (iWordCount * 16) + " bits"); + } + if (strEpcValue != null) { + if (strEpcValue.length() != 0) { + editTextRWTagID.setText(strEpcValue); editTextAccessRWEpc.setText(strEpcValue); + editTextAccessRWEpc.addTextChangedListener(new GenericTextWatcher(editTextAccessRWEpc, iWordCount * 4)); + } + } + } else { + boolean needPopup = false; + boolean needMaskUpdate = false; + if (spinnerSelectBank.getSelectedItemPosition() == 0) needMaskUpdate = true; + if (DEBUG) + MainActivity.mCs108Library4a.appendToLog("strPCValueRef strPCValue = " + strPCValue + "strPCValueRef A = " + strPCValueRef + ", strEpcValue = " + strEpcValue); + if (strPCValue == null) strPCValue = ""; + if (strPCValue.length() != 0) editTextAccPc.setText(strPCValue); + else strPCValue = strPCValueRef; + if (strPCValueRef != null && strPCValue != null) { + if (strPCValue.matches(strPCValueRef) == false && strPCValue.length() == 4) { + needPopup = true; + strPCValueRef = strPCValue; + } + } + + int iWordCount = getPC2EpcWordCount(strPCValue); + textViewEpcLength.setText("EPC has " + (iWordCount * 16) + " bits"); + if (strEpcValue != null) { + if (needMaskUpdate) editTextRWTagID.setText(strEpcValue); + editTextAccessRWEpc.setText(strEpcValue); + } else { + if (iWordCount * 4 < editTextRWTagID.getText().toString().length()) { + // needPopup = true; + String strTemp = editTextRWTagID.getText().toString().substring(0, iWordCount * 4); + if (needMaskUpdate) editTextRWTagID.setText(strTemp); + } + if (iWordCount * 4 < editTextAccessRWEpc.getText().toString().length()) { + // needPopup = true; + String strTemp = editTextAccessRWEpc.getText().toString().substring(0, iWordCount * 4); + editTextAccessRWEpc.setText(strTemp); + } + if (editTextAccessRWEpc.getText().toString().length() != 0) { + String strTemp = editTextAccessRWEpc.getText().toString(); + if (editTextRWTagID.getText().toString().matches(strTemp) == false) { + // needPopup = true; + if (needMaskUpdate) editTextRWTagID.setText(strTemp); + } + } + } + editTextAccessRWEpc.addTextChangedListener(new GenericTextWatcher(editTextAccessRWEpc, iWordCount * 4)); + String strTemp = editTextAccessRWEpc.getText().toString(); + editTextAccessRWEpc.setText(strTemp); + + if (needPopup) { + CustomPopupWindow customPopupWindow = new CustomPopupWindow(mContext); + customPopupWindow.popupStart("Changing EPC Length will automatically modify to " + (iWordCount * 16) + " bits.", false); + } + } } void startAccessTask() { @@ -218,8 +281,8 @@ else if (taskRequest) { } }; - TextView textViewReserveOk, textViewEpcOk, textViewTidOk, textViewUserOk, textViewEpc1Ok; - CheckBox checkBoxReserve, checkBoxEpc, checkBoxTid, checkBoxUser, checkBoxEpc1; + TextView textViewReserveOk, textViewPcOk, textViewEpcOk, textViewTidOk, textViewUserOk, textViewEpc1Ok; + CheckBox checkBoxReserve, checkBoxPc, checkBoxEpc, checkBoxTid, checkBoxUser, checkBoxEpc1; int accessBank, accSize, accOffset; int restartCounter = 0; int restartAccessBank = -1; boolean processResult() { @@ -233,6 +296,9 @@ boolean processResult() { if (readWriteTypes == ReadWriteTypes.RESERVE) { textViewReserveOk.setText("E"); checkBoxReserve.setChecked(false); } + if (readWriteTypes == ReadWriteTypes.PC) { + textViewPcOk.setText("E"); checkBoxPc.setChecked(false); + } if (readWriteTypes == ReadWriteTypes.EPC) { textViewEpcOk.setText("E"); checkBoxEpc.setChecked(false); } @@ -263,34 +329,40 @@ boolean processResult() { } else { editTextAccessRWAccPwd.setText(accessResult.subSequence(8, 16)); } + } else if (readWriteTypes == ReadWriteTypes.PC) { + textViewPcOk.setText("O"); checkBoxPc.setChecked(false); + readWriteTypes = ReadWriteTypes.NULL; + if (operationRead) { + String newValue = ""; + if (accessResult.length() <= 4) { + newValue = accessResult.subSequence(0, accessResult.length()).toString(); + } else { + newValue = accessResult.subSequence(0, 4).toString(); + } + editTextAccPc.setText(newValue); + } + updatePCEpc(editTextAccPc.getText().toString(), null); } else if (readWriteTypes == ReadWriteTypes.EPC) { if (DEBUG) MainActivity.mCs108Library4a.appendToLog("AccessReadWrite(). EPC DATA with accessBank = " + accessBank + ", with accessResult.length = " + accessResult.length()); textViewEpcOk.setText("O"); checkBoxEpc.setChecked(false); readWriteTypes = ReadWriteTypes.NULL; if (operationRead) { String newValue = ""; - if (accessResult.length() < 4) { - newValue = accessResult.subSequence(4, accessResult.length()).toString(); + if (accessResult.length() <= 4) { + newValue = accessResult.subSequence(0, accessResult.length()).toString(); } else { newValue = accessResult.subSequence(0, 4).toString(); } editTextAccPc.setText(newValue); - accPcValue = newValue; - } else { - accPcValue = editTextAccPc.getText().toString(); } + updatePCEpc(editTextAccPc.getText().toString(), null); if (operationRead) { - int epclength = accSize - 2; String newValue = ""; - if (accessResult.length() <= 4) { - } else { + if (accessResult.length() > 4) { newValue = accessResult.subSequence(4, accessResult.length()).toString(); } editTextAccessRWEpc.setText(newValue); - accEpcValue = newValue; - } else { - accEpcValue = editTextAccessRWEpc.getText().toString(); } } else if (readWriteTypes == ReadWriteTypes.XPC) { if (DEBUG) MainActivity.mCs108Library4a.appendToLog("AccessReadWrite(). XPC DATA with accessBank = " + accessBank + ", with accessResult.length = " + accessResult.length() + ", with accessResult=" + accessResult); @@ -321,7 +393,11 @@ boolean processResult() { textViewEpc1Ok.setText("O"); checkBoxEpc1.setChecked(false); readWriteTypes = ReadWriteTypes.NULL; if (accessResult.length() == 0 || operationRead == false) { - } else editTextEpcValue.setText(accessResult); + } else { + editTextEpcValue.setText(accessResult); + accEpcValue = accessResult; + } + if (operationRead == false) accEpcValue = editTextEpcValue.getText().toString(); } accessResult = null; } @@ -335,12 +411,14 @@ boolean processTickItems() { boolean invalidRequest1 = false; textViewReserveOk = (TextView) getActivity().findViewById(R.id.accessRWReserveOK); + textViewPcOk = (TextView) getActivity().findViewById(R.id.accessRWPcOK); textViewEpcOk = (TextView) getActivity().findViewById(R.id.accessRWEpcOK); textViewTidOk = (TextView) getActivity().findViewById(R.id.accessRWTidOK); textViewUserOk = (TextView) getActivity().findViewById(R.id.accessRWUserOK); textViewEpc1Ok = (TextView) getActivity().findViewById(R.id.accessRWEpc1OK); checkBoxReserve = (CheckBox) getActivity().findViewById(R.id.accessRWReserveTitle); + checkBoxPc = (CheckBox) getActivity().findViewById(R.id.accessRWPcTitle); checkBoxEpc = (CheckBox) getActivity().findViewById(R.id.accessRWEpcTitle); checkBoxTid = (CheckBox) getActivity().findViewById(R.id.accessRWTidTitle); checkBoxUser = (CheckBox) getActivity().findViewById(R.id.accessRWUserTitle); @@ -361,27 +439,29 @@ boolean processTickItems() { writeData = strValue + strValue1; } } + } else if (checkBoxPc.isChecked() == true) { + textViewPcOk.setText(""); + accessBank = 1; accOffset = 1; accSize = 1; readWriteTypes = ReadWriteTypes.PC; + if (operationRead) { + editTextAccPc.setText(""); + } else { + String strValue = editTextAccPc.getText().toString(); + if (strValue.length() != 4) invalidRequest1 = true; + else writeData = strValue; + } } else if (checkBoxEpc.isChecked() == true) { textViewEpcOk.setText(""); accessBank = 1; accOffset = 1; accSize = 0; readWriteTypes = ReadWriteTypes.EPC; if (DEBUG) MainActivity.mCs108Library4a.appendToLog("processTickItems(): start EPC operation"); if (operationRead) { - String detail = editTextAccPc.getText().toString(); - if (detail.length() != 4) accSize = 1; + if (strPCValueRef.length() != 4) accSize = 1; else { - String detail2 = detail.substring(0, 1); - int number2 = Integer.valueOf(detail2, 16) * 2; - String detail3 = detail.substring(1, 2); - int number3 = Integer.valueOf(detail3, 16); - if ((number3 % 2) == 1) number2 += 1; - accSize = number2 + 1; - MainActivity.mCs108Library4a.appendToLog("number3 = " + number3 + ", accSize = " + accSize); + accSize = getPC2EpcWordCount(strPCValueRef) + 1; editTextAccessRWEpc.setText(""); } } else { String strValue = editTextAccPc.getText().toString(); String strValue1 = editTextAccessRWEpc.getText().toString(); - if (DEBUG) MainActivity.mCs108Library4a.appendToLog("TestDebug111(): strValue = " + strValue + ", accPcValue = " + accPcValue); if (strValue1.length() == 0) { if (strValue.length() != 4) invalidRequest1 = true; else { @@ -392,6 +472,8 @@ boolean processTickItems() { accSize += strValue1.length() / 4; if (strValue1.length() % 4 != 0) accSize++; if (strValue.length() == 4) { + int iPCWordCount = getPC2EpcWordCount(strValue); + if (iPCWordCount < accSize) accSize = iPCWordCount; accSize++; writeData = strValue + strValue1; } else { diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryRfidiMultiFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryRfidiMultiFragment.java index 0c3a7c9..e01bc29 100755 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryRfidiMultiFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryRfidiMultiFragment.java @@ -151,7 +151,12 @@ public void onActivityCreated(Bundle savedInstanceState) { rfidListView = (ListView) getActivity().findViewById(R.id.inventoryRfidList1); rfidEmptyView = (TextView) getActivity().findViewById(R.id.inventoryRfidEmpty1); rfidListView.setEmptyView(rfidEmptyView); - readerListAdapter = new ReaderListAdapter(getActivity(), R.layout.readers_list_item, MainActivity.sharedObjects.tagsList, ((bMultiBank && mDid == null) ? false : true)); + boolean bSelect4detail = false; + if (bMultiBank == false) bSelect4detail = true; + else if (mDid != null) { + if (mDid.matches("E282403") == false) bSelect4detail = true; + } + readerListAdapter = new ReaderListAdapter(getActivity(), R.layout.readers_list_item, MainActivity.sharedObjects.tagsList, bSelect4detail); rfidListView.setAdapter(readerListAdapter); rfidListView.setChoiceMode(ListView.CHOICE_MODE_SINGLE); rfidListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @@ -253,6 +258,9 @@ public void setUserVisibleHint(boolean isVisibleToUser) { userVisibleHint = false; MainActivity.mCs108Library4a.appendToLog("InventoryRfidiMultiFragment is now INVISIBLE"); MainActivity.mCs108Library4a.setNotificationListener(null); + if (inventoryRfidTask != null) { + inventoryRfidTask.taskCancelReason = InventoryRfidTask.TaskCancelRReason.STOP; + } } } @@ -346,11 +354,30 @@ void startInventoryTask() { extra2Bank = 3; extra2Offset = 8; extra2Count = 4; + } else if (mDid.matches("E282403")) { + if (true) { + extra1Bank = 0; + extra1Offset = 13; + extra1Count = 2; + extra2Bank = 3; + extra2Offset = 8; + extra2Count = 4; + } else { + extra2Bank = 0; + extra2Offset = 13; + extra2Count = 2; + } } else { extra1Count = (mDid.length() * 4) / 16; if (extra1Count * 16 != mDid.length() * 4) extra1Count++; } MainActivity.mCs108Library4a.setSelectedTagByTID(mDid, 300); + if (mDid.matches("E282403")) { + MainActivity.mCs108Library4a.setInvSelectIndex(1); + MainActivity.mCs108Library4a.setSelectCriteria(true, 4, 2, 3, 0xD0, "20"); + MainActivity.mCs108Library4a.appendToLog("setSelectCriteria 1 = TRUE"); + MainActivity.mCs108Library4a.setInvSelectIndex(0); + } // extra2Offset = 0x10d; extra2Count = 1; //0 - 0x60: Ok, 70-B0, EC-F0: long, , C0-D0 no response for 30 seconds } else if (bMultiBank) { CheckBox checkBox = (CheckBox) getActivity().findViewById(R.id.accessInventoryBankTitle1); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/MicronFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/MicronFragment.java index 2809e3d..ad742b8 100755 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/MicronFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/MicronFragment.java @@ -10,6 +10,7 @@ import android.view.View; import android.view.ViewGroup; +import com.csl.cs108ademoapp.MainActivity; import com.csl.cs108ademoapp.R; import com.csl.cs108ademoapp.adapters.MicronAdapter; @@ -18,7 +19,7 @@ public class MicronFragment extends CommonFragment { private ViewPager viewPager; MicronAdapter mAdapter; - private String[] tabs = {"Configuration", "Scan"}; + private String[] tabs = {"Select Tag", "Read Temp."}; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -102,6 +103,9 @@ public void onDestroyView() { @Override public void onDestroy() { + MainActivity.mCs108Library4a.setInvSelectIndex(1); + MainActivity.mCs108Library4a.setSelectCriteria(false, 0, 0, 0, 0, ""); MainActivity.mCs108Library4a.appendToLog("setSelectCriteria 1 = FALSE"); + MainActivity.mCs108Library4a.setInvSelectIndex(0); mAdapter.fragment0.onDestroy(); mAdapter.fragment1.onDestroy(); super.onDestroy(); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/SettingOperateFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/SettingOperateFragment.java index 58c76bd..8af44c8 100755 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/SettingOperateFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/SettingOperateFragment.java @@ -27,7 +27,7 @@ public class SettingOperateFragment extends CommonFragment { boolean overriding = false; int countrySelect = -1; - int channelSelect = -1; + int channelOrder = -1; int channelSelect = -1; long powerLevel = -1; final long powerLevelMin = 0; final long powerLevelMax = 300; int iPopulation = -1; int iPopulationMin = 1; int iPopulationMax = 9999; byte byteFixedQValue = -1; byte byteFixedQValueMin = 0; byte byteFixedQValueMax = 15; @@ -49,11 +49,7 @@ public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); spinnerRegulatoryRegion = (Spinner) getActivity().findViewById(R.id.settingOperateRegulatoryRegion); - spinnerFrequencyOrder = (Spinner) getActivity().findViewById(R.id.settingOperateFrequencyOrder); - ArrayAdapter targetAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.frequencyOrder_options, R.layout.custom_spinner_layout); - targetAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - spinnerFrequencyOrder.setAdapter(targetAdapter); - + spinnerFrequencyOrder = (Spinner) getActivity().findViewById(R.id.settingOperateFrequencyOrder); spinnerFrequencyOrder.setEnabled(false); editTextChannel = (EditText) getActivity().findViewById(R.id.settingOperateChannel); TextView textViewOperatePowerLabel = (TextView) getActivity().findViewById(R.id.settingOperatePowerLabel); @@ -71,7 +67,7 @@ public void onActivityCreated(Bundle savedInstanceState) { editTextStartQValue = (EditText) getActivity().findViewById(R.id.settingOperateQValue); spinnerQueryTarget = (Spinner) getActivity().findViewById(R.id.settingOperateTarget); - targetAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.query_target_options, R.layout.custom_spinner_layout); + ArrayAdapter targetAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.query_target_options, R.layout.custom_spinner_layout); targetAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinnerQueryTarget.setAdapter(targetAdapter); @@ -135,6 +131,7 @@ public void onClick(View v) { } else { try { countrySelect = spinnerRegulatoryRegion.getSelectedItemPosition(); + channelOrder = spinnerFrequencyOrder.getSelectedItemPosition(); channelSelect = Integer.parseInt(editTextChannel.getText().toString()); powerLevel = Long.parseLong(editTextOperatePower.getText().toString()); iPopulation = Integer.parseInt(editTextPopulation.getText().toString()); @@ -193,9 +190,10 @@ public void run() { } } if (updating == false) { + MainActivity.mCs108Library4a.appendToLog("2A channel = "); int channel = MainActivity.mCs108Library4a.getChannel(); if (channel < 0) updating = true; - else editTextChannel.setText(String.valueOf(channel)); + else { editTextChannel.setText(String.valueOf(channel)); MainActivity.mCs108Library4a.appendToLog("2 channel = "); } } if (updating == false) { lValue = MainActivity.mCs108Library4a.getPwrlevel(); @@ -231,14 +229,16 @@ public void run() { else spinnerRegulatoryRegion.setSelection(countryNumber); if (strCountryList.length == 1) spinnerRegulatoryRegion.setEnabled(false); else spinnerRegulatoryRegion.setEnabled(true); - spinnerFrequencyOrder.setEnabled(false); - if (MainActivity.mCs108Library4a.getChannelHopping()) { - spinnerFrequencyOrder.setSelection(0); - editTextChannel.setEnabled(false); - } else { - spinnerFrequencyOrder.setSelection(1); - editTextChannel.setEnabled(true); - } + + ArrayAdapter targetAdapter; + if (MainActivity.mCs108Library4a.getChannelHoppingDefault()) + targetAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.frequencyOrder_options, R.layout.custom_spinner_layout); + else targetAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.frequencyAgile_options, R.layout.custom_spinner_layout); + targetAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); + spinnerFrequencyOrder.setAdapter(targetAdapter); + spinnerFrequencyOrder.setSelection(MainActivity.mCs108Library4a.getChannelHoppingStatus() ? 0 : 1); + if (MainActivity.mCs108Library4a.getChannelHoppingStatus()) editTextChannel.setEnabled(false); + else editTextChannel.setEnabled(true); } } } @@ -264,6 +264,13 @@ void settingUpdate() { sameSetting = false; if (MainActivity.mCs108Library4a.setCountryInList(countrySelect) == false) invalidRequest = true; } + if (invalidRequest == false && (MainActivity.mCs108Library4a.getChannelHoppingStatus() != (channelOrder == 0 ? true : false) || sameCheck == false)) { + sameSetting = false; + if (MainActivity.mCs108Library4a.setChannelHoppingStatus(channelOrder == 0 ? true : false) == false) invalidRequest = true; + else if (channelOrder > 0) editTextChannel.setEnabled(true); + else editTextChannel.setEnabled(false); + editTextChannel.setText(String.valueOf(MainActivity.mCs108Library4a.getChannel())); MainActivity.mCs108Library4a.appendToLog("1 channel = "); + } if (invalidRequest == false && (MainActivity.mCs108Library4a.getChannel() != channelSelect || sameCheck == false)) { sameSetting = false; if (channelSelect < MainActivity.mCs108Library4a.FreqChnCnt()) { diff --git a/app/src/main/res/layout/fragment_access_micron.xml b/app/src/main/res/layout/fragment_access_micron.xml index 55e49c6..1df7d19 100755 --- a/app/src/main/res/layout/fragment_access_micron.xml +++ b/app/src/main/res/layout/fragment_access_micron.xml @@ -59,6 +59,45 @@ android:layout_height="wrap_content" android:paddingLeft="@dimen/default_left_padding"> + + + + + + + + + + + + + + @@ -67,10 +106,18 @@ android:id="@+id/accesMNModelCodeTitle" android:layout_width="0dp" android:layout_weight="1" - android:enabled="false" + android:visibility="gone" style="@style/style_normal_font" android:text="Model code:" /> + + + + + android:text="Calibration data =" /> + + + android:text="On chip RSSI code = " /> diff --git a/app/src/main/res/layout/fragment_access_readwrite.xml b/app/src/main/res/layout/fragment_access_readwrite.xml index 861c31a..e19e69e 100755 --- a/app/src/main/res/layout/fragment_access_readwrite.xml +++ b/app/src/main/res/layout/fragment_access_readwrite.xml @@ -156,22 +156,11 @@ android:layout_height="wrap_content"> - - - - - @@ -194,20 +183,22 @@ + android:layout_height="wrap_content"> + + + android:text="@string/epc_memory_title" /> @@ -215,16 +206,17 @@ + android:paddingLeft="15dp" + android:visibility="gone"> + android:text="@string/xpc_title" /> diff --git a/app/src/main/res/layout/home_special_layout.xml b/app/src/main/res/layout/home_special_layout.xml index 509f43c..d6cfd5b 100755 --- a/app/src/main/res/layout/home_special_layout.xml +++ b/app/src/main/res/layout/home_special_layout.xml @@ -73,7 +73,7 @@ android:layout_marginBottom="@dimen/home_icon_margin_1" android:background="@drawable/btn_back" android:gravity="center" - android:text="RFMicron Temperature" + android:text="RFMicron" android:onClick="microTemperatureClicked"/> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 77bc55a..2066148 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -98,6 +98,11 @@ Fixed channel + + Frequency agile + Fixed channel + + hide none hide some diff --git a/build.gradle b/build.gradle index f0a50bb..6e44fe0 100755 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ buildscript { google() } dependencies { - classpath 'com.android.tools.build:gradle:3.2.0' + classpath 'com.android.tools.build:gradle:3.3.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/cs108library4a/build.gradle b/cs108library4a/build.gradle index 99e1cfd..97a7163 100755 --- a/cs108library4a/build.gradle +++ b/cs108library4a/build.gradle @@ -5,8 +5,8 @@ android { defaultConfig { minSdkVersion 19 targetSdkVersion 26 - versionCode 18 - versionName "1.13.0" + versionCode 19 + versionName "1.14.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" diff --git a/cs108library4a/src/main/java/com/csl/cs108library4a/Cs108Connector.java b/cs108library4a/src/main/java/com/csl/cs108library4a/Cs108Connector.java index 703e842..e2f1388 100755 --- a/cs108library4a/src/main/java/com/csl/cs108library4a/Cs108Connector.java +++ b/cs108library4a/src/main/java/com/csl/cs108library4a/Cs108Connector.java @@ -3341,7 +3341,7 @@ boolean setAccessWriteData(String dataInput) { // } } appendToLog("complete 4 bytes: " + byteArrayToString(msgBuffer)); - msgBuffer[2] = (byte) ((msgBuffer[2] & 0xFF) + i); + msgBuffer[2] = (byte) ((msgBuffer[2] & 0xFF) + (i % 16)); if (wrieByteSize == 4) { msgBuffer[6] = (byte)(i); } @@ -3390,6 +3390,7 @@ int getFreqChannelSelect() { } boolean setFreqChannelSelect(int freqChannelSelect) { byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, 0x0C, 0, 0, 0, 0}; + appendToLog("FrequencyA: freqChannelSelect = " + freqChannelSelect); if (freqChannelSelect < FREQCHANSEL_MIN || freqChannelSelect > FREQCHANSEL_MAX) freqChannelSelect = mDefault.freqChannelSelect; if (this.freqChannelSelect == freqChannelSelect && sameCheck) return true; msgBuffer[4] = (byte) (freqChannelSelect); @@ -3890,10 +3891,11 @@ int getSelectMaskLength() { } boolean setSelectMaskLength(int selectMaskLength) { byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 4, 8, 0, 0, 0, 0}; - if (selectMaskLength < INVSELMLENGTH_MIN || selectMaskLength > INVSELMLENGTH_MAX) - selectMaskLength = mDefault.selectMaskLength; + if (selectMaskLength < INVSELMLENGTH_MIN) selectMaskLength = INVSELMLENGTH_MIN; + else if (selectMaskLength > INVSELMLENGTH_MAX) selectMaskLength = INVSELMLENGTH_MAX; if (this.selectMaskLength == selectMaskLength && sameCheck) return true; msgBuffer[4] |= (byte) (selectMaskLength & 0xFF); + if (selectMaskLength == INVSELMLENGTH_MAX) msgBuffer[5] = 1; this.selectMaskLength = selectMaskLength; return mRfidDevice.mRx000Device.sendHostRegRequest(HostRegRequests.HST_TAGMSK_PTR, true, msgBuffer); } @@ -4260,8 +4262,9 @@ void writeOEM(int address, int value) { } } + final int RFID_READING_BUFFERSIZE = 150; public class Rx000Device { - byte[] mRfidToReading = new byte[100]; + byte[] mRfidToReading = new byte[RFID_READING_BUFFERSIZE]; int mRfidToReadingOffset = 0; boolean mRfidReadingReset = false; ArrayList mRx000ToWrite = new ArrayList<>(); @@ -4286,7 +4289,7 @@ private void clearTempDataIn() { cs108DataLeft = new byte[CS108DATALEFT_SIZE]; cs108DataLeftOffset = 0; mCs108DataRead.clear(); - mRfidToReading = new byte[100]; + mRfidToReading = new byte[RFID_READING_BUFFERSIZE]; mRfidToReadingOffset = 0; mRx000ToRead.clear(); mRfidDevice.mRfidToRead.clear(); @@ -4321,7 +4324,7 @@ void mRx000UplinkHandler() { byte[] unhandledBytes = new byte[mRfidToReadingOffset]; System.arraycopy(mRfidToReading, 0, unhandledBytes, 0, unhandledBytes.length); if (DEBUG) appendToLog("ERROR insufficient buffer, mRfidToReadingOffset=" + mRfidToReadingOffset + ", dataIn.length=" + dataIn.length + ", clear mRfidToReading: " + byteArrayToString(unhandledBytes)); - byte[] mRfidToReadingNew = new byte[100]; + byte[] mRfidToReadingNew = new byte[RFID_READING_BUFFERSIZE]; mRfidToReading = mRfidToReadingNew; mRfidToReadingOffset = 0; invalidUpdata++; @@ -4927,7 +4930,7 @@ else if (!(dataWritten[0] == (byte) 0x70 && dataWritten[1] == 1 && dataWritten[2 System.arraycopy(dataValuesFull, index, dataA.decodedPc, 0, dataA.decodedPc.length); index += 2; } - int epcLength = (dataA.decodedPc[0] >> 3) * 2; + int epcLength = ((dataA.decodedPc[0] & 0xFF) >> 3) * 2; if (dataValuesFull.length >= index + epcLength) { dataA.decodedEpc = new byte[epcLength]; System.arraycopy(dataValuesFull, index, dataA.decodedEpc, 0, epcLength); @@ -5156,7 +5159,7 @@ else if (!(dataWritten[0] == (byte) 0x70 && dataWritten[1] == 1 && dataWritten[2 startIndex = startIndexNew; startIndexOld = startIndexNew; //if (startIndexNew != mRfidToReadingOffset) { - byte[] mRfidToReadingNew = new byte[100]; + byte[] mRfidToReadingNew = new byte[RFID_READING_BUFFERSIZE]; System.arraycopy(mRfidToReading, startIndexNew, mRfidToReadingNew, 0, mRfidToReadingOffset - startIndexNew); mRfidToReading = mRfidToReadingNew; mRfidToReadingOffset -= startIndexNew; @@ -5176,7 +5179,7 @@ else if (!(dataWritten[0] == (byte) 0x70 && dataWritten[1] == 1 && dataWritten[2 } } if (mRfidToReadingOffset == startIndexNew) { - mRfidToReading = new byte[100]; + mRfidToReading = new byte[RFID_READING_BUFFERSIZE]; mRfidToReadingOffset = 0; } if (false && bdebugging) appendToLog("mRx000UplinkHandler(): END"); diff --git a/cs108library4a/src/main/java/com/csl/cs108library4a/Cs108Library4A.java b/cs108library4a/src/main/java/com/csl/cs108library4a/Cs108Library4A.java index 9ec9967..7d5814d 100755 --- a/cs108library4a/src/main/java/com/csl/cs108library4a/Cs108Library4A.java +++ b/cs108library4a/src/main/java/com/csl/cs108library4a/Cs108Library4A.java @@ -10,9 +10,7 @@ import android.content.pm.PackageManager; import android.os.Build; import android.os.Handler; -import android.provider.ContactsContract; import android.support.annotation.Keep; -import android.support.annotation.MainThread; import android.widget.TextView; import java.io.BufferedReader; @@ -28,7 +26,7 @@ import static java.lang.Math.log10; public class Cs108Library4A extends Cs108Connector { - final boolean DEBUG = true; + final boolean DEBUG = false; Context context; private Handler mHandler = new Handler(); BluetoothAdapter.LeScanCallback mLeScanCallback = null; @@ -387,6 +385,7 @@ void loadSetting1File() { } int countryInListNew = Integer.valueOf(dataArray[1]); if (countryInList != countryInListNew) setCountryInList(countryInListNew); + channelOrderType = -1; } else if (dataArray[0].matches("antennaPower")) { setPowerLevel(Long.valueOf(dataArray[1])); @@ -2013,6 +2012,7 @@ class PreMatchData { PreMatchData preMatchData; public boolean setSelectCriteria(boolean enable, int target, int action, int bank, int offset, String mask) { appendToLog("target = " + target); + if (mask.length() > 64) mask = mask.substring(0, 64); preMatchData = new PreMatchData(enable, target, action, bank, offset, mask, mRfidDevice.mRx000Device.mRx000Setting.getQuerySelect(), getAntennaCycle(), getPwrlevel(), getInvAlgo(), getQValue()); boolean result = mRfidDevice.mRx000Device.mRx000Setting.setInvSelectIndex(mRfidDevice.mRx000Device.mRx000Setting.invSelectIndex); if (result) result = mRfidDevice.mRx000Device.mRx000Setting.setSelectEnable(enable ? 1 : 0, target, action); @@ -2419,6 +2419,7 @@ public boolean setCountryInList(int countryInList) { this.countryInList = countryInList; regionCode = regionCodeNew; if (DEBUG) appendToLog("getChannel =" + getChannel() + ", FreqChnCnt = " + FreqChnCnt()); + appendToLog("X channel = "); if (getChannel() >= FreqChnCnt()) setChannel(0); switch (getCountryCode()) { case 1: @@ -2463,20 +2464,52 @@ public boolean setCountryInList(int countryInList) { if (DEBUG) appendToLog("New regionCode = " + regionCode.toString() + ", channel = " + getChannel() + ", FreqChnCnt = " + FreqChnCnt()); return true; } - public boolean getChannelHopping() { + public boolean getChannelHoppingDefault() { int countryCode = getCountryCode(); if (countryCode == 1 || countryCode == 8 || countryCode == 9) return false; return true; } + + int channelOrderType; // 0 for frequency hopping / agile, 1 for fixed frequencey + public boolean getChannelHoppingStatus() { + if (channelOrderType < 0) { + if (getChannelHoppingDefault()) channelOrderType = 0; + else channelOrderType = 1; + } + return (channelOrderType == 0 ? true : false); + } + public boolean setChannelHoppingStatus(boolean channelOrderHopping) { + if (this.channelOrderType != (channelOrderHopping ? 0 : 1)) { + boolean result = true; + if (getChannelHoppingDefault() == false) { + result = mRfidDevice.mRx000Device.mRx000Setting.setAntennaFreqAgile(channelOrderHopping ? 1 : 0); + } + int freqcnt = FreqChnCnt(); appendToLog("FrequencyA Count = " + freqcnt); + int channel = getChannel(); appendToLog(" FrequencyA Channel = " + channel); + for (int i = 0; i < freqcnt; i++) { + if (result == true) mRfidDevice.mRx000Device.mRx000Setting.setFreqChannelSelect(i); + if (result == true) mRfidDevice.mRx000Device.mRx000Setting.setFreqChannelConfig(channelOrderHopping); + } + if (result == true) mRfidDevice.mRx000Device.mRx000Setting.setFreqChannelSelect(channel); + if (result == true) mRfidDevice.mRx000Device.mRx000Setting.setFreqChannelConfig(true); + appendToLog(" FrequencyA: end of setting"); + + this.channelOrderType = (channelOrderHopping ? 0 : 1); + } + return true; + } + public int getChannel() { int channel = -1; - int countryCode = getCountryCode(); - if (countryCode == 1 || countryCode == 8 || countryCode == 9) { - if (mRfidDevice.mRx000Device.mRx000Setting.getFreqChannelConfig() != 0) { - channel = mRfidDevice.mRx000Device.mRx000Setting.getFreqChannelSelect(); - } - } else + if (mRfidDevice.mRx000Device.mRx000Setting.getFreqChannelConfig() != 0) { + channel = mRfidDevice.mRx000Device.mRx000Setting.getFreqChannelSelect(); + appendToLog("A channel = " + channel); + } + if (getChannelHoppingStatus()) { channel = 0; + appendToLog("B channel = " + channel); + } + appendToLog("C channel = " + channel); return channel; } public boolean setChannel(int channelSelect) { diff --git a/cs108library4a/src/main/java/com/csl/cs108library4a/ReaderDevice.java b/cs108library4a/src/main/java/com/csl/cs108library4a/ReaderDevice.java index 2de1735..730097a 100755 --- a/cs108library4a/src/main/java/com/csl/cs108library4a/ReaderDevice.java +++ b/cs108library4a/src/main/java/com/csl/cs108library4a/ReaderDevice.java @@ -1,7 +1,6 @@ package com.csl.cs108library4a; import android.bluetooth.BluetoothDevice; -import android.support.annotation.Keep; public class ReaderDevice implements Comparable { boolean isUsbDevice; @@ -10,21 +9,17 @@ public class ReaderDevice implements Comparable { private String address; boolean selected; private String details; - int pcValue, crcValue; int extra1Bank, extra2Bank, extra1Offset, extra2Offset; String strPc, strCrc16, strExtra1, strExtra2; private int count; private double rssi; private int phase, channel; - private String password; - private String serial; - private String model; private boolean isConnected; private String timeOfRead, timeZone; private String location; private String compass; - @Keep public ReaderDevice(String name, String address, boolean selected, String details, + public ReaderDevice(String name, String address, boolean selected, String details, String strPc, String strCrc16, String strExtra1, int extra1Bank, int extra1Offset, String strExtra2, int extra2Bank, int extra2Offset, @@ -61,7 +56,7 @@ public class ReaderDevice implements Comparable { this.channel = channel; } - @Keep public ReaderDevice(BluetoothDevice bluetoothDevice, String name, String address, boolean selected, String details, int count, double rssi) { + public ReaderDevice(BluetoothDevice bluetoothDevice, String name, String address, boolean selected, String details, int count, double rssi) { if (address == null) isUsbDevice = false; else if (address.contains(":")) { isUsbDevice = false; @@ -77,7 +72,7 @@ else if (address.contains(":")) { this.rssi = rssi; } - @Keep public String getName() { + public String getName() { return name; } @@ -85,7 +80,7 @@ void setName(String name) { this.name = name; } - @Keep public String getAddress() { + public String getAddress() { return address; } @@ -93,15 +88,15 @@ void setAddress(String address) { this.address = address; } - @Keep public boolean getSelected() { + public boolean getSelected() { return selected; } - @Keep public void setSelected(boolean selected) { + public void setSelected(boolean selected) { this.selected = selected; } - @Keep public String getDetails() { + public String getDetails() { if (details == null) { String strDetail = "PC=" + strPc + ", CRC16=" + strCrc16; if (strExtra1 != null) { @@ -147,102 +142,85 @@ void setAddress(String address) { return details; } - @Keep public void setDetails(String details) { + public void setDetails(String details) { this.details = details; } - @Keep public String getPc() { return strPc; } - @Keep public String getRes() { + public String getPc() { return strPc; } + public String getRes() { if (extra1Bank == 0) return strExtra1; else if (extra2Bank == 0) return strExtra2; else return null; } - @Keep public String getEpc() { + public String getEpc() { if (extra1Bank == 1) return strExtra1; else if (extra2Bank == 1) return strExtra2; else return null; } - @Keep public String getTid() { + public String getTid() { if (extra1Bank == 2) return strExtra1; else if (extra2Bank == 2) return strExtra2; else return null; } - @Keep public String getUser() { + public String getUser() { if (extra1Bank == 3) return strExtra1; else if (extra2Bank == 3) return strExtra2; else return null; } - @Keep public int getCount() { + public int getCount() { return count; } - @Keep public void setCount(int count) { + public void setCount(int count) { this.count = count; } - @Keep public double getRssi() { + public double getRssi() { return rssi; } - @Keep public void setRssi(double rssi) { + public void setRssi(double rssi) { this.rssi = rssi; } - @Keep public int getPhase() { + public int getPhase() { return phase; } - @Keep public void setPhase(int phase) { + public void setPhase(int phase) { this.phase = phase; } - @Keep public int getChannel() { + public int getChannel() { return channel; } - @Keep public void setChannel(int channel) { + public void setChannel(int channel) { this.channel = channel; } - String getPassword() { - return password; - } - - void setPassword(String password) { - this.password = password; - } - - String getSerial() { - return serial; - } - - void setSerial(String serial) { - this.serial = serial; - } - - String getModel() { - return model; - } - - void setModel(String model) { - this.model = model; + public void setExtra1(String strExtra1, int extra1Bank, int extra1Offset) { + this.strExtra1 = strExtra1; + this.extra1Bank = extra1Bank; + this.extra1Offset = extra1Offset; + this.details = null; getDetails(); } - @Keep public boolean isConnected() { + public boolean isConnected() { return isConnected; } - @Keep public void setConnected(boolean isConnected) { + public void setConnected(boolean isConnected) { this.isConnected = isConnected; } - @Keep public String getTimeOfRead() { return timeOfRead; } - @Keep public String getTimeZone() { return timeZone; } - @Keep public String getLocation() { return location; } - @Keep public void setLocation(String location) { this.location = location; } - @Keep public String getCompass() { return compass; } - @Keep public void setCcompass(String compass) { this.compass = compass; } + public String getTimeOfRead() { return timeOfRead; } + public String getTimeZone() { return timeZone; } + public String getLocation() { return location; } + public void setLocation(String location) { this.location = location; } + public String getCompass() { return compass; } + public void setCcompass(String compass) { this.compass = compass; } BluetoothDevice getBluetoothDevice() { return bluetoothDevice; diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8d0adcd..c9d8743 100755 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Oct 05 09:54:56 CST 2018 +#Tue Jan 22 18:03:25 CST 2019 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip