diff --git a/app/build.gradle b/app/build.gradle index fa2e0b7..5c93f13 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -12,7 +12,7 @@ android { minSdk 23 targetSdk 35 versionCode 42 - versionName "2.14.31" + versionName "2.14.38" } } diff --git a/app/release/cs108ademo-20241202-v2.14.31-36-app-release.zip b/app/release/cs108ademo-20250120-v2.14.38-54-app-release.zip similarity index 54% rename from app/release/cs108ademo-20241202-v2.14.31-36-app-release.zip rename to app/release/cs108ademo-20250120-v2.14.38-54-app-release.zip index d758cdc..9878e8a 100644 Binary files a/app/release/cs108ademo-20241202-v2.14.31-36-app-release.zip and b/app/release/cs108ademo-20250120-v2.14.38-54-app-release.zip differ diff --git a/app/src/main/java/com/csl/cs108ademoapp/AccessTask.java b/app/src/main/java/com/csl/cs108ademoapp/AccessTask.java index 3a105bb..54d8bf9 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/AccessTask.java +++ b/app/src/main/java/com/csl/cs108ademoapp/AccessTask.java @@ -25,7 +25,7 @@ public enum TaskCancelRReason { Button button; String buttonText; TextView registerRunTime, registerTagGot, registerVoltageLevel; TextView registerYield, registerTotal; - boolean invalidRequest; + boolean invalidRequest, selectOne = false; String selectMask; int selectBank, selectOffset; String strPassword; int powerLevel; RfidReaderChipData.HostCommands hostCommand; @@ -49,7 +49,7 @@ public enum TaskCancelRReason { int batteryCountInventory_old; boolean bSkipClearFilter = false; - public AccessTask(Button button, boolean invalidRequest, + public AccessTask(Button button, boolean invalidRequest, boolean selectOne, String selectMask, int selectBank, int selectOffset, String strPassword, int powerLevel, RfidReaderChipData.HostCommands hostCommand, boolean bEnableErrorPopWindow, Runnable updateRunnable) { @@ -58,6 +58,7 @@ public AccessTask(Button button, boolean invalidRequest, this.registerVoltageLevel = registerVoltageLevel; this.invalidRequest = invalidRequest; MainActivity.csLibrary4A.appendToLog("invalidRequest = " + invalidRequest); + this.selectOne = selectOne; this.selectMask = selectMask; this.selectBank = selectBank; this.selectOffset = selectOffset; @@ -72,7 +73,7 @@ public AccessTask(Button button, boolean invalidRequest, } preExecute(); } - public AccessTask(Button button, TextView textViewWriteCount, boolean invalidRequest, + public AccessTask(Button button, TextView textViewWriteCount, boolean invalidRequest, boolean selectOne, String selectMask, int selectBank, int selectOffset, String strPassword, int powerLevel, RfidReaderChipData.HostCommands hostCommand, int qValue, int repeat, boolean resetCount, boolean bSkipClearFilter, @@ -86,6 +87,7 @@ public AccessTask(Button button, TextView textViewWriteCount, boolean invalidReq this.registerTotal = registerTotalView; this.invalidRequest = invalidRequest; MainActivity.csLibrary4A.appendToLog("invalidRequest = " + invalidRequest); + this.selectOne = selectOne; this.selectMask = selectMask; this.selectBank = selectBank; this.selectOffset = selectOffset; @@ -96,6 +98,7 @@ public AccessTask(Button button, TextView textViewWriteCount, boolean invalidReq if (repeat > 255) repeat = 255; this.repeat = repeat; this.bSkipClearFilter = bSkipClearFilter; + if (bSkipClearFilter) this.selectOne = false; if (resetCount) { total = 0; tagList.clear(); @@ -151,19 +154,18 @@ else if (hostCommand == RfidReaderChipData.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) { + if (false && bSkipClearFilter == false) { MainActivity.csLibrary4A.appendToLog("Going to setSelectCriteria disable"); MainActivity.csLibrary4A.setSelectCriteriaDisable(-1); } if (powerLevel < 0 || powerLevel > 330) invalidRequest = true; else if (skipSelect == false) { - MainActivity.csLibrary4A.appendToLog("setSelectCriteria: Going to setSelectTag"); - if (MainActivity.csLibrary4A.setSelectedTag(selectMask, selectBank, selectOffset, powerLevel, qValue, matchRep) == false) { + MainActivity.csLibrary4A.appendToLog("AccessTask.preExecute goes to setSelectTag"); + if (MainActivity.csLibrary4A.setSelectedTag(selectOne, selectMask, selectBank, selectOffset, powerLevel, qValue, matchRep) == false) { invalidRequest = true; MainActivity.csLibrary4A.appendToLog("setSelectedTag is failed with selectMask = " + selectMask + ", selectBank = " + selectBank + ", selectOffset = " + selectOffset + ", powerLevel = " + powerLevel); } } @@ -178,6 +180,7 @@ else if (skipSelect == false) { if (MainActivity.csLibrary4A.checkHostProcessorVersion(MainActivity.csLibrary4A.getMacVer(), 2, 6, 8)) { MainActivity.csLibrary4A.setInvModeCompact(false); } + //MainActivity.csLibrary4A.setTagRead(0); MainActivity.csLibrary4A.sendHostRegRequestHST_CMD(hostCommand); } } @@ -226,6 +229,7 @@ else if (rx000pkgData != null) { if (rx000pkgData.decodedError != null) { endingMessaage = rx000pkgData.decodedError; ending = true; } else if (repeat > 0 && resultError.length() == 0) { resultError = ""; + if (true) MainActivity.csLibrary4A.appendToLog("Debug_InvCfg: AccessTask.doInBackground goes to setMatchRep with repeat = " + repeat); MainActivity.csLibrary4A.setMatchRep(repeat); MainActivity.csLibrary4A.sendHostRegRequestHST_CMD(hostCommand); } else { @@ -319,7 +323,7 @@ protected void onPostExecute(String result) { } void DeviceConnectTask4RegisterEnding() { - MainActivity.csLibrary4A.setAccessCount(0); + //MainActivity.csLibrary4A.setAccessCount(0); String strErrorMessage = ""; if (false) { boolean success = false; diff --git a/app/src/main/java/com/csl/cs108ademoapp/AccessTask1.java b/app/src/main/java/com/csl/cs108ademoapp/AccessTask1.java index 3d35c7a..abeba1f 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/AccessTask1.java +++ b/app/src/main/java/com/csl/cs108ademoapp/AccessTask1.java @@ -196,7 +196,7 @@ void setup() { } MainActivity.csLibrary4A.appendToLog("HelloA: accOffset=" + accOffset + ", accSizeNow=" + accSizeNow + ", accSize=" + accSize); MainActivity.csLibrary4A.appendToLog("HelloK: invalidRequest=" + invalidRequest); - accessTask = new AccessTask(button, invalidRequest, + accessTask = new AccessTask(button, invalidRequest, true, selectMask, selectBank, selectOffset, strPassword, powerLevel, hostCommand, tryCount==tryCountMax, updateRunnable); } diff --git a/app/src/main/java/com/csl/cs108ademoapp/CustomIME.java b/app/src/main/java/com/csl/cs108ademoapp/CustomIME.java index 38fd482..4fc3346 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/CustomIME.java +++ b/app/src/main/java/com/csl/cs108ademoapp/CustomIME.java @@ -143,7 +143,7 @@ else if (MainActivity.sharedObjects == null || MainActivity.csLibrary4A == null) String strSgtin = null; if (MainActivity.csLibrary4A.getWedgeOutput() == 1) { strSgtin = MainActivity.csLibrary4A.getUpcSerial(strEpc); - MainActivity.csLibrary4A.appendToLog("strSgtin = " + (strSgtin == null ? "null" : strSgtin)); + appendToLog("strSgtin = " + (strSgtin == null ? "null" : strSgtin)); if (strSgtin == null) strEpc = null; } boolean matched = false; @@ -164,7 +164,7 @@ else if (MainActivity.sharedObjects == null || MainActivity.csLibrary4A == null) strValue = MainActivity.csLibrary4A.getWedgePrefix() + strValue; if (MainActivity.csLibrary4A.getWedgeSuffix() != null) strValue += MainActivity.csLibrary4A.getWedgeSuffix(); - MainActivity.csLibrary4A.appendToLog("CustomIME, serviceRunnable: wedgeDelimiter = " + MainActivity.csLibrary4A.getWedgeDelimiter()); + appendToLog("CustomIME, serviceRunnable: wedgeDelimiter = " + MainActivity.csLibrary4A.getWedgeDelimiter()); switch (MainActivity.csLibrary4A.getWedgeDelimiter()) { default: strValue += "\n"; @@ -181,7 +181,7 @@ else if (MainActivity.sharedObjects == null || MainActivity.csLibrary4A == null) case -1: break; } - MainActivity.csLibrary4A.appendToLog("CustomIME BtData to Keyboard: " + strValue); + appendToLog("CustomIME BtData to Keyboard: " + strValue); ic.commitText(strValue, 1); } } @@ -190,7 +190,7 @@ else if (MainActivity.sharedObjects == null || MainActivity.csLibrary4A == null) } int iDelayms = 500; if (inventoring) iDelayms = 100; - MainActivity.csLibrary4A.appendToLog("CustomIME BtData set next time as " + iDelayms); + appendToLog("CustomIME BtData set next time as " + iDelayms); mHandler.postDelayed(serviceRunnable, iDelayms); } }; @@ -215,6 +215,7 @@ void startStopHandler() { inventoryBarcodeTask.execute(); } else { MainActivity.csLibrary4A.setPowerLevel(MainActivity.csLibrary4A.getWedgePower()); + MainActivity.csLibrary4A.appendToLog("Debug_Compact: CustomIME.startStopHandler"); MainActivity.csLibrary4A.startOperation(RfidReaderChipData.OperationTypes.TAG_INVENTORY_COMPACT); inventoryRfidTask = new InventoryRfidTask(); inventoryRfidTask.execute(); diff --git a/app/src/main/java/com/csl/cs108ademoapp/InventoryRfidTask.java b/app/src/main/java/com/csl/cs108ademoapp/InventoryRfidTask.java index fa59af1..bb623d7 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/InventoryRfidTask.java +++ b/app/src/main/java/com/csl/cs108ademoapp/InventoryRfidTask.java @@ -63,6 +63,7 @@ public enum TaskCancelRReason { Handler handler = new Handler(); boolean bValidVibrateNewAll = false; boolean bUseVibrateMode0 = false; void inventoryHandler_setup() { + MainActivity.csLibrary4A.appendToLog("InventoryRfidTask.inventoryHandler_setup set runningInventoryRfidTask as true "); MainActivity.sharedObjects.runningInventoryRfidTask = true; total = 0; allTotal = 0; yield = 0; if (tagsList != null) { @@ -165,6 +166,7 @@ protected String doInBackground(Void... a) { if (rx000pkgData.decodedError != null) endingMessaage = rx000pkgData.decodedError; if (continousRequest) { MainActivity.csLibrary4A.batteryLevelRequest(); + MainActivity.csLibrary4A.appendToLog("Debug_Compact: InventoryRfidTask.doInBackground"); MainActivity.csLibrary4A.startOperation(RfidReaderChipData.OperationTypes.TAG_INVENTORY_COMPACT); } else ending = true; } @@ -293,14 +295,15 @@ void tagHandler() { if (DEBUG) MainActivity.csLibrary4A.appendToLog("InventoryRfidTask: !!! rx000pkgData.Pc length = " + strPc.length()); continue; } - int extraLength = 0; + /*int extraLength = 0; if (extra1Bank != -1 && rx000pkgData.decodedData1 != null) extraLength += rx000pkgData.decodedData1.length; if (extra2Bank != -1 && rx000pkgData.decodedData2 != null) extraLength += rx000pkgData.decodedData2.length; if (extraLength != 0) { byte[] decodedEpcNew = new byte[rx000pkgData.decodedEpc.length - extraLength]; System.arraycopy(rx000pkgData.decodedEpc, 0, decodedEpcNew, 0, decodedEpcNew.length); rx000pkgData.decodedEpc = decodedEpcNew; - } + }*/ + MainActivity.csLibrary4A.appendToLog("ApData: decodedEpc = " + MainActivity.csLibrary4A.byteArrayToString(rx000pkgData.decodedEpc) + ", data1,2 = " + MainActivity.csLibrary4A.byteArrayToString(rx000pkgData.decodedData1) + ", " + MainActivity.csLibrary4A.byteArrayToString(rx000pkgData.decodedData2)); String strEpc = MainActivity.csLibrary4A.byteArrayToString(rx000pkgData.decodedEpc); if (DEBUG) MainActivity.csLibrary4A.appendToLog("HelloC: decodePc = " + strPc + ", decodedEpc = " + strEpc + ", iFlags = " + String.format("%2X", iFlag)); portstatus = INVALID_CODEVALUE; backport1 = INVALID_CODEVALUE; backport2 = INVALID_CODEVALUE; codeSensor = INVALID_CODEVALUE; codeRssi = INVALID_CODEVALUE; codeTempC = INVALID_CODEVALUE; brand = null; @@ -335,15 +338,19 @@ void tagHandler() { } boolean bFastId = false; boolean bTempId = false; + MainActivity.csLibrary4A.appendToLog("bFastId is false with MainActivity.mDid = " + MainActivity.mDid + ", getFastId = " + MainActivity.csLibrary4A.getFastId()); if (MainActivity.mDid != null) { - MainActivity.csLibrary4A.appendToLog("mDid = " + MainActivity.mDid); if (MainActivity.mDid.indexOf("E28011") == 0) { int iValue = Integer.valueOf(MainActivity.mDid.substring("E28011".length()), 16); MainActivity.csLibrary4A.appendToLog(String.format("iValue = 0x%02X", iValue)); - if ((iValue & 0x20) != 0) bFastId = true; + if ((iValue & 0x20) != 0) { + bFastId = true; MainActivity.csLibrary4A.appendToLog("bFastId is true"); + } if (DEBUG) MainActivity.csLibrary4A.appendToLog("HelloK: iValue = " + String.format("%02X", iValue)); } - } else if (MainActivity.csLibrary4A.getFastId() > 0) bFastId = true; + } else if (MainActivity.csLibrary4A.getFastId() > 0) { + bFastId = true; MainActivity.csLibrary4A.appendToLog("bFastId is true"); + } if (DEBUG) MainActivity.csLibrary4A.appendToLog("HelloK: strMdid = " + strMdid + ", MainMdid = " + MainActivity.mDid + ", bFastId = " + bFastId); int iPc = Integer.parseInt(strPc, 16); @@ -549,13 +556,14 @@ else if (readerDevice.getstrExtra2() != null) { if (ALLOW_WEDGE) MainActivity.sharedObjects.serviceArrayList.add(strEpc); boolean bAddDevice = true; String strValue = null; + MainActivity.csLibrary4A.appendToLog("bProtectOnly = " + bProtectOnly); if (bSgtinOnly) { strValue = MainActivity.csLibrary4A.getUpcSerial(strEpc); MainActivity.csLibrary4A.appendToLog("bSgtinOnly = " + bSgtinOnly + ", strValue = " + (strValue == null ? "null" : strValue)); if (strValue == null) bAddDevice = false; } else if (bProtectOnly) { + bAddDevice = false; if (strExtra1 != null) { - bAddDevice = false; strValue = strExtra1.substring(strExtra1.length() - 1); int iValue = Integer.parseInt(strValue, 16); MainActivity.csLibrary4A.appendToLog("bProtectOnly = " + bProtectOnly + ", strExtra1 = " + (strExtra1 == null ? "null" : strExtra1) + ", iValue = " + iValue); @@ -833,7 +841,9 @@ void DeviceConnectTask4InventoryEnding(TaskCancelRReason taskCancelReason) { MainActivity.csLibrary4A.appendToLog("INVENDING: Toasting"); if (mytoast != null) mytoast.show(); } - if (button != null) button.setText("Start"); MainActivity.sharedObjects.runningInventoryRfidTask = false; + if (button != null) button.setText("Start"); + MainActivity.csLibrary4A.appendToLog("InventoryRfidTask.DeviceConnectTask4InventoryEnding set runningInventoryRfidTask as false "); + MainActivity.sharedObjects.runningInventoryRfidTask = false; if (endingMessaage != null) { CustomPopupWindow customPopupWindow = new CustomPopupWindow(MainActivity.mContext); customPopupWindow.popupStart(endingMessaage, false); diff --git a/app/src/main/java/com/csl/cs108ademoapp/MainActivity.java b/app/src/main/java/com/csl/cs108ademoapp/MainActivity.java index fddae73..8eed037 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/MainActivity.java +++ b/app/src/main/java/com/csl/cs108ademoapp/MainActivity.java @@ -1,5 +1,10 @@ package com.csl.cs108ademoapp; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_ALIEN; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_ASYGNTAG; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_CTESIUS; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_EM_BAP; + import android.content.Context; import android.content.Intent; import android.net.Uri; @@ -48,6 +53,7 @@ import com.csl.cs108ademoapp.fragments.UcodeFragment; import com.csl.cslibrary4a.Cs108Library4A; import com.csl.cslibrary4a.ReaderDevice; +import com.csl.cslibrary4a.RfidReader; public class MainActivity extends AppCompatActivity { final boolean DEBUG = false; final String TAG = "Hello"; @@ -73,6 +79,7 @@ public class MainActivity extends AppCompatActivity { Handler mHandler = new Handler(); public static String mDid; public static int selectHold; public static int selectFor; + public static RfidReader.TagType tagType; public static class Config { public String configPassword, configPower, config0, config1, config2, config3; }; @@ -199,7 +206,7 @@ private void selectItem(DrawerPositions position) { fragment = new InventoryRfidSearchFragment(false); break; case MULTIBANK: - fragment = InventoryRfidiMultiFragment.newInstance(true, null); + fragment = InventoryRfidiMultiFragment.newInstance(true, null, null); break; case SIMINVENTORY: fragment = InventoryRfidSimpleFragment.newInstance(false, null); @@ -224,7 +231,7 @@ private void selectItem(DrawerPositions position) { fragment = new ImpinjM775Fragment(); break; case ALIEN: - fragment = InventoryRfidiMultiFragment.newInstance(true, "E2003"); + fragment = InventoryRfidiMultiFragment.newInstance(true, TAG_ALIEN, "E2003"); break; case UCODE8: fragment = new Ucode8Fragment(); @@ -233,7 +240,7 @@ private void selectItem(DrawerPositions position) { fragment = new UcodeFragment(); break; case BAPCARD: - fragment = InventoryRfidiMultiFragment.newInstance(true, "E200B0"); + fragment = InventoryRfidiMultiFragment.newInstance(true, TAG_EM_BAP, "E200B0"); break; case COLDCHAIN: fragment = new ColdChainFragment(); @@ -257,10 +264,10 @@ private void selectItem(DrawerPositions position) { fragment = new FdmicroFragment(); break; case CTESIUS: - fragment = InventoryRfidiMultiFragment.newInstance(true, "E203510"); + fragment = InventoryRfidiMultiFragment.newInstance(true, TAG_CTESIUS, "E203510"); break; case ASYGNTAG: - fragment = InventoryRfidiMultiFragment.newInstance(true, "E283A"); + fragment = InventoryRfidiMultiFragment.newInstance(true, TAG_ASYGNTAG, "E283A"); break; case REGISTER: diff --git a/app/src/main/java/com/csl/cs108ademoapp/MyForegroundService.java b/app/src/main/java/com/csl/cs108ademoapp/MyForegroundService.java index 2729069..88075bb 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/MyForegroundService.java +++ b/app/src/main/java/com/csl/cs108ademoapp/MyForegroundService.java @@ -31,7 +31,6 @@ import androidx.core.app.NotificationCompat; import com.csl.cs108ademoapp.fragments.AboutFragment; -import com.csl.cslibrary4a.Cs108Library4A; import com.csl.cslibrary4a.BluetoothGatt; import com.csl.cslibrary4a.ReaderDevice; import com.csl.cslibrary4a.RfidReaderChipData; @@ -43,12 +42,12 @@ import java.util.Random; public class MyForegroundService extends Service { + boolean DEBUG = false; Handler mHandler = new Handler(); public static final String CHANNEL_ID = "ForegroundServiceChannelA"; public static final int SERVICE_ID = 1; NotificationManager notificationManager; NotificationCompat.Builder notificationCompatBuilder; - Cs108Library4A csLibrary4A; ReaderDevice readerDevice; SaveList2ExternalTask saveExternalTask; boolean isHttpServerOpened; MyMqttClient myMqttClient; @@ -74,8 +73,7 @@ public void onCreate() { @Override public int onStartCommand(Intent intent, int flags, int startId) { //String input = intent.getStringExtra("inputExtra"); - csLibrary4A = MainActivity.csLibrary4A; //new CsLibrary4A(this, null); //MainActivity.csLibrary4A - if (csLibrary4A != null) Log.i("Hello", "MyForegroundService onStartCommand: csLibrary4A is created"); + if (MainActivity.csLibrary4A != null) Log.i("Hello", "MyForegroundService onStartCommand: csLibrary4A is created"); else Log.i("Hello", "MyForegroundService onStartCommand: null csLibrary4A"); Log.i("Hello", "MyForegroundService: onStartCommand"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { @@ -113,7 +111,7 @@ public int onStartCommand(Intent intent, int flags, int startId) { new Runnable() { @Override public void run() { - while (csLibrary4A != null) { + while (MainActivity.csLibrary4A != null) { int iRandom = getRandomNumber(); String strMessage = iRandom + ", ServiceState = " + foregroundServiceState.toString(); ForegroundServiceState foregroundServiceStateOld = foregroundServiceState; @@ -132,8 +130,8 @@ public void run() { } else if (MainActivity.activityActive == false) { MainActivity.csLibrary4A.appendToLog("runnableStartService: BLUETOOTH_CONNECT and BLUETOOTH_SCAN and (ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION) is permitted"); } else { - csLibrary4A.appendToLog("Start ScanLeDevice"); - csLibrary4A.scanLeDevice(true); + MainActivity.csLibrary4A.appendToLog("Start ScanLeDevice"); + MainActivity.csLibrary4A.scanLeDevice(true); foregroundServiceState = SCAN; } } @@ -144,8 +142,8 @@ public void run() { } else if (isForegroundEnable()) { BluetoothGatt.Cs108ScanData cs108ScanData = null; while (true) { - cs108ScanData = csLibrary4A.getNewDeviceScanned(); - csLibrary4A.appendToLog("cs108ScanData is " + (cs108ScanData == null ? "null" : "valid") + ", foregroundReader = " + MainActivity.csLibrary4A.getForegroundReader()); + cs108ScanData = MainActivity.csLibrary4A.getNewDeviceScanned(); + MainActivity.csLibrary4A.appendToLog("cs108ScanData is " + (cs108ScanData == null ? "null" : "valid") + ", foregroundReader = " + MainActivity.csLibrary4A.getForegroundReader()); if (cs108ScanData == null) break; strMessage += ("\n" + cs108ScanData.device.getAddress()); if (cs108ScanData.device.getAddress().matches(MainActivity.csLibrary4A.getForegroundReader())) { //"84:C6:92:9D:DD:52")) { @@ -156,8 +154,8 @@ public void run() { } readerDevice.setDetails(strInfo + "scanRecord=" + MainActivity.csLibrary4A.byteArrayToString(cs108ScanData.scanRecord)); - csLibrary4A.scanLeDevice(false); - csLibrary4A.connect(readerDevice); + MainActivity.csLibrary4A.scanLeDevice(false); + MainActivity.csLibrary4A.connect(readerDevice); foregroundServiceState = CONNECT; iConnectingCount = 0; break; } @@ -165,30 +163,30 @@ public void run() { if (foregroundServiceState != CONNECT && cs108ScanData != null) strMessage += ("\n" + cs108ScanData.device.getAddress()); } else { - csLibrary4A.appendToLog("Stop ScanLeDevice"); - csLibrary4A.scanLeDevice(false); + MainActivity.csLibrary4A.appendToLog("Stop ScanLeDevice"); + MainActivity.csLibrary4A.scanLeDevice(false); foregroundServiceState = NULL; } } else if (foregroundServiceState == CONNECT) { - if (csLibrary4A.isBleConnected()) { + if (MainActivity.csLibrary4A.isBleConnected()) { readerDevice.setConnected(true); readerDevice.setSelected(true); MainActivity.sharedObjects.readersList.add(readerDevice); foregroundServiceState = CONNECTED; } else if (++iConnectingCount > 10) { - csLibrary4A.disconnect(false); + MainActivity.csLibrary4A.disconnect(false); foregroundServiceState = NULL; } } else if (foregroundServiceState == CLOUDCONNECT) { - if (!csLibrary4A.isBleConnected()) foregroundServiceState = CONNECTED; + if (!MainActivity.csLibrary4A.isBleConnected()) foregroundServiceState = CONNECTED; else if (!isForegroundEnable()) foregroundServiceState = CONNECTED; - if (false && csLibrary4A.getInventoryCloudSave() == 1) { + if (false && MainActivity.csLibrary4A.getInventoryCloudSave() == 1) { saveExternalTask = new SaveList2ExternalTask(false); - csLibrary4A.appendToLog("Server: new saveExternalTask"); + MainActivity.csLibrary4A.appendToLog("Server: new saveExternalTask"); isHttpServerOpened = saveExternalTask.openServer(false); - csLibrary4A.appendToLog("Server: openServer is " + isHttpServerOpened); + MainActivity.csLibrary4A.appendToLog("Server: openServer is " + isHttpServerOpened); foregroundServiceState = CONNECTED; - } else if (csLibrary4A.getInventoryCloudSave() == 2) { + } else if (MainActivity.csLibrary4A.getInventoryCloudSave() == 2) { if (myMqttClient != null && myMqttClient.isMqttServerConnected) foregroundServiceState = CONNECTED; else { @@ -197,22 +195,22 @@ public void run() { } } else foregroundServiceState = NULL; } else if (foregroundServiceState == CONNECTED) { - if (csLibrary4A.isBleConnected()) { + if (MainActivity.csLibrary4A.isBleConnected()) { if (isForegroundEnable()) { boolean bStartInventory = false; - if (csLibrary4A.getInventoryCloudSave() == 1) { + if (MainActivity.csLibrary4A.getInventoryCloudSave() == 1) { if (false && !isHttpServerOpened) { - csLibrary4A.appendToLog("Server: going to CloudConnect"); + MainActivity.csLibrary4A.appendToLog("Server: going to CloudConnect"); foregroundServiceState = CLOUDCONNECT; - } else if (csLibrary4A.getTriggerButtonStatus()) { + } else if (MainActivity.csLibrary4A.getTriggerButtonStatus()) { strMessage += ("\n" + "H pressed trigger"); bStartInventory = true; } else strMessage += ("\n" + "H released trigger"); - } else if (csLibrary4A.getInventoryCloudSave() == 2 - && csLibrary4A.getServerMqttLocation().length() > 0 && csLibrary4A.getTopicMqtt().length() > 0) { + } else if (MainActivity.csLibrary4A.getInventoryCloudSave() == 2 + && MainActivity.csLibrary4A.getServerMqttLocation().length() > 0 && MainActivity.csLibrary4A.getTopicMqtt().length() > 0) { if (myMqttClient == null || !myMqttClient.isMqttServerConnected) foregroundServiceState = CLOUDCONNECT; - else if (csLibrary4A.getTriggerButtonStatus()) { + else if (MainActivity.csLibrary4A.getTriggerButtonStatus()) { strMessage += ("\n" + "M pressed trigger"); bStartInventory = true; } else strMessage += ("\n" + "M released trigger"); @@ -220,28 +218,32 @@ else if (csLibrary4A.getTriggerButtonStatus()) { if (bStartInventory) { //write2Server(messageStr); csLibrary4A.appendToLog("bImpinjServer: doInBackground after write2Server"); //closeServer(); csLibrary4A.appendToLog("bImpinjServer: doInBackground after closeServer"); - csLibrary4A.startOperation(RfidReaderChipData.OperationTypes.TAG_INVENTORY_COMPACT); - csLibrary4A.appendToLog("Server:sss startOperation"); + MainActivity.csLibrary4A.appendToLog("Debug_Compact: MyForegroundService.onStartCommand"); + MainActivity.csLibrary4A.startOperation(RfidReaderChipData.OperationTypes.TAG_INVENTORY_COMPACT); + MainActivity.csLibrary4A.appendToLog("Server:sss startOperation"); inventoryStartTimeMillis = System.currentTimeMillis(); foregroundServiceState = INVENTORY; } } - MainActivity.csLibrary4A.appendToLog("isForegroundEnable = " + isForegroundEnable() + ", getInventoryCloudSave = " + csLibrary4A.getInventoryCloudSave() + ", getServerMqttLocation = " + csLibrary4A.getServerMqttLocation() + ", getTopicMqtt = " + csLibrary4A.getTopicMqtt()); + MainActivity.csLibrary4A.appendToLog("isForegroundEnable = " + isForegroundEnable() + + ", getInventoryCloudSave = " + MainActivity.csLibrary4A.getInventoryCloudSave() + + ", getServerMqttLocation = " + MainActivity.csLibrary4A.getServerMqttLocation() + + ", getTopicMqtt = " + MainActivity.csLibrary4A.getTopicMqtt()); } else { - csLibrary4A.appendToLog("disconnect"); - csLibrary4A.disconnect(false); + MainActivity.csLibrary4A.appendToLog("disconnect"); + MainActivity.csLibrary4A.disconnect(false); if (isHttpServerOpened) { - if (saveExternalTask.closeServer()) csLibrary4A.appendToLog("Server: closeServer success"); - else csLibrary4A.appendToLog("Server: closeServer failure"); + if (saveExternalTask.closeServer()) MainActivity.csLibrary4A.appendToLog("Server: closeServer success"); + else MainActivity.csLibrary4A.appendToLog("Server: closeServer failure"); isHttpServerOpened = false; } if (myMqttClient != null) myMqttClient.disconnect(null); foregroundServiceState = NULL; } } else if (foregroundServiceState == INVENTORY) { - MainActivity.csLibrary4A.appendToLog("inventory: isBleConnected = " + csLibrary4A.isBleConnected()); + MainActivity.csLibrary4A.appendToLog("inventory: isBleConnected = " + MainActivity.csLibrary4A.isBleConnected()); MainActivity.csLibrary4A.appendToLog("inventory: myMqttClient = " + (myMqttClient == null ? "null" : myMqttClient.isMqttServerConnected)); - if (!csLibrary4A.isBleConnected()) foregroundServiceState = CONNECTED; + if (!MainActivity.csLibrary4A.isBleConnected()) foregroundServiceState = CONNECTED; // else if (csLibrary4A.getInventoryCloudSave() == 2 && (myMqttClient == null || !myMqttClient.isMqttServerConnected)) foregroundServiceState = CONNECTED; else { long timePeriod = System.currentTimeMillis() - startTimeMillis; @@ -251,11 +253,11 @@ else if (csLibrary4A.getTriggerButtonStatus()) { epcArrayList.clear(); } timePeriod = System.currentTimeMillis() - inventoryStartTimeMillis; - if (csLibrary4A.getInventoryCloudSave() == 2) timePeriod = 0; - if (isForegroundEnable() && csLibrary4A.getTriggerButtonStatus() && timePeriod < 2000L) { + if (MainActivity.csLibrary4A.getInventoryCloudSave() == 2) timePeriod = 0; + if (isForegroundEnable() && MainActivity.csLibrary4A.getTriggerButtonStatus() && timePeriod < 2000L) { RfidReaderChipData.Rx000pkgData rx000pkgData = null, rx000pkgData1 = null; - while (csLibrary4A.getTriggerButtonStatus()) { - rx000pkgData = csLibrary4A.onRFIDEvent(); + while (MainActivity.csLibrary4A.getTriggerButtonStatus()) { + rx000pkgData = MainActivity.csLibrary4A.onRFIDEvent(); MainActivity.csLibrary4A.appendToLog("rx000pkgData is " + (rx000pkgData == null ? "null" : "valid") + ", rx000pkgData1 is " + (rx000pkgData1 == null ? "null" : "valid")); if (rx000pkgData == null) { @@ -280,10 +282,10 @@ else if (csLibrary4A.getTriggerButtonStatus()) { else rx000pkgData1 = null; } if (rx000pkgData1 != null) { - csLibrary4A.appendToLog("Server: getInventoryCloudSave = " + MainActivity.csLibrary4A.getInventoryCloudSave()); + MainActivity.csLibrary4A.appendToLog("Server: getInventoryCloudSave = " + MainActivity.csLibrary4A.getInventoryCloudSave()); if (MainActivity.csLibrary4A.getInventoryCloudSave() == 1) { - ReaderDevice readerDevice1 = new ReaderDevice("", csLibrary4A.byteArrayToString(rx000pkgData1.decodedEpc), false, null, - csLibrary4A.byteArrayToString(rx000pkgData1.decodedPc), null, csLibrary4A.byteArrayToString(rx000pkgData1.decodedCrc), null, + ReaderDevice readerDevice1 = new ReaderDevice("", MainActivity.csLibrary4A.byteArrayToString(rx000pkgData1.decodedEpc), false, null, + MainActivity.csLibrary4A.byteArrayToString(rx000pkgData1.decodedPc), null, MainActivity.csLibrary4A.byteArrayToString(rx000pkgData1.decodedCrc), null, null, -1, -1, null, -1, -1, new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS").format(new Date()), new SimpleDateFormat("z").format(new Date()).replaceAll("GMT", ""), @@ -298,25 +300,26 @@ else if (csLibrary4A.getTriggerButtonStatus()) { } } if (rx000pkgData1 != null) - strMessage += ("\n " + csLibrary4A.byteArrayToString(rx000pkgData1.decodedEpc)); + strMessage += ("\n " + MainActivity.csLibrary4A.byteArrayToString(rx000pkgData1.decodedEpc)); } else { //isForegroundEnable() && csLibrary4A.getTriggerButtonStatus() && timePeriod - csLibrary4A.appendToLog("Server:sss abortOperation with isForegroundEnable = " + isForegroundEnable() + ", getTriggerButtonStatus = " + csLibrary4A.getTriggerButtonStatus() + ", timePeriod = " + timePeriod + ", "); - csLibrary4A.abortOperation(); + MainActivity.csLibrary4A.appendToLog("Server:sss abortOperation with isForegroundEnable = " + isForegroundEnable() + + ", getTriggerButtonStatus = " + MainActivity.csLibrary4A.getTriggerButtonStatus() + ", timePeriod = " + timePeriod + ", "); + MainActivity.csLibrary4A.abortOperation(); while (true) { - RfidReaderChipData.Rx000pkgData rx000pkgData = csLibrary4A.onRFIDEvent(); + RfidReaderChipData.Rx000pkgData rx000pkgData = MainActivity.csLibrary4A.onRFIDEvent(); if (rx000pkgData == null) break; } if (readerDeviceArrayList.size() != 0) { saveExternalTask = new SaveList2ExternalTask(false); - csLibrary4A.appendToLog("Server: new saveExternalTask"); + MainActivity.csLibrary4A.appendToLog("Server: new saveExternalTask"); isHttpServerOpened = saveExternalTask.openServer(false); - csLibrary4A.appendToLog("Server: openServer is " + isHttpServerOpened); + MainActivity.csLibrary4A.appendToLog("Server: openServer is " + isHttpServerOpened); String messageStr = saveExternalTask.createJSON(readerDeviceArrayList, null).toString(); MainActivity.csLibrary4A.appendToLog("Server: Json = " + messageStr); saveExternalTask.write2Server(messageStr); - csLibrary4A.appendToLog("Server: write2Server success"); - if (saveExternalTask.closeServer()) csLibrary4A.appendToLog("Server: closeServer success"); - else csLibrary4A.appendToLog("Server: closeServer failure"); + MainActivity.csLibrary4A.appendToLog("Server: write2Server success"); + if (saveExternalTask.closeServer()) MainActivity.csLibrary4A.appendToLog("Server: closeServer success"); + else MainActivity.csLibrary4A.appendToLog("Server: closeServer failure"); } foregroundServiceState = CONNECTED; } @@ -352,9 +355,9 @@ else if (csLibrary4A.getTriggerButtonStatus()) { public void onDestroy() { Log.i("Hello1", "MyForegroundService: onDestroy"); mHandler.removeCallbacks(serviceRunnable); - if (csLibrary4A != null) { - csLibrary4A.disconnect(false); - csLibrary4A.appendToLog("MyForegroundService: onDestroy 0"); + if (MainActivity.csLibrary4A != null) { + MainActivity.csLibrary4A.disconnect(false); + MainActivity.csLibrary4A.appendToLog("MyForegroundService: onDestroy 0"); } thread.stop(); stopSelf(); @@ -364,13 +367,13 @@ public void onDestroy() { @Nullable @Override public IBinder onBind(Intent intent) { - csLibrary4A.appendToLog("MyForegroundService: onBind"); + MainActivity.csLibrary4A.appendToLog("MyForegroundService: onBind"); return binder; // null; } @Override public void onTaskRemoved(Intent rootIntent) { - csLibrary4A.appendToLog("MyForegroundService: onTaskRemoved"); + MainActivity.csLibrary4A.appendToLog("MyForegroundService: onTaskRemoved"); System.out.println("onTaskRemoved called"); super.onTaskRemoved(rootIntent); //do something you want @@ -381,7 +384,7 @@ public void onTaskRemoved(Intent rootIntent) { Thread thread = null; Notification updateNotification(String string) { - Log.i("Hello","MyForegroundService updateNotification: " + string); + if (DEBUG) Log.i("Hello","MyForegroundService updateNotification: " + string); notificationCompatBuilder.setContentText(string); Notification notification = notificationCompatBuilder.build(); notificationManager.notify(1, notification); @@ -397,17 +400,17 @@ public void run() { else if (MainActivity.activityActive == false && MainActivity.csLibrary4A.isBleConnected()) { int batteryCount = MainActivity.csLibrary4A.getBatteryCount(); String strBatteryLow = MainActivity.csLibrary4A.isBatteryLow(); - MainActivity.csLibrary4A.appendToLog("CustomIME Debug 11 with batteryCount = " + batteryCount + ", batteryCount_old = " + batteryCount_old); + if (DEBUG) MainActivity.csLibrary4A.appendToLog("CustomIME Debug 11 with batteryCount = " + batteryCount + ", batteryCount_old = " + batteryCount_old); if (batteryCount_old != batteryCount) { batteryCount_old = batteryCount; - MainActivity.csLibrary4A.appendToLog("CustomIME Debug 110 with isBatteryLow as " + strBatteryLow + ", strBattteryLow_old = " + strBatteryLow_old); + if (DEBUG) MainActivity.csLibrary4A.appendToLog("CustomIME Debug 110 with isBatteryLow as " + strBatteryLow + ", strBattteryLow_old = " + strBatteryLow_old); if (strBatteryLow == null || strBatteryLow_old == null) strBatteryLow_old = strBatteryLow; else if (!strBatteryLow.matches(strBatteryLow_old)) strBatteryLow_old = strBatteryLow; } if (strBatteryLow != null) { - MainActivity.csLibrary4A.appendToLog("CustomIME Debug 112"); + if (false) MainActivity.csLibrary4A.appendToLog("CustomIME Debug 112"); Toast.makeText(mContext, "Battery Low: " + strBatteryLow + "% Battery Life Left", Toast.LENGTH_SHORT).show(); @@ -422,7 +425,7 @@ int getRandomNumber() { } boolean isForegroundEnable() { - MainActivity.csLibrary4A.appendToLog("isHomeFragment = " + MainActivity.isHomeFragment + ", getForegroundReader = " + MainActivity.csLibrary4A.getForegroundReader()); + if (DEBUG) MainActivity.csLibrary4A.appendToLog("isHomeFragment = " + MainActivity.isHomeFragment + ", getForegroundReader = " + MainActivity.csLibrary4A.getForegroundReader()); return (MainActivity.isHomeFragment && MainActivity.csLibrary4A.getForegroundReader().length() != 0); } diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessAuraSenseFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessAuraSenseFragment.java index 4284618..31ece29 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessAuraSenseFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessAuraSenseFragment.java @@ -1,6 +1,12 @@ package com.csl.cs108ademoapp.fragments; import static com.csl.cs108ademoapp.MainActivity.tagSelected; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_EM; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_EM_AURASENSE; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_EM_AURASENSE_ATBOOT; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_EM_AURASENSE_ATSELECT; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_EM_BAP; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_EM_COLDCHAIN; import android.app.Activity; import android.os.AsyncTask; @@ -87,25 +93,25 @@ public void onItemSelected(AdapterView parentView, View selectedItemView, int if (MainActivity.csLibrary4A.get98XX() == 2) tableRow.setVisibility(View.GONE); LinearLayout layout4 = (LinearLayout) getActivity().findViewById(R.id.accessCustomReadWrite); if (position == eMicroTag.emAuraSense.ordinal()) { - MainActivity.mDid = "E280B12"; + MainActivity.tagType = TAG_EM_AURASENSE; MainActivity.mDid = "E280B12"; layout0.setVisibility(View.VISIBLE); layout1.setVisibility(View.VISIBLE); layout2.setVisibility(View.GONE); layout4.setVisibility(View.VISIBLE); } else if (position == eMicroTag.emColdChain.ordinal()) { - MainActivity.mDid = "E280B0"; + MainActivity.tagType = TAG_EM_COLDCHAIN; MainActivity.mDid = "E280B0"; layout0.setVisibility(View.VISIBLE); layout1.setVisibility(View.GONE); layout2.setVisibility(View.VISIBLE); layout4.setVisibility(View.VISIBLE); } else if (position == eMicroTag.emBap.ordinal()) { - MainActivity.mDid = "E200B0"; + MainActivity.tagType = TAG_EM_BAP; MainActivity.mDid = "E200B0"; layout0.setVisibility(View.GONE); layout1.setVisibility(View.GONE); layout2.setVisibility(View.GONE); layout4.setVisibility(View.GONE); } else { - MainActivity.mDid = "E280B"; + MainActivity.tagType = TAG_EM; MainActivity.mDid = "E280B"; layout0.setVisibility(View.GONE); layout1.setVisibility(View.GONE); layout2.setVisibility(View.GONE); @@ -282,6 +288,7 @@ public void onClick(View v) { @Override public void onDestroy() { if (accessTask != null) accessTask.cancel(true); + MainActivity.csLibrary4A.setSameCheck(true); super.onDestroy(); } @@ -308,8 +315,12 @@ public void setUserVisibleHint(boolean isVisibleToUser) { else { if (spinnerTagSelect != null && spinnerTagSelect.getSelectedItemPosition() == eMicroTag.emAuraSense.ordinal()) { if (radioButtonAuraSensAtBoot != null && radioButtonAuraSensAtSelect != null) { - if (radioButtonAuraSensAtBoot.isChecked()) MainActivity.mDid = "E280B12A"; - if (radioButtonAuraSensAtSelect.isChecked()) MainActivity.mDid = "E280B12B"; + if (radioButtonAuraSensAtBoot.isChecked()) { + MainActivity.tagType = TAG_EM_AURASENSE_ATBOOT; MainActivity.mDid = "E280B12A"; + } + if (radioButtonAuraSensAtSelect.isChecked()) { + MainActivity.tagType = TAG_EM_AURASENSE_ATSELECT; MainActivity.mDid = "E280B12B"; + } } } userVisibleHint = false; @@ -382,8 +393,7 @@ else if (taskRequest) { buttonAccess = buttonWrite; } MainActivity.csLibrary4A.appendToLog("hostCommand 1 = " + hostCommand.toString()); - accessTask = new AccessTask( - buttonAccess, null, invalid, + accessTask = new AccessTask(buttonAccess, null, invalid, true, selectMask, selectBank, selectOffset, selectTag.editTextAccessPassword.getText().toString(), Integer.valueOf(selectTag.editTextAccessAntennaPower.getText().toString()), diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessColdChainFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessColdChainFragment.java index 97b3e17..90e789f 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessColdChainFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessColdChainFragment.java @@ -294,9 +294,7 @@ else if (taskRequest) { if (readWriteTypes == ReadWriteTypes.TEMPERATURE) hostCommand = RfidReaderChipData.HostCommands.CMD_GETSENSORDATA; else if (operationRead) hostCommand = RfidReaderChipData.HostCommands.CMD_18K6CREAD; else hostCommand = RfidReaderChipData.HostCommands.CMD_18K6CWRITE; - accessTask = new AccessTask( - (operationRead ? buttonRead : buttonWrite), null, - invalid, + accessTask = new AccessTask((operationRead ? buttonRead : buttonWrite), null, invalid, true, editTextRWTagID.getText().toString(), 1, 32, editTextAccessRWAccPassword.getText().toString(), Integer.valueOf(editTextaccessRWAntennaPower.getText().toString()), diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessEm4325PassiveFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessEm4325PassiveFragment.java index d7957d5..dcb001d 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessEm4325PassiveFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessEm4325PassiveFragment.java @@ -154,9 +154,7 @@ else if (taskRequest) { else if (operationRead) hostCommand = RfidReaderChipData.HostCommands.CMD_18K6CREAD; else hostCommand = RfidReaderChipData.HostCommands.CMD_18K6CWRITE; MainActivity.csLibrary4A.appendToLog("hostCommand = " + hostCommand.toString()); - accessTask = new AccessTask( - buttonRead, null, - invalid, + accessTask = new AccessTask(buttonRead, null, invalid, true, editTextRWTagID.getText().toString(), 1, 32, editTextAccessRWAccPassword.getText().toString(), Integer.valueOf(editTextaccessRWAntennaPower.getText().toString()), diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessFdmicroFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessFdmicroFragment.java index 054532e..e7a1f83 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessFdmicroFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessFdmicroFragment.java @@ -543,9 +543,7 @@ void doAccessTask(RfidReaderChipData.HostCommands hostCommand) { int selectBank = selectTag.spinnerSelectBank.getSelectedItemPosition() + 1; int selectOffset = Integer.valueOf(selectTag.editTextSelectOffset.getText().toString()); boolean invalid = false; - accessTask = new AccessTask( - (operationRead ? buttonRead : buttonWrite), null, - invalid, + accessTask = new AccessTask((operationRead ? buttonRead : buttonWrite), null, invalid, true, selectMask, selectBank, selectOffset, selectTag.editTextAccessPassword.getText().toString(), Integer.valueOf(selectTag.editTextAccessAntennaPower.getText().toString()), diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessImpinjFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessImpinjFragment.java index ae7d8e7..6fd45fa 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessImpinjFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessImpinjFragment.java @@ -1,5 +1,7 @@ package com.csl.cs108ademoapp.fragments; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_IMPINJ; + import android.app.Activity; import android.os.AsyncTask; import android.os.Bundle; @@ -170,7 +172,7 @@ public void onClick(View v) { textViewAuthenticatedResult.setText(""); boolean invalidRequest = MainActivity.csLibrary4A.setAuthenticateConfiguration(); - accessTask = new AccessTask(button, null, false, + accessTask = new AccessTask(button, null, false, true, selectTag.editTextTagID.getText().toString(), 1, 32, selectTag.editTextAccessPassword.getText().toString(), Integer.valueOf(selectTag.editTextAccessAntennaPower.getText().toString()), RfidReaderChipData.HostCommands.CMD_18K6CAUTHENTICATE, -1, -1, false, false, @@ -204,7 +206,7 @@ public void onClick(View v) { else if (itagSelect == impinjTag.monza_R6P.ordinal()) iAccOffset = 0x14; MainActivity.csLibrary4A.appendToLog(String.format("AutoTune offset is 0x%X", iAccOffset)); if (set_before_access(0, itagSelect, 1) == false) invalidRequest = true; - accessTask = new AccessTask(buttonAutoTuneValueRead, null, invalidRequest, + accessTask = new AccessTask(buttonAutoTuneValueRead, null, invalidRequest, true, selectTag.editTextTagID.getText().toString(), 1, 32, selectTag.editTextAccessPassword.getText().toString(), Integer.valueOf(selectTag.editTextAccessAntennaPower.getText().toString()), RfidReaderChipData.HostCommands.CMD_18K6CREAD, -1, -1, false, checkProtectedBoxBeforeAccess(), @@ -228,7 +230,7 @@ public void onClick(View v) { textViewProtectValue.setText(""); boolean invalidRequest = false; if (set_before_access(1, 2, 6) == false) invalidRequest = true; - accessTask = new AccessTask(buttonProtectValueRead, null, invalidRequest, + accessTask = new AccessTask(buttonProtectValueRead, null, invalidRequest, true, selectTag.editTextTagID.getText().toString(), 1, 32, selectTag.editTextAccessPassword.getText().toString(), Integer.valueOf(selectTag.editTextAccessAntennaPower.getText().toString()), RfidReaderChipData.HostCommands.CMD_18K6CREAD, -1, -1, false, checkProtectedBoxBeforeAccess(), @@ -279,7 +281,7 @@ public void onClick(View v) { textViewEpc128Value.setText(""); boolean invalidRequest = false; if (set_before_access(1, 2, 8) == false) invalidRequest = true; - accessTask = new AccessTask(buttonEpc128ValueRead, null, invalidRequest, + accessTask = new AccessTask(buttonEpc128ValueRead, null, invalidRequest, true, selectTag.editTextTagID.getText().toString(), 1, 32, selectTag.editTextAccessPassword.getText().toString(), Integer.valueOf(selectTag.editTextAccessAntennaPower.getText().toString()), RfidReaderChipData.HostCommands.CMD_18K6CREAD, -1, -1, false, checkProtectedBoxBeforeAccess(), @@ -417,7 +419,7 @@ void startConfigRead() { int iSelectBank = selectTag.spinnerSelectBank.getSelectedItemPosition() + 1; int iSelectOffset = 32; if (iSelectBank != 1) iSelectOffset = 0; - accessTask = new AccessTask(buttonRead, null, invalidRequest, + accessTask = new AccessTask(buttonRead, null, invalidRequest, true, selectTag.editTextTagID.getText().toString(), iSelectBank, iSelectOffset, selectTag.editTextAccessPassword.getText().toString(), Integer.valueOf(selectTag.editTextAccessAntennaPower.getText().toString()), RfidReaderChipData.HostCommands.CMD_18K6CREAD, -1, -1, false, checkProtectedBoxBeforeAccess(), @@ -483,7 +485,7 @@ void startConfigWrite() { } } - accessTask = new AccessTask(buttonWrite, null, invalidRequest, + accessTask = new AccessTask(buttonWrite, null, invalidRequest, true, selectTag.editTextTagID.getText().toString(), 1, 32, selectTag.editTextAccessPassword.getText().toString(), Integer.valueOf(selectTag.editTextAccessAntennaPower.getText().toString()), RfidReaderChipData.HostCommands.CMD_18K6CWRITE, -1, -1, false, checkProtectedBoxBeforeAccess(), @@ -492,12 +494,15 @@ void startConfigWrite() { mHandler.removeCallbacks(updateRunnable); iRunType = 6; mHandler.post(updateRunnable); } + boolean bReadySelected = false; boolean checkProtectedBoxBeforeAccess() { + bReadySelected = false; if (checkBoxProtectSelect.isChecked()) { MainActivity.csLibrary4A.appendToLog("Going to setSelectCriteria disable"); MainActivity.csLibrary4A.setSelectCriteriaDisable(-1); MainActivity.csLibrary4A.appendToLog("Going to setSelectCriteria"); MainActivity.csLibrary4A.setSelectCriteria(-1, true, 4, 0, 3, 0, selectTag.editTextAccessPassword.getText().toString(), false); + bReadySelected = true; } return checkBoxProtectSelect.isChecked(); } @@ -673,7 +678,7 @@ public void setUserVisibleHint(boolean isVisibleToUser) { } else MainActivity.csLibrary4A.setTagGroup(MainActivity.csLibrary4A.getQuerySelect(), 0, 2); if (checkBoxFastId.isChecked()) iValue |= 0x20; if (spinnerTagSelect.getSelectedItemPosition() != impinjTag.others.ordinal()) iValue |= (spinnerTagSelect.getSelectedItemPosition() + 1); - MainActivity.mDid = "E28011" + String.format("%02X", iValue); + MainActivity.tagType = TAG_IMPINJ; /* need more tagType */ MainActivity.mDid = "E28011" + String.format("%02X", iValue); MainActivity.csLibrary4A.appendToLog(String.format("HelloK: iValue = 0x%02X, mDid = %s", iValue, MainActivity.mDid)); MainActivity.csLibrary4A.setImpinJExtension(checkBoxTagFocus.isChecked(), checkBoxFastId.isChecked()); } diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessKilowayFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessKilowayFragment.java index d20e028..8e0600c 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessKilowayFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessKilowayFragment.java @@ -143,8 +143,7 @@ public void run() { if (checkBoxRepeat != null && checkBoxRepeat.isChecked()) { bankProcessing = 0; checkProcessing = 0; } else rerunRequest = false; } else { - accessTask = new AccessTask( - buttonRead, invalid, + accessTask = new AccessTask(buttonRead, invalid, true, editTextRWTagID.getText().toString(), 1, 32, "00000000", Integer.valueOf(editTextaccessRWAntennaPower.getText().toString()), RfidReaderChipData.HostCommands.CMD_18K6CREAD, false, null); 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 b341bcc..ca21334 100644 --- 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,10 @@ package com.csl.cs108ademoapp.fragments; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_AXZON; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_MAGNUS_S2; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_MAGNUS_S3; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_XERXES; + import androidx.lifecycle.Lifecycle; import android.graphics.Color; import android.os.AsyncTask; @@ -120,16 +125,16 @@ public void onItemSelected(AdapterView adapterView, View view, int i, long l) switch (spinnerTagType.getSelectedItemPosition()) { case 0: - MainActivity.mDid = "E28240"; + MainActivity.tagType = TAG_AXZON; MainActivity.mDid = "E28240"; break; case 1: - MainActivity.mDid = "E282402"; + MainActivity.tagType = TAG_MAGNUS_S2; MainActivity.mDid = "E282402"; break; case 2: - MainActivity.mDid = "E282403"; + MainActivity.tagType = TAG_MAGNUS_S3; MainActivity.mDid = "E282403"; break; case 3: - MainActivity.mDid = "E282405"; + MainActivity.tagType = TAG_XERXES; MainActivity.mDid = "E282405"; break; } if (btagTypeSelected) { @@ -393,9 +398,7 @@ else if (taskRequest) { int selectBank = 1; int selectOffset = 32; String selectMask = editTextRWTagID.getText().toString(); - accessTask = new AccessTask( - buttonRead, null, - invalid, + accessTask = new AccessTask(buttonRead, null, invalid, true, selectMask, selectBank, selectOffset, editTextAccessRWAccPassword.getText().toString(), Integer.valueOf(editTextaccessRWAntennaPower.getText().toString()), diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessRegisterFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessRegisterFragment.java index fa73a7b..1197b25 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessRegisterFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessRegisterFragment.java @@ -223,6 +223,7 @@ public void onClick(View view) { long pwrlevel = Integer.parseInt(editTextAntennaPower.getText().toString()); MainActivity.csLibrary4A.setTagRead(0); MainActivity.csLibrary4A.setSelectedTag(strTagId, selectBank, pwrlevel); + MainActivity.csLibrary4A.appendToLog("Debug_Compact: AccessRegisterFragment.onActivityCreated.onClick"); MainActivity.csLibrary4A.startOperation(RfidReaderChipData.OperationTypes.TAG_INVENTORY); inventoryRfidTask = new InventoryRfidTask(); inventoryRfidTask.execute(); @@ -661,7 +662,7 @@ else if (MainActivity.csLibrary4A.setAccessCount(writeLength) == false) { MainActivity.csLibrary4A.appendToLog("invalidRequest1 = " + invalidRequest1 + ", selectMask = " + selectMask + ", selectBank1 = " + selectBank1 + ", selectOffset1 = " + selectOffset1 + ", password = " + password + ", power = " + antennaPower + ", repeatCount = " + repeatCount + ", resetCount = " + resetCount); - accessTask = new AccessTask(buttonWrite, textViewWriteCount, invalidRequest1, + accessTask = new AccessTask(buttonWrite, textViewWriteCount, invalidRequest1, true, selectMask, selectBank1, selectOffset1, password, antennaPower, RfidReaderChipData.HostCommands.CMD_18K6CWRITE, selectQValue, repeatCount, resetCount, false, diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessSecurityFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessSecurityFragment.java index 98c4341..df7800a 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessSecurityFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessSecurityFragment.java @@ -11,13 +11,13 @@ import com.csl.cs108ademoapp.MainActivity; import com.csl.cs108ademoapp.R; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; public class AccessSecurityFragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = {"Lock", "Kill"}; @@ -37,7 +37,7 @@ public void onActivityCreated(Bundle savedInstanceState) { TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.OperationsTabLayout); - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); adapter.setFragment(0, new AccessSecurityLockFragment()); adapter.setFragment(1, new AccessSecurityKillFragment()); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessSecurityKillFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessSecurityKillFragment.java index 587db27..d8b37fa 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessSecurityKillFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessSecurityKillFragment.java @@ -122,7 +122,7 @@ void startAccessTask() { String strTagID = editTextTagID.getText().toString(); String strPassword = editTextPassword.getText().toString(); int powerLevel = Integer.valueOf(editTextAntennaPower.getText().toString()); - accessTask = new AccessTask(button, null, invalidRequest, + accessTask = new AccessTask(button, null, invalidRequest, true, strTagID, 1, 32, strPassword, powerLevel, RfidReaderChipData.HostCommands.CMD_18K6CKILL, 0, 0, true, false, diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessSecurityLockFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessSecurityLockFragment.java index d25260b..ac837ea 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessSecurityLockFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessSecurityLockFragment.java @@ -187,7 +187,7 @@ void startAccessTask() { invalidRequest = true; } } - accessTask = new AccessTask(button, null, invalidRequest, + accessTask = new AccessTask(button, null, invalidRequest, true, strTagID, 1, 32, strPassword, powerLevel, RfidReaderChipData.HostCommands.CMD_18K6CLOCK, 0, 0, true, false, diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessUcode8Fragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessUcode8Fragment.java index 4e5db17..67320a9 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessUcode8Fragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessUcode8Fragment.java @@ -1,5 +1,13 @@ package com.csl.cs108ademoapp.fragments; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_NXP; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_NXP_UCODE8; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_NXP_UCODE8_EPC; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_NXP_UCODE8_EPCBRAND; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_NXP_UCODE8_EPCBRANDTID; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_NXP_UCODE8_EPCTID; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_NXP_UCODEDNA; + import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; @@ -44,14 +52,19 @@ public void onItemSelected(AdapterView parentView, View selectedItemView, int TabLayout.TabView tabViewUntrace = tabLayout.getTabAt(3).view; tabViewUntrace.setVisibility(View.GONE); LinearLayout layout = (LinearLayout) getActivity().findViewById(R.id.accessNxpUcode8Select); layout.setVisibility(View.GONE); if (position == nxpTag.ucode8.ordinal()) { - MainActivity.mDid = "E2806894"; + updateUcode8Type(); + MainActivity.csLibrary4A.appendToLog("AccessUcode8Fragment.onItemSelected[spinnerTagSelect] set MainActivity.mDid as " + MainActivity.mDid); if (MainActivity.csLibrary4A.get98XX() == 0) tabViewUntrace.setVisibility(View.VISIBLE); layout.setVisibility(View.VISIBLE); } else if (position == nxpTag.ucodeDNA.ordinal()) { - MainActivity.mDid = "E2C06"; + MainActivity.tagType = TAG_NXP_UCODEDNA; MainActivity.mDid = "E2C06"; + MainActivity.csLibrary4A.appendToLog("AccessUcode8Fragment.onItemSelected set MainActivity.mDid as E2C06"); tabView.setVisibility(View.VISIBLE); if (MainActivity.csLibrary4A.get98XX() == 0) tabViewUntrace.setVisibility(View.VISIBLE); - } else MainActivity.mDid = "E2806"; + } else { + MainActivity.tagType = TAG_NXP; MainActivity.mDid = "E2806"; + MainActivity.csLibrary4A.appendToLog("AccessUcode8Fragment.onItemSelected set MainActivity.mDid as E2806"); + } MainActivity.csLibrary4A.appendToLog("new mDid = " + MainActivity.mDid); } @@ -77,6 +90,7 @@ public void onNothingSelected(AdapterView parentView) { @Override public void onDestroy() { + MainActivity.csLibrary4A.setSameCheck(true); super.onDestroy(); } @@ -89,32 +103,41 @@ public void setUserVisibleHint(boolean isVisibleToUser) { MainActivity.csLibrary4A.appendToLog("AccessUcode8Fragment is now VISIBLE"); // setNotificationListener(); } else { - if (spinnerTagSelect != null && spinnerTagSelect.getSelectedItemPosition() == nxpTag.ucode8.ordinal()) { - if (radioButtonSelectEpc != null && radioButtonSelectEpcTid != null && radioButtonSelectEpcBrand != null && radioButtonSelectEpcBrandTidCheck != null) { - if (radioButtonSelectEpc.isChecked()) { - MainActivity.csLibrary4A.appendToLog("Selected EPC"); - MainActivity.mDid = "E2806894A"; - } - if (radioButtonSelectEpcTid.isChecked()) { - MainActivity.csLibrary4A.appendToLog("Selected EPC+TID"); - MainActivity.mDid = "E2806894B"; - } - if (radioButtonSelectEpcBrand.isChecked()) { - MainActivity.csLibrary4A.appendToLog("Selected EPC+BRAND"); - MainActivity.mDid = "E2806894C"; - } - if (radioButtonSelectEpcBrandTidCheck.isChecked()) { - MainActivity.csLibrary4A.appendToLog("Selected EPC+BRAND"); - MainActivity.mDid = "E2806894d"; - } - MainActivity.csLibrary4A.appendToLog("newDid 1 = " + MainActivity.mDid); - } - } + updateUcode8Type(); + MainActivity.csLibrary4A.appendToLog("AccessUcode8Fragment.setUserVisibleHint set MainActivity.mDid as " + MainActivity.mDid); userVisibleHint = false; MainActivity.csLibrary4A.appendToLog("AccessUcode8Fragment is now INVISIBLE"); } } + void updateUcode8Type() { + if (spinnerTagSelect != null && spinnerTagSelect.getSelectedItemPosition() == nxpTag.ucode8.ordinal()) { + if (radioButtonSelectEpc != null && radioButtonSelectEpcTid != null && radioButtonSelectEpcBrand != null && radioButtonSelectEpcBrandTidCheck != null) { + if (radioButtonSelectEpc.isChecked()) { + MainActivity.csLibrary4A.appendToLog("Selected EPC"); + MainActivity.tagType = TAG_NXP_UCODE8_EPC; MainActivity.mDid = "E2806894A"; + MainActivity.csLibrary4A.appendToLog("AccessUcode8Fragment.setUserVisibleHint set MainActivity.mDid as E2806894A"); + } + if (radioButtonSelectEpcTid.isChecked()) { + MainActivity.csLibrary4A.appendToLog("Selected EPC+TID"); + MainActivity.tagType = TAG_NXP_UCODE8_EPCTID; MainActivity.mDid = "E2806894B"; + MainActivity.csLibrary4A.appendToLog("AccessUcode8Fragment.setUserVisibleHint set MainActivity.mDid as E2806894b"); + } + if (radioButtonSelectEpcBrand.isChecked()) { + MainActivity.csLibrary4A.appendToLog("Selected EPC+BRAND"); + MainActivity.tagType = TAG_NXP_UCODE8_EPCBRAND; MainActivity.mDid = "E2806894C"; + MainActivity.csLibrary4A.appendToLog("AccessUcode8Fragment.setUserVisibleHint set MainActivity.mDid as E2806894C"); + } + if (radioButtonSelectEpcBrandTidCheck.isChecked()) { + MainActivity.csLibrary4A.appendToLog("Selected EPC+BRAND"); + MainActivity.tagType = TAG_NXP_UCODE8_EPCBRANDTID; MainActivity.mDid = "E2806894d"; + MainActivity.csLibrary4A.appendToLog("AccessUcode8Fragment.setUserVisibleHint set MainActivity.mDid as E2806894d"); + } + MainActivity.csLibrary4A.appendToLog("newDid 1 = " + MainActivity.mDid); + } + } + } + public AccessUcode8Fragment() { super("AccessUcode8Fragment"); } diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessUcodeFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessUcodeFragment.java index 0a52030..6b23a2c 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessUcodeFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessUcodeFragment.java @@ -24,6 +24,7 @@ import com.csl.cs108ademoapp.R; import com.csl.cs108ademoapp.SaveList2ExternalTask; import com.csl.cs108ademoapp.SelectTag; +import com.csl.cslibrary4a.AesCmac; import com.csl.cslibrary4a.ReaderDevice; import com.csl.cslibrary4a.RfidReaderChipData; @@ -682,8 +683,7 @@ else if (taskRequest) { else if (operationRead) hostCommand = RfidReaderChipData.HostCommands.CMD_18K6CREAD; else hostCommand = RfidReaderChipData.HostCommands.CMD_18K6CWRITE; - accessTask = new AccessTask( - button, null, invalid, + accessTask = new AccessTask(button, null, invalid, true, selectTag.editTextTagID.getText().toString(), 1, 32, selectTag.editTextAccessPassword.getText().toString(), Integer.valueOf(selectTag.editTextAccessAntennaPower.getText().toString()), hostCommand, 0, 0, true, false, diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessXerxesLoggerFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessXerxesLoggerFragment.java index 161bcea..b65a619 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessXerxesLoggerFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AccessXerxesLoggerFragment.java @@ -262,8 +262,7 @@ else if (taskRequest) { int selectBank = 1; int selectOffset = 32; String selectMask = editTextRWTagID.getText().toString(); - accessTask = new AccessTask( - (operationRead ? buttonRead : buttonWrite), null, invalid, + accessTask = new AccessTask((operationRead ? buttonRead : buttonWrite), null, invalid, true, selectMask, selectBank, selectOffset, editTextAccessRWAccPassword.getText().toString(), Integer.valueOf(editTextaccessRWAntennaPower.getText().toString()), (operationRead ? RfidReaderChipData.HostCommands.CMD_18K6CREAD: RfidReaderChipData.HostCommands.CMD_18K6CWRITE), 0, 0, true, false, diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AuraSenseFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AuraSenseFragment.java index d1ab38c..9c80b89 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AuraSenseFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AuraSenseFragment.java @@ -1,6 +1,9 @@ package com.csl.cs108ademoapp.fragments; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_EM_AURASENSE; + import android.os.Bundle; + import com.google.android.material.tabs.TabLayout; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -141,7 +144,7 @@ public Fragment getItem(int index) { fragment0 = fragment; break; default: - fragment = InventoryRfidiMultiFragment.newInstance(true,"E280B12"); + fragment = InventoryRfidiMultiFragment.newInstance(true, TAG_EM_AURASENSE, "E280B12"); fragment1 = fragment; break; } diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AxzonFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AxzonFragment.java index ca8f4f0..c61834e 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AxzonFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AxzonFragment.java @@ -3,7 +3,7 @@ import androidx.lifecycle.Lifecycle; import android.os.Bundle; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; import androidx.viewpager.widget.ViewPager; import androidx.appcompat.app.ActionBar; @@ -19,7 +19,7 @@ public class AxzonFragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = { "Scan/Select", "Read" }; private String[] tabsXerxes = { "Logger", "Security" }; @@ -72,8 +72,8 @@ public void onActivityCreated(Bundle savedInstanceState) { TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.OperationsTabLayout); - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), (bXervesTag ? 4 : 2)); - adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true, "")); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), (bXervesTag ? 4 : 2)); + adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true, null, "")); adapter.setFragment(1, AccessMicronFragment.newInstance(true)); adapter.setFragment(2, new AccessXerxesLoggerFragment()); adapter.setFragment(3, new AccessUcodeFragment()); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AxzonSelectorFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/AxzonSelectorFragment.java index 4fc6999..c77e879 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AxzonSelectorFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/AxzonSelectorFragment.java @@ -1,5 +1,10 @@ package com.csl.cs108ademoapp.fragments; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_AXZON; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_MAGNUS_S2; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_MAGNUS_S3; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_XERXES; + import android.os.Bundle; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; @@ -78,16 +83,16 @@ public AxzonSelectorFragment() { void gotoAxzonFragment(int tagType) { switch(tagType) { case 2: - MainActivity.mDid = "E282402"; + MainActivity.tagType = TAG_MAGNUS_S2; MainActivity.mDid = "E282402"; break; case 3: - MainActivity.mDid = "E282403"; + MainActivity.tagType = TAG_MAGNUS_S3; MainActivity.mDid = "E282403"; break; case 5: - MainActivity.mDid = "E282405"; + MainActivity.tagType = TAG_XERXES; MainActivity.mDid = "E282405"; break; default: - MainActivity.mDid = "E2824"; + MainActivity.tagType = TAG_AXZON; MainActivity.mDid = "E2824"; break; } MainActivity.csLibrary4A.appendToLog("HelloABC: gotoAxzonFragment with tagType = " + tagType + ", MainActivity.mDid = " + MainActivity.mDid); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/ColdChainFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/ColdChainFragment.java index 5b4eef7..b5270d7 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/ColdChainFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/ColdChainFragment.java @@ -1,5 +1,7 @@ package com.csl.cs108ademoapp.fragments; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_EM_COLDCHAIN; + import android.os.Bundle; import android.view.LayoutInflater; import android.view.MenuItem; @@ -12,13 +14,13 @@ import com.csl.cs108ademoapp.MainActivity; import com.csl.cs108ademoapp.R; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; public class ColdChainFragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = {"Select Tag", "Logging", "One-shot"}; @@ -59,8 +61,8 @@ public void onActivityCreated(Bundle savedInstanceState) { TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.OperationsTabLayout); - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); - adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true,"E280B0")); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); + adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true, TAG_EM_COLDCHAIN, "E280B0")); adapter.setFragment(1, new AccessColdChainFragment()); adapter.setFragment(2, new AccessEm4325PassiveFragment()); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/FdmicroFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/FdmicroFragment.java index c459d07..d49c5b3 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/FdmicroFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/FdmicroFragment.java @@ -1,8 +1,10 @@ package com.csl.cs108ademoapp.fragments; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_FDMICRO; + import android.os.Bundle; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; import androidx.viewpager.widget.ViewPager; @@ -18,7 +20,7 @@ public class FdmicroFragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = {"Scan", "Configuration"}; @@ -76,8 +78,8 @@ public void onTabReselected(TabLayout.Tab tab) { } }); - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); - adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true,"E2827001")); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); + adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true, TAG_FDMICRO, "E2827001")); adapter.setFragment(1, new AccessFdmicroFragment()); viewPager = (ViewPager) getActivity().findViewById(R.id.OperationsPager); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/HomeFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/HomeFragment.java index 8eaf931..f10e0de 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/HomeFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/HomeFragment.java @@ -103,7 +103,7 @@ public void onActivityCreated(Bundle savedInstanceState) { } } - MainActivity.mDid = null; + MainActivity.tagType = null; MainActivity.mDid = null; if (true || MainActivity.sharedObjects.versionWarningShown == false) mHandler.post(runnableConfiguring); mHandler.postDelayed(runnableStartService, 1000); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/HomeSpecialFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/HomeSpecialFragment.java index 11c8190..d1c5b76 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/HomeSpecialFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/HomeSpecialFragment.java @@ -36,7 +36,7 @@ public void onActivityCreated(Bundle savedInstanceState) { buttonAuraSense.setVisibility(View.GONE); buttonFdmicro.setVisibility(View.GONE); buttonLanda.setVisibility(View.GONE); } - MainActivity.mDid = null; + MainActivity.tagType = null; MainActivity.mDid = null; if (MainActivity.csLibrary4A.isBleConnected()) MainActivity.csLibrary4A.restoreAfterTagSelect(); } diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/HomeWFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/HomeWFragment.java index 3490ae4..27875f1 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/HomeWFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/HomeWFragment.java @@ -12,13 +12,13 @@ import com.csl.cs108ademoapp.MainActivity; import com.csl.cs108ademoapp.R; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; public class HomeWFragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = {"Normal", "Simple"}; int iTargetOld, iSessionOld; @@ -66,7 +66,7 @@ public void onActivityCreated(Bundle savedInstanceState) { adapter.fragment1.onDestroy(); } - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); adapter.setFragment(0, new HomeFragment()); adapter.setFragment(1, new DirectWedgeFragment()); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/ImpinjFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/ImpinjFragment.java index bf4886a..7d49148 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/ImpinjFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/ImpinjFragment.java @@ -12,13 +12,13 @@ import com.csl.cs108ademoapp.MainActivity; import com.csl.cs108ademoapp.R; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; public class ImpinjFragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = {"Configure", "Scan", "Authenticate"}; int iTargetOld, iSessionOld; @@ -60,9 +60,9 @@ public void onActivityCreated(Bundle savedInstanceState) { TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.OperationsTabLayout); - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); adapter.setFragment(0, new AccessImpinjFragment(false)); - adapter.setFragment(1, InventoryRfidiMultiFragment.newInstance(true,"")); + adapter.setFragment(1, InventoryRfidiMultiFragment.newInstance(true, null, "")); adapter.setFragment(2, new AccessUcodeFragment()); viewPager = (ViewPager) getActivity().findViewById(R.id.OperationsPager); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/ImpinjM775Fragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/ImpinjM775Fragment.java index 155c320..00c3964 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/ImpinjM775Fragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/ImpinjM775Fragment.java @@ -1,5 +1,7 @@ package com.csl.cs108ademoapp.fragments; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_IMPINJ_M755; + import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import androidx.viewpager.widget.ViewPager; @@ -12,13 +14,13 @@ import com.csl.cs108ademoapp.MainActivity; import com.csl.cs108ademoapp.R; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; public class ImpinjM775Fragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = {"Configuration", "Scan"}; int iTargetOld, iSessionOld; @@ -45,9 +47,9 @@ public void onActivityCreated(Bundle savedInstanceState) { TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.OperationsTabLayout); - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); adapter.setFragment(0, new AccessImpinjFragment(true)); - adapter.setFragment(1, InventoryRfidiMultiFragment.newInstance(true, "E2C011")); + adapter.setFragment(1, InventoryRfidiMultiFragment.newInstance(true, TAG_IMPINJ_M755, "E2C011")); viewPager = (ViewPager) getActivity().findViewById(R.id.OperationsPager); viewPager.setAdapter(adapter); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryBarcodeFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryBarcodeFragment.java index 6567760..9f6c6be 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryBarcodeFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryBarcodeFragment.java @@ -136,6 +136,8 @@ public void onClick(View v) { }); barcodeTotal = (TextView) getActivity().findViewById(R.id.inventoryBarcodeTotal); + + MainActivity.csLibrary4A.getBarcodePreSuffix(); } @Override diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryFragment.java index bf4614e..41ea798 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryFragment.java @@ -13,13 +13,13 @@ import com.csl.cs108ademoapp.MainActivity; import com.csl.cs108ademoapp.R; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; public class InventoryFragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = {"RFID", "Barcode"}; @@ -55,8 +55,8 @@ public void onActivityCreated(Bundle savedInstanceState) { TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.OperationsTabLayout); - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); - adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(false, null)); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); + adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(false, null, null)); adapter.setFragment(1, new InventoryBarcodeFragment()); viewPager = (ViewPager) getActivity().findViewById(R.id.OperationsPager); 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 2cd435c..d8d04de 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryRfidiMultiFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/InventoryRfidiMultiFragment.java @@ -20,6 +20,7 @@ import android.widget.TextView; import android.widget.Toast; +import androidx.appcompat.app.ActionBar; import androidx.appcompat.app.AppCompatActivity; import com.csl.cs108ademoapp.CustomPopupWindow; @@ -31,6 +32,7 @@ import com.csl.cs108ademoapp.adapters.ReaderListAdapter; import com.csl.cslibrary4a.NotificationConnector; import com.csl.cslibrary4a.ReaderDevice; +import com.csl.cslibrary4a.RfidReader; import com.csl.cslibrary4a.RfidReaderChipData; import java.util.Collections; @@ -39,6 +41,7 @@ public class InventoryRfidiMultiFragment extends CommonFragment { final private boolean bAdd2End = false; private boolean bMultiBank = false, bMultiBankInventory = false, bctesiusInventory = false; + private RfidReader.TagType tagType; private String mDid = null; int vibrateTimeBackup = 0; @@ -133,6 +136,12 @@ public void onCreate(Bundle savedInstanceState) { if (getArguments() != null) { bMultiBank = getArguments().getBoolean("bMultiBank"); mDid = getArguments().getString("mDid"); + try { + int iValue = getArguments().getInt("enumTagType"); + MainActivity.csLibrary4A.appendToLog("onCreate: enumTagType iValue = " + iValue); + tagType = RfidReader.TagType.values()[iValue]; + MainActivity.csLibrary4A.appendToLog("onCreate: enumTagType = " + tagType.toString()); + } catch (Exception e) { } if (bMultiBank && mDid == null) { bMultiBankInventory = true; } else if (bMultiBank && mDid != null) { @@ -152,7 +161,7 @@ public void onActivityCreated(Bundle savedInstanceState) { MainActivity.selectFor = -1; if (bMultiBankInventory | bctesiusInventory) { - androidx.appcompat.app.ActionBar actionBar; + ActionBar actionBar; actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar(); actionBar.setIcon(R.drawable.dl_inv); if (bMultiBankInventory) actionBar.setTitle(R.string.title_activity_inventoryRfidMulti); @@ -178,7 +187,7 @@ public void onClick(View view) { } checkBoxFilterByTid = (CheckBox) getActivity().findViewById(R.id.accessInventoryFilterByTid); - MainActivity.csLibrary4A.appendToLog("mDid = " + mDid + ", MainActivity.mDid = " + MainActivity.mDid); + MainActivity.csLibrary4A.appendToLog("InventoryRfidMultiFragment.onActivityCreated: mDid = " + mDid + ", MainActivity.mDid = " + MainActivity.mDid); if (mDid != null) { if (mDid.indexOf("E2827001") == 0) { checkBoxFilterByTid.setVisibility(View.VISIBLE); @@ -347,10 +356,12 @@ public void setUserVisibleHint(boolean isVisibleToUser) { } } - public static InventoryRfidiMultiFragment newInstance(boolean bMultiBank, String mDid) { + public static InventoryRfidiMultiFragment newInstance(boolean bMultiBank, RfidReader.TagType tagType, String mDid) { InventoryRfidiMultiFragment myFragment = new InventoryRfidiMultiFragment(); Bundle args = new Bundle(); + MainActivity.csLibrary4A.appendToLog("newInstance: enumTagType = " + (tagType == null ? "null" : tagType.toString())); + if (tagType != null) args.putInt("enumTagType", tagType.ordinal()); args.putBoolean("bMultiBank", bMultiBank); args.putString("mDid", mDid); myFragment.setArguments(args); @@ -374,7 +385,7 @@ public void onChange() { boolean needResetData = false; void resetSelectData() { - MainActivity.csLibrary4A.appendToLog("mDid = " + mDid + ", MainActivity.mDid = " + MainActivity.mDid); + MainActivity.csLibrary4A.appendToLog("InventoryRfidMultiFragment.resetSelectData: mDid = " + mDid + ", MainActivity.mDid = " + MainActivity.mDid); if (MainActivity.mDid != null && MainActivity.mDid.indexOf("E282405") == 0) { } else MainActivity.csLibrary4A.restoreAfterTagSelect(); if (needResetData) { @@ -421,246 +432,106 @@ void startStopHandler(boolean buttonTrigger) { MainActivity.csLibrary4A.appendToLogView("CANCELLING: StartStopHandler generates taskCancelReason = " + inventoryRfidTask.taskCancelReason.toString()); } else MainActivity.csLibrary4A.appendToLog("BtData. Stop when still writing !!!"); } - void startInventoryTask() { MainActivity.csLibrary4A.appendToLog("startInventoryTask"); - int extra1Bank = -1, extra2Bank = -1; - int extra1Count = 0, extra2Count = 0; - int extra1Offset = 0, extra2Offset = 0; + //RfidReader.ExtraBankData extraBankData = new RfidReader.ExtraBankData(); String mDid = this.mDid; MainActivity.csLibrary4A.appendToLog("Rin: mDid = " + (mDid == null ? "null" : mDid) + ", MainActivity.mDid = " + MainActivity.mDid + ", bMultiBankInventory = " + bMultiBankInventory); if (mDid != null && MainActivity.mDid != null) { if (MainActivity.mDid.indexOf("E280B12") != 0) mDid = MainActivity.mDid; } + + RfidReader.ExtraBankData extraBankData = new RfidReader.ExtraBankData(); + if (mDid != null) extraBankData.setExtraBankData(MainActivity.tagType, mDid); + else if (bMultiBank) { + CheckBox checkBox = (CheckBox) getActivity().findViewById(R.id.accessInventoryBankTitle1); + int extra1Bank = 0, extra2Bank = 0; + int extra1Count, extra2Count; + int extra1Offset = 0, extra2Offset = 0; + if (checkBox.isChecked()) { + extra1Bank = spinnerBank1.getSelectedItemPosition(); + EditText editText = (EditText) getActivity().findViewById(R.id.accessInventoryOffset1); + extra1Offset = Integer.valueOf(editText.getText().toString()); + editText = (EditText) getActivity().findViewById(R.id.accessInventoryLength1); + extra1Count = Integer.valueOf(editText.getText().toString()); + } else extra1Count = 0; + checkBox = (CheckBox) getActivity().findViewById(R.id.accessInventoryBankTitle2); + if (checkBox.isChecked()) { + extra2Bank = spinnerBank2.getSelectedItemPosition(); + EditText editText = (EditText) getActivity().findViewById(R.id.accessInventoryOffset2); + extra2Offset = Integer.valueOf(editText.getText().toString()); + editText = (EditText) getActivity().findViewById(R.id.accessInventoryLength2); + extra2Count = Integer.valueOf(editText.getText().toString()); + } else extra2Count = 0; + extraBankData.setExtraBankData(extra1Bank, extra1Count, extra1Offset, extra2Bank, extra2Count, extra2Offset); + } + if (mDid != null) { MainActivity.csLibrary4A.appendToLog("mDid is valid as " + mDid); - //if (MainActivity.csLibrary4A.getSelectEnable()) - MainActivity.csLibrary4A.setSelectCriteriaDisable(-1); if (MainActivity.mDid != null && mDid.length() == 0) mDid = MainActivity.mDid; MainActivity.csLibrary4A.appendToLog("new mDid is " + mDid); - extra2Bank = 2; - extra2Offset = 0; - extra2Count = 2; - MainActivity.csLibrary4A.appendToLog("mDid = " + mDid); - if (mDid.matches("E2801101") || mDid.matches("E2801102") || mDid.matches("E2801103") || mDid.matches("E2801104") || mDid.matches("E2801105")) { - extra1Bank = 0; - extra1Offset = 4; - extra1Count = 1; - if (mDid.matches("E2801101")) extra2Count = 6; - } else if (mDid.matches("E200B0")) { - extra1Bank = 2; - extra1Offset = 0; - extra1Count = 2; - extra2Bank = 3; - extra2Offset = 0x2d; - extra2Count = 1; - } else if (mDid.matches("E203510")) { - extra1Bank = 2; - extra1Offset = 0; - extra1Count = 2; - extra2Bank = 3; - extra2Offset = 8; - extra2Count = 2; - } else if (mDid.matches("E283A")) { - extra1Bank = 2; - extra1Offset = 0; - extra1Count = 2; - extra2Bank = 3; - extra2Offset = 0; - extra2Count = 8; - } else if (mDid.indexOf("E280B12") == 0) { - extra1Bank = 2; - extra1Offset = 0; - extra1Count = 2; - extra2Bank = 3; - extra2Offset = 0x120; - extra2Count = 1; - } else if (mDid.indexOf("E280B0") == 0) { - extra1Bank = 3; - extra1Offset = 188; - extra1Count = 2; - //extra2Bank = 3; - //extra2Offset = 0x10d; - //extra2Count = 1; - } else if (mDid.indexOf("E281D") == 0) { //need atmel firmware 0.2.20 - extra1Bank = 0; - extra1Offset = 4; - extra1Count = 1; - extra2Count = 6; - } else if (mDid.indexOf("E201E") == 0) { - extra1Bank = 3; - extra1Offset = 112; - extra1Count = 1; - extra2Count = 6; - } else if (mDid.matches("E282402")) { - extra1Bank = 0; - extra1Offset = 11; - extra1Count = 1; - extra2Bank = 0; - extra2Offset = 13; - extra2Count = 1; - } else if (mDid.matches("E282403")) { - extra1Bank = 0; - extra1Offset = 12; - extra1Count = 3; - extra2Bank = 3; - extra2Offset = 8; - extra2Count = 4; - } else if (mDid.matches("E282405")) { - extra1Bank = 0; - extra1Offset = 10; - extra1Count = 5; - extra2Bank = 3; - extra2Offset = 0x12; - extra2Count = 4; - } + MainActivity.csLibrary4A.appendToLog("mDid = " + mDid); - if (mDid.indexOf("E280B12") == 0) { - if (MainActivity.mDid.matches("E280B12B")) { - MainActivity.csLibrary4A.setSelectCriteria(0, true, 4, 0, 5, 1, 0x220, "8321"); - MainActivity.csLibrary4A.appendToLog("Hello123: Set Sense at Select !!!"); - } else { //if (MainActivity.mDid.matches("E280B12A")) { - MainActivity.csLibrary4A.setSelectCriteriaDisable(-1); - MainActivity.csLibrary4A.appendToLog("Hello123: Set Sense at BOOT !!!"); - } - } else if (mDid.matches("E203510")) { - MainActivity.csLibrary4A.setSelectCriteria(0, true, 7, 4, 0, 2, 0, mDid); + if (mDid.matches("E203510")) { if (MainActivity.csLibrary4A.get98XX() == 2) MainActivity.csLibrary4A.setCurrentLinkProfile(1); } else if (mDid.matches("E283A")) { if (MainActivity.csLibrary4A.get98XX() == 2) MainActivity.csLibrary4A.setCurrentLinkProfile(9); - } else if (mDid.matches("E28240")) { - if (MainActivity.selectFor != 0) { - MainActivity.csLibrary4A.setSelectCriteriaDisable(-1); - MainActivity.selectFor = 0; - } - } else if (mDid.matches("E282402")) { - MainActivity.csLibrary4A.appendToLog("selectFor = " + MainActivity.selectFor); - if (MainActivity.selectFor != 2) { - MainActivity.csLibrary4A.setSelectCriteria(0, true, 4, 2, 0, 3, 0xA0, "20"); - MainActivity.selectFor = 2; - } - } else if (mDid.matches("E282403")) { - if (MainActivity.selectFor != 3) { - MainActivity.csLibrary4A.setSelectCriteria(0, true, 4, 2, 0, 3, 0xD0, "1F"); - MainActivity.csLibrary4A.setSelectCriteria(1, true, 4, 2, 5, 3, 0xE0, ""); - MainActivity.selectFor = 3; - } } else if (mDid.matches("E282405")) { - if (MainActivity.selectFor != 5) { - MainActivity.csLibrary4A.setSelectCriteria(0, true, 4, 5, MainActivity.selectHold, 3, 0x3B0, "00"); - MainActivity.csLibrary4A.setSelectCriteriaDisable(2); - if (MainActivity.csLibrary4A.getRetryCount() < 2) MainActivity.csLibrary4A.setRetryCount(2); - MainActivity.selectFor = 5; - } - } else { - MainActivity.csLibrary4A.appendToLog("MainActivity.selectFor = " + MainActivity.selectFor); - if (MainActivity.selectFor != -1) { - MainActivity.csLibrary4A.setSelectCriteriaDisable(-1); - MainActivity.selectFor = -1; - } + if (MainActivity.csLibrary4A.getRetryCount() < 2) MainActivity.csLibrary4A.setRetryCount(2); } boolean bNeedSelectedTagByTID = true; if (mDid.indexOf("E2806894") == 0) { - mDid = "E2806894"; - Log.i(TAG, "HelloK: Find E2806894 with MainActivity.mDid = " + MainActivity.mDid); - if (MainActivity.mDid.matches("E2806894A")) { + Log.i(TAG, "HelloK: Find E2806894 with MainActivity.mDid = " + MainActivity.mDid + ", mDid = " + mDid); + if (mDid.matches("E2806894A")) { Log.i(TAG, "HelloK: Find E2806894A"); MainActivity.csLibrary4A.setInvBrandId(false); - MainActivity.csLibrary4A.setSelectCriteriaDisable(1); - } else if (MainActivity.mDid.matches("E2806894B")) { + } else if (mDid.matches("E2806894B")) { Log.i(TAG, "HelloK: Find E2806894B"); MainActivity.csLibrary4A.setInvBrandId(false); - MainActivity.csLibrary4A.setSelectCriteria(0, true, 4, 0, 1, 0x203, "1", true); - MainActivity.csLibrary4A.setSelectCriteria(1, true, 4, 2, 2, 0, "E2806894", false); if (true) bNeedSelectedTagByTID = false; - } else if (MainActivity.mDid.matches("E2806894C") || MainActivity.mDid.matches("E2806894d")) { + } else if (mDid.matches("E2806894C") || mDid.matches("E2806894d")) { Log.i(TAG, "HelloK: Find " + MainActivity.mDid); MainActivity.csLibrary4A.setInvBrandId(true); - MainActivity.csLibrary4A.setSelectCriteria(0, true, 4, 0, 1, 0x204, "1", true); - MainActivity.csLibrary4A.setSelectCriteria(1, true, 4, 2, 2, 0, "E2806894", false); if (true) bNeedSelectedTagByTID = false; } - } //else if (mDid.indexOf("E28011") == 0) bNeedSelectedTagByTID = false; - Log.i(TAG, "BleStreamOut: going to setSelectedTagByTID with mDid = " + mDid + " with extra1Bank = " + extra1Bank + ", extra2Bank = " + extra2Bank + ", bNeedSelectedTagByTID = " + bNeedSelectedTagByTID + ", checkBoxFilterFdTag = " + checkBoxFilterByTid.isChecked() + ", bMultiBank = " + bMultiBank); - if (bNeedSelectedTagByTID) { - String strMdid = mDid; - if (strMdid.indexOf("E28011") == 0) { - int iValue = Integer.valueOf(strMdid.substring(6, 8), 16); iValue &= 0x0F; - MainActivity.csLibrary4A.appendToLog(String.format("iValue = 0x%X", iValue)); - if (iValue == 1) strMdid = "E2C011A2"; - else if (iValue == 2) strMdid = "E28011C"; - else if (iValue == 3) strMdid = "E28011B"; - else if (iValue == 4) strMdid = "E28011A"; - else if (iValue == 5) strMdid = "E280119"; - else if (iValue == 6) strMdid = "E2801171"; - else if (iValue == 7) strMdid = "E2801170"; - else if (iValue == 8) strMdid = "E2801150"; - else strMdid = "E2001"; //strMdid.substring(0, 5); even E2801 or E2C01 will return - } - MainActivity.csLibrary4A.appendToLog("revised mDid = " + strMdid + " with checkBoxFilterByTid.isChecked() = " + checkBoxFilterByTid.isChecked()); - if (checkBoxFilterByTid.isChecked()) { - MainActivity.csLibrary4A.appendToLog("setSelectCriteria: Going to setSelectedByTID"); - if (checkBoxFilterByProtect.isChecked()) { - if (editTextProtectPassword.getText().toString().trim().length() == 0) editTextProtectPassword.setText("00000000"); - MainActivity.csLibrary4A.setSelectCriteria(-1, true, 4, 0, 3, 0, editTextProtectPassword.getText().toString(), false); - } - MainActivity.csLibrary4A.setSelectedTagByTID(strMdid, -1); - } else { - //MainActivity.csLibrary4A.setSelectCriteriaDisable(-1); - MainActivity.csLibrary4A.setInvAlgo(MainActivity.csLibrary4A.getInvAlgo()); - } - } - } else if (bMultiBankInventory) { - CheckBox checkBox = (CheckBox) getActivity().findViewById(R.id.accessInventoryBankTitle1); - if (checkBox.isChecked()) { - extra1Bank = spinnerBank1.getSelectedItemPosition(); - EditText editText = (EditText) getActivity().findViewById(R.id.accessInventoryOffset1); - extra1Offset = Integer.valueOf(editText.getText().toString()); - editText = (EditText) getActivity().findViewById(R.id.accessInventoryLength1); - extra1Count = Integer.valueOf(editText.getText().toString()); } - checkBox = (CheckBox) getActivity().findViewById(R.id.accessInventoryBankTitle2); - if (checkBox.isChecked()) { - extra2Bank = spinnerBank2.getSelectedItemPosition(); - EditText editText = (EditText) getActivity().findViewById(R.id.accessInventoryOffset2); - extra2Offset = Integer.valueOf(editText.getText().toString()); - editText = (EditText) getActivity().findViewById(R.id.accessInventoryLength2); - extra2Count = Integer.valueOf(editText.getText().toString()); + int iValue123 = MainActivity.csLibrary4A.setSelectData(MainActivity.tagType, mDid, + bNeedSelectedTagByTID && checkBoxFilterByTid.isChecked(), + (checkBoxFilterByProtect.isChecked() ? editTextProtectPassword.getText().toString(): null), + MainActivity.selectFor, MainActivity.selectHold); + if (mDid.indexOf("E2806894") == 0) { + mDid = "E2806894"; } + if (iValue123 > 0) MainActivity.selectFor = iValue123; } - MainActivity.csLibrary4A.appendToLog("bMultiBank = " + bMultiBank + " with extra1Bank = " + extra1Bank + "," + extra1Offset + "," + extra1Count + ", extra2Bank = " + extra2Bank + "," + extra2Offset + "," + extra2Count); + MainActivity.csLibrary4A.appendToLog("bSgtinOnly: bMultiBank is " + bMultiBank + ", checkBoxFilterByEpc is " + (checkBoxFilterByEpc == null ? "null" : checkBoxFilterByEpc.isChecked())); if (bMultiBank == false) { + if (checkBoxFilterByEpc.isChecked()) { + MainActivity.csLibrary4A.appendToLog("bSgtinOnly: clearTagList"); + clearTagsList(); + } MainActivity.csLibrary4A.restoreAfterTagSelect(); inventoryRfidTask = new InventoryRfidTask(getContext(), -1, -1, 0, 0, 0, 0, false, MainActivity.csLibrary4A.getInventoryBeep(), MainActivity.sharedObjects.tagsList, readerListAdapter, null, null, rfidRunTime, null, rfidVoltageLevel, rfidYieldView, button, rfidRateView); inventoryRfidTask.bSgtinOnly = checkBoxFilterByEpc.isChecked(); - if (checkBoxFilterByEpc.isChecked()) clearTagsList(); + MainActivity.csLibrary4A.appendToLog("Debug_Compact 1: InventoryRfidMultiFragment.startInventoryTask"); MainActivity.csLibrary4A.startOperation(RfidReaderChipData.OperationTypes.TAG_INVENTORY_COMPACT); } else { boolean inventoryUcode8_bc = mDid != null && mDid.matches("E2806894") && MainActivity.mDid != null && (MainActivity.mDid.matches("E2806894B") || MainActivity.mDid.matches("E2806894C")); - if ((extra1Bank != -1 && extra1Count != 0) || (extra2Bank != -1 && extra2Count != 0)) { - if (extra1Bank == -1 || extra1Count == 0) { - extra1Bank = extra2Bank; - extra2Bank = 0; - extra1Count = extra2Count; - extra2Count = 0; - extra1Offset = extra2Offset; - extra2Offset = 0; - } - if (extra1Bank == 1) extra1Offset += 2; - if (extra2Bank == 1) extra2Offset += 2; - MainActivity.csLibrary4A.appendToLog("HelloK: mDid = " + mDid + ", MainActivity.mDid = " + MainActivity.mDid + " with extra1Bank = " + extra1Bank + "," + extra1Offset + "," + extra1Count + ", extra2Bank = " + extra2Bank + "," + extra2Offset + "," + extra2Count); + if ((extraBankData.extra1Bank != -1 && extraBankData.extra1Count != 0) || (extraBankData.extra2Bank != -1 && extraBankData.extra2Count != 0)) { + extraBankData.adjustExtraBank1(); + MainActivity.csLibrary4A.appendToLog("HelloK: mDid = " + mDid + ", MainActivity.mDid = " + MainActivity.mDid + " with extra1Bank = " + extraBankData.extra1Bank + "," + extraBankData.extra1Offset + "," + extraBankData.extra1Count + ", extra2Bank = " + extraBankData.extra2Bank + "," + extraBankData.extra2Offset + "," + extraBankData.extra2Count); if (mDid != null) MainActivity.csLibrary4A.setResReadNoReply(mDid.matches("E281D")); if (inventoryUcode8_bc == false) { MainActivity.csLibrary4A.appendToLog("BleStreamOut: Set Multibank"); - MainActivity.csLibrary4A.setTagRead(extra2Count != 0 && extra2Count != 0 ? 2 : 1); - MainActivity.csLibrary4A.setAccessBank(extra1Bank, extra2Bank); - MainActivity.csLibrary4A.setAccessOffset(extra1Offset, extra2Offset); - MainActivity.csLibrary4A.setAccessCount(extra1Count, extra2Count); + MainActivity.csLibrary4A.setTagRead(extraBankData.extra2Count != 0 && extraBankData.extra2Count != 0 ? 2 : 1); + MainActivity.csLibrary4A.setAccessBank(extraBankData.extra1Bank, extraBankData.extra2Bank); + MainActivity.csLibrary4A.setAccessOffset(extraBankData.extra1Offset, extraBankData.extra2Offset); + MainActivity.csLibrary4A.setAccessCount(extraBankData.extra1Count, extraBankData.extra2Count); needResetData = true; } else if (needResetData) { MainActivity.csLibrary4A.setTagRead(0); @@ -670,16 +541,19 @@ void startInventoryTask() { needResetData = false; } } else resetSelectData(); - MainActivity.csLibrary4A.appendToLog("startInventoryTask: going to startOperation with extra1Bank = " + extra1Bank + "," + extra1Offset + "," + extra1Count + ", extra2Bank = " + extra2Bank + "," + extra2Offset + "," + extra2Count); - inventoryRfidTask = new InventoryRfidTask(getContext(), extra1Bank, extra2Bank, extra1Count, extra2Count, extra1Offset, extra2Offset, + MainActivity.csLibrary4A.appendToLog("startInventoryTask: going to startOperation with extra1Bank = " + extraBankData.extra1Bank + "," + extraBankData.extra1Offset + "," + extraBankData.extra1Count + ", extra2Bank = " + extraBankData.extra2Bank + "," + extraBankData.extra2Offset + "," + extraBankData.extra2Count); + inventoryRfidTask = new InventoryRfidTask(getContext(), extraBankData.extra1Bank, extraBankData.extra2Bank, extraBankData.extra1Count, extraBankData.extra2Count, extraBankData.extra1Offset, extraBankData.extra2Offset, false, MainActivity.csLibrary4A.getInventoryBeep(), MainActivity.sharedObjects.tagsList, readerListAdapter, null, mDid, rfidRunTime, null, rfidVoltageLevel, rfidYieldView, button, rfidRateView); inventoryRfidTask.bProtectOnly = checkBoxFilterByProtect.isChecked(); - if (inventoryUcode8_bc) + if (inventoryUcode8_bc) { + MainActivity.csLibrary4A.appendToLog("Debug_Compact 2: InventoryRfidMultiFragment.startInventoryTask"); MainActivity.csLibrary4A.startOperation(RfidReaderChipData.OperationTypes.TAG_INVENTORY_COMPACT); - else + } else { + MainActivity.csLibrary4A.appendToLog("Debug_Compact 3: InventoryRfidMultiFragment.startInventoryTask"); MainActivity.csLibrary4A.startOperation(RfidReaderChipData.OperationTypes.TAG_INVENTORY); + } } inventoryRfidTask.execute(); } diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/KilowayFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/KilowayFragment.java index d6339eb..a418685 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/KilowayFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/KilowayFragment.java @@ -1,5 +1,7 @@ package com.csl.cs108ademoapp.fragments; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_KILOWAY; + import android.os.Bundle; import android.view.LayoutInflater; import android.view.MenuItem; @@ -12,13 +14,13 @@ import com.csl.cs108ademoapp.MainActivity; import com.csl.cs108ademoapp.R; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; public class KilowayFragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = {"Scan", "Geiger"}; //, "Access"}; int iTargetOld, iSessionOld; @@ -60,8 +62,8 @@ public void onActivityCreated(Bundle savedInstanceState) { TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.OperationsTabLayout); - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); - adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true,"E281D")); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); + adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true, TAG_KILOWAY, "E281D")); adapter.setFragment(1, new InventoryRfidSearchFragment(true)); adapter.setFragment(2, new AccessKilowayFragment(false)); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/LongjingFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/LongjingFragment.java index d70f9f3..8ca1ce7 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/LongjingFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/LongjingFragment.java @@ -1,5 +1,7 @@ package com.csl.cs108ademoapp.fragments; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_LONGJING; + import android.os.Bundle; import android.view.LayoutInflater; import android.view.MenuItem; @@ -12,13 +14,13 @@ import com.csl.cs108ademoapp.MainActivity; import com.csl.cs108ademoapp.R; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; public class LongjingFragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = {"Scan", "Geiger"}; //"Access", int iTargetOld, iSessionOld; @@ -60,8 +62,8 @@ public void onActivityCreated(Bundle savedInstanceState) { TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.OperationsTabLayout); - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); - adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true,"E201E")); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); + adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true, TAG_LONGJING, "E201E")); adapter.setFragment(1, new InventoryRfidSearchFragment(true)); adapter.setFragment(2, new AccessKilowayFragment(true)); 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 2891b8f..4abb333 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/MicronFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/MicronFragment.java @@ -2,7 +2,7 @@ import android.os.Bundle; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; import androidx.viewpager.widget.ViewPager; import androidx.appcompat.app.ActionBar; @@ -18,7 +18,7 @@ public class MicronFragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = { "Scan/Select", "Read" }; @@ -59,8 +59,8 @@ public void onActivityCreated(Bundle savedInstanceState) { TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.OperationsTabLayout); - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); - adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true, "")); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); + adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true, null, "")); adapter.setFragment(1, AccessMicronFragment.newInstance(false)); viewPager = (ViewPager) getActivity().findViewById(R.id.OperationsPager); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/SettingFilterFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/SettingFilterFragment.java index 30312cb..1a655a7 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/SettingFilterFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/SettingFilterFragment.java @@ -11,13 +11,13 @@ import androidx.viewpager.widget.ViewPager; import com.csl.cs108ademoapp.R; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; public class SettingFilterFragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = {"Pre-filter", "Post-filter", "Rssi-filter"}; @@ -37,7 +37,7 @@ public void onActivityCreated(Bundle savedInstanceState) { TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.OperationsTabLayout); - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); adapter.setFragment(0, new SettingFilterPreFragment()); adapter.setFragment(1, new SettingFilterPostFragment()); adapter.setFragment(2, new SettingFilterRssiFragment()); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/SettingFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/SettingFragment.java index 9b26817..c0f35cc 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/SettingFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/SettingFragment.java @@ -14,7 +14,7 @@ import androidx.viewpager.widget.ViewPager; import com.csl.cs108ademoapp.MainActivity; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.csl.cs108ademoapp.R; import com.google.android.material.tabs.TabLayout; @@ -22,7 +22,7 @@ public class SettingFragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; FragmentStatePagerAdapter pagerAdapter; - MyAdapter adapter; + AdapterTab adapter; Fragment fragment0, fragment1; private String[] tabs = { "Operation", "Administration" }; @@ -69,7 +69,7 @@ public Fragment getItem(int position) { return fragment; } }; - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); adapter.setFragment(0, new SettingOperateFragment()); adapter.setFragment(1, new SettingAdminFragment()); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/Ucode8Fragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/Ucode8Fragment.java index 1144a35..8acd3e0 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/Ucode8Fragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/Ucode8Fragment.java @@ -12,13 +12,13 @@ import com.csl.cs108ademoapp.MainActivity; import com.csl.cs108ademoapp.R; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; public class Ucode8Fragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = {"Configure", "Scan", "Security", "Untrace"}; @@ -59,9 +59,9 @@ public void onActivityCreated(Bundle savedInstanceState) { TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.OperationsTabLayout); - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); adapter.setFragment(0, new AccessUcode8Fragment()); - adapter.setFragment(1, InventoryRfidiMultiFragment.newInstance(true,"")); + adapter.setFragment(1, InventoryRfidiMultiFragment.newInstance(true, null, "")); adapter.setFragment(2, new AccessUcodeFragment()); adapter.setFragment(3, new UtraceFragment()); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/UcodeFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/UcodeFragment.java index d2a5d8d..a8bc339 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/UcodeFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/UcodeFragment.java @@ -1,5 +1,7 @@ package com.csl.cs108ademoapp.fragments; +import static com.csl.cslibrary4a.RfidReader.TagType.TAG_NXP_UCODEDNA; + import android.os.Bundle; import android.view.LayoutInflater; import android.view.MenuItem; @@ -11,13 +13,13 @@ import androidx.viewpager.widget.ViewPager; import com.csl.cs108ademoapp.R; -import com.csl.cs108ademoapp.adapters.MyAdapter; +import com.csl.cslibrary4a.AdapterTab; import com.google.android.material.tabs.TabLayout; public class UcodeFragment extends CommonFragment { private ActionBar actionBar; private ViewPager viewPager; - MyAdapter adapter; + AdapterTab adapter; private String[] tabs = {"Scan", "Authenticate"}; @@ -58,8 +60,8 @@ public void onActivityCreated(Bundle savedInstanceState) { TabLayout tabLayout = (TabLayout) getActivity().findViewById(R.id.OperationsTabLayout); - adapter = new MyAdapter(getActivity().getSupportFragmentManager(), tabs.length); - adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true,"E2C06")); + adapter = new AdapterTab(getActivity().getSupportFragmentManager(), tabs.length); + adapter.setFragment(0, InventoryRfidiMultiFragment.newInstance(true, TAG_NXP_UCODEDNA, "E2C06")); adapter.setFragment(1, new AccessUcodeFragment()); diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/UtraceFragment.java b/app/src/main/java/com/csl/cs108ademoapp/fragments/UtraceFragment.java index d18ef17..d5fdfc7 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/UtraceFragment.java +++ b/app/src/main/java/com/csl/cs108ademoapp/fragments/UtraceFragment.java @@ -228,16 +228,13 @@ else if (taskRequest) { Button button = buttonUntrace; int selectBank = selectTag.spinnerSelectBank.getSelectedItemPosition() + 1; MainActivity.csLibrary4A.appendToLog("selectBank = " + selectBank); //if (strUntraceButtonBackup == null) strUntraceButtonBackup = buttonUntrace.getText().toString(); buttonUntrace.setText("Show"); button = buttonUntrace; - accessTask = new AccessTask( - button, null, invalid, + accessTask = new AccessTask(button, null, invalid, true, selectTag.editTextTagID.getText().toString(), selectBank, (selectBank == 1 ? 32 : 0), selectTag.editTextAccessPassword.getText().toString(), Integer.valueOf(selectTag.editTextAccessAntennaPower.getText().toString()), RfidReaderChipData.HostCommands.CMD_UNTRACEABLE, 0, 0, true, false, null, null, null, null, null); - MainActivity.csLibrary4A.appendToLog("setSelectCriteria: going to execute accessTask"); accessTask.execute(); rerunRequest = true; - MainActivity.csLibrary4A.appendToLog("setSelectCriteria: accessTask is executed"); } if (rerunRequest) { mHandler.postDelayed(updateRunnable, 500); diff --git a/app_img/CS108-AndroidSDK.png b/app_img/CS108-AndroidSDK.png new file mode 100644 index 0000000..368d8c8 Binary files /dev/null and b/app_img/CS108-AndroidSDK.png differ diff --git a/app_img/CS108-AndroidStudio.png b/app_img/CS108-AndroidStudio.png new file mode 100644 index 0000000..bcb2586 Binary files /dev/null and b/app_img/CS108-AndroidStudio.png differ diff --git a/app_img/CS108-selectAndroidDevice.png b/app_img/CS108-selectAndroidDevice.png new file mode 100644 index 0000000..cfb7649 Binary files /dev/null and b/app_img/CS108-selectAndroidDevice.png differ diff --git a/app_img/CS108-syncCradleFile.png b/app_img/CS108-syncCradleFile.png new file mode 100644 index 0000000..27b3cb0 Binary files /dev/null and b/app_img/CS108-syncCradleFile.png differ diff --git a/build.gradle b/build.gradle index d174f62..d28cc45 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { maven { url "https://repo.eclipse.org/content/repositories/paho-releases/" } } dependencies { - classpath 'com.android.tools.build:gradle:8.7.2' + classpath 'com.android.tools.build:gradle:8.8.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/cslibrary4a/build.gradle b/cslibrary4a/build.gradle index 0a8c378..5ddad5d 100644 --- a/cslibrary4a/build.gradle +++ b/cslibrary4a/build.gradle @@ -10,7 +10,7 @@ android { defaultConfig { minSdk 23 targetSdk 35 - buildConfigField 'String', 'VERSION_NAME', "\"22\"" + buildConfigField 'String', 'VERSION_NAME', "\"34\"" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/app/src/main/java/com/csl/cs108ademoapp/adapters/MyAdapter.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/AdapterTab.java similarity index 91% rename from app/src/main/java/com/csl/cs108ademoapp/adapters/MyAdapter.java rename to cslibrary4a/src/main/java/com/csl/cslibrary4a/AdapterTab.java index fa3bcd5..9bfa60d 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/adapters/MyAdapter.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/AdapterTab.java @@ -1,15 +1,15 @@ -package com.csl.cs108ademoapp.adapters; +package com.csl.cslibrary4a; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentStatePagerAdapter; import androidx.viewpager.widget.PagerAdapter; -public class MyAdapter extends FragmentStatePagerAdapter { +public class AdapterTab extends FragmentStatePagerAdapter { private int iNumOfTabs; public Fragment fragment0, fragment1, fragment2, fragment3, fragment4 = null; - public MyAdapter(FragmentManager fm, int iNumOfTabs) { + public AdapterTab(FragmentManager fm, int iNumOfTabs) { super(fm); this.iNumOfTabs = iNumOfTabs; } diff --git a/app/src/main/java/com/csl/cs108ademoapp/fragments/AesCmac.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/AesCmac.java similarity index 95% rename from app/src/main/java/com/csl/cs108ademoapp/fragments/AesCmac.java rename to cslibrary4a/src/main/java/com/csl/cslibrary4a/AesCmac.java index 331d23d..9bda696 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/fragments/AesCmac.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/AesCmac.java @@ -1,153 +1,148 @@ -package com.csl.cs108ademoapp.fragments; - -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.NoSuchAlgorithmException; - - - - - - -import javax.crypto.*; -import javax.crypto.spec.IvParameterSpec; -import javax.crypto.spec.SecretKeySpec; - -public class AesCmac { - private static final byte CONSTANT = (byte) 0x87; - private static final int BLOCK_SIZE = 16; - - private int macLength; - private Cipher aesCipher; - - private byte[] buffer; - private int bufferCount; - - private byte[] k1; - private byte[] k2; - - public AesCmac() throws NoSuchAlgorithmException { - this(BLOCK_SIZE); - } - - public AesCmac(int length) throws NoSuchAlgorithmException { - if (length > BLOCK_SIZE) { - throw new NoSuchAlgorithmException("AES CMAC maximum length is " + BLOCK_SIZE); - } - - try { - macLength = length; - aesCipher = Cipher.getInstance("AES/CBC/NOPADDING"); - buffer = new byte[BLOCK_SIZE]; - } catch (NoSuchPaddingException nspe) { - nspe.printStackTrace(); - } - } - - private byte[] doubleSubKey(byte[] k) { - byte[] ret = new byte[k.length]; - - boolean firstBitSet = ((k[0]&0x80) != 0); - for (int i=0; i 0) { - System.arraycopy(data, 0, buffer, bufferCount, BLOCK_SIZE-bufferCount); - try { - aesCipher.update(buffer, 0, BLOCK_SIZE, buffer, 0); - } catch (ShortBufferException sbe) {} - currentOffset += BLOCK_SIZE-bufferCount; - bufferCount = 0; - } - - // Transform all the full blocks in data - while (currentOffset+BLOCK_SIZE < data.length) { - try { - aesCipher.update(data, currentOffset, BLOCK_SIZE, buffer, 0); - } catch (ShortBufferException sbe) {} - currentOffset += BLOCK_SIZE; - } - - // Save the leftover bytes to buffer - if (currentOffset != data.length) { - System.arraycopy(data, currentOffset, buffer, 0, data.length-currentOffset); - bufferCount = data.length-currentOffset; - } - } - - public final byte[] doFinal() { - byte[] subKey = k1; - if (bufferCount < BLOCK_SIZE) { - // Add padding and XOR with k2 instead - buffer[bufferCount] = (byte) 0x80; - for (int i=bufferCount+1; i BLOCK_SIZE) { + throw new NoSuchAlgorithmException("AES CMAC maximum length is " + BLOCK_SIZE); + } + + try { + macLength = length; + aesCipher = Cipher.getInstance("AES/CBC/NOPADDING"); + buffer = new byte[BLOCK_SIZE]; + } catch (NoSuchPaddingException nspe) { + nspe.printStackTrace(); + } + } + + private byte[] doubleSubKey(byte[] k) { + byte[] ret = new byte[k.length]; + + boolean firstBitSet = ((k[0]&0x80) != 0); + for (int i=0; i 0) { + System.arraycopy(data, 0, buffer, bufferCount, BLOCK_SIZE-bufferCount); + try { + aesCipher.update(buffer, 0, BLOCK_SIZE, buffer, 0); + } catch (ShortBufferException sbe) {} + currentOffset += BLOCK_SIZE-bufferCount; + bufferCount = 0; + } + + // Transform all the full blocks in data + while (currentOffset+BLOCK_SIZE < data.length) { + try { + aesCipher.update(data, currentOffset, BLOCK_SIZE, buffer, 0); + } catch (ShortBufferException sbe) {} + currentOffset += BLOCK_SIZE; + } + + // Save the leftover bytes to buffer + if (currentOffset != data.length) { + System.arraycopy(data, currentOffset, buffer, 0, data.length-currentOffset); + bufferCount = data.length-currentOffset; + } + } + + public final byte[] doFinal() { + byte[] subKey = k1; + if (bufferCount < BLOCK_SIZE) { + // Add padding and XOR with k2 instead + buffer[bufferCount] = (byte) 0x80; + for (int i=bufferCount+1; i= 3) { if (DEBUG) appendToLog("BarStream: dataValue = " + byteArrayToString(dataValues) + ", writeDataValue = " + byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); @@ -355,7 +354,7 @@ public boolean decodeBarcodeUplinkData(byte[] dataValues, BarcodeConnector.CsRea else if (dataValues[index+7] == 0x31) strModeType = "auto_Scan"; else if (dataValues[index+7] == 0x32) strModeType = "continue_Scan"; else if (dataValues[index+7] == 0x33) strModeType = "batch_Scan"; - if (DEBUG_PKDATA) appendToLog(String.format("PkData: Barcode.Uplink.DataRead.QueryResponse.ReadingMode is processed as last 0x%X[%s]", dataValues[index+7], strModeType)); + if (utility.DEBUG_PKDATA) appendToLog(String.format("PkData: Barcode.Uplink.DataRead.QueryResponse.ReadingMode is processed as last 0x%X[%s]", dataValues[index+7], strModeType)); } else appendToLog("Barcode.Uplink.DataRead.QueryResponse has mis-matched values"); } else appendToLog("Barcode.Uplink.DataRead.QueryResponse has mis-matched values"); } else appendToLog("Barcode.Uplink.DataRead.QueryResponse has mis-matched values"); @@ -394,17 +393,17 @@ public boolean decodeBarcodeUplinkData(byte[] dataValues, BarcodeConnector.CsRea foundOk = true; found = true; } if (false) appendToLog("00 matcched = " + matched); - if (matched) { if (DEBUG_PKDATA) appendToLog("PkData: Barcode.Uplink.DataRead." + byteArrayToString(dataValues) + " is processed with matched = " + matched + ", OkCount = " + barcodeConnector.iOkCount + ", expected count = " + count + " for " + byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); } - else if (foundOk) { if (DEBUG_PKDATA) appendToLog("PkData: Barcode.Uplink.DataRead." + byteArrayToString(dataValues) + " is processed with matched = " + matched + ", but OkCount = " + barcodeConnector.iOkCount + ", expected count = " + count + " for " + byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); } + if (matched) { if (utility.DEBUG_PKDATA) appendToLog("PkData: Barcode.Uplink.DataRead." + byteArrayToString(dataValues) + " is processed with matched = " + matched + ", OkCount = " + barcodeConnector.iOkCount + ", expected count = " + count + " for " + byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); } + else if (foundOk) { if (utility.DEBUG_PKDATA) appendToLog("PkData: Barcode.Uplink.DataRead." + byteArrayToString(dataValues) + " is processed with matched = " + matched + ", but OkCount = " + barcodeConnector.iOkCount + ", expected count = " + count + " for " + byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); } else { barcodeConnector.mBarcodeToRead.add(csReaderBarcodeData); - if (DEBUG_PKDATA) appendToLog("PkData: uplink data Barcode.DataRead." + byteArrayToString(csReaderBarcodeData.dataValues) + " is added to mBarcodeToRead"); + if (utility.DEBUG_PKDATA) appendToLog("PkData: uplink data Barcode.DataRead." + byteArrayToString(csReaderBarcodeData.dataValues) + " is added to mBarcodeToRead"); } } if (matched) { found = true; barcodeConnector.barcodeToWrite.remove(0); barcodeConnector.sendDataToWriteSent = 0; barcodeConnector.mDataToWriteRemoved = true; appendToLog("barcodeToWrite remove0 with length = " + barcodeConnector.barcodeToWrite.size()); - if (DEBUG_PKDATA) appendToLog("PkData: new mBarcodeToWrite size = " + barcodeConnector.barcodeToWrite.size()); + if (utility.DEBUG_PKDATA) appendToLog("PkData: new mBarcodeToWrite size = " + barcodeConnector.barcodeToWrite.size()); } appendToLog("decodeBarcodeUplinkData found = " + found); return found; diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/BluetoothGatt.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/BluetoothGatt.java index 9a6d1be..8a9341c 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/BluetoothGatt.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/BluetoothGatt.java @@ -32,7 +32,6 @@ public class BluetoothGatt extends BluetoothGattCallback { boolean DEBUG_PKDATA, DEBUG_APDATA; public final boolean DEBUG_SCAN = false; public final boolean DEBUG_CONNECT = true; - final boolean DEBUG_BTDATA = true; final boolean DEBUG = true, DEBUG_BTOP = false; static final String TAG = "Hello"; @@ -400,7 +399,7 @@ public boolean writeBleStreamOut(byte[] value) { if (bValue == false) writeBleFailure++; else { writeBleFailure = 0; - if (DEBUG_BTDATA || true) appendToLogView("BtDataOut: " + byteArrayToString(value)); + if (utility.DEBUG_BTDATA || true) appendToLogView("BtDataOut: " + byteArrayToString(value)); writeDebug2File("Down " + byteArrayToString(value)); _writeCharacteristic_in_progress = true; mStreamWriteCountOld = mStreamWriteCount; @@ -459,7 +458,7 @@ public void onCharacteristicChanged(android.bluetooth.BluetoothGatt gatt, Blueto streamInBytesMissing += v.length; } else { if (true) utility.writeDebug2File("Up1 " + byteArrayToString(v)); - if (DEBUG_BTDATA) Log.i(TAG, "BtDataIn= " + byteArrayToString(v)); + if (utility.DEBUG_BTDATA) Log.i(TAG, "BtDataIn= " + byteArrayToString(v)); if (isStreamInBufferRing) { streamInBufferPush(v, 0, v.length); } else { diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/ControllerConnector.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/ControllerConnector.java index 248958c..29e5c39 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/ControllerConnector.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/ControllerConnector.java @@ -7,14 +7,13 @@ import java.util.ArrayList; public class ControllerConnector { - boolean DEBUG_PKDATA; final boolean DEBUG = false; boolean userDebugEnableDefault = false, userDebugEnable = userDebugEnableDefault; Context context; Utility utility; public ControllerConnector(Context context, Utility utility) { this.context = context; - this.utility = utility; DEBUG_PKDATA = utility.DEBUG_PKDATA; + this.utility = utility; } private String byteArrayToString(byte[] packet) { return utility.byteArrayToString(packet); } private boolean compareArray(byte[] array1, byte[] array2, int length) { return utility.compareByteArray(array1, array2, length); } @@ -39,7 +38,7 @@ class ControllerReadData { private byte[] controllerVersion = new byte[]{-1, -1, -1}; public String getVersion() { - boolean DEBUG = true; + boolean DEBUG = false; if (controllerVersion[0] == -1) { boolean repeatRequest = false; if (controllerToWrite.size() != 0) { @@ -49,7 +48,7 @@ public String getVersion() { } if (repeatRequest == false) { controllerToWrite.add(ControllerPayloadEvents.CONTROLLER_GET_VERSION); - if (DEBUG_PKDATA || DEBUG) appendToLog("PkData: add GET_VERSION to controllerWrite with length = " + controllerToWrite.size()); + if (utility.DEBUG_PKDATA || DEBUG) appendToLog("PkData: add GET_VERSION to controllerWrite with length = " + controllerToWrite.size()); } return ""; } else { @@ -71,7 +70,7 @@ public String getSerialNumber() { } if (repeatRequest == false) { controllerToWrite.add(ControllerPayloadEvents.CONTROLLER_GET_SERIALNUMBER); - if (DEBUG_PKDATA) appendToLog("PkData: add GET_SERIALNUMBER to controllerToWrite with length = " + controllerToWrite.size()); + if (utility.DEBUG_PKDATA) appendToLog("PkData: add GET_SERIALNUMBER to controllerToWrite with length = " + controllerToWrite.size()); } return ""; } else { @@ -177,22 +176,22 @@ public boolean isMatchControllerToWrite(ConnectorData connectorData) { byte[] dataInCompare = new byte[]{(byte) 0xB0, 0}; if (arrayTypeSet(dataInCompare, 1, controllerToWrite.get(0)) && (connectorData.dataValues.length >= dataInCompare.length + 1)) { if (match = compareArray(connectorData.dataValues, dataInCompare, dataInCompare.length)) { - if (DEBUG_PKDATA) appendToLog("PkData: matched Controller.Reply with payload = " + byteArrayToString(connectorData.dataValues) + " for writeData.Controller." + controllerToWrite.get(0).toString()); + if (utility.DEBUG_PKDATA) appendToLog("PkData: matched Controller.Reply with payload = " + byteArrayToString(connectorData.dataValues) + " for writeData.Controller." + controllerToWrite.get(0).toString()); if (controllerToWrite.get(0) == ControllerPayloadEvents.CONTROLLER_GET_VERSION) { if (connectorData.dataValues.length >= 2 + controllerVersion.length) { System.arraycopy(connectorData.dataValues, 2, controllerVersion, 0, controllerVersion.length); - if (DEBUG_PKDATA) appendToLog("PkData: matched Controller.Reply.GetVersion with version = " + byteArrayToString(controllerVersion)); + if (utility.DEBUG_PKDATA) appendToLog("PkData: matched Controller.Reply.GetVersion with version = " + byteArrayToString(controllerVersion)); } } else if (controllerToWrite.get(0) == ControllerPayloadEvents.CONTROLLER_GET_SERIALNUMBER) { int length = connectorData.dataValues.length - 2; serialNumber = new byte[length]; System.arraycopy(connectorData.dataValues, 2, serialNumber, 0, length); - if (DEBUG_PKDATA) appendToLog("PkData: matched Controller.Reply.GetSerialNumber with serialNumber = " + byteArrayToString(serialNumber)); + if (utility.DEBUG_PKDATA) appendToLog("PkData: matched Controller.Reply.GetSerialNumber with serialNumber = " + byteArrayToString(serialNumber)); } else if (controllerToWrite.get(0) == ControllerPayloadEvents.CONTROLLER_GET_MODELNAME) { int length = connectorData.dataValues.length - 2; modelName = new byte[length]; System.arraycopy(connectorData.dataValues, 2, modelName, 0, length); - if (DEBUG_PKDATA) appendToLog("PkData: matched controller.GetModelName.reply with modelName = " + byteArrayToString(modelName)); + if (utility.DEBUG_PKDATA) appendToLog("PkData: matched controller.GetModelName.reply with modelName = " + byteArrayToString(modelName)); } else if (controllerToWrite.get(0) == ControllerPayloadEvents.CONTROLLER_RESET) { if (connectorData.dataValues[2] != 0) { appendToLog("Controller RESET is found with error"); @@ -201,7 +200,7 @@ public boolean isMatchControllerToWrite(ConnectorData connectorData) { appendToLog("matched controller.Other.reply data is found."); } controllerToWrite.remove(0); sendDataToWriteSent = 0; - if (DEBUG_PKDATA) appendToLog("PkData: new controllerToWrite size = " + controllerToWrite.size()); + if (utility.DEBUG_PKDATA) appendToLog("PkData: new controllerToWrite size = " + controllerToWrite.size()); } } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs108Library4A.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs108Library4A.java index 244f1fd..1559fed 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs108Library4A.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs108Library4A.java @@ -19,7 +19,6 @@ import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; @@ -122,7 +121,7 @@ public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] public String getlibraryVersion() { String version = BuildConfig.VERSION_NAME; //int iVersion = Integer.parseInt(version) + 10; - version = "14.14"; //+ String.valueOf(iVersion); + version = "14.20"; //+ String.valueOf(iVersion); appendToLog("version = " + version); return utility.getCombinedVersion(version); } @@ -310,6 +309,7 @@ public void run() { final Runnable disconnectRunnable = new Runnable() { @Override public void run() { + if (barcodeConnector == null) return; appendToLog("abcc disconnectRunnable with mBarcodeToWrite.size = " + barcodeConnector.barcodeToWrite.size()); if (barcodeConnector.barcodeToWrite.size() != 0) mHandler.postDelayed(disconnectRunnable, 100); @@ -359,7 +359,8 @@ public boolean isBleConnected() { csReaderConnector.cs108ConnectorDataInit(); rfidReaderChip = csReaderConnector.rfidReader.rfidReaderChipR2000; - barcodeNewland = csReaderConnector.barcodeNewland; barcodeConnector = csReaderConnector.barcodeConnector; + barcodeNewland = csReaderConnector.barcodeNewland; + barcodeConnector = csReaderConnector.barcodeConnector; notificationConnector = csReaderConnector.notificationConnector; controllerConnector = csReaderConnector.controllerConnector; bluetoothConnector = csReaderConnector.bluetoothConnector; @@ -370,9 +371,9 @@ public boolean isBleConnected() { getBluetoothICFirmwareVersion(); csReaderConnector.rfidReader.channelOrderType = -1; { - getBarcodePreSuffix(); - getBarcodeReadingMode(); - getBarcodeSerial(); + // getBarcodePreSuffix(); + // getBarcodeReadingMode(); + // getBarcodeSerial(); //getBarcodeNoDuplicateReading(); //getBarcodeDelayTimeOfEachReading(); //getBarcodeEnable2dBarCodes(); @@ -380,18 +381,18 @@ public boolean isBleConnected() { //getBarcodeVersion(); //barcodeSendCommandLoadUserDefault(); //barcodeSendQuerySystem(); - barcodeNewland.barcodeSendCommandItf14Cksum(); + // barcodeNewland.barcodeSendCommandItf14Cksum(); notificationConnector.setBatteryAutoReport(true); //0xA003 } - abortOperation(); - getHostProcessorICSerialNumber(); //0xb004 (but access Oem as bluetooth version is not got) - getMacVer(); - { //following two instructions seems not used + //abortOperation(); + //getHostProcessorICSerialNumber(); //0xb004 (but access Oem as bluetooth version is not got) + //getMacVer(); + if (false) { //following two instructions seems not used int iValue = rfidReaderChip.rx000Setting.getDiagnosticConfiguration(); if (DEBUG) appendToLog("diagnostic data = " + iValue); macWrite(0xC08, 0x100); - rfidReaderChip.rx000OemSetting.getVersionCode(); + //rfidReaderChip.rx000OemSetting.getVersionCode(); } csReaderConnector.rfidReader.regionCode = null; getCountryCode(); @@ -399,14 +400,20 @@ public boolean isBleConnected() { rfidReaderChip.rx000OemSetting.getFreqModifyCode(); rfidReaderChip.rx000OemSetting.getSpecialCountryVersion(); } - getSerialNumber(); + //getSerialNumber(); + getQueryTarget(); + rfidReaderChip.rx000Setting.getImpinjExtension(); rfidReaderChip.rx000Setting.getInvAlgo(); + rfidReaderChip.rx000Setting.getFreqChannelConfig(); if (DEBUG_CONNECT || DEBUG) appendToLog("Start checkVersionRunnable"); mHandler.postDelayed(checkVersionRunnable, 500); if (csReaderConnector.settingData.strForegroundReader.trim().length() != 0) { csReaderConnector.settingData.strForegroundReader = bluetoothGatt.getmBluetoothDevice().getAddress(); } - csReaderConnector.settingData.saveSetting2File0(); + csReaderConnector.settingData.saveForegroundSetting2File(); + } else if (rfidReaderChip == null) { + bleConnection = false; + appendToLog("rfidReaderChip is NULL"); } else if (rfidReaderChip.bFirmware_reset_before) { rfidReaderChip.bFirmware_reset_before = false; mHandler.postDelayed(reinitaliseDataRunnable, 500); @@ -433,9 +440,9 @@ public void disconnect(boolean tempDisconnect) { if (getBarcodeOnStatus()) { appendToLog("tempDisconnect: setBarcodeOn(false)"); if (barcodeConnector.barcodeToWrite.size() != 0) { - appendToLog("going to disconnectRunnable with remaining mBarcodeToWrite.size = " + barcodeConnector.barcodeToWrite.size() + ", data = " + byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); + appendToLog("going to disconnectRunnable with remaining barcodeToWrite.size = " + barcodeConnector.barcodeToWrite.size() + ", data = " + byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); } - barcodeConnector.barcodeToWrite.clear(); + barcodeConnector.barcodeToWrite.clear(); appendToLog("barcodeToWrite is clear"); setBarcodeOn(false); } else appendToLog("tempDisconnect: getBarcodeOnStatus is false"); mHandler.postDelayed(disconnectRunnable, 100); @@ -466,8 +473,6 @@ public int get98XX() { return 0; } - //============ Rfid ============ - //============ Rfid ============ //============ Rfid ============ //============ Rfid ============ //============ Rfid ============ @@ -478,10 +483,6 @@ boolean setInvAlgoNoSave(boolean dynamicAlgo) { boolean setInvAlgo1(boolean dynamicAlgo) { return csReaderConnector.rfidReader.setInvAlgo1(dynamicAlgo); } - - //============ Rfid ============ - //============ Rfid ============ - public String getAuthMatchData() { return csReaderConnector.rfidReader.getAuthMatchData(); } @@ -532,24 +533,22 @@ public void run() { public boolean getChannelHoppingDefault() { return csReaderConnector.rfidReader.getChannelHoppingDefault(); } - int getCountryCode() { - if (true) return csReaderConnector.rfidReader.getCountryCode(); - return rfidReaderChip.rx000OemSetting.getCountryCode(); + return csReaderConnector.rfidReader.getCountryCode(); } int getFreqModifyCode() { - if (true) return csReaderConnector.rfidReader.getFreqModifyCode(); - return rfidReaderChip.rx000OemSetting.getFreqModifyCode(); + return csReaderConnector.rfidReader.getFreqModifyCode(); } public boolean getRfidOnStatus() { return csReaderConnector.rfidReader.getRfidOnStatus(); } public boolean isRfidFailure() { + //appendToLog("BtDataOut: isRfidFailure rfidReader is " + (csReaderConnector.rfidReader == null ? "null" : csReaderConnector.rfidReader.isRfidFailure())); if (csReaderConnector.rfidReader == null) return false; return csReaderConnector.rfidReader.isRfidFailure(); } public void setReaderDefault() { - if (true ) csReaderConnector.rfidReader.setReaderDefault(); + if (true) csReaderConnector.rfidReader.setReaderDefault(); else { setPowerLevel(300); setTagGroup(0, 0, 2); @@ -654,23 +653,10 @@ public long getPwrlevel() { } //long pwrlevelSetting; public boolean setPowerLevel(long pwrlevel) { - if (true) return csReaderConnector.rfidReader.setPowerLevel(pwrlevel); - csReaderConnector.rfidReader.pwrlevelSetting = pwrlevel; - boolean bValue = false; - bValue = rfidReaderChip.rx000Setting.setAntennaPower(pwrlevel); - if (false) appendToLog("PowerLevel = " + pwrlevel + " returning " + bValue); - return bValue; + return csReaderConnector.rfidReader.setPowerLevel(pwrlevel); } public int getQueryTarget() { - if (true) return csReaderConnector.rfidReader.getQueryTarget(); - int iValue; - iValue = rfidReaderChip.rx000Setting.getAlgoAbFlip(); - if (iValue > 0) return 2; - else { - iValue = rfidReaderChip.rx000Setting.getQueryTarget(); - if (iValue > 0) return 1; - return 0; - } + return csReaderConnector.rfidReader.getQueryTarget(); } public int getQuerySession() { if (true) return csReaderConnector.rfidReader.getQuerySession(); @@ -685,6 +671,7 @@ public boolean setTagGroup(int sL, int session, int target1) { if (false) appendToLog("Hello6: invAlgo = " + rfidReaderChip.rx000Setting.getInvAlgo()); if (false) appendToLog("setTagGroup: going to setAlgoSelect with invAlgo = " + rfidReaderChip.rx000Setting.getInvAlgo()); rfidReaderChip.rx000Setting.setAlgoSelect(rfidReaderChip.rx000Setting.getInvAlgo()); //Must not delete this line + if (false) appendToLog("Cs108Library4A.setTagGroup[" + target1 + ", " + session + ", " + sL); return rfidReaderChip.rx000Setting.setQueryTarget(target1, session, sL); } public int getTagFocus() { @@ -697,6 +684,7 @@ public int getFastId() { return csReaderConnector.rfidReader.getFastId(); } public boolean setFastId(boolean fastIdNew) { + appendToLog("bFastId: setFastId[" + fastIdNew); return csReaderConnector.rfidReader.setFastId(fastIdNew); } public boolean getInvAlgo() { @@ -845,6 +833,7 @@ public boolean setInvSelectIndex(int invSelect) { return csReaderConnector.rfidReader.setInvSelectIndex(invSelect); } public boolean setSelectCriteriaDisable(int index) { + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: Cs108Library4A.setSelectCriteriaDisable[" + index + "] goes to setSelectCriteriaDisable"); return csReaderConnector.rfidReader.setSelectCriteriaDisable(index); } int findFirstEmptySelect() { @@ -900,8 +889,8 @@ public boolean setPostMatchCriteria(boolean enable, boolean target, int offset, } public int mrfidToWriteSize() { if (isBleConnected() == false) return -1; - if (true) return csReaderConnector.rfidReader.mrfidToWriteSize(); - return csReaderConnector.rfidReader.mRfidToWrite.size(); + if (csReaderConnector.rfidReader == null) return -1; + return csReaderConnector.rfidReader.mrfidToWriteSize(); } public void mrfidToWritePrint() { if (true) { csReaderConnector.rfidReader.mrfidToWriteSize(); return; } @@ -910,8 +899,7 @@ public void mrfidToWritePrint() { } } public long getTagRate() { - if (true) return csReaderConnector.rfidReader.getTagRate(); - return -1; + return csReaderConnector.rfidReader.getTagRate(); } public boolean startOperation(RfidReaderChipData.OperationTypes operationTypes) { return csReaderConnector.rfidReader.startOperation(operationTypes); @@ -921,16 +909,16 @@ public boolean abortOperation() { } public void restoreAfterTagSelect() { if (!isBleConnected()) return; - appendToLog("Start"); + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: Cs108Library4A.restoreAfterTagSelect goes to setSelectCriteriaDisable"); setSelectCriteriaDisable(0); setSelectCriteriaDisable(1); setSelectCriteriaDisable(2); - if (true) loadSetting1File(); - else if (DEBUG) appendToLog("postMatchDataChanged = " + csReaderConnector.rfidReader.postMatchDataChanged + ", preMatchDataChanged = " + csReaderConnector.rfidReader.preMatchDataChanged + ", macVersion = " + getMacVer()); + loadSetting1File(); + setAccessCount(0); setRx000AccessPassword("00000000"); if (checkHostProcessorVersion(getMacVer(), 2, 6, 8)) { - rfidReaderChip.rx000Setting.setMatchRep(0); - rfidReaderChip.rx000Setting.setTagDelay(csReaderConnector.rfidReader.tagDelaySetting); - rfidReaderChip.rx000Setting.setCycleDelay(csReaderConnector.rfidReader.cycleDelaySetting); - rfidReaderChip.rx000Setting.setInvModeCompact(true); + setMatchRep(0); + setTagDelay(csReaderConnector.rfidReader.tagDelaySetting); + setCycleDelay(csReaderConnector.rfidReader.cycleDelaySetting); + setInvModeCompact(true); } if (csReaderConnector.rfidReader.postMatchDataChanged) { csReaderConnector.rfidReader.postMatchDataChanged = false; @@ -947,10 +935,11 @@ public boolean setSelectedTagByTID(String strTagId, long pwrlevel) { public boolean setSelectedTag(String strTagId, int selectBank, long pwrlevel) { return csReaderConnector.rfidReader.setSelectedTag(strTagId, selectBank, pwrlevel); } - public boolean setSelectedTag(String selectMask, int selectBank, int selectOffset, long pwrlevel, int qValue, int matchRep) { - return csReaderConnector.rfidReader.setSelectedTag(selectMask, selectBank, selectOffset, pwrlevel, qValue, matchRep); + public boolean setSelectedTag(boolean selectOne, String selectMask, int selectBank, int selectOffset, long pwrlevel, int qValue, int matchRep) { + return csReaderConnector.rfidReader.setSelectedTag4Access(selectOne, selectMask, selectBank, selectOffset, pwrlevel, qValue, matchRep); } public boolean setMatchRep(int matchRep) { + if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: Cs108Library4A.setMatchRep goes to setMatchRep with matchRep = " + matchRep); return csReaderConnector.rfidReader.setMatchRep(matchRep); } public String[] getCountryList() { @@ -994,18 +983,7 @@ public boolean setChannelHoppingStatus(boolean channelOrderHopping) { return true; } public String[] getChannelFrequencyList() { - if (true) return csReaderConnector.rfidReader.getChannelFrequencyList(); - boolean DEBUG = true; - appendToLog("regionCode is " + csReaderConnector.rfidReader.regionCode.toString()); - double[] table = csReaderConnector.rfidReader.GetAvailableFrequencyTable(csReaderConnector.rfidReader.regionCode); - appendToLog("table length = " + table.length); - for (int i = 0; i < table.length; i++) appendToLog("table[" + i + "] = " + table[i]); - String[] strChannnelFrequencyList = new String[table.length]; - for (int i = 0; i < table.length ; i++) { - strChannnelFrequencyList[i] = String.format("%.2f MHz", table[i]); - appendToLog("strChannnelFrequencyList[" + i + "] = " + strChannnelFrequencyList[i]); - } - return strChannnelFrequencyList; + return csReaderConnector.rfidReader.getChannelFrequencyList(); } public int getChannel() { return csReaderConnector.settingData.channel; @@ -1065,6 +1043,7 @@ public boolean setAccessRetry(boolean accessVerfiy, int accessRetry) { return csReaderConnector.rfidReader.setAccessRetry(accessVerfiy, accessRetry); } public boolean setInvModeCompact(boolean invModeCompact) { + if (utility.DEBUG_COMPACT) appendToLog("Debug_Compact 1: Cs108Library4A.setInvModeCompact goes to setInvModeCompact"); return csReaderConnector.rfidReader.setInvModeCompact(invModeCompact); } public boolean setAccessLockAction(int accessLockAction, int accessLockMask) { @@ -1163,7 +1142,8 @@ public String getBarcodeDate() { return barcodeNewland.getBarcodeDate(); } public boolean getBarcodeOnStatus() { - return barcodeConnector.getOnStatus(); + if (barcodeConnector == null) return false; + return barcodeConnector.getOnStatus(); } public boolean setBarcodeOn(boolean on) { boolean retValue; @@ -1395,90 +1375,10 @@ else if (barcodeData != null) { //============ Android General ============ public void setSameCheck(boolean sameCheck1) { if (csReaderConnector.sameCheck == sameCheck1) return; - appendToLog("!!! new sameCheck = " + sameCheck1 + ", with old sameCheck = " + csReaderConnector.sameCheck); + if (false) appendToLog("new sameCheck = " + sameCheck1 + ", with old sameCheck = " + csReaderConnector.sameCheck); csReaderConnector.sameCheck = sameCheck1; //sameCheck = false; } -/* - public void saveSetting2File() { - appendToLog("Start"); - FileOutputStream stream; - try { - stream = new FileOutputStream(csReaderConnector.settingData.file); - stream.write("Start of data\n".getBytes()); - - String outData = "appVersion," + getlibraryVersion() +"\n"; stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "countryInList," + String.valueOf(getCountryNumberInList() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - if (getChannelHoppingStatus() == false) - outData = "channel," + String.valueOf(getChannel() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - - outData = "antennaPower," + String.valueOf(csReaderConnector.rfidReader.getPwrlevel() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "population," + String.valueOf(getPopulation() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "querySession," + String.valueOf(getQuerySession() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "queryTarget," + String.valueOf(getQueryTarget() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "tagFocus," + String.valueOf(getTagFocus() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "fastId," + String.valueOf(getFastId() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "invAlgo," + String.valueOf(getInvAlgo() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "retry," + String.valueOf(getRetryCount() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "currentProfile," + String.valueOf(getCurrentProfile() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "rxGain," + String.valueOf(getRxGain() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - - outData = "deviceName," + getBluetoothICFirmwareName() +"\n"; stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "batteryDisplay," + String.valueOf(getBatteryDisplaySetting() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "rssiDisplay," + String.valueOf(getRssiDisplaySetting() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "tagDelay," + String.valueOf(getTagDelay() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "cycleDelay," + String.valueOf(getCycleDelay() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "intraPkDelay," + String.valueOf(getIntraPkDelay() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "dupDelay," + String.valueOf(getDupDelay() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - - outData = "triggerReporting," + String.valueOf(notificationConnector.getTriggerReporting() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "triggerReportingCount," + String.valueOf(notificationConnector.getTriggerReportingCount() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "inventoryBeep," + String.valueOf(csReaderConnector.settingData.inventoryBeep + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "inventoryBeepCount," + String.valueOf(getBeepCount() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "inventoryVibrate," + String.valueOf(getInventoryVibrate() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "inventoryVibrateTime," + String.valueOf(getVibrateTime() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "inventoryVibrateMode," + String.valueOf(getVibrateModeSetting() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "inventoryVibrateWindow," + String.valueOf(getVibrateWindow() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - - outData = "savingFormat," + String.valueOf(getSavingFormatSetting() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "csvColumnSelect," + String.valueOf(getCsvColumnSelectSetting() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "saveFileEnable," + String.valueOf(getSaveFileEnable() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "saveCloudEnable," + String.valueOf(getSaveCloudEnable() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "saveNewCloudEnable," + String.valueOf(getSaveNewCloudEnable() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "saveAllCloudEnable," + String.valueOf(getSaveAllCloudEnable() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "serverLocation," + getServerLocation() + "\n"; stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "serverTimeout," + String.valueOf(getServerTimeout() +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - csReaderConnector.settingData.write2FileStream(stream, "serverMqttLocation," + getServerMqttLocation() + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "topicMqtt," + getTopicMqtt() + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "foregroundDupElim," + String.valueOf(getForegroundDupElim() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "inventoryCloudSave," + getInventoryCloudSave() + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "serverImpinjLocation," + getServerImpinjLocation() + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "serverImpinjName," + getServerImpinjName() + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "serverImpinjPassword," + getServerImpinjPassword() + "\n"); - outData = "barcode2TriggerMode," + String.valueOf(csReaderConnector.settingData.barcode2TriggerMode +"\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - -// outData = "wedgePrefix," + getWedgePrefix() + "\n"; stream.write(outData.getBytes()); appendToLog("outData = " + outData); -// outData = "wedgeSuffix," + getWedgeSuffix() + "\n"; stream.write(outData.getBytes()); appendToLog("outData = " + outData); -// outData = "wedgeDelimiter," + String.valueOf(getWedgeDelimiter() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "userDebugEnable," + String.valueOf(getUserDebugEnable() + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - if (csReaderConnector.settingData.preFilterData != null) { - outData = "preFilterData.enable," + String.valueOf(csReaderConnector.settingData.preFilterData.enable + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "preFilterData.target," + String.valueOf(csReaderConnector.settingData.preFilterData.target + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "preFilterData.action," + String.valueOf(csReaderConnector.settingData.preFilterData.action + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "preFilterData.bank," + String.valueOf(csReaderConnector.settingData.preFilterData.bank + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "preFilterData.offset," + String.valueOf(csReaderConnector.settingData.preFilterData.offset + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "preFilterData.mask," + String.valueOf(csReaderConnector.settingData.preFilterData.mask + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - outData = "preFilterData.maskbit," + String.valueOf(csReaderConnector.settingData.preFilterData.maskbit + "\n"); stream.write(outData.getBytes()); appendToLog("outData = " + outData); - } - - stream.write("End of data\n".getBytes()); appendToLog("outData = " + outData); - stream.close(); - } catch (Exception ex){ - // - } - csReaderConnector.settingData.saveSetting2File0(); - } -*/ public int getBeepCount() { return csReaderConnector.settingData.beepCountSetting; } @@ -1488,13 +1388,10 @@ public boolean setBeepCount(int beepCount) { } public boolean getInventoryBeep() { - if (true) return csReaderConnector.settingData.inventoryBeep; return csReaderConnector.settingData.inventoryBeep; } public boolean setInventoryBeep(boolean inventoryBeep) { - if (true) return csReaderConnector.settingData.inventoryBeep = inventoryBeep; - csReaderConnector.settingData.inventoryBeep = inventoryBeep; - return true; + return csReaderConnector.settingData.inventoryBeep = inventoryBeep; } public boolean getSaveFileEnable() { @@ -1873,6 +1770,7 @@ public boolean batteryLevelRequest() { appendToLog("Skip batteryLevelREquest as inventoring !!!"); return true; } + if (mrfidToWriteSize() != 0) return false; return notificationConnector.batteryLevelRequest(); } public boolean setAutoBarStartSTop(boolean enable) { @@ -1984,17 +1882,18 @@ public void run() { boolean DEBUG = false; @Override public void run() { - if (DEBUG_CONNECT) appendToLog("0 checkVersionRunnable with getFreqChannelConfig = " + rfidReaderChip.rx000Setting.getFreqChannelConfig() + ", isBarcodeFailure = " + isBarcodeFailure() + ", bBarcodeTriggerMode = " + barcodeNewland.bBarcodeTriggerMode); + if (DEBUG_CONNECT || true) appendToLog("0 checkVersionRunnable with mrfidToWriteSize = " + mrfidToWriteSize()); //if (false && (mRfidDevice.mRfidReaderChip.mRfidReaderChip.mRx000Setting.getFreqChannelConfig() < 0 || (isBarcodeFailure() == false && mBarcodeDevice.bBarcodeTriggerMode == (byte)0xFF))) { - if (rfidReaderChip.rx000Setting.getFreqChannelConfig() < 0 || (isBarcodeFailure() == false && barcodeNewland.bBarcodeTriggerMode == (byte)0xFF)) { - if (DEBUG) appendToLog("checkVersionRunnable: RESTART with FreqChannelConfig = " + rfidReaderChip.rx000Setting.getFreqChannelConfig() + ", bBarcodeTriggerMode = " + barcodeNewland.bBarcodeTriggerMode); + if (mrfidToWriteSize() > 0) { //rfidReaderChip.rx000Setting.getFreqChannelConfig() < 0) { // || (isBarcodeFailure() == false && barcodeNewland.bBarcodeTriggerMode == (byte)0xFF)) { + //if (DEBUG) appendToLog("checkVersionRunnable: RESTART with FreqChannelConfig = " + rfidReaderChip.rx000Setting.getFreqChannelConfig() + ", bBarcodeTriggerMode = " + barcodeNewland.bBarcodeTriggerMode); mHandler.removeCallbacks(checkVersionRunnable); mHandler.postDelayed(checkVersionRunnable, 500); } else { - setSameCheck(false); + //setSameCheck(false); + setAccessCount(0); //appendToLog("btDataOut: setAccessCount as 0"); notificationConnector.setVersion(hostProcessorICGetFirmwareVersion()); if (DEBUG) appendToLog("checkVersionRunnable: Checkpoint 1 with BarcodeFailure = " + isBarcodeFailure()); - if (isBarcodeFailure() == false) { + if (false && isBarcodeFailure() == false) { if (DEBUG) appendToLog("checkVersionRunnable: Checkpoint 2"); if (barcodeNewland.checkPreSuffix(barcodeNewland.prefixRef, barcodeNewland.suffixRef) == false) barcodeNewland.barcodeSendCommandSetPreSuffix(); if (barcodeNewland.bBarcodeTriggerMode != 0x30) barcodeNewland.barcodeSendCommandTrigger(); @@ -2018,22 +1917,23 @@ public void run() { if (DEBUG) appendToLog("checkVersionRunnable: macVersion = " + getMacVer()); if (checkHostProcessorVersion(getMacVer(), 2, 6, 8)) { if (DEBUG) appendToLog("checkVersionRunnable: macVersion >= 2.6.8"); - rfidReaderChip.rx000Setting.setTagDelay(csReaderConnector.rfidReader.tagDelaySetting); - rfidReaderChip.rx000Setting.setCycleDelay(csReaderConnector.rfidReader.cycleDelaySetting); - rfidReaderChip.rx000Setting.setInvModeCompact(true); + setTagDelay(csReaderConnector.rfidReader.tagDelaySetting); + setCycleDelay(csReaderConnector.rfidReader.cycleDelaySetting); + setInvModeCompact(true); } else { if (DEBUG) appendToLog("checkVersionRunnable: macVersion < 2.6.8"); - rfidReaderChip.rx000Setting.setTagDelay(csReaderConnector.rfidReader.tagDelayDefaultNormalSetting); - rfidReaderChip.rx000Setting.setCycleDelay(csReaderConnector.rfidReader.cycleDelaySetting); + setTagDelay(csReaderConnector.rfidReader.tagDelayDefaultNormalSetting); + setCycleDelay(csReaderConnector.rfidReader.cycleDelaySetting); } rfidReaderChip.rx000Setting.setDiagnosticConfiguration(true); if (DEBUG) appendToLog("checkVersionRunnable: Checkpoint 10"); - setSameCheck(true); + //setSameCheck(true); } } }; boolean loadSetting1File() { + if (true) return csReaderConnector.settingData.loadSettingFile(getlibraryVersion(), getChannelHoppingStatus(), getCurrentProfile()); File path = context.getFilesDir(); String fileName = bluetoothGatt.getmBluetoothDevice().getAddress(); @@ -2200,7 +2100,7 @@ boolean loadSetting1File() { appendToLog("preFilterData is valid. Going to setSelectCriteria"); setSelectCriteria(0, csReaderConnector.settingData.preFilterData.enable, csReaderConnector.settingData.preFilterData.target, csReaderConnector.settingData.preFilterData.action, csReaderConnector.settingData.preFilterData.bank, csReaderConnector.settingData.preFilterData.offset, csReaderConnector.settingData.preFilterData.mask, csReaderConnector.settingData.preFilterData.maskbit); } else { - appendToLog("preFilterData is null or disabled. Going to setSelectCriteriaDisable"); + appendToLog("Debug_Select: preFilterData is null or disabled. Going to setSelectCriteriaDisable"); setSelectCriteriaDisable(0); } } @@ -2246,4 +2146,8 @@ public int getInvalidUpdata() { public int getValidata() { return csReaderConnector.validata; } + + public int setSelectData(RfidReader.TagType tagType, String mDid, boolean bNeedSelectedTagByTID, String stringProtectPassword, int selectFor, int selectHold) { + return csReaderConnector.rfidReader.setSelectData4Inventory(tagType, mDid, bNeedSelectedTagByTID, stringProtectPassword, selectFor, selectHold); + } } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs710Library4A.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs710Library4A.java index aac14a5..6cf15fd 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs710Library4A.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs710Library4A.java @@ -16,12 +16,7 @@ import com.csl.cslibrary4a.RfidReader.RegionCodes; -import java.io.BufferedReader; import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.InputStreamReader; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; @@ -324,12 +319,12 @@ public BluetoothGatt.Cs108ScanData getNewDeviceScanned() { } else return null; } public String getBluetoothDeviceAddress() { - if (bluetoothGatt.getmBluetoothDevice() == null) return null; - return bluetoothGatt.getmBluetoothDevice().getAddress(); + if (bluetoothGatt.getmBluetoothDevice() == null) return null; + return bluetoothGatt.getmBluetoothDevice().getAddress(); } public String getBluetoothDeviceName() { - if (bluetoothGatt.getmBluetoothDevice() == null) return null; - return bluetoothGatt.getmBluetoothDevice().getName(); + if (bluetoothGatt.getmBluetoothDevice() == null) return null; + return bluetoothGatt.getmBluetoothDevice().getName(); } public boolean isBleConnected() { boolean DEBUG = false; @@ -346,7 +341,6 @@ public boolean isBleConnected() { controllerConnector = csReaderConnector.controllerConnector; bluetoothConnector = csReaderConnector.bluetoothConnector; - setRfidOn(true); setBarcodeOn(true); hostProcessorICGetFirmwareVersion(); @@ -355,7 +349,7 @@ public boolean isBleConnected() { { getBarcodePreSuffix(); getBarcodeReadingMode(); - barcodeNewland.getBarcodeSerial(); + getBarcodeSerial(); //getBarcodeNoDuplicateReading(); //getBarcodeDelayTimeOfEachReading(); //getBarcodeEnable2dBarCodes(); @@ -394,11 +388,11 @@ public boolean isBleConnected() { mHandler.postDelayed(checkVersionRunnable, 500); if (csReaderConnector.settingData.strForegroundReader.trim().length() != 0) { - appendToLog("foregroundReader: set 3"); csReaderConnector.settingData.strForegroundReader = bluetoothGatt.getmBluetoothDevice().getAddress(); } - csReaderConnector.settingData.saveSetting2File0(); + csReaderConnector.settingData.saveForegroundSetting2File(); } else if (rfidReaderChip == null) { + bleConnection = false; appendToLog("rfidReaderChip is NULL"); } else if (rfidReaderChip.bFirmware_reset_before) { rfidReaderChip.bFirmware_reset_before = false; @@ -532,75 +526,10 @@ public boolean getChannelHoppingDefault() { } int getCountryCode() { - if (true) return csReaderConnector.rfidReader.getCountryCode(); - final boolean DEBUG = false; - int iCountrycode = -1; - int iValue = rfidReaderChip.rx000Setting.getCountryEnum(); - if (DEBUG) appendToLog("getCountryEnum 0x3014 = " + iValue); - if (iValue > 0 && iValue < csReaderConnector.rfidReader.strCountryEnumInfo.length/csReaderConnector.rfidReader.iCountryEnumInfoColumn) { - if (DEBUG) { - for (int i = 1; i <= 160; i++) { - appendToLog("i = " + i + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(i - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 0] - + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(i - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 1] - + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(i - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 2] - + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(i - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 3] - + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(i - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 4] - + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(i - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 5] - + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(i - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 6] - ); - } - } - String strCountryCode = csReaderConnector.rfidReader.strCountryEnumInfo[(iValue - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 2]; - if (DEBUG) appendToLog("strCountryCode 0 = " + strCountryCode); - String[] countryCodePart = strCountryCode.split(" "); - strCountryCode = countryCodePart[0].substring(1); - if (DEBUG) appendToLog("strCountryCode 1 = " + strCountryCode); - try { - iCountrycode = Integer.decode(strCountryCode); - if (DEBUG) appendToLog("iCountrycode = " + iCountrycode); - } catch (Exception ex) { - } - } - if (true) { - int iCountrycode1 = rfidReaderChip.rx000Setting.getCountryEnumOem(); - if (DEBUG) appendToLog("getCountryEnumOem 0x5040 = " + iCountrycode1); - int iCountrycode2 = rfidReaderChip.rx000Setting.getCountryCodeOem(); - if (DEBUG) appendToLog("getCountryCodeOem 0xef98 = " + iCountrycode2); - if (iCountrycode < 0 && iCountrycode1 > 0 && iCountrycode1 < 10) iCountrycode = iCountrycode1; - if (iCountrycode < 0 && iCountrycode2 > 0 && iCountrycode2 < 10) iCountrycode = iCountrycode2; - } - return iCountrycode; - } - String getSpecialCountryVersion() { - boolean DEBUG = false; - String strSpecialCountryCode = null; - int iValue = rfidReaderChip.rx000Setting.getCountryEnum(); - if (DEBUG) appendToLog("getCountryEnum 0x3014 = " + iValue); - if (iValue > 0 && iValue < csReaderConnector.rfidReader.strCountryEnumInfo.length/csReaderConnector.rfidReader.iCountryEnumInfoColumn) { - String strCountryCode = csReaderConnector.rfidReader.strCountryEnumInfo[(iValue - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 2]; - if (DEBUG) appendToLog("strCountryCode 0 = " + strCountryCode); - String[] countryCodePart = strCountryCode.split(" "); - if (DEBUG) appendToLog("countryCodePart.length = " + countryCodePart.length); - if (countryCodePart.length >= 2) strSpecialCountryCode = countryCodePart[1]; - else strSpecialCountryCode = ""; - if (DEBUG) appendToLog("strSpecialCountryCode = " + strSpecialCountryCode); - } - if (true) { - String strValue = rfidReaderChip.rx000Setting.getSpecialCountryCodeOem(); - if (DEBUG) appendToLog("getCountryCodeOem 0xefac = " + strValue); - if (strSpecialCountryCode == null && strValue != null) { - if (DEBUG) appendToLog("strSpecialCountryCode is replaced with countryCodeOem"); - strSpecialCountryCode = strValue; - } - } - return strSpecialCountryCode; + return csReaderConnector.rfidReader.getCountryCode(); } int getFreqModifyCode() { - if (true) return csReaderConnector.rfidReader.getFreqModifyCode(); - boolean DEBUG = false; - int iFreqModifyCode = rfidReaderChip.rx000Setting.getFreqModifyCode(); - if (DEBUG) appendToLog("getFreqModifyCode 0xefb0 = " + iFreqModifyCode); - return iFreqModifyCode; + return csReaderConnector.rfidReader.getFreqModifyCode(); } public boolean getRfidOnStatus() { return csReaderConnector.rfidReader.getRfidOnStatus(); @@ -623,7 +552,7 @@ public void setReaderDefault() { string = string.substring(string.length()-6, string.length()); setBluetoothICFirmwareName("CS710Sreader" + string); //getlibraryVersion() - if (false) { + if (false) { setCountryInList(csReaderConnector.rfidReader.countryInListDefault); setChannel(0); @@ -637,7 +566,7 @@ public void setReaderDefault() { //\\getRetryCount() //getCurrentProfile() + "\n")); //\\getRxGain() + "\n")); - } + } //getBluetoothICFirmwareName() + "\n"); setBatteryDisplaySetting(csReaderConnector.settingData.batteryDisplaySelectDefault); setRssiDisplaySetting(csReaderConnector.settingData.rssiDisplaySelectDefault); @@ -715,20 +644,10 @@ public long getPwrlevel() { } //long pwrlevelSetting; public boolean setPowerLevel(long pwrlevel) { - if (true) return csReaderConnector.rfidReader.setPowerLevel(pwrlevel); - csReaderConnector.rfidReader.pwrlevelSetting = pwrlevel; - boolean bValue = false; - bValue = rfidReaderChip.rx000Setting.setAntennaPower(pwrlevel); - return bValue; + return csReaderConnector.rfidReader.setPowerLevel(pwrlevel); } public int getQueryTarget() { - if (true) return csReaderConnector.rfidReader.getQueryTarget(); - int iValue; boolean DEBUG = false; - if (DEBUG) appendToLog("1 getQueryTarget"); - iValue = rfidReaderChip.rx000Setting.getQueryTarget(); - if (DEBUG) appendToLog("1A getQueryTarget: iValue = " + iValue); - if (iValue < 0) iValue = 0; - return iValue; + return csReaderConnector.rfidReader.getQueryTarget(); } public int getQuerySession() { if (true) return csReaderConnector.rfidReader.getQuerySession(); @@ -772,7 +691,8 @@ public List getProfileList() { return csReaderConnector.rfidReader.getProfileList(); } public int getCurrentProfile() { - boolean DEBUG = true; + if (true) return csReaderConnector.rfidReader.getCurrentProfile(); + boolean DEBUG = false; if (DEBUG) appendToLog("1 getCurrentProfile"); int iValue; if (true) { @@ -876,11 +796,12 @@ public int getUntraceableEpcLength() { } public boolean setUntraceable(boolean bHideEpc, int ishowEpcSize, int iHideTid, boolean bHideUser, boolean bHideRange) { return csReaderConnector.rfidReader.setUntraceable(bHideEpc, ishowEpcSize, iHideTid, bHideUser, bHideRange); - } + } public boolean setUntraceable(int range, boolean user, int tid, int epcLength, boolean epc, boolean uxpc) { return csReaderConnector.rfidReader.setUntraceable(range, user, tid, epcLength, epc, uxpc); } public boolean setAuthenticateConfiguration() { + if (true) return csReaderConnector.rfidReader.setAuthenticateConfiguration(); appendToLog("setAuthenticateConfiguration Started"); boolean bValue = rfidReaderChip.rx000Setting.setAuthenticateConfig((48 << 10) | (1 << 2) | 0x03); appendToLog("setAuthenticateConfiguration 1: bValue = " + (bValue ? "true" : "false")); @@ -904,6 +825,7 @@ public int getInvSelectIndex() { return csReaderConnector.rfidReader.getInvSelectIndex(); } public boolean getSelectEnable() { + if (true) return csReaderConnector.rfidReader.getSelectEnable(); int iValue; iValue = rfidReaderChip.rx000Setting.getSelectEnable(); return iValue > 0 ? true : false; @@ -983,8 +905,7 @@ public boolean setPostMatchCriteria(boolean enable, boolean target, int offset, public int mrfidToWriteSize() { if (isBleConnected() == false) return -1; if (csReaderConnector.rfidReader == null) return -1; - if (true) return csReaderConnector.rfidReader.mrfidToWriteSize(); - return csReaderConnector.rfidReader.mRfidToWrite.size(); + return csReaderConnector.rfidReader.mrfidToWriteSize(); } public void mrfidToWritePrint() { if (true) { csReaderConnector.rfidReader.mrfidToWriteSize(); return; } @@ -993,8 +914,7 @@ public void mrfidToWritePrint() { } } public long getTagRate() { - if (true) return csReaderConnector.rfidReader.getTagRate(); - return rfidReaderChip.rx000Setting.getTagRate(); + return csReaderConnector.rfidReader.getTagRate(); } public boolean startOperation(RfidReaderChipData.OperationTypes operationTypes) { return csReaderConnector.rfidReader.startOperation(operationTypes); @@ -1004,7 +924,7 @@ public boolean abortOperation() { } public void restoreAfterTagSelect() { if (!isBleConnected()) return; - appendToLog("!!! Start"); + appendToLog("Start"); setSelectCriteriaDisable(0); setSelectCriteriaDisable(1); setSelectCriteriaDisable(2); if (true) loadSetting1File(); else if (DEBUG) appendToLog("postMatchDataChanged = " + csReaderConnector.rfidReader.postMatchDataChanged + ", preMatchDataChanged = " + csReaderConnector.rfidReader.preMatchDataChanged + ", macVersion = " + getMacVer()); @@ -1012,7 +932,6 @@ public void restoreAfterTagSelect() { rfidReaderChip.rx000Setting.setMatchRep(0); rfidReaderChip.rx000Setting.setTagDelay(csReaderConnector.rfidReader.tagDelaySetting); rfidReaderChip.rx000Setting.setCycleDelay(csReaderConnector.rfidReader.cycleDelaySetting); - appendToLog("2EC setInvAlgo"); rfidReaderChip.rx000Setting.setInvModeCompact(true); } if (csReaderConnector.rfidReader.postMatchDataChanged) { @@ -1020,9 +939,7 @@ public void restoreAfterTagSelect() { setPostMatchCriteria(csReaderConnector.rfidReader.postMatchDataOld.enable, csReaderConnector.rfidReader.postMatchDataOld.target, csReaderConnector.rfidReader.postMatchDataOld.offset, csReaderConnector.rfidReader.postMatchDataOld.mask); appendToLog("PowerLevel"); setPowerLevel(csReaderConnector.rfidReader.postMatchDataOld.pwrlevel); - appendToLog("00C getRetryCount"); appendToLog("writeBleStreamOut: invAlgo = " + csReaderConnector.rfidReader.postMatchDataOld.invAlgo); setInvAlgo1(csReaderConnector.rfidReader.postMatchDataOld.invAlgo); - appendToLog("4A setAlgoStartQ"); setQValue1(csReaderConnector.rfidReader.postMatchDataOld.qValue); } } @@ -1033,7 +950,7 @@ public boolean setSelectedTag(String strTagId, int selectBank, long pwrlevel) { return csReaderConnector.rfidReader.setSelectedTag(strTagId, selectBank, pwrlevel); } public boolean setSelectedTag(String selectMask, int selectBank, int selectOffset, long pwrlevel, int qValue, int matchRep) { - return csReaderConnector.rfidReader.setSelectedTag(selectMask, selectBank, selectOffset, pwrlevel, qValue, matchRep); + return csReaderConnector.rfidReader.setSelectedTag4Access(false, selectMask, selectBank, selectOffset, pwrlevel, qValue, matchRep); } public boolean setMatchRep(int matchRep) { return csReaderConnector.rfidReader.setMatchRep(matchRep); @@ -1048,11 +965,12 @@ public boolean setCountryInList(int countryInList) { return csReaderConnector.rfidReader.setCountryInList(countryInList); } public boolean getChannelHoppingStatus() { + if (true) csReaderConnector.rfidReader.getChannelHoppingStatus(); boolean bValue = false, DEBUG = false; int iValue = rfidReaderChip.rx000Setting.getCountryEnum(); //iValue--; if (DEBUG) appendToLog("getChannelHoppingStatus: countryEnum = " + iValue); if (iValue > 0) { - String strFixedHop = csReaderConnector.rfidReader.strCountryEnumInfo[(iValue - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 4]; + String strFixedHop = csReaderConnector.rfidReader.countryChannelData.strCountryEnumInfo[(iValue - 1) * csReaderConnector.rfidReader.countryChannelData.iCountryEnumInfoColumn + 4]; if (DEBUG) appendToLog("getChannelHoppingStatus: FixedHop = " + strFixedHop); if (strFixedHop.matches("Hop")) { if (DEBUG) appendToLog("getChannelHoppingStatus: matched"); @@ -1079,29 +997,7 @@ public boolean setChannelHoppingStatus(boolean channelOrderHopping) { return true; } public String[] getChannelFrequencyList() { - if (true) return csReaderConnector.rfidReader.getChannelFrequencyList(); - boolean DEBUG = true; - int iCountryEnum = rfidReaderChip.rx000Setting.getCountryEnum(); - appendToLog("countryEnum = " + iCountryEnum); - appendToLog("i = " + iCountryEnum + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(iCountryEnum - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 0] - + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(iCountryEnum - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 1] - + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(iCountryEnum - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 2] - + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(iCountryEnum - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 3] - + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(iCountryEnum - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 4] - + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(iCountryEnum - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 5] - + ", " + csReaderConnector.rfidReader.strCountryEnumInfo[(iCountryEnum - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 6] - ); - int iFrequencyCount = Integer.valueOf(csReaderConnector.rfidReader.strCountryEnumInfo[(iCountryEnum - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 3]); - int iFrequencyInterval = Integer.valueOf(csReaderConnector.rfidReader.strCountryEnumInfo[(iCountryEnum - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 5]); - float iFrequencyStart = Float.valueOf(csReaderConnector.rfidReader.strCountryEnumInfo[(iCountryEnum - 1) * csReaderConnector.rfidReader.iCountryEnumInfoColumn + 6]); - appendToLog("iFrequencyCount = " + iFrequencyCount + ", interval = " + iFrequencyInterval + ", start = " + iFrequencyStart); - - String[] strChannnelFrequencyList = new String[iFrequencyCount]; - for (int i = 0; i < iFrequencyCount ; i++) { - strChannnelFrequencyList[i] = String.format("%.2f MHz", (iFrequencyStart * 1000 + iFrequencyInterval * i) / 1000); - appendToLog("strChannnelFrequencyList[" + i + "] = " + strChannnelFrequencyList[i]); - } - return strChannnelFrequencyList; + return csReaderConnector.rfidReader.getChannelFrequencyList(); } public int getChannel() { return csReaderConnector.settingData.channel; @@ -1112,7 +1008,6 @@ public boolean setChannel(int channelSelect) { public byte getPopulation2Q(int population) { return csReaderConnector.rfidReader.getPopulation2Q(population); } - //int population = 30; public int getPopulation() { return csReaderConnector.rfidReader.getPopulation(); } @@ -1208,6 +1103,7 @@ public boolean setAccessRetry(boolean accessVerfiy, int accessRetry) { return csReaderConnector.rfidReader.setAccessRetry(accessVerfiy, accessRetry); } public boolean setInvModeCompact(boolean invModeCompact) { + if (utility.DEBUG_COMPACT) appendToLog("Debug_Compact 2: Cs710Library4A.setInvModeCompact goes to setInvModeCompact"); return csReaderConnector.rfidReader.setInvModeCompact(invModeCompact); } public boolean setAccessLockAction(int accessLockAction, int accessLockMask) { @@ -1215,7 +1111,7 @@ public boolean setAccessLockAction(int accessLockAction, int accessLockMask) { } public boolean setAccessBank(int accessBank) { return csReaderConnector.rfidReader.setAccessBank(accessBank); - } + } public boolean setAccessBank(int accessBank, int accessBank2) { return csReaderConnector.rfidReader.setAccessBank(accessBank, accessBank2); } @@ -1541,87 +1437,7 @@ public void setSameCheck(boolean sameCheck1) { appendToLog("!!! new sameCheck = " + sameCheck1 + ", with old sameCheck = " + csReaderConnector.sameCheck); csReaderConnector.sameCheck = sameCheck1; //sameCheck = false; } -/* - public void saveSetting2File(String strLibraryVersion, int iProfile) { - boolean DEBUG = true; - if (DEBUG) appendToLog("Start"); - FileOutputStream stream; - try { - stream = new FileOutputStream(csReaderConnector.settingData.file); - csReaderConnector.settingData.write2FileStream(stream, "Start of data\n"); - - csReaderConnector.settingData.write2FileStream(stream, "appVersion," + getlibraryVersion() + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "countryInList," + String.valueOf(csReaderConnector.rfidReader.countryInList + "\n")); - if (getChannelHoppingStatus() == false) csReaderConnector.settingData.write2FileStream(stream, "channel," + String.valueOf(csReaderConnector.settingData.channel + "\n")); - - csReaderConnector.settingData.write2FileStream(stream, "antennaPower," + String.valueOf(csReaderConnector.rfidReader.getPwrlevel() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "population," + String.valueOf(csReaderConnector.rfidReader.getPopulation() +"\n")); - csReaderConnector.settingData.write2FileStream(stream, "querySession," + String.valueOf(csReaderConnector.rfidReader.getQuerySession() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "queryTarget," + String.valueOf(csReaderConnector.rfidReader.getQueryTarget() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "tagFocus," + String.valueOf(csReaderConnector.rfidReader.getTagFocus() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "fastId," + String.valueOf(csReaderConnector.rfidReader.getFastId() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "invAlgo," + String.valueOf(csReaderConnector.rfidReader.getInvAlgo() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "retry," + String.valueOf(csReaderConnector.rfidReader.getRetryCount() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "currentProfile," + String.valueOf(getCurrentProfile() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "rxGain," + String.valueOf(csReaderConnector.rfidReader.getRxGain() + "\n")); - - csReaderConnector.settingData.write2FileStream(stream, "deviceName," + csReaderConnector.bluetoothConnector.getBluetoothIcName() + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "batteryDisplay," + String.valueOf(csReaderConnector.settingData.batteryDisplaySelect + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "rssiDisplay," + String.valueOf(csReaderConnector.settingData.rssiDisplaySelect + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "tagDelay," + String.valueOf(csReaderConnector.rfidReader.getTagDelay() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "cycleDelay," + String.valueOf(csReaderConnector.rfidReader.getCycleDelay() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "intraPkDelay," + String.valueOf(csReaderConnector.rfidReader.getIntraPkDelay() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "dupDelay," + String.valueOf(csReaderConnector.rfidReader.getDupDelay() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "triggerReporting," + String.valueOf(notificationConnector.getTriggerReporting() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "triggerReportingCount," + String.valueOf(notificationConnector.getTriggerReportingCount() + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "inventoryBeep," + String.valueOf(csReaderConnector.settingData.inventoryBeep + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "inventoryBeepCount," + String.valueOf(csReaderConnector.settingData.beepCountSetting + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "inventoryVibrate," + String.valueOf(csReaderConnector.settingData.inventoryVibrate + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "inventoryVibrateTime," + String.valueOf(csReaderConnector.settingData.vibrateTimeSetting + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "inventoryVibrateMode," + String.valueOf(csReaderConnector.settingData.vibrateModeSelect + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "inventoryVibrateWindow," + String.valueOf(csReaderConnector.settingData.vibrateWindowSetting + "\n")); - - csReaderConnector.settingData.write2FileStream(stream, "savingFormat," + String.valueOf(csReaderConnector.settingData.savingFormatSelect + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "csvColumnSelect," + String.valueOf(csReaderConnector.settingData.csvColumnSelect + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "saveFileEnable," + String.valueOf(csReaderConnector.settingData.saveFileEnable + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "saveCloudEnable," + String.valueOf(csReaderConnector.settingData.saveCloudEnable + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "saveNewCloudEnable," + String.valueOf(csReaderConnector.settingData.saveNewCloudEnable + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "saveAllCloudEnable," + String.valueOf(csReaderConnector.settingData.saveAllCloudEnable + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "serverLocation," + csReaderConnector.settingData.serverLocation + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "serverTimeout," + String.valueOf(csReaderConnector.settingData.serverTimeout + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "serverMqttLocation," + csReaderConnector.settingData.serverMqttLocation + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "topicMqtt," + csReaderConnector.settingData.topicMqtt + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "foregroundDupElim," + String.valueOf(csReaderConnector.settingData.iForegroundDupElim + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "inventoryCloudSave," + csReaderConnector.settingData.inventoryCloudSave + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "serverImpinjLocation," + csReaderConnector.settingData.serverImpinjLocation + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "serverImpinjName," + csReaderConnector.settingData.serverImpinjName + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "serverImpinjPassword," + csReaderConnector.settingData.serverImpinjPassword + "\n"); - csReaderConnector.settingData.write2FileStream(stream, "barcode2TriggerMode," + String.valueOf(csReaderConnector.settingData.barcode2TriggerMode + "\n")); - -// write2FileStream(stream, "wedgePrefix," + getWedgePrefix() + "\n"); -// write2FileStream(stream, "wedgeSuffix," + getWedgeSuffix() + "\n"); -// write2FileStream(stream, "wedgeDelimiter," + String.valueOf(getWedgeDelimiter()) + "\n"); - - csReaderConnector.settingData.write2FileStream(stream, "userDebugEnable," + String.valueOf(csReaderConnector.settingData.userDebugEnable + "\n")); - if (csReaderConnector.settingData.preFilterData != null) { - csReaderConnector.settingData.write2FileStream(stream, "preFilterData.enable," + String.valueOf(csReaderConnector.settingData.preFilterData.enable + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "preFilterData.target," + String.valueOf(csReaderConnector.settingData.preFilterData.target + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "preFilterData.action," + String.valueOf(csReaderConnector.settingData.preFilterData.action + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "preFilterData.bank," + String.valueOf(csReaderConnector.settingData.preFilterData.bank + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "preFilterData.offset," + String.valueOf(csReaderConnector.settingData.preFilterData.offset + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "preFilterData.mask," + String.valueOf(csReaderConnector.settingData.preFilterData.mask + "\n")); - csReaderConnector.settingData.write2FileStream(stream, "preFilterData.maskbit," + String.valueOf(csReaderConnector.settingData.preFilterData.maskbit + "\n")); - } - - csReaderConnector.settingData.write2FileStream(stream, "End of data\n"); //.getBytes()); if (DEBUG) appendToLog("outData = " + outData); - stream.close(); - } catch (Exception ex){ - // - } - csReaderConnector.settingData.saveSetting2File0(); - } -*/ public int getBeepCount() { return csReaderConnector.settingData.beepCountSetting; } @@ -1630,19 +1446,16 @@ public boolean setBeepCount(int beepCount) { return true; } - public boolean getInventoryBeep() { - if (true) return csReaderConnector.settingData.inventoryBeep; return csReaderConnector.settingData.inventoryBeep; } public boolean setInventoryBeep(boolean inventoryBeep) { - if (true) return csReaderConnector.settingData.inventoryBeep = inventoryBeep; csReaderConnector.settingData.inventoryBeep = inventoryBeep; return true; } public boolean getSaveFileEnable() { - return csReaderConnector.settingData.saveFileEnable; + return csReaderConnector.settingData.saveFileEnable; } public boolean setSaveFileEnable(boolean saveFileEnable) { appendToLog("this.saveFileEnable = " + csReaderConnector.settingData.saveFileEnable + ", saveFileEnable = " + saveFileEnable); @@ -1651,21 +1464,21 @@ public boolean setSaveFileEnable(boolean saveFileEnable) { return true; } public boolean getSaveCloudEnable() { - return csReaderConnector.settingData.saveCloudEnable; + return csReaderConnector.settingData.saveCloudEnable; } public boolean setSaveCloudEnable(boolean saveCloudEnable) { csReaderConnector.settingData.saveCloudEnable = saveCloudEnable; return true; } public boolean getSaveNewCloudEnable() { - return csReaderConnector.settingData.saveNewCloudEnable; + return csReaderConnector.settingData.saveNewCloudEnable; } public boolean setSaveNewCloudEnable(boolean saveNewCloudEnable) { csReaderConnector.settingData.saveNewCloudEnable = saveNewCloudEnable; return true; } public boolean getSaveAllCloudEnable() { - return csReaderConnector.settingData.saveAllCloudEnable; + return csReaderConnector.settingData.saveAllCloudEnable; } public boolean setSaveAllCloudEnable(boolean saveAllCloudEnable) { csReaderConnector.settingData.saveAllCloudEnable = saveAllCloudEnable; @@ -1687,7 +1500,6 @@ public boolean getForegroundServiceEnable() { return (string.trim().length() == 0 ? false : true); } public boolean setForegroundServiceEnable(boolean bForegroundService) { - appendToLog("foregroundReader: set 4"); if (bForegroundService) csReaderConnector.settingData.strForegroundReader = csReaderConnector.bluetoothGatt.getmBluetoothDevice().getAddress(); else csReaderConnector.settingData.strForegroundReader = ""; return true; @@ -1700,7 +1512,7 @@ public boolean setServerLocation(String serverLocation) { return true; } public int getServerTimeout() { - return csReaderConnector.settingData.serverTimeout; + return csReaderConnector.settingData.serverTimeout; } public boolean setServerTimeout(int serverTimeout) { csReaderConnector.settingData.serverTimeout = serverTimeout; @@ -1759,7 +1571,7 @@ public boolean setServerImpinjPassword(String serverImpinjPassword) { return true; } public int getBatteryDisplaySetting() { - return csReaderConnector.settingData.batteryDisplaySelect; + return csReaderConnector.settingData.batteryDisplaySelect; } public boolean setBatteryDisplaySetting(int batteryDisplaySelect) { if (batteryDisplaySelect < 0 || batteryDisplaySelect > 1) return false; @@ -1768,7 +1580,7 @@ public boolean setBatteryDisplaySetting(int batteryDisplaySelect) { } public double dBuV_dBm_constant = RfidReader.dBuV_dBm_constant; //106.98; public int getRssiDisplaySetting() { - return csReaderConnector.settingData.rssiDisplaySelect; + return csReaderConnector.settingData.rssiDisplaySelect; } public boolean setRssiDisplaySetting(int rssiDisplaySelect) { if (rssiDisplaySelect < 0 || rssiDisplaySelect > 1) return false; @@ -1776,16 +1588,15 @@ public boolean setRssiDisplaySetting(int rssiDisplaySelect) { return true; } public int getVibrateModeSetting() { - return csReaderConnector.settingData.vibrateModeSelect; + return csReaderConnector.settingData.vibrateModeSelect; } public boolean setVibrateModeSetting(int vibrateModeSelect) { if (vibrateModeSelect < 0 || vibrateModeSelect > 1) return false; csReaderConnector.settingData.vibrateModeSelect = vibrateModeSelect; return true; } - public int getSavingFormatSetting() { - return csReaderConnector.settingData.savingFormatSelect; + return csReaderConnector.settingData.savingFormatSelect; } public boolean setSavingFormatSetting(int savingFormatSelect) { if (savingFormatSelect < 0 || savingFormatSelect > 1) return false; @@ -1823,7 +1634,6 @@ public int getWedgeDelimiter() { public int getWedgeOutput() { return csReaderConnector.settingData.wedgeOutput; } - public void setWedgeDeviceName(String wedgeDeviceName) { csReaderConnector.settingData.wedgeDeviceName = wedgeDeviceName; } @@ -2018,19 +1828,19 @@ public boolean batteryLevelRequest() { appendToLog("Skip batteryLevelREquest as inventoring !!!"); return true; } + if (mrfidToWriteSize() != 0) return false; return notificationConnector.batteryLevelRequest(); } public boolean setAutoBarStartSTop(boolean enable) { - return notificationConnector.setAutoBarStartSTop(enable); + return notificationConnector.setAutoBarStartSTop(enable); } public boolean getTriggerReporting() { - return csReaderConnector.settingData.triggerReporting; + return csReaderConnector.settingData.triggerReporting; } public boolean setTriggerReporting(boolean triggerReporting) { - return notificationConnector.setTriggerReporting(triggerReporting); + return notificationConnector.setTriggerReporting(triggerReporting); } public final int iNO_SUCH_SETTING = 10000; - public short getTriggerReportingCount() { boolean bValue = false; if (getcsModel() == 108) bValue = checkHostProcessorVersion(hostProcessorICGetFirmwareVersion(), 1, 0, 16); @@ -2083,17 +1893,17 @@ public String isBatteryLow() { return null; } public int getBatteryCount() { - return csReaderConnector.mCs108ConnectorData.getVoltageCnt(); + return csReaderConnector.mCs108ConnectorData.getVoltageCnt(); } public boolean getTriggerButtonStatus() { - return notificationConnector.getTriggerStatus(); + return notificationConnector.getTriggerStatus(); } public int getTriggerCount() { - return csReaderConnector.mCs108ConnectorData.getTriggerCount(); + return csReaderConnector.mCs108ConnectorData.getTriggerCount(); } //public interface NotificationListener { void onChange(); } public void setNotificationListener(NotificationConnector.NotificationListener listener) { - notificationConnector.setNotificationListener0(listener); + notificationConnector.setNotificationListener0(listener); } public byte[] onNotificationEvent() { byte[] notificationData = null; @@ -2195,217 +2005,9 @@ public void run() { } } }; -/* - boolean loadSetting1File() { - File path = context.getFilesDir(); - String fileName = bluetoothGatt.getmBluetoothDevice().getAddress(); - - fileName = "csReaderA_" + fileName.replaceAll(":", ""); - csReaderConnector.settingData.file = new File(path, fileName); - boolean bNeedDefault = true, DEBUG = false; - if (DEBUG_FILE) - utility.appendToLogView("FileName = " + fileName + ".exits = " + csReaderConnector.settingData.file.exists() + ", with beepEnable = " + getInventoryBeep()); - if (csReaderConnector.settingData.file.exists()) { - int length = (int) csReaderConnector.settingData.file.length(); - byte[] bytes = new byte[length]; - try { - InputStream instream = new FileInputStream(csReaderConnector.settingData.file); - if (instream != null) { - InputStreamReader inputStreamReader = new InputStreamReader(instream); - BufferedReader bufferedReader = new BufferedReader(inputStreamReader); - String line; - int queryTarget = -1; - int querySession = -1; - int querySelect = -1; - int startQValue = -1; - int maxQValue = -1; - int minQValue = -1; - int retryCount = -1; - int fixedQValue = -1; - int fixedRetryCount = -1; - int population = -1; - boolean invAlgo = true; - int retry = -1; - csReaderConnector.settingData.preFilterData = new SettingData.PreFilterData(); - while ((line = bufferedReader.readLine()) != null) { - if (DEBUG_FILE || true) appendToLog("Data read = " + line); - String[] dataArray = line.split(","); - if (dataArray.length == 2) { - if (dataArray[0].matches("appVersion")) { - if (dataArray[1].matches(getlibraryVersion())) bNeedDefault = false; - } else if (bNeedDefault == true) { - } else if (dataArray[0].matches("countryInList")) { - getRegionList(); - int countryInListNew = Integer.valueOf(dataArray[1]); - if (csReaderConnector.rfidReader.countryInList != countryInListNew && countryInListNew >= 0) - setCountryInList(countryInListNew); - csReaderConnector.rfidReader.channelOrderType = -1; - } else if (dataArray[0].matches("channel")) { - int channelNew = Integer.valueOf(dataArray[1]); - if (getChannelHoppingStatus() == false && channelNew >= 0) - setChannel(channelNew); - } else if (dataArray[0].matches("antennaPower")) { - long lValue = Long.valueOf(dataArray[1]); - if (lValue >= 0) setPowerLevel(lValue); - } else if (dataArray[0].matches("population")) { - population = Integer.valueOf(dataArray[1]); - } else if (dataArray[0].matches("querySession")) { - int iValue = Integer.valueOf(dataArray[1]); - if (iValue >= 0) querySession = iValue; - } else if (dataArray[0].matches("queryTarget")) { - queryTarget = Integer.valueOf(dataArray[1]); - } else if (dataArray[0].matches("tagFocus")) { - int iValue = Integer.valueOf(dataArray[1]); - if (iValue >= 0) csReaderConnector.rfidReader.tagFocus = iValue; - } else if (dataArray[0].matches("fastId")) { - int iValue = Integer.valueOf(dataArray[1]); - if (iValue >= 0) csReaderConnector.rfidReader.fastId = iValue; - } else if (dataArray[0].matches("invAlgo")) { - invAlgo = dataArray[1].matches("true") ? true : false; - } else if (dataArray[0].matches("retry")) { - retry = Integer.valueOf(dataArray[1]); - } else if (dataArray[0].matches("currentProfile")) { - int iValue = Integer.valueOf(dataArray[1]); - if (iValue >= 0) setCurrentLinkProfile(iValue); - } else if (dataArray[0].matches("rxGain")) { - setRxGain(Integer.valueOf(dataArray[1])); - } else if (dataArray[0].matches("deviceName")) { - bluetoothConnector.deviceName = dataArray[1].getBytes(); - } else if (dataArray[0].matches("batteryDisplay")) { - setBatteryDisplaySetting(Integer.valueOf(dataArray[1])); - } else if (dataArray[0].matches("rssiDisplay")) { - setRssiDisplaySetting(Integer.valueOf(dataArray[1])); - } else if (dataArray[0].matches("tagDelay")) { - setTagDelay(Byte.valueOf(dataArray[1])); - } else if (dataArray[0].matches("cycleDelay")) { - setCycleDelay(Long.valueOf(dataArray[1])); - } else if (dataArray[0].matches("intraPkDelay")) { - setIntraPkDelay(Byte.valueOf(dataArray[1])); - } else if (dataArray[0].matches("dupDelay")) { - setDupDelay(Byte.valueOf(dataArray[1])); - } else if (dataArray[0].matches(("triggerReporting"))) { - notificationConnector.setTriggerReporting(dataArray[1].matches("true") ? true : false); - } else if (dataArray[0].matches(("triggerReportingCount"))) { - notificationConnector.setTriggerReportingCount(Short.valueOf(dataArray[1])); - } else if (dataArray[0].matches(("inventoryBeep"))) { - setInventoryBeep(dataArray[1].matches("true") ? true : false); - } else if (dataArray[0].matches(("inventoryBeepCount"))) { - setBeepCount(Integer.valueOf(dataArray[1])); - } else if (dataArray[0].matches(("inventoryVibrate"))) { - setInventoryVibrate(dataArray[1].matches("true") ? true : false); - } else if (dataArray[0].matches(("inventoryVibrateTime"))) { - setVibrateTime(Integer.valueOf(dataArray[1])); - } else if (dataArray[0].matches(("inventoryVibrateMode"))) { - setVibrateModeSetting(Integer.valueOf(dataArray[1])); - } else if (dataArray[0].matches(("savingFormat"))) { - setSavingFormatSetting(Integer.valueOf(dataArray[1])); - } else if (dataArray[0].matches(("csvColumnSelect"))) { - setCsvColumnSelectSetting(Integer.valueOf(dataArray[1])); - } else if (dataArray[0].matches(("inventoryVibrateWindow"))) { - setVibrateWindow(Integer.valueOf(dataArray[1])); - - } else if (dataArray[0].matches(("saveFileEnable"))) { - csReaderConnector.settingData.saveFileEnable = dataArray[1].matches("true") ? true : false; - } else if (dataArray[0].matches(("saveCloudEnable"))) { - csReaderConnector.settingData.saveCloudEnable = dataArray[1].matches("true") ? true : false; - } else if (dataArray[0].matches(("saveNewCloudEnable"))) { - csReaderConnector.settingData.saveNewCloudEnable = dataArray[1].matches("true") ? true : false; - } else if (dataArray[0].matches(("saveAllCloudEnable"))) { - csReaderConnector.settingData.saveAllCloudEnable = dataArray[1].matches("true") ? true : false; - } else if (dataArray[0].matches(("serverLocation"))) { - csReaderConnector.settingData.serverLocation = dataArray[1]; - } else if (dataArray[0].matches("serverTimeout")) { - csReaderConnector.settingData.serverTimeout = Integer.valueOf(dataArray[1]); - } else if (dataArray[0].matches(("serverMqttLocation"))) { - csReaderConnector.settingData.serverMqttLocation = dataArray[1]; - } else if (dataArray[0].matches(("topicMqtt"))) { - csReaderConnector.settingData.topicMqtt = dataArray[1]; - } else if (dataArray[0].matches(("foregroundDupElim"))) { - csReaderConnector.settingData.iForegroundDupElim = Integer.valueOf(dataArray[1]); - } else if (dataArray[0].matches(("inventoryCloudSave"))) { - csReaderConnector.settingData.inventoryCloudSave = Integer.parseInt(dataArray[1]); - } else if (dataArray[0].matches(("serverImpinjLocation"))) { - csReaderConnector.settingData.serverImpinjLocation = dataArray[1]; - } else if (dataArray[0].matches(("serverImpinjName"))) { - csReaderConnector.settingData.serverImpinjName = dataArray[1]; - } else if (dataArray[0].matches(("serverImpinjPassword"))) { - csReaderConnector.settingData.serverImpinjPassword = dataArray[1]; - - } else if (dataArray[0].matches("barcode2TriggerMode")) { - if (dataArray[1].matches("true")) - csReaderConnector.settingData.barcode2TriggerMode = true; - else csReaderConnector.settingData.barcode2TriggerMode = false; -// } else if (dataArray[0].matches("wedgePrefix")) { -// setWedgePrefix(dataArray[1]); -// } else if (dataArray[0].matches("wedgeSuffix")) { -// setWedgeSuffix(dataArray[1]); -// } else if (dataArray[0].matches("wedgeDelimiter")) { -// setWedgeDelimiter(Integer.valueOf(dataArray[1])); - } else if (dataArray[0].matches("preFilterData.enable")) { - if (dataArray[1].matches("true")) - csReaderConnector.settingData.preFilterData.enable = true; - else csReaderConnector.settingData.preFilterData.enable = false; - } else if (dataArray[0].matches("preFilterData.target")) { - if (csReaderConnector.settingData.preFilterData == null) - csReaderConnector.settingData.preFilterData = new SettingData.PreFilterData(); - csReaderConnector.settingData.preFilterData.target = Integer.valueOf(dataArray[1]); - } else if (dataArray[0].matches("preFilterData.action")) { - if (csReaderConnector.settingData.preFilterData == null) - csReaderConnector.settingData.preFilterData = new SettingData.PreFilterData(); - csReaderConnector.settingData.preFilterData.action = Integer.valueOf(dataArray[1]); - } else if (dataArray[0].matches("preFilterData.bank")) { - if (csReaderConnector.settingData.preFilterData == null) - csReaderConnector.settingData.preFilterData = new SettingData.PreFilterData(); - csReaderConnector.settingData.preFilterData.bank = Integer.valueOf(dataArray[1]); - } else if (dataArray[0].matches("preFilterData.offset")) { - if (csReaderConnector.settingData.preFilterData == null) - csReaderConnector.settingData.preFilterData = new SettingData.PreFilterData(); - csReaderConnector.settingData.preFilterData.offset = Integer.valueOf(dataArray[1]); - } else if (dataArray[0].matches("preFilterData.mask")) { - if (csReaderConnector.settingData.preFilterData == null) - csReaderConnector.settingData.preFilterData = new SettingData.PreFilterData(); - csReaderConnector.settingData.preFilterData.mask = dataArray[1]; - } else if (dataArray[0].matches("preFilterData.maskbit")) { - if (csReaderConnector.settingData.preFilterData == null) - csReaderConnector.settingData.preFilterData = new SettingData.PreFilterData(); - if (dataArray[1].matches("true")) - csReaderConnector.settingData.preFilterData.maskbit = true; - else csReaderConnector.settingData.preFilterData.maskbit = false; - } else if (dataArray[0].matches(("userDebugEnable"))) { - csReaderConnector.settingData.userDebugEnable = dataArray[1].matches("true") ? true : false; - } - } - } - setInvAlgo(invAlgo); - setPopulation(population); - setRetryCount(retry); - setTagGroup(querySelect, querySession, queryTarget); - setTagFocus(csReaderConnector.rfidReader.tagFocus > 0 ? true : false); - if (csReaderConnector.settingData.preFilterData != null && csReaderConnector.settingData.preFilterData.enable) { - appendToLog("preFilterData is valid. Going to setSelectCriteria"); - setSelectCriteria(0, csReaderConnector.settingData.preFilterData.enable, csReaderConnector.settingData.preFilterData.target, csReaderConnector.settingData.preFilterData.action, csReaderConnector.settingData.preFilterData.bank, csReaderConnector.settingData.preFilterData.offset, csReaderConnector.settingData.preFilterData.mask, csReaderConnector.settingData.preFilterData.maskbit); - } else { - appendToLog("preFilterData is null or disabled. Going to setSelectCriteriaDisable"); - setSelectCriteriaDisable(0); - } - } - instream.close(); - if (DEBUG_FILE) appendToLog("Data is read from FILE."); - } catch (Exception ex) { - // - } - } - if (bNeedDefault) { - appendToLog("saveSetting2File default !!!"); - setReaderDefault(); - saveSetting2File(); - } - return bNeedDefault; - } -*/ public boolean loadSetting1File() { - return csReaderConnector.settingData.loadSetting1File(getlibraryVersion(), getChannelHoppingStatus(), getCurrentProfile()); + return csReaderConnector.settingData.loadSettingFile(getlibraryVersion(), getChannelHoppingStatus(), getCurrentProfile()); } public void saveSetting2File() { csReaderConnector.settingData.saveSetting2File(getlibraryVersion(), getChannelHoppingStatus(), getCurrentProfile()); @@ -2436,4 +2038,8 @@ public int getInvalidUpdata() { public int getValidata() { return csReaderConnector.validata; } + + public int setSelectData(RfidReader.TagType tagType, String mDid, boolean bNeedSelectedTagByTID, String stringProtectPassword, int selectFor, int selectHold) { + return csReaderConnector.rfidReader.setSelectData4Inventory(tagType, mDid, bNeedSelectedTagByTID, stringProtectPassword, selectFor, selectHold); + } } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsLibrary4A.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsLibrary4A.java index 9968089..7327c02 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsLibrary4A.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsLibrary4A.java @@ -8,7 +8,7 @@ public class CsLibrary4A { boolean DEBUG = false, DEBUG2 = false; - String stringVersion = "14.8"; + String stringVersion = "14.9"; Utility utility; Cs710Library4A cs710Library4A; Cs108Library4A cs108Library4A; @@ -937,9 +937,9 @@ public boolean setSelectedTag(String strTagId, int selectBank, long pwrlevel) { else Log.i("Hello2", "setSelectedTag 1" + stringNOTCONNECT); return false; } - public boolean setSelectedTag(String selectMask, int selectBank, int selectOffset, long pwrlevel, int qValue, int matchRep) { + public boolean setSelectedTag(boolean selectOne, String selectMask, int selectBank, int selectOffset, long pwrlevel, int qValue, int matchRep) { appendToLog("csLibraryA: setSelectCriteria strTagId = " + selectMask + ", selectBank = " + selectBank + ", selectOffset = " + selectOffset + ", pwrlevel = " + pwrlevel + ", qValue = " + qValue + ", matchRep = " + matchRep); - if (isCs108Connected()) return cs108Library4A.setSelectedTag(selectMask, selectBank, selectOffset, pwrlevel, qValue, matchRep); + if (isCs108Connected()) return cs108Library4A.setSelectedTag(selectOne, selectMask, selectBank, selectOffset, pwrlevel, qValue, matchRep); else if (isCs710Connected()) return cs710Library4A.setSelectedTag(selectMask, selectBank, selectOffset, pwrlevel, qValue, matchRep); else Log.i("Hello2", "setSelectedTag 2" + stringNOTCONNECT); return false; @@ -2175,9 +2175,18 @@ public int getValidata() { else Log.i("Hello2", "getValidata" + stringNOTCONNECT); return -1; } + //============ not public ============ int bConnectStatus = 0; int iServiceUuidConnectedBefore = -1; private boolean isCs108Connected() { return (bConnectStatus == 1); } private boolean isCs710Connected() { return (bConnectStatus == 7); } + + public int setSelectData(RfidReader.TagType tagType, String mDid, boolean bNeedSelectedTagByTID, String stringProtectPassword, int selectFor, int selectHold) { + if (DEBUG2) Log.i("Hello2", "setSelectData"); + if (isCs108Connected()) return cs108Library4A.setSelectData(tagType, mDid, bNeedSelectedTagByTID, stringProtectPassword, selectFor, selectHold); + else if (isCs710Connected()) return cs710Library4A.setSelectData(tagType, mDid, bNeedSelectedTagByTID, stringProtectPassword, selectFor, selectHold); + else Log.i("Hello2", "setSelectData" + stringNOTCONNECT); + return -1; + } } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsReaderConnector.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsReaderConnector.java index 182eb50..28d3620 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsReaderConnector.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsReaderConnector.java @@ -12,7 +12,7 @@ public class CsReaderConnector { final boolean appendToLogViewDisable = false; final boolean DEBUG = false; final boolean DEBUGTHREAD = false; boolean DEBUG_CONNECT, DEBUG_SCAN; - boolean DEBUG_PKDATA, DEBUG_APDATA; + boolean DEBUG_APDATA; public boolean sameCheck = true; String byteArrayToString(byte[] packet) { return utility.byteArrayToString(packet); } @@ -36,7 +36,7 @@ public void disconnect() { public long getStreamInRate() { return bluetoothGatt.getStreamInRate(); } - int writeDataCount; int btSendTimeOut = 0; long btSendTime = 0; + int writeDataCount; int btSendTimeOut = 0; long btSendTime = 0; int BTSENDDELAY = 20; boolean writeData(byte[] buffer, int timeout) { if (rfidReader.isInventoring()) { utility.appendToLogView("BtData: isInventoring is true when writeData " + byteArrayToString(buffer)); @@ -45,7 +45,7 @@ boolean writeData(byte[] buffer, int timeout) { if (result == false) appendToLog("!!! failure to writeData with previous btSendTimeout = " + btSendTimeOut + ", btSendTime = " + btSendTime); if (true) { btSendTime = System.currentTimeMillis(); - btSendTimeOut = timeout + 60; + btSendTimeOut = timeout + BTSENDDELAY; if (bluetoothGatt.isCharacteristicListRead() == false) btSendTimeOut += 3000; } return result; @@ -94,7 +94,7 @@ public void clearInvalidata() { invalidUpdata = 0; validata = 0; } - boolean dataInBufferResetting; + //boolean dataInBufferResetting; void processBleStreamInData() { final boolean DEBUG = false; @@ -103,49 +103,54 @@ void processBleStreamInData() { boolean validHeader = false; if (cs108DataLeft == null) return; - if (dataInBufferResetting) { - if (DEBUG) appendToLog("RESET."); + /*if (false && dataInBufferResetting) { + if (utility.DEBUG_FMDATA) appendToLog("FmData: RESET."); dataInBufferResetting = false; - /*cs108DataLeft = new byte[CS108DATALEFT_SIZE];*/ cs108DataLeftOffset = 0; connectorDataList.clear(); - } - if (DEBUG) appendToLog("START, cs108DataLeftOffset=" + cs108DataLeftOffset + ", streamInBufferSize=" + bluetoothGatt.getStreamInBufferSize()); - boolean bFirst = true; long lTime = System.currentTimeMillis(); - while (true) { + }*/ + int iStreamInBufferSize = bluetoothGatt.getStreamInBufferSize(); + //boolean bFirst = true; + long lTime = System.currentTimeMillis(); + boolean bLooping = false; + while (bluetoothGatt.getStreamInBufferSize() != 0) { + if (utility.DEBUG_FMDATA && bLooping == false) appendToLog("FmData: Enter loop with cs108DataLeftOffset=" + cs108DataLeftOffset + ", streamInBufferSize=" + iStreamInBufferSize); + bLooping = true; + if (System.currentTimeMillis() - lTime > (bluetoothGatt.getIntervalProcessBleStreamInData()/2)) { utility.writeDebug2File("Up2 " + bluetoothGatt.getIntervalProcessBleStreamInData()/2 + "ms Timeout"); - if (DEBUG) utility.appendToLogView("processCs108DataIn_TIMEOUT"); + utility.appendToLogView("FmData: Timeout !!!"); break; } long streamInOverflowTime = bluetoothGatt.getStreamInOverflowTime(); int streamInMissing = bluetoothGatt.getStreamInBytesMissing(); - if (streamInMissing != 0) utility.appendToLogView("processCs108DataIn(" + bluetoothGatt.getStreamInTotalCounter() + ", " + bluetoothGatt.getStreamInAddCounter() + "): len=0, getStreamInOverflowTime()=" + streamInOverflowTime + ", MissBytes=" + streamInMissing + ", Offset=" + cs108DataLeftOffset); + if (streamInMissing != 0) utility.appendToLogView("FmData: processCs108DataIn(" + bluetoothGatt.getStreamInTotalCounter() + ", " + bluetoothGatt.getStreamInAddCounter() + "): len=0, getStreamInOverflowTime()=" + streamInOverflowTime + ", MissBytes=" + streamInMissing + ", Offset=" + cs108DataLeftOffset); int len = readData(cs108DataLeft, cs108DataLeftOffset, cs108DataLeft.length); - if (len != 0) { + if (utility.DEBUG_FMDATA && len != 0) { byte[] debugData = new byte[len]; System.arraycopy(cs108DataLeft, cs108DataLeftOffset, debugData, 0, len); - if (DEBUG) appendToLog("DataIn = " + byteArrayToString(debugData)); + appendToLog("FmData: dataIn " + len + " = " + byteArrayToString(debugData)); } - if (len != 0 && bFirst) { bFirst = false; } //writeDebug2File("B" + String.valueOf(getIntervalProcessBleStreamInData()) + ", " + System.currentTimeMillis()); } + //if (len != 0 && bFirst) { bFirst = false; } //writeDebug2File("B" + String.valueOf(getIntervalProcessBleStreamInData()) + ", " + System.currentTimeMillis()); } cs108DataLeftOffset += len; if (len == 0) { + appendToLog("FmData: len is zero !!!"); if (zeroLenDisplayed == false) { zeroLenDisplayed = true; if (bluetoothGatt.getStreamInTotalCounter() != bluetoothGatt.getStreamInAddCounter() || bluetoothGatt.getStreamInAddTime() != 0 || cs108DataLeftOffset != 0) { - if (DEBUG) appendToLog("processCs108DataIn(" + bluetoothGatt.getStreamInTotalCounter() + "," + bluetoothGatt.getStreamInAddCounter() + "): len=0, getStreamInAddTime()=" + bluetoothGatt.getStreamInAddTime() + ", Offset=" + cs108DataLeftOffset); + if (DEBUG) appendToLog("FmData: processCs108DataIn(" + bluetoothGatt.getStreamInTotalCounter() + "," + bluetoothGatt.getStreamInAddCounter() + "): len=0, getStreamInAddTime()=" + bluetoothGatt.getStreamInAddTime() + ", Offset=" + cs108DataLeftOffset); } } if (cs108DataLeftOffset == cs108DataLeft.length) { - if (DEBUG) appendToLog("cs108DataLeftOffset=" + cs108DataLeftOffset + ", cs108DataLeft=" + byteArrayToString(cs108DataLeft)); + if (DEBUG) appendToLog("FmData: cs108DataLeftOffset=" + cs108DataLeftOffset + ", cs108DataLeft=" + byteArrayToString(cs108DataLeft)); } break; } else { dataRead = true; zeroLenDisplayed = false; - if (DEBUG) appendToLog("cs108DataLeftOffset = " + cs108DataLeftOffset + ", cs108DataReadStart = " + cs108DataReadStart); + if (utility.DEBUG_FMDATA) appendToLog("FmData: cs108DataReadStart = " + cs108DataReadStart + ", cs108DataLeftOffset = " + cs108DataLeftOffset); while (cs108DataLeftOffset >= cs108DataReadStart + 8) { validHeader = false; byte[] dataIn = cs108DataLeft; @@ -173,52 +178,44 @@ void processBleStreamInData() { checksum2 = (checksum2 >> 8) ^ table_value; } } - if (DEBUG) appendToLog("checksum = " + String.format("%04X", checksum) + ", checksum2 = " + String.format("%04X", checksum2)); + if (false) appendToLog("FmData: checksum = " + String.format("%04X", checksum) + ", checksum2 = " + String.format("%04X", checksum2)); } if (bcheckChecksum && checksum != checksum2) { - if (iPayloadLength < 0) { - if (DEBUG) appendToLog("processCs108DataIn_ERROR, iPayloadLength=" + iPayloadLength + ", cs108DataLeftOffset=" + cs108DataLeftOffset + ", dataIn=" + byteArrayToString(dataIn)); - } - if (true) { + if (utility.DEBUG_FMDATA) { + if (iPayloadLength < 0) { + appendToLog("FmData: CheckSum ERROR, iPayloadLength=" + iPayloadLength + ", cs108DataLeftOffset=" + cs108DataLeftOffset + ", dataIn=" + byteArrayToString(dataIn)); + } byte[] invalidPart = new byte[8 + iPayloadLength]; System.arraycopy(dataIn, cs108DataReadStart, invalidPart, 0, invalidPart.length); - if (DEBUG) appendToLog("processCs108DataIn_ERROR, INCORRECT RevChecksum=" + Integer.toString(checksum, 16) + ", CalChecksum2=" + Integer.toString(checksum2, 16) + ",data=" + byteArrayToString(invalidPart)); + appendToLog("FmData: processCs108DataIn_ERROR, INCORRECT RevChecksum=" + Integer.toString(checksum, 16) + ", CalChecksum2=" + Integer.toString(checksum2, 16) + ",data=" + byteArrayToString(invalidPart)); } } else { validHeader = true; if (cs108DataReadStart > cs108DataReadStartOld) { - if (true) { + if (utility.DEBUG_FMDATA) { byte[] invalidPart = new byte[cs108DataReadStart - cs108DataReadStartOld]; System.arraycopy(dataIn, cs108DataReadStartOld, invalidPart, 0, invalidPart.length); - if (DEBUG) appendToLog("processCs108DataIn_ERROR, before valid data, invalid unused data: " + invalidPart.length + ", " + byteArrayToString(invalidPart)); + appendToLog("FmData: processCs108DataIn_ERROR, before valid data, invalid unused data: " + invalidPart.length + ", " + byteArrayToString(invalidPart)); } } else if (cs108DataReadStart < cs108DataReadStartOld) - if (DEBUG) appendToLog("processCs108DataIn_ERROR, invalid cs108DataReadStartdata=" + cs108DataReadStart + " < cs108DataReadStartOld=" + cs108DataReadStartOld); + if (utility.DEBUG_FMDATA) appendToLog("FmData: processCs108DataIn_ERROR, invalid cs108DataReadStartdata=" + cs108DataReadStart + " < cs108DataReadStartOld=" + cs108DataReadStartOld); cs108DataReadStartOld = cs108DataReadStart; ConnectorData connectorData = new ConnectorData(); byte[] dataValues = new byte[iPayloadLength]; System.arraycopy(dataIn, cs108DataReadStart + 8, dataValues, 0, dataValues.length); connectorData.dataValues = dataValues; - connectorData.milliseconds = System.currentTimeMillis(); //getStreamInDataMilliSecond(); // - if (DEBUG) appendToLog("current:" + System.currentTimeMillis() + ", streamInData:" + bluetoothGatt.getStreamInDataMilliSecond()); - if (false) { + connectorData.milliseconds = System.currentTimeMillis(); + if (utility.DEBUG_FMDATA) { byte[] headerbytes = new byte[8]; System.arraycopy(dataIn, cs108DataReadStart, headerbytes, 0, headerbytes.length); - if (DEBUG) appendToLog("processCs108DataIn: Got package=" + byteArrayToString(headerbytes) + " " + byteArrayToString(dataValues)); + appendToLog("FmData: Got formatted dataIn = " + byteArrayToString(headerbytes) + " " + byteArrayToString(dataValues)); } switch (dataIn[cs108DataReadStart + 3]) { case (byte) 0xC2: case (byte) 0x6A: if (dataIn[cs108DataReadStart + 3] == (byte) 0xC2) connectorData.connectorTypes = ConnectorData.ConnectorTypes.RFID; - else { - if (true) { - appendToLog("BarStreamIn: " + byteArrayToString(connectorData.dataValues)); - utility.appendToLogView("BIn: " + byteArrayToString(connectorData.dataValues)); - } - connectorData.connectorTypes = ConnectorData.ConnectorTypes.BARCODE; - } - appendToLog("dataIn = " + byteArrayToString(dataIn) + ", with start = " + cs108DataReadStart); + else connectorData.connectorTypes = ConnectorData.ConnectorTypes.BARCODE; if (dataIn[cs108DataReadStart + 8] == (byte) 0x81 || (bis108 == false && dataIn[cs108DataReadStart + 8] == (byte) 0x91)) { int iSequenceNumber = (int) (dataIn[cs108DataReadStart + 4] & 0xFF); int itemp = iSequenceNumber; @@ -226,9 +223,9 @@ void processBleStreamInData() { itemp += 256; } itemp -= (this.iSequenceNumber + 1); - appendToLog("iSequenceNumber = " + iSequenceNumber + ", old iSequenceNumber = " + this.iSequenceNumber + ", difference = " + itemp); + if (DEBUG) appendToLog("iSequenceNumber = " + iSequenceNumber + ", old iSequenceNumber = " + this.iSequenceNumber + ", difference = " + itemp); if (itemp != 0) { - appendToLog("Non-zero iSequenceNumber difference = " + itemp); + if (DEBUG) appendToLog("Non-zero iSequenceNumber difference = " + itemp); connectorData.invalidSequence = true; if (bFirstSequence == false) { invalidata += itemp; @@ -238,18 +235,17 @@ void processBleStreamInData() { if (iMissedNumber < 0) iMissedNumber += 256; stringSequenceList += (i != 0 ? ", " : "") + String.format("%X", iMissedNumber); } - utility.appendToLogView(String.format("ERROR !!!: invalidata = %d, %X - %X, miss %d: ", invalidata, iSequenceNumber, this.iSequenceNumber, itemp) + stringSequenceList); + if (DEBUG) utility.appendToLogView(String.format("ERROR !!!: invalidata = %d, %X - %X, miss %d: ", invalidata, iSequenceNumber, this.iSequenceNumber, itemp) + stringSequenceList); } } bFirstSequence = false; this.iSequenceNumber = iSequenceNumber; } - if (false) utility.appendToLogView("Rin: " + (connectorData.invalidSequence ? "invalid sequence" : "ok") + "," + byteArrayToString(connectorData.dataValues)); + if (DEBUG) utility.appendToLogView("Rin: " + (connectorData.invalidSequence ? "invalid sequence" : "ok") + "," + byteArrayToString(connectorData.dataValues)); validata++; break; case (byte) 0xD9: - if (DEBUG) - appendToLog("BARTRIGGER NotificationData = " + byteArrayToString(connectorData.dataValues)); + if (DEBUG) appendToLog("BARTRIGGER NotificationData = " + byteArrayToString(connectorData.dataValues)); connectorData.connectorTypes = ConnectorData.ConnectorTypes.NOTIFICATION; break; case (byte) 0xE8: @@ -260,12 +256,13 @@ void processBleStreamInData() { break; } this.connectorDataList.add(connectorData); + if (utility.DEBUG_FMDATA) appendToLog("FmData: Got PackageIn " + connectorData.connectorTypes.toString() + ", " + byteArrayToString(connectorData.dataValues)); utility.writeDebug2File("Up2 " + connectorData.connectorTypes.toString() + ", " + byteArrayToString(connectorData.dataValues)); cs108DataReadStart += ((8 + iPayloadLength)); byte[] cs108DataLeftNew = new byte[CS108DATALEFT_SIZE]; if (cs108DataLeftOffset - cs108DataReadStart < 0) { - appendToLog("cs108DataLeftOffset = " + cs108DataLeftOffset + ", cs108DataReadStart = " + cs108DataReadStart + ", buffer = " + byteArrayToString(cs108DataLeft)); + if (utility.DEBUG_FMDATA) appendToLog("FmData: cs108DataLeftOffset = " + cs108DataLeftOffset + ", cs108DataReadStart = " + cs108DataReadStart + ", buffer = " + byteArrayToString(cs108DataLeft)); break; } System.arraycopy(cs108DataLeft, cs108DataReadStart, cs108DataLeftNew, 0, cs108DataLeftOffset - cs108DataReadStart); @@ -273,12 +270,13 @@ void processBleStreamInData() { cs108DataLeftOffset -= cs108DataReadStart; cs108DataReadStart = 0; cs108DataReadStart = -1; - if (mCs108DataReadRequest == false) { + if (true || mCs108DataReadRequest == false) { mCs108DataReadRequest = true; - if (DEBUGTHREAD) appendToLog("ready2Write: start immediate mReadWriteRunnable"); + if (DEBUGTHREAD && DEBUG) appendToLog("ready2Write: start immediate mReadWriteRunnable"); //appendToLog("post mReadWriteRunnable within processBleStreamInData"); mHandler.removeCallbacks(mReadWriteRunnable); mHandler.post(mReadWriteRunnable); - } + if (utility.DEBUG_BTDATA && DEBUG) appendToLog("BtData: CsReaderConnector.processBleStreamOut starts mReadWriteRunnable as mCs108DataReadRequest"); + } //appendToLog("BtData: processBleStreamOut cannot start mReadWriteRunnable as mCs108DataReadRequest is true"); } } if (validHeader && cs108DataReadStart < 0) { @@ -289,12 +287,12 @@ void processBleStreamInData() { } } if (cs108DataReadStart != 0 && cs108DataLeftOffset >= 8) { - if (true) { + if (utility.DEBUG_FMDATA) { byte[] invalidPart = new byte[cs108DataReadStart]; System.arraycopy(cs108DataLeft, 0, invalidPart, 0, invalidPart.length); byte[] validPart = new byte[cs108DataLeftOffset - cs108DataReadStart]; System.arraycopy(cs108DataLeft, cs108DataReadStart, validPart, 0, validPart.length); - if (DEBUG) appendToLog("processCs108DataIn_ERROR, ENDLOOP invalid unused data: " + invalidPart.length + ", " + byteArrayToString(invalidPart) + ", with valid data length=" + validPart.length + ", " + byteArrayToString(validPart)); + appendToLog("FmData: processCs108DataIn_ERROR, ENDLOOP invalid unused data: " + invalidPart.length + ", " + byteArrayToString(invalidPart) + ", with valid data length=" + validPart.length + ", " + byteArrayToString(validPart)); utility.writeDebug2File("Up2 Invalid " + invalidPart.length + ", " + byteArrayToString(invalidPart)); } @@ -305,7 +303,7 @@ void processBleStreamInData() { } } } - if (DEBUG) appendToLog("END, cs108DataLeftOffset=" + cs108DataLeftOffset + ", streamInBufferSize=" + bluetoothGatt.getStreamInBufferSize()); + if (utility.DEBUG_FMDATA && bLooping) appendToLog("FmData: Exit loop with cs108DataLeftOffset=" + cs108DataLeftOffset + ", streamInBufferSize=" + bluetoothGatt.getStreamInBufferSize()); } private int readData(byte[] buffer, int byteOffset, int byteCount) { return bluetoothGatt.readBleSteamIn(buffer, byteOffset, byteCount); } @@ -341,7 +339,7 @@ public void cs108ConnectorDataInit() { invalidata = 0; validata = 0; - dataInBufferResetting = false; + //dataInBufferResetting = false; writeDataCount = 0; @@ -381,7 +379,7 @@ public CsReaderConnector(Context context, TextView mLogView, Utility utility, bo this.utility = utility; this.bis108 = bis108; - DEBUG_PKDATA = utility.DEBUG_PKDATA; DEBUG_APDATA = utility.DEBUG_APDATA; + DEBUG_APDATA = utility.DEBUG_APDATA; bluetoothGatt = new BluetoothGatt(context, utility, (bis108 ? "9800" : "9802")); bluetoothGatt.bluetoothGattConnectorCallback = new BluetoothGatt.BluetoothGattConnectorCallback(){ @Override @@ -409,9 +407,10 @@ public void callbackMethod() { @Override public void run() { - if (DEBUGTHREAD) appendToLog("mReadWriteRunnable starts"); + if (DEBUGTHREAD || utility.DEBUG_BTDATA) appendToLog("BtData: CsReaderConnector.mReadWriteRunnable starts"); if (rfidConnector == null) { mHandler.postDelayed(mReadWriteRunnable, 500); + if (utility.DEBUG_BTDATA) appendToLog("BtData: CsReaderConnector.mReadWriteRunnable restart after 500ms"); return; } if (timer2Write != 0 || bluetoothGatt.getStreamInBufferSize() != 0 || rfidConnector.mRfidToRead.size() != 0) { @@ -438,16 +437,21 @@ public void run() { if (DEBUGTHREAD) appendToLog("start new mReadWriteRunnable after " + intervalReadWrite + " ms"); //appendToLog("postDelayed mReadWriteRunnable within mReadWriteRunnable"); mHandler.removeCallbacks(mReadWriteRunnable); mHandler.postDelayed(mReadWriteRunnable, intervalReadWrite); + if (utility.DEBUG_BTDATA) appendToLog("BtData: CsReaderConnector.mReadWriteRunnable restart after 250ms"); if (rfidReader == null) return; boolean bFirst = true; + boolean bLooping = false; mCs108DataReadRequest = false; while (connectorDataList.size() != 0) { + if (utility.DEBUG_PKDATA && bLooping == false) appendToLog("PkData: Entering loop with connectorDataList.size = " + connectorDataList.size()); + bLooping = true; + if (isBleConnected() == false) { connectorDataList.clear(); } else if (System.currentTimeMillis() - lTime > (intervalRx000UplinkHandler / 2)) { utility.writeDebug2File("Up3 " + "Timeout"); - utility.appendToLogView("mReadWriteRunnable: TIMEOUT !!! mCs108DataRead.size() = " + connectorDataList.size()); + utility.appendToLogView("PkData: mReadWriteRunnable: TIMEOUT !!! mCs108DataRead.size() = " + connectorDataList.size()); break; } else { if (bFirst) { bFirst = false; } //writeDebug2File("C" + String.valueOf(intervalReadWrite) + ", " + System.currentTimeMillis()); } @@ -455,7 +459,7 @@ public void run() { ConnectorData connectorData = connectorDataList.get(0); connectorDataList.remove(0); boolean bValid = true; - if (DEBUG) appendToLog("mReadWriteRunnable(): mCs108DataRead.dataValues = " + byteArrayToString(connectorData.dataValues)); + if (utility.DEBUG_PKDATA) appendToLog("PkData: connectorData.type = " + connectorData.connectorTypes.toString() + ", connectorData.dataValues = " + byteArrayToString(connectorData.dataValues)); if (rfidConnector.isMatchRfidToWrite(connectorData)) { if (false) { for (int i = 0; i < rfidReader.mRx000ToRead.size(); i++) { @@ -469,11 +473,11 @@ public void run() { } else if (barcodeConnector.isMatchBarcodeToWrite(connectorData)) { if (writeDataCount > 0) writeDataCount--; if (bis108) ready2Write = true; //btSendTime = 0; } else if (notificationConnector.isMatchNotificationToWrite(connectorData)) { - if (writeDataCount > 0) writeDataCount--; ready2Write = true; appendToLog("ready2Write is set true after true isMatchNotificationToWrite "); btSendTime = 0; if (DEBUG_PKDATA) appendToLog("PkData: mReadWriteRunnable: matched notification. btSendTime is set to 0 to allow new sending."); + if (writeDataCount > 0) writeDataCount--; ready2Write = true; if (false) appendToLog("ready2Write is set true after true isMatchNotificationToWrite "); btSendTime = 0; if (utility.DEBUG_PKDATA) appendToLog("PkData: mReadWriteRunnable: matched notification. btSendTime is set to 0 to allow new sending."); } else if (controllerConnector.isMatchControllerToWrite(connectorData)) { - if (writeDataCount > 0) writeDataCount--; ready2Write = true; appendToLog("ready2Write is set true after true isMatchSiliconLabIcToWrite "); btSendTime = 0; if (DEBUG_PKDATA) appendToLog("PkData: mReadWriteRunnable: matched AtmelIc. btSendTime is set to 0 to allow new sending."); + if (writeDataCount > 0) writeDataCount--; ready2Write = true; if (false) appendToLog("ready2Write is set true after true isMatchSiliconLabIcToWrite "); btSendTime = 0; if (utility.DEBUG_PKDATA) appendToLog("PkData: mReadWriteRunnable: matched AtmelIc. btSendTime is set to 0 to allow new sending."); } else if (bluetoothConnector.isMatchBluetoothIcToWrite(connectorData)) { - if (writeDataCount > 0) writeDataCount--; ready2Write = true; appendToLog("ready2Write is set true after true isMatchBluetoothIcToWrite "); btSendTime = 0; if (DEBUG_PKDATA) appendToLog("PKData: mReadWriteRunnable: matched bluetoothIc. btSendTime is set to 0 to allow new sending."); + if (writeDataCount > 0) writeDataCount--; ready2Write = true; appendToLog("ready2Write is set true after true isMatchBluetoothIcToWrite "); btSendTime = 0; if (utility.DEBUG_PKDATA) appendToLog("PKData: mReadWriteRunnable: matched bluetoothIc. btSendTime is set to 0 to allow new sending."); } else if (rfidConnector.isRfidToRead(connectorData)) { rfidConnector.rfidValid = true; } else if (barcodeConnector.isBarcodeToRead(connectorData)) { } else if (notificationConnector.isNotificationToRead(connectorData)) { @@ -495,21 +499,23 @@ public void run() { if (barcodeConnector.mDataToWriteRemoved) { barcodeConnector.mDataToWriteRemoved = false; ready2Write = true; btSendTime = 0; appendToLog("ready2Write is set true after true mBarcodeDevice.mDataToWriteRemoved "); - if (DEBUG_PKDATA) appendToLog("PkData: mReadWriteRunnable: processed barcode. btSendTime is set to 0 to allow new sending."); + if (utility.DEBUG_PKDATA) appendToLog("PkData: mReadWriteRunnable: processed barcode. btSendTime is set to 0 to allow new sending."); } } catch (Exception ex) { } } } + if (utility.DEBUG_PKDATA && bLooping) appendToLog("PkData: Exiting loop with connectorDataList.size = " + connectorDataList.size()); lTime = System.currentTimeMillis(); if (rfidConnector.mRfidToWriteRemoved) { - rfidConnector.mRfidToWriteRemoved = false; ready2Write = true; btSendTime = 0; appendToLog("ready2Write is set true after true mRfidDevice.mRfidToWriteRemoved "); - btSendTime = (lTime - btSendTimeOut + 60); - if (DEBUGTHREAD) appendToLog("ready2Write: start new mReadWriteRunnable after " + 60 + " ms"); + rfidConnector.mRfidToWriteRemoved = false; ready2Write = true; btSendTime = 0; if (false) appendToLog("ready2Write is set true after true mRfidDevice.mRfidToWriteRemoved "); + btSendTime = (lTime - btSendTimeOut + BTSENDDELAY); + if (DEBUGTHREAD) appendToLog("ready2Write: start new mReadWriteRunnable after " + BTSENDDELAY + " ms"); //appendToLog("postDelayed mReadWriteRunnable within mReadWriteRunnable 2"); - mHandler.removeCallbacks(mReadWriteRunnable); mHandler.postDelayed(mReadWriteRunnable, 60 + 2); - if (DEBUG_PKDATA) appendToLog("PkData: mReadWriteRunnable: processed Rfidcode. btSendTime is set to 0 to allow new sending with systime = " + lTime); + mHandler.removeCallbacks(mReadWriteRunnable); mHandler.postDelayed(mReadWriteRunnable, BTSENDDELAY + 2); + if (utility.DEBUG_BTDATA) appendToLog("BtData: CsReaderConnector.mReadWriteRunnable restart after " + (BTSENDDELAY + 2) +"ms") ; + if (utility.DEBUG_PKDATA) appendToLog("PkData: mReadWriteRunnable: processed Rfidcode. btSendTime is set to 0 to allow new sending with systime = " + lTime); } if (bis108) { int timeout2Ready = 2000; @@ -521,6 +527,7 @@ public void run() { ready2Write = true; } } + if (DEBUG) appendToLog("BtData: ready2Write = " + ready2Write); if (ready2Write) { timeReady = System.currentTimeMillis(); timer2Write = 0; @@ -557,24 +564,23 @@ public void run() { } if (barcodeConnector.barcodeToWrite.size() != 0 && true) appendToLog("AAA 1 barcodeToWrite.size = " + barcodeConnector.barcodeToWrite.size() + ", bisRfidCommandStop = " + bisRfidCommandStop + ", barcodePowerOnTimeOut = " + barcodeConnector.barcodePowerOnTimeOut); + if (DEBUG) appendToLog("BtData: bisRfidCommandStop is " + bisRfidCommandStop); if (bisRfidCommandStop) { - appendToLog("AAA 2"); if (rfidConnector.rfidPowerOnTimeOut != 0) { if (DEBUG) appendToLog("rfidPowerOnTimeOut = " + rfidConnector.rfidPowerOnTimeOut + ", mRfidToWrite.size() = " + rfidConnector.mRfidToWrite.size()); } else if (rfidConnector.rfidFailure == false && rfidConnector.mRfidToWrite.size() != 0) { if (isBleConnected() == false) { rfidConnector.mRfidToWrite.clear(); } else { - if (DEBUG) - appendToLog("BtDataOut: currentTime = " + System.currentTimeMillis() + ", btSendTime = " + btSendTime + ", difference = " + (System.currentTimeMillis() - btSendTime) + ", btSendTimeOut = " + btSendTimeOut); + if (utility.DEBUG_BTDATA) appendToLog("BtData: CsReaderConnector.mReadWriteRunnable 1: currentTime = " + System.currentTimeMillis() + ", btSendTime = " + btSendTime + ", difference = " + (System.currentTimeMillis() - btSendTime) + ", btSendTimeOut = " + btSendTimeOut); if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { boolean retValue = false; byte[] dataOut = rfidConnector.sendRfidToWrite(); if (dataOut != null) { retValue = writeData(dataOut, (rfidConnector.mRfidToWrite.get(0).waitUplinkResponse ? 500 : 0)); - appendToLog("done writeData with waitUplinkResponse = " + rfidConnector.mRfidToWrite.get(0).waitUplinkResponse); + if (false) appendToLog("BtData: done writeData with waitUplinkResponse = " + rfidConnector.mRfidToWrite.get(0).waitUplinkResponse); } - if (DEBUG) appendToLog("BtDataOut: done writeRfid with size = " + rfidConnector.mRfidToWrite.size() + ", PayloadEvents = " + rfidConnector.mRfidToWrite.get(0).rfidPayloadEvent.toString() + ", data=" + byteArrayToString(rfidConnector.mRfidToWrite.get(0).dataValues)); + appendToLog("BtData: done writeRfid with size = " + rfidConnector.mRfidToWrite.size() + ", PayloadEvents = " + rfidConnector.mRfidToWrite.get(0).rfidPayloadEvent.toString() + ", data=" + byteArrayToString(rfidConnector.mRfidToWrite.get(0).dataValues)); rfidConnector.sendRfidToWriteSent++; if (retValue) { rfidConnector.mRfidToWriteRemoved = false; @@ -588,7 +594,6 @@ public void run() { } } } else if (!bis108 && rfidReader.isInventoring()) { - appendToLog("AAA 3 BtDataOut: done sendRfidToWrite with isInventoring is true"); if (rfidConnector.rfidPowerOnTimeOut != 0) { if (DEBUG) appendToLog("rfidPowerOnTimeOut = " + rfidConnector.rfidPowerOnTimeOut + ", mRfidToWrite.size() = " + rfidConnector.mRfidToWrite.size()); } else if (rfidConnector.rfidFailure == false && rfidConnector.mRfidToWrite.size() != 0) { @@ -596,13 +601,13 @@ public void run() { rfidConnector.mRfidToWrite.clear(); } else { if (DEBUG) - appendToLog("BtDataOut: currentTime = " + System.currentTimeMillis() + ", btSendTime = " + btSendTime + ", difference = " + (System.currentTimeMillis() - btSendTime) + ", btSendTimeOut = " + btSendTimeOut); + appendToLog("BtDataOut 2: currentTime = " + System.currentTimeMillis() + ", btSendTime = " + btSendTime + ", difference = " + (System.currentTimeMillis() - btSendTime) + ", btSendTimeOut = " + btSendTimeOut); if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { boolean retValue = false; byte[] dataOut = rfidConnector.sendRfidToWrite(); if (dataOut != null) { retValue = writeData(dataOut, (rfidConnector.mRfidToWrite.get(0).waitUplinkResponse ? 500 : 0)); - appendToLog("done writeData with waitUplinkResponse = " + rfidConnector.mRfidToWrite.get(0).waitUplinkResponse); + if (false) appendToLog("done writeData with waitUplinkResponse = " + rfidConnector.mRfidToWrite.get(0).waitUplinkResponse); } if (DEBUG) appendToLog("BtDataOut: done writeRfid with size = " + rfidConnector.mRfidToWrite.size() + ", PayloadEvents = " + rfidConnector.mRfidToWrite.get(0).rfidPayloadEvent.toString() + ", data=" + byteArrayToString(rfidConnector.mRfidToWrite.get(0).dataValues)); rfidConnector.sendRfidToWriteSent++; @@ -615,27 +620,26 @@ public void run() { if (retValue) { ready2Write = false; - appendToLog("ready2Write is set false after true sendRfidToWrite"); + if (false) appendToLog("ready2Write is set false after true sendRfidToWrite"); } } } } } else if (notificationConnector.notificationToWrite.size() != 0) { - appendToLog("AAA 4"); if (isBleConnected() == false) { notificationConnector.notificationToWrite.clear(); appendToLog("notificationToWrite is clear"); } else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { byte[] dataOut = notificationConnector.sendNotificationToWrite(); boolean retValue = false; - if (DEBUG_PKDATA && notificationConnector.sendDataToWriteSent != 0) - appendToLog("!!! siliconLabIcDevice.sendDataToWriteSent = " + controllerConnector.sendDataToWriteSent); - if (DEBUG_PKDATA) - appendToLog(String.format("PkData: write mSiliconLabIcDevice.%s with mSiliconLabIcDevice.sendDataToWriteSent = %d", + if (utility.DEBUG_PKDATA && notificationConnector.sendDataToWriteSent != 0) + appendToLog("!!! notificationToWrite.sendDataToWriteSent = " + controllerConnector.sendDataToWriteSent); + if (utility.DEBUG_PKDATA) + appendToLog(String.format("PkData: write notificationToWrite.%s with notificationConnector.sendDataToWriteSent = %d", notificationConnector.notificationToWrite.get(0).notificationPayloadEvent.toString(), notificationConnector.sendDataToWriteSent)); - if (notificationConnector.sendDataToWriteSent != 0) - appendToLog("!!! mSiliconLabIcDevice.sendDataToWriteSent = " + controllerConnector.sendDataToWriteSent); + if (false && notificationConnector.sendDataToWriteSent != 0) + appendToLog("!!! mSiliconLabIcDevice.sendDataToWriteSent = " + notificationConnector.sendDataToWriteSent); if (dataOut != null) retValue = writeData(dataOut, 0); if (retValue) { @@ -646,7 +650,7 @@ else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { } } ready2Write = false; // - appendToLog("ready2Write is set false after true sendSiliconLabIcToWrite"); + if (false) appendToLog("ready2Write is set false after true sendSiliconLabIcToWrite"); } else if (controllerConnector.controllerToWrite.size() != 0) { appendToLog("AAA 5"); if (isBleConnected() == false) controllerConnector.controllerToWrite.clear(); @@ -654,13 +658,13 @@ else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { byte[] dataOut = controllerConnector.sendControllerToWrite(); boolean retValue = false; - if (DEBUG_PKDATA && controllerConnector.sendDataToWriteSent != 0) + if (utility.DEBUG_PKDATA && controllerConnector.sendDataToWriteSent != 0) appendToLog("!!! siliconLabIcDevice.sendDataToWriteSent = " + controllerConnector.sendDataToWriteSent); - if (DEBUG_PKDATA) + if (utility.DEBUG_PKDATA) appendToLog(String.format("PkData: write mSiliconLabIcDevice.%s with mSiliconLabIcDevice.sendDataToWriteSent = %d", controllerConnector.controllerToWrite.get(0).toString(), controllerConnector.sendDataToWriteSent)); - if (controllerConnector.sendDataToWriteSent != 0) + if (false && controllerConnector.sendDataToWriteSent != 0) appendToLog("!!! mSiliconLabIcDevice.sendDataToWriteSent = " + controllerConnector.sendDataToWriteSent); if (dataOut != null) retValue = writeData(dataOut, 0); @@ -672,7 +676,7 @@ else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { } } ready2Write = false; // - appendToLog("ready2Write is set false after true sendSiliconLabIcToWrite"); + if (false) appendToLog("ready2Write is set false after true sendSiliconLabIcToWrite"); } else if (bluetoothConnector.bluetoothIcToWrite.size() != 0) { //Bluetooth version affects Barcode operation appendToLog("AAA 6"); if (isBleConnected() == false) bluetoothConnector.bluetoothIcToWrite.clear(); @@ -680,9 +684,9 @@ else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { byte[] dataOut = bluetoothConnector.sendBluetoothIcToWrite(); boolean retValue = false; - if (DEBUG_PKDATA && bluetoothConnector.sendDataToWriteSent != 0) + if (utility.DEBUG_PKDATA && bluetoothConnector.sendDataToWriteSent != 0) appendToLog("!!! mBluetoothIcDevice.sendDataToWriteSent = " + bluetoothConnector.sendDataToWriteSent); - if (DEBUG_PKDATA) + if (utility.DEBUG_PKDATA) appendToLog(String.format("PkData: write mBluetoothIcDevice.%s.%s with mBluetoothIcDevice.sendDataToWriteSent = %d", bluetoothConnector.bluetoothIcToWrite.get(0).bluetoothIcPayloadEvent.toString(), byteArrayToString(bluetoothConnector.bluetoothIcToWrite.get(0).dataValues), @@ -711,38 +715,42 @@ else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { ready2Write = false; appendToLog("ready2Write is set false after true sendBarcodeToWrite"); } else if (rfidConnector.rfidPowerOnTimeOut != 0) { - if (DEBUG) appendToLog("rfidPowerOnTimeOut = " + rfidConnector.rfidPowerOnTimeOut + ", mRfidToWrite.size() = " + rfidConnector.mRfidToWrite.size()); + if (DEBUG || true) appendToLog("rfidPowerOnTimeOut = " + rfidConnector.rfidPowerOnTimeOut + ", mRfidToWrite.size() = " + rfidConnector.mRfidToWrite.size()); } else if (rfidConnector.rfidFailure == false && rfidConnector.mRfidToWrite.size() != 0) { + if (utility.DEBUG_BTDATA) appendToLog("BtData: CsReaderConnector.mReadWriteRunnable rfidFailure is false and mRfidToWrite.size is " + rfidConnector.mRfidToWrite.size()); if (isBleConnected() == false) { rfidConnector.mRfidToWrite.clear(); } else { - if (DEBUG) - appendToLog("BtDataOut: currentTime = " + System.currentTimeMillis() + ", btSendTime = " + btSendTime + ", difference = " + (System.currentTimeMillis() - btSendTime) + ", btSendTimeOut = " + btSendTimeOut); + if (utility.DEBUG_BTDATA) + appendToLog("BtData: CsReaderConnector.mReadWriteRunnable 3 currentTime = " + System.currentTimeMillis() + ", btSendTime = " + btSendTime + ", difference = " + (System.currentTimeMillis() - btSendTime) + ", btSendTimeOut = " + btSendTimeOut); if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { boolean retValue = false; byte[] dataOut = rfidConnector.sendRfidToWrite(); if (dataOut != null) { retValue = writeData(dataOut, (rfidConnector.mRfidToWrite.get(0).waitUplinkResponse ? 500 : 0)); - appendToLog("done writeData with waitUplinkResponse = " + rfidConnector.mRfidToWrite.get(0).waitUplinkResponse); + if (false) appendToLog("done writeData with waitUplinkResponse = " + rfidConnector.mRfidToWrite.get(0).waitUplinkResponse); - appendToLog("AAA sending rifd data = " + byteArrayToString(dataOut)); + if (false) appendToLog("AAA sending rifd data = " + byteArrayToString(dataOut)); String string = byteArrayToString(dataOut).substring(16); String stringCompare = "800280B310A"; if (bis108) stringCompare = "8002700100F00F000000"; - appendToLog("AAA sending rifd data portion = " + string + ", " + string.indexOf(stringCompare)); - if (string.indexOf(stringCompare) == 0) rfidReader.setInventoring(true); + if (false) appendToLog("AAA sending rifd data portion = " + string + ", " + string.indexOf(stringCompare)); + if (string.indexOf(stringCompare) == 0) + rfidReader.setInventoring(true); } - if (DEBUG) appendToLog("BtDataOut: done writeRfid with size = " + rfidConnector.mRfidToWrite.size() + ", PayloadEvents = " + rfidConnector.mRfidToWrite.get(0).rfidPayloadEvent.toString() + ", data=" + byteArrayToString(rfidConnector.mRfidToWrite.get(0).dataValues)); + if (DEBUG) + appendToLog("BtDataOut: done writeRfid with size = " + rfidConnector.mRfidToWrite.size() + ", PayloadEvents = " + rfidConnector.mRfidToWrite.get(0).rfidPayloadEvent.toString() + ", data=" + byteArrayToString(rfidConnector.mRfidToWrite.get(0).dataValues)); rfidConnector.sendRfidToWriteSent++; - if (retValue) { + if (retValue) { rfidConnector.mRfidToWriteRemoved = false; - if (DEBUG) appendToLog("writeRfid() with sendRfidToWriteSent = " + rfidConnector.sendRfidToWriteSent); + if (DEBUG) + appendToLog("writeRfid() with sendRfidToWriteSent = " + rfidConnector.sendRfidToWriteSent); sendFailure = false; //bValue = true; } else sendFailure = true; if (retValue) { - appendToLog("ready2Write is set false after true sendRfidToWrite"); + if (false) appendToLog("ready2Write is set false after true sendRfidToWrite"); ready2Write = false; } } @@ -755,7 +763,7 @@ else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { //appendToLog("mRfidDevice is " + (mRfidDevice == null ? "null" : "valid")); //appendToLog("mRfidDevice.mRfidReaderChip is " + (mRfidDevice.mRfidReaderChip == null ? "null" : "valid")); //appendToLog("mRfidDevice.mRfidReaderChip.mRfidReaderChip is " + (mRfidDevice.mRfidReaderChip.mRfidReaderChip == null ? "null" : "valid")); - if (rfidReader != null) rfidReader.mRx000UplinkHandler(); + if (rfidReader != null) rfidReader.uplinkHandler(); if (DEBUGTHREAD) appendToLog("mReadWriteRunnable: mReadWriteRunnable ends"); } }; diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/NotificationConnector.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/NotificationConnector.java index 4d9562e..b7bb9b7 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/NotificationConnector.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/NotificationConnector.java @@ -47,7 +47,7 @@ boolean getAutoRfidAbortStatus() { if (!autoRfidAbortStatusUpdate) { CsReaderNotificationData csReaderNotificationData = new CsReaderNotificationData(); csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_GET_AUTO_RFIDINV_ABORT; - notificationToWrite.add(csReaderNotificationData); appendToLog("notificationToWrite is added with length = " + notificationToWrite.size()); + notificationToWrite.add(csReaderNotificationData); if (false) appendToLog("notificationToWrite is added with length = " + notificationToWrite.size()); if (DEBUG_PKDATA) appendToLog("PkData: add NOTIFICATION_GET_AUTO_RFIDINV_ABORT to mNotificationToWrite with length = " + notificationToWrite.size()); } return autoRfidAbortStatus; @@ -59,7 +59,7 @@ public boolean getAutoBarStartStopStatus() { if (mAutoBarStartStopStatusUpdated == false) { CsReaderNotificationData csReaderNotificationData = new CsReaderNotificationData(); csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_GET_AUTO_BARINV_STARTSTOP; - notificationToWrite.add(csReaderNotificationData); appendToLog("notificationToWrite is added with length = " + notificationToWrite.size()); + notificationToWrite.add(csReaderNotificationData); if (false) appendToLog("notificationToWrite is added with length = " + notificationToWrite.size()); if (DEBUG_PKDATA) appendToLog("PkData: add NOTIFICATION_GET_AUTO_BARINV_STARTSTOP to mNotificationToWrite with length = " + notificationToWrite.size()); } return mAutoBarStartStopStatus; @@ -208,7 +208,7 @@ public boolean isMatchNotificationToWrite(ConnectorData connectorData) { } String string = "Up31 " + (bprocessed ? "" : "Unprocessed, ") + notificationToWrite.get(0).notificationPayloadEvent.toString() + ", " + byteArrayToString(data1); utility.writeDebug2File(string); - notificationToWrite.remove(0); sendDataToWriteSent = 0; appendToLog("notificationToWrite remove0 with length = " + notificationToWrite.size()); + notificationToWrite.remove(0); sendDataToWriteSent = 0; if (false) appendToLog("notificationToWrite remove0 with length = " + notificationToWrite.size()); if (DEBUG_PKDATA) appendToLog("PkData: new mNotificationToWrite size = " + notificationToWrite.size()); } } @@ -221,11 +221,11 @@ public boolean isMatchNotificationToWrite(ConnectorData connectorData) { public byte[] sendNotificationToWrite() { boolean DEBUG = false; if (notificationFailure) { - notificationToWrite.remove(0); sendDataToWriteSent = 0; appendToLog("notificationToWrite remove0 with length = " + notificationToWrite.size()); + notificationToWrite.remove(0); sendDataToWriteSent = 0; if (false) appendToLog("notificationToWrite remove0 with length = " + notificationToWrite.size()); } else if (sendDataToWriteSent >= 5) { int oldSize = notificationToWrite.size(); CsReaderNotificationData csReaderNotificationData = notificationToWrite.get(0); - notificationToWrite.remove(0); sendDataToWriteSent = 0; appendToLog("notificationToWrite remove0 with length = " + notificationToWrite.size()); + notificationToWrite.remove(0); sendDataToWriteSent = 0; if (false) appendToLog("notificationToWrite remove0 with length = " + notificationToWrite.size()); if (DEBUG) appendToLog("Removed after sending count-out with oldSize = " + oldSize + ", updated mNotificationToWrite.size() = " + notificationToWrite.size()); if (DEBUG) appendToLog("Removed after sending count-out."); String string = "Problem in sending data to Notification Module. Removed data sending after count-out"; @@ -325,14 +325,14 @@ public NotificationConnector(Context context, Utility utility, boolean triggerRe public boolean batteryLevelRequest() { CsReaderNotificationData csReaderNotificationData = new CsReaderNotificationData(); csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_GET_BATTERY_VOLTAGE; - boolean bValue = notificationToWrite.add(csReaderNotificationData); appendToLog("notificationToWrite is added with length = " + notificationToWrite.size()); + boolean bValue = notificationToWrite.add(csReaderNotificationData); if (false) appendToLog("notificationToWrite is added with length = " + notificationToWrite.size()); if (DEBUG_PKDATA) appendToLog("PkData: add NOTIFICATION_GET_BATTERY_VOLTAGE to mNotificationToWrite with length = " + notificationToWrite.size()); return bValue; } public boolean triggerButtoneStatusRequest() { CsReaderNotificationData csReaderNotificationData = new CsReaderNotificationData(); csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_GET_TRIGGER_STATUS; - boolean bValue = notificationToWrite.add(csReaderNotificationData); appendToLog("notificationToWrite is added with length = " + notificationToWrite.size()); + boolean bValue = notificationToWrite.add(csReaderNotificationData); if (false) appendToLog("notificationToWrite is added with length = " + notificationToWrite.size()); if (DEBUG_PKDATA) appendToLog("PkData: add NOTIFICATION_GET_TRIGGER_STATUS to mNotificationToWrite with length = " + notificationToWrite.size()); return bValue; } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidConnector.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidConnector.java index 7cac02f..0b6cb21 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidConnector.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidConnector.java @@ -7,11 +7,10 @@ import java.util.ArrayList; public class RfidConnector { - boolean DEBUG_PKDATA; Context context; Utility utility; public RfidConnector(Context context, Utility utility) { this.context = context; - this.utility = utility; DEBUG_PKDATA = utility.DEBUG_PKDATA; + this.utility = utility; } private String byteArrayToString(byte[] packet) { return utility.byteArrayToString(packet); } private boolean compareArray(byte[] array1, byte[] array2, int length) { return utility.compareByteArray(array1, array2, length); } @@ -84,7 +83,7 @@ public byte[] writeRfid(RfidConnector.CsReaderRfidData data) { }*/ if (arrayTypeSet(dataOut, 9, data.rfidPayloadEvent)) { if (false) appendToLogView(byteArrayToString(dataOut)); - if (DEBUG_PKDATA) appendToLog(String.format("PkData: write Rfid.%s.%s with mRfidDevice.sendRfidToWriteSent = %d", data.rfidPayloadEvent.toString(), byteArrayToString(data.dataValues), sendRfidToWriteSent)); + if (utility.DEBUG_PKDATA) appendToLog(String.format("PkData: write Rfid.%s.%s with mRfidDevice.sendRfidToWriteSent = %d", data.rfidPayloadEvent.toString(), byteArrayToString(data.dataValues), sendRfidToWriteSent)); if (sendRfidToWriteSent != 0) appendToLog("!!! mRfidDevice.sendRfidToWriteSent = " + sendRfidToWriteSent); return dataOut; } @@ -99,28 +98,28 @@ public boolean isMatchRfidToWrite(ConnectorData connectorData) { if (match = compareArray(connectorData.dataValues, dataInCompare, dataInCompare.length)) { boolean bprocessed = false; byte[] data1 = new byte[connectorData.dataValues.length - 2]; System.arraycopy(connectorData.dataValues, 2, data1, 0, data1.length); - if (DEBUG_PKDATA) appendToLog("PkData: matched Rfid.Reply with payload = " + byteArrayToString(connectorData.dataValues) + " for writeData Rfid." + mRfidToWrite.get(0).rfidPayloadEvent.toString() + "." + byteArrayToString(mRfidToWrite.get(0).dataValues)); + if (utility.DEBUG_PKDATA) appendToLog("PkData: matched Rfid.Reply with payload = " + byteArrayToString(connectorData.dataValues) + " for writeData Rfid." + mRfidToWrite.get(0).rfidPayloadEvent.toString() + "." + byteArrayToString(mRfidToWrite.get(0).dataValues)); if (connectorData.dataValues[2] != 0) { if (DEBUG) appendToLog("Rfid.reply data is found with error"); } else { if (mRfidToWrite.get(0).rfidPayloadEvent == RfidConnector.RfidPayloadEvents.RFID_POWER_ON) { rfidPowerOnTimeOut = 3000; onStatus = true; - if (DEBUG_PKDATA) appendToLog("PkData: matched Rfid.Reply.PowerOn with result 0 and onStatus = " + onStatus); + if (utility.DEBUG_PKDATA) appendToLog("PkData: matched Rfid.Reply.PowerOn with result 0 and onStatus = " + onStatus); bprocessed = true; } else if (mRfidToWrite.get(0).rfidPayloadEvent == RfidConnector.RfidPayloadEvents.RFID_POWER_OFF) { onStatus = false; - if (DEBUG_PKDATA) appendToLog("PkData: matched Rfid.Reply.PowerOff with result 0 and onStatus = " + onStatus); + if (utility.DEBUG_PKDATA) appendToLog("PkData: matched Rfid.Reply.PowerOff with result 0 and onStatus = " + onStatus); bprocessed = true; } else { bprocessed = true; - if (DEBUG_PKDATA) appendToLog("matched Rfid.Other.Reply data is found."); + if (utility.DEBUG_PKDATA) appendToLog("PkData: matched Rfid.Other.Reply data is found."); } RfidConnector.CsReaderRfidData csReaderRfidData = mRfidToWrite.get(0); if (csReaderRfidData.waitUplinkResponse) { csReaderRfidData.downlinkResponded = true; mRfidToWrite.set(0, csReaderRfidData); - if (DEBUG_PKDATA) appendToLog("PkData: mRfidToWrite.downlinkResponsed is set and waiting uplink data"); + if (utility.DEBUG_PKDATA) appendToLog("PkData: mRfidToWrite.downlinkResponsed is set and waiting uplink data"); /*if (false) { for (int i = 0; i < rfidReaderChip.mRfidReaderChip.mRx000ToRead.size(); i++) { if (rfidReaderChip.mRfidReaderChip.mRx000ToRead.get(i).responseType == Cs710Library4A.HostCmdResponseTypes.TYPE_COMMAND_END) @@ -138,7 +137,7 @@ public boolean isMatchRfidToWrite(ConnectorData connectorData) { String string = "Up31 " + (bprocessed ? "" : "Unprocessed, ") + mRfidToWrite.get(0).rfidPayloadEvent.toString() + ", " + byteArrayToString(data1); utility.writeDebug2File(string); mRfidToWrite.remove(0); sendRfidToWriteSent = 0; mRfidToWriteRemoved = true; if (DEBUG) appendToLog("mmRfidToWrite remove 1 with remained write size = " + mRfidToWrite.size()); - if (DEBUG_PKDATA) appendToLog("PkData: new mRfidToWrite size = " + mRfidToWrite.size()); + if (utility.DEBUG_PKDATA) appendToLog("PkData: new mRfidToWrite size = " + mRfidToWrite.size()); /*if (false) { for (int i = 0; i < rfidReaderChip.mRfidReaderChip.mRx000ToRead.size(); i++) { if (rfidReaderChip.mRfidReaderChip.mRx000ToRead.get(i).responseType == Cs710Library4A.HostCmdResponseTypes.TYPE_COMMAND_END) @@ -168,10 +167,12 @@ public byte[] sendRfidToWrite() { if (true) { appendToLog("Rfdid data transmission failure !!! clear mRfidToWrite buffer !!!"); //utility.writeDebug2File("Down fails to transmit " + byteArrayToString(mRfidToWrite.get(0).dataValues)); + //appendToLog("BtDataOut: sendRfidToWrite 1 set rfidFailure as true with dataValues as " + byteArrayToString(mRfidToWrite.get(0).dataValues)); rfidFailure = true; mRfidToWrite.clear(); } else if (rfidValid == false) { Toast.makeText(context, "Problem in sending data to Rfid Module. Rfid is disabled.", Toast.LENGTH_SHORT).show(); + appendToLog("BtDataOut: sendRfidToWrite 2 set rfidFailure as true"); rfidFailure = true; } /*else { Toast.makeText(context, "Problem in Sending Commands to RFID Module. Bluetooth Disconnected. Please Reconnect", Toast.LENGTH_SHORT).show(); @@ -194,11 +195,9 @@ public boolean isRfidToRead(ConnectorData connectorData) { boolean DEBUG = false; found = false; if (connectorData.dataValues[0] == (byte) 0x81) { - if (DEBUG_PKDATA) appendToLog("PkData: found Rfid.Uplink with payload = " + byteArrayToString(connectorData.dataValues)); RfidConnector.CsReaderRfidData cs108RfidReadData = new RfidConnector.CsReaderRfidData(); byte[] dataValues = new byte[connectorData.dataValues.length - 2]; System.arraycopy(connectorData.dataValues, 2, dataValues, 0, dataValues.length); - if (DEBUG_PKDATA) appendToLog("PkData: found Rfid.Uplink.DataRead with payload = " + byteArrayToString(dataValues)); switch (connectorData.dataValues[1]) { case 0: if (rfidConnectorCallback != null) { @@ -209,12 +208,12 @@ public boolean isRfidToRead(ConnectorData connectorData) { cs108RfidReadData.invalidSequence = connectorData.invalidSequence; cs108RfidReadData.milliseconds = connectorData.milliseconds; mRfidToRead.add(cs108RfidReadData); - if (DEBUG_PKDATA) appendToLog("PkData: uplink data Rfid.Uplink.DataRead is uploaded to mRfidToRead"); + if (utility.DEBUG_PKDATA) appendToLog("PkData: Got Rfid.Uplink.DataRead with updated mRfidToRead data as " + byteArrayToString(dataValues)); found = true; break; default: invalidUpdata++; - appendToLog("!!! found INVALID Rfid.Uplink with payload = " + byteArrayToString(connectorData.dataValues)); + if (utility.DEBUG_PKDATA) appendToLog("PkData: !!! found INVALID Rfid.Uplink with payload = " + byteArrayToString(connectorData.dataValues)); break; } if (found) { diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReader.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReader.java index ce5503d..cfff3c2 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReader.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReader.java @@ -3,6 +3,9 @@ import static java.lang.Math.log10; import android.content.Context; +import android.util.Log; + +import androidx.annotation.NonNull; import java.math.BigInteger; import java.util.ArrayList; @@ -16,6 +19,7 @@ public class RfidReader { ArrayList mRx000ToWrite; ArrayList mRx000ToRead; public ArrayList mRfidToWrite; + CountryChannelData countryChannelData; Context context; Utility utility; boolean bis108; BluetoothGatt bluetoothGatt; SettingData settingData; NotificationConnector notificationConnector; public RfidReader(Context context, Utility utility, CsReaderConnector csReaderConnector, boolean bis108, BluetoothGatt bluetoothGatt, SettingData settingData, NotificationConnector notificationConnector) { this.context = context; @@ -43,14 +47,240 @@ public boolean callbackMethod(byte[] dataValues) { } }; } - fccFreqTableIdx = new int[50]; - int[] freqSortedINx = fccFreqSortedIdx; + countryChannelData = new CountryChannelData(); + countryChannelData.fccFreqTableIdx = new int[50]; + int[] freqSortedINx = countryChannelData.fccFreqSortedIdx; for (int i = 0; i < 50; i++) { - fccFreqTableIdx[fccFreqSortedIdx[i]] = i; + countryChannelData.fccFreqTableIdx[countryChannelData.fccFreqSortedIdx[i]] = i; } for (int i = 0; i < 50; i++) { - if (false) appendToLog("fccFreqTableIdx[" + i + "] = " + fccFreqTableIdx[i]); + if (false) appendToLog("fccFreqTableIdx[" + i + "] = " + countryChannelData.fccFreqTableIdx[i]); + } + } + + public enum TagType { + TAG_NULL, + TAG_IMPINJ, TAG_IMPINJ_M755, //E28011, E2C011 + TAG_ALIEN, //E2003 + TAG_NXP, TAG_NXP_UCODEDNA, TAG_NXP_UCODE8, //E2806, E2C06, E2806894 + TAG_NXP_UCODE8_EPC, TAG_NXP_UCODE8_EPCTID, TAG_NXP_UCODE8_EPCBRAND, TAG_NXP_UCODE8_EPCBRANDTID, //E2806894A, E2806894B, E2806894C, E2806894d + TAG_EM, TAG_EM_BAP, TAG_EM_COLDCHAIN, TAG_EM_AURASENSE, TAG_EM_AURASENSE_ATBOOT, TAG_EM_AURASENSE_ATSELECT, //E280B, E200B0, E280B0, E280B12, E280B12A, E280B12B + TAG_KILOWAY, //E281D + TAG_LONGJING, //E201E + TAG_FDMICRO, //E2827001 + TAG_CTESIUS, //E203510 + TAG_ASYGNTAG, //E283A + TAG_AXZON, TAG_MAGNUS_S2, TAG_MAGNUS_S3, TAG_XERXES, //E2824, E282402, E282403, E282405 + } + public static class ExtraBankData { + public int extra1Bank; + public int extra2Bank; + public int extra1Count; + public int extra2Count; + public int extra1Offset; + public int extra2Offset; + + public ExtraBankData() { + extra1Bank = -1; extra2Bank = -1; + extra1Count = 0; extra2Count = 0; + extra1Offset = 0; extra2Offset = 0; + } + + public void setExtraBankData(int extra1Bank, int extra1Count, int extra1Offset, int extra2Bank, int extra2Count, int extra2Offset) { + this.extra1Bank = extra1Bank; this.extra2Bank = extra2Bank; + this.extra1Count = extra1Count; this.extra2Count = extra2Count; + this.extra1Offset = extra1Offset; this.extra2Offset = extra2Offset; + } + public void setExtraBankData(RfidReader.TagType tagType, String mDid) { + extra2Bank = 2; + extra2Offset = 0; + extra2Count = 2; + Log.i("Hello", "tagType = " + (tagType == null ? "null" : tagType.toString()) + ", mDid = " + mDid); + if (mDid == null) mDid = ""; + if (mDid.matches("E2801101") || mDid.matches("E2801102") || mDid.matches("E2801103") || mDid.matches("E2801104") || mDid.matches("E2801105")) { + extra1Bank = 0; + extra1Offset = 4; + extra1Count = 1; + if (mDid.matches("E2801101")) extra2Count = 6; + } else if (mDid.matches("E200B0")) { + extra1Bank = 2; + extra1Offset = 0; + extra1Count = 2; + extra2Bank = 3; + extra2Offset = 0x2d; + extra2Count = 1; + } else if (mDid.matches("E203510")) { + extra1Bank = 2; + extra1Offset = 0; + extra1Count = 2; + extra2Bank = 3; + extra2Offset = 8; + extra2Count = 2; + } else if (mDid.matches("E283A")) { + extra1Bank = 2; + extra1Offset = 0; + extra1Count = 2; + extra2Bank = 3; + extra2Offset = 0; + extra2Count = 8; + } else if (mDid.indexOf("E280B12") == 0) { + extra1Bank = 2; + extra1Offset = 0; + extra1Count = 2; + extra2Bank = 3; + extra2Offset = 0x120; + extra2Count = 1; + } else if (mDid.indexOf("E280B0") == 0) { + extra1Bank = 3; + extra1Offset = 188; + extra1Count = 2; + //extra2Bank = 3; + //extra2Offset = 0x10d; + //extra2Count = 1; + } else if (mDid.indexOf("E281D") == 0) { //need atmel firmware 0.2.20 + extra1Bank = 0; + extra1Offset = 4; + extra1Count = 1; + extra2Count = 6; + } else if (mDid.indexOf("E201E") == 0) { + extra1Bank = 3; + extra1Offset = 112; + extra1Count = 1; + extra2Count = 6; + } else if (mDid.matches("E282402")) { + extra1Bank = 0; + extra1Offset = 11; + extra1Count = 1; + extra2Bank = 0; + extra2Offset = 13; + extra2Count = 1; + } else if (mDid.matches("E282403")) { + extra1Bank = 0; + extra1Offset = 12; + extra1Count = 3; + extra2Bank = 3; + extra2Offset = 8; + extra2Count = 4; + } else if (mDid.matches("E282405")) { + extra1Bank = 0; + extra1Offset = 10; + extra1Count = 5; + extra2Bank = 3; + extra2Offset = 0x12; + extra2Count = 4; + } } + + public void adjustExtraBank1() { + if (extra1Bank == -1 || extra1Count == 0) { + extra1Bank = extra2Bank; + extra2Bank = 0; + extra1Count = extra2Count; + extra2Count = 0; + extra1Offset = extra2Offset; + extra2Offset = 0; + } + if (extra1Bank == 1) extra1Offset += 2; + if (extra2Bank == 1) extra2Offset += 2; + } + } + public int setSelectData4Inventory(RfidReader.TagType tagType, String mDid, boolean bNeedSelectedTagByTID, String stringProtectPassword, int selectFor, int selectHold) { + int iValue = -1; + if (utility.DEBUG_SELECT) appendToLog("RfidReader.setSelectData with mDid = " + mDid); + if (mDid != null) { + setSelectCriteriaDisable(-1); + if (mDid.indexOf("E280B12") == 0) { + if (mDid.matches("E280B12B")) { + setSelectCriteria(0, true, 4, 0, 5, 1, 0x220, "8321"); + appendToLog("Hello123: Set Sense at Select !!!"); + } else { //if (MainActivity.mDid.matches("E280B12A")) { + //setSelectCriteriaDisable(-1); + appendToLog("Hello123: Set Sense at BOOT !!!"); + } + } else if (mDid.matches("E203510")) { + setSelectCriteria(0, true, 7, 4, 0, 2, 0, mDid); + } else if (mDid.matches("E28240")) { + if (selectFor != 0) { + //setSelectCriteriaDisable(-1); + selectFor = 0; + iValue = selectFor; + } + } else if (mDid.matches("E282402")) { + appendToLog("selectFor = " + selectFor); + if (selectFor != 2) { + setSelectCriteria(0, true, 4, 2, 0, 3, 0xA0, "20"); + selectFor = 2; + iValue = selectFor; + } + } else if (mDid.matches("E282403")) { + if (selectFor != 3) { + setSelectCriteria(0, true, 4, 2, 0, 3, 0xD0, "1F"); + setSelectCriteria(1, true, 4, 2, 5, 3, 0xE0, ""); + selectFor = 3; + iValue = selectFor; + } + } else if (mDid.matches("E282405")) { + if (selectFor != 5) { + setSelectCriteria(0, true, 4, 5, selectHold, 3, 0x3B0, "00"); + //setSelectCriteriaDisable(2); + selectFor = 5; + iValue = selectFor; + } + } else { + appendToLog("MainActivity.selectFor = " + selectFor); + if (selectFor != -1) { + //setSelectCriteriaDisable(-1); + selectFor = -1; + iValue = selectFor; + } + } + + if (mDid.indexOf("E2806894") == 0) { + appendToLog("RfidReader.setSelectData 0 found " + mDid + ".indexOf[E2806894] == 0"); + if (mDid.matches("E2806894A")) { + appendToLog("RfidReader.setSelectData 1 found E2806894A"); + //setSelectCriteriaDisable(1); + } else if (mDid.matches("E2806894B")) { + appendToLog("RfidReader.setSelectData 2 found E2806894B"); + appendToLog("BtDataOut BBB 2"); + setSelectCriteria(0, true, 4, 0, 1, 0x203, "1", true); + setSelectCriteria(1, true, 4, 2, 2, 0, "E2806894", false); + } else if (mDid.matches("E2806894C") || mDid.matches("E2806894d")) { + appendToLog("RfidReader.setSelectData 3 found " + mDid); + setSelectCriteria(0, true, 4, 0, 1, 0x204, "1", true); + setSelectCriteria(1, true, 4, 2, 2, 0, "E2806894", false); + } + mDid = "E2806894"; + } + + if (bNeedSelectedTagByTID) { + String strMdid = mDid; + if (strMdid.indexOf("E28011") == 0) { + int iValue1 = Integer.valueOf(strMdid.substring(6, 8), 16); + iValue1 &= 0x0F; + appendToLog(String.format("iValue1 = 0x%X", iValue1)); + if (iValue1 == 1) strMdid = "E2C011A2"; + else if (iValue1 == 2) strMdid = "E28011C"; + else if (iValue1 == 3) strMdid = "E28011B"; + else if (iValue1 == 4) strMdid = "E28011A"; + else if (iValue1 == 5) strMdid = "E280119"; + else if (iValue1 == 6) strMdid = "E2801171"; + else if (iValue1 == 7) strMdid = "E2801170"; + else if (iValue1 == 8) strMdid = "E2801150"; + else + strMdid = "E2001"; //strMdid.substring(0, 5); even E2801 or E2C01 will return + } + if (stringProtectPassword != null) { + if (stringProtectPassword.trim().length() == 0) + stringProtectPassword = "00000000"; + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectCriteria: Going to setSelectCriteria"); + setSelectCriteria(-1, true, 4, 0, 3, 0, stringProtectPassword, false); + } + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectCriteria: Going to setSelectedByTID"); + setSelectedTagByTID(strMdid, -1); + } + } + return iValue; } //============ utility ============ @@ -87,870 +317,1037 @@ public boolean setInvAlgo1(boolean dynamicAlgo) { return bValue; } - private final int FCC_CHN_CNT = 50; - private final double[] FCCTableOfFreq = new double[] { - 902.75, 903.25, 903.75, 904.25, 904.75, 905.25, 905.75, 906.25, 906.75, 907.25,//10 - 907.75, 908.25, 908.75, 909.25, 909.75, 910.25, 910.75, 911.25, 911.75, 912.25,//20 - 912.75, 913.25, 913.75, 914.25, 914.75, 915.25, 915.75, 916.25, 916.75, 917.25, - 917.75, 918.25, 918.75, 919.25, 919.75, 920.25, 920.75, 921.25, 921.75, 922.25, - 922.75, 923.25, 923.75, 924.25, 924.75, 925.25, 925.75, 926.25, 926.75, 927.25 }; - private final double[] FCCTableOfFreq0 = new double[] { - 903.75, 912.25, 907.75, 910.25, 922.75, 923.25, 923.75, 915.25, 909.25, 912.75, - 910.75, 913.75, 909.75, 905.25, 911.75, 902.75, 914.25, 918.25, 926.25, 925.75, - 920.75, 920.25, 907.25, 914.75, 919.75, 922.25, 903.25, 906.25, 905.75, 926.75, - 924.25, 904.75, 925.25, 924.75, 919.25, 916.75, 911.25, 921.25, 908.25, 908.75, - 913.25, 916.25, 904.25, 906.75, 917.75, 921.75, 917.25, 927.25, 918.75, 915.75 }; - private int[] fccFreqSortedIdx0; - private final double[] FCCTableOfFreq1 = new double[] { - 915.25, 920.75, 909.25, 912.25, 918.25, 920.25, 909.75, 910.25, 919.75, 922.75, - 908.75, 913.75, 903.75, 919.25, 922.25, 907.75, 911.75, 923.75, 916.75, 926.25, - 908.25, 912.75, 924.25, 916.25, 927.25, 907.25, 910.75, 903.25, 917.75, 926.75, - 905.25, 911.25, 924.75, 917.25, 925.75, 906.75, 914.25, 904.75, 918.75, 923.25, - 902.75, 914.75, 905.75, 915.75, 925.25, 906.25, 921.25, 913.25, 921.75, 904.25 }; - private int[] fccFreqSortedIdx1; - private int[] fccFreqTable = new int[] { - 0x00180E4F, //915.75 MHz - 0x00180E4D, //915.25 MHz - 0x00180E1D, //903.25 MHz - 0x00180E7B, //926.75 MHz - 0x00180E79, //926.25 MHz - 0x00180E21, //904.25 MHz - 0x00180E7D, //927.25 MHz - 0x00180E61, //920.25 MHz - 0x00180E5D, //919.25 MHz - 0x00180E35, //909.25 MHz - 0x00180E5B, //918.75 MHz - 0x00180E57, //917.75 MHz - 0x00180E25, //905.25 MHz - 0x00180E23, //904.75 MHz - 0x00180E75, //925.25 MHz - 0x00180E67, //921.75 MHz - 0x00180E4B, //914.75 MHz - 0x00180E2B, //906.75 MHz - 0x00180E47, //913.75 MHz - 0x00180E69, //922.25 MHz - 0x00180E3D, //911.25 MHz - 0x00180E3F, //911.75 MHz - 0x00180E1F, //903.75 MHz - 0x00180E33, //908.75 MHz - 0x00180E27, //905.75 MHz - 0x00180E41, //912.25 MHz - 0x00180E29, //906.25 MHz - 0x00180E55, //917.25 MHz - 0x00180E49, //914.25 MHz - 0x00180E2D, //907.25 MHz - 0x00180E59, //918.25 MHz - 0x00180E51, //916.25 MHz - 0x00180E39, //910.25 MHz - 0x00180E3B, //910.75 MHz - 0x00180E2F, //907.75 MHz - 0x00180E73, //924.75 MHz - 0x00180E37, //909.75 MHz - 0x00180E5F, //919.75 MHz - 0x00180E53, //916.75 MHz - 0x00180E45, //913.25 MHz - 0x00180E6F, //923.75 MHz - 0x00180E31, //908.25 MHz - 0x00180E77, //925.75 MHz - 0x00180E43, //912.75 MHz - 0x00180E71, //924.25 MHz - 0x00180E65, //921.25 MHz - 0x00180E63, //920.75 MHz - 0x00180E6B, //922.75 MHz - 0x00180E1B, //902.75 MHz - 0x00180E6D, //923.25 MHz - }; - private int[] fccFreqTableIdx; - private final int[] fccFreqSortedIdx = new int[] { - 26, 25, 1, 48, 47, - 3, 49, 35, 33, 13, - 32, 30, 5, 4, 45, - 38, 24, 8, 22, 39, - 17, 18, 2, 12, 6, - 19, 7, 29, 23, 9, - 31, 27, 15, 16, 10, - 44, 14, 34, 28, 21, - 42, 11, 46, 20, 43, - 37, 36, 40, 0, 41 }; - private final int AUS_CHN_CNT = 10; - private final double[] AUSTableOfFreq = new double[] { - 920.75, 921.25, 921.75, 922.25, 922.75, - 923.25, 923.75, 924.25, 924.75, 925.25 }; - private final int[] AusFreqTable = new int[] { - 0x00180E63, // 920.75MHz - 0x00180E69, // 922.25MHz - 0x00180E6F, // 923.75MHz - 0x00180E73, // 924.75MHz - 0x00180E65, // 921.25MHz - 0x00180E6B, // 922.75MHz - 0x00180E71, // 924.25MHz - 0x00180E75, // 925.25MHz - 0x00180E67, // 921.75MHz - 0x00180E6D, // 923.25MHz - }; - private final int[] ausFreqSortedIdx = new int[] { - 0, 3, 6, 8, 1, - 4, 7, 9, 2, 5 }; - - private double[] PRTableOfFreq = new double[] { - 915.25, 915.75, 916.25, 916.75, 917.25, - 917.75, 918.25, 918.75, 919.25, 919.75, 920.25, 920.75, 921.25, 921.75, 922.25, - 922.75, 923.25, 923.75, 924.25, 924.75, 925.25, 925.75, 926.25, 926.75, 927.25 }; private int[] freqTable = null; private int[] freqSortedIdx = null; + static class CountryChannelData { + final int FCC_CHN_CNT = 50; + private final double[] FCCTableOfFreq = new double[]{ + 902.75, 903.25, 903.75, 904.25, 904.75, 905.25, 905.75, 906.25, 906.75, 907.25,//10 + 907.75, 908.25, 908.75, 909.25, 909.75, 910.25, 910.75, 911.25, 911.75, 912.25,//20 + 912.75, 913.25, 913.75, 914.25, 914.75, 915.25, 915.75, 916.25, 916.75, 917.25, + 917.75, 918.25, 918.75, 919.25, 919.75, 920.25, 920.75, 921.25, 921.75, 922.25, + 922.75, 923.25, 923.75, 924.25, 924.75, 925.25, 925.75, 926.25, 926.75, 927.25}; + private final double[] FCCTableOfFreq0 = new double[]{ + 903.75, 912.25, 907.75, 910.25, 922.75, 923.25, 923.75, 915.25, 909.25, 912.75, + 910.75, 913.75, 909.75, 905.25, 911.75, 902.75, 914.25, 918.25, 926.25, 925.75, + 920.75, 920.25, 907.25, 914.75, 919.75, 922.25, 903.25, 906.25, 905.75, 926.75, + 924.25, 904.75, 925.25, 924.75, 919.25, 916.75, 911.25, 921.25, 908.25, 908.75, + 913.25, 916.25, 904.25, 906.75, 917.75, 921.75, 917.25, 927.25, 918.75, 915.75}; + private int[] fccFreqSortedIdx0; + private final double[] FCCTableOfFreq1 = new double[]{ + 915.25, 920.75, 909.25, 912.25, 918.25, 920.25, 909.75, 910.25, 919.75, 922.75, + 908.75, 913.75, 903.75, 919.25, 922.25, 907.75, 911.75, 923.75, 916.75, 926.25, + 908.25, 912.75, 924.25, 916.25, 927.25, 907.25, 910.75, 903.25, 917.75, 926.75, + 905.25, 911.25, 924.75, 917.25, 925.75, 906.75, 914.25, 904.75, 918.75, 923.25, + 902.75, 914.75, 905.75, 915.75, 925.25, 906.25, 921.25, 913.25, 921.75, 904.25}; + private int[] fccFreqSortedIdx1; + private int[] fccFreqTable = new int[]{ + 0x00180E4F, //915.75 MHz + 0x00180E4D, //915.25 MHz + 0x00180E1D, //903.25 MHz + 0x00180E7B, //926.75 MHz + 0x00180E79, //926.25 MHz + 0x00180E21, //904.25 MHz + 0x00180E7D, //927.25 MHz + 0x00180E61, //920.25 MHz + 0x00180E5D, //919.25 MHz + 0x00180E35, //909.25 MHz + 0x00180E5B, //918.75 MHz + 0x00180E57, //917.75 MHz + 0x00180E25, //905.25 MHz + 0x00180E23, //904.75 MHz + 0x00180E75, //925.25 MHz + 0x00180E67, //921.75 MHz + 0x00180E4B, //914.75 MHz + 0x00180E2B, //906.75 MHz + 0x00180E47, //913.75 MHz + 0x00180E69, //922.25 MHz + 0x00180E3D, //911.25 MHz + 0x00180E3F, //911.75 MHz + 0x00180E1F, //903.75 MHz + 0x00180E33, //908.75 MHz + 0x00180E27, //905.75 MHz + 0x00180E41, //912.25 MHz + 0x00180E29, //906.25 MHz + 0x00180E55, //917.25 MHz + 0x00180E49, //914.25 MHz + 0x00180E2D, //907.25 MHz + 0x00180E59, //918.25 MHz + 0x00180E51, //916.25 MHz + 0x00180E39, //910.25 MHz + 0x00180E3B, //910.75 MHz + 0x00180E2F, //907.75 MHz + 0x00180E73, //924.75 MHz + 0x00180E37, //909.75 MHz + 0x00180E5F, //919.75 MHz + 0x00180E53, //916.75 MHz + 0x00180E45, //913.25 MHz + 0x00180E6F, //923.75 MHz + 0x00180E31, //908.25 MHz + 0x00180E77, //925.75 MHz + 0x00180E43, //912.75 MHz + 0x00180E71, //924.25 MHz + 0x00180E65, //921.25 MHz + 0x00180E63, //920.75 MHz + 0x00180E6B, //922.75 MHz + 0x00180E1B, //902.75 MHz + 0x00180E6D, //923.25 MHz + }; + private int[] fccFreqTableIdx; + private final int[] fccFreqSortedIdx = new int[]{ + 26, 25, 1, 48, 47, + 3, 49, 35, 33, 13, + 32, 30, 5, 4, 45, + 38, 24, 8, 22, 39, + 17, 18, 2, 12, 6, + 19, 7, 29, 23, 9, + 31, 27, 15, 16, 10, + 44, 14, 34, 28, 21, + 42, 11, 46, 20, 43, + 37, 36, 40, 0, 41}; + + private final int AUS_CHN_CNT = 10; + private final double[] AUSTableOfFreq = new double[]{ + 920.75, 921.25, 921.75, 922.25, 922.75, + 923.25, 923.75, 924.25, 924.75, 925.25}; + private final int[] AusFreqTable = new int[]{ + 0x00180E63, // 920.75MHz + 0x00180E69, // 922.25MHz + 0x00180E6F, // 923.75MHz + 0x00180E73, // 924.75MHz + 0x00180E65, // 921.25MHz + 0x00180E6B, // 922.75MHz + 0x00180E71, // 924.25MHz + 0x00180E75, // 925.25MHz + 0x00180E67, // 921.75MHz + 0x00180E6D, // 923.25MHz + }; + private final int[] ausFreqSortedIdx = new int[]{ + 0, 3, 6, 8, 1, + 4, 7, 9, 2, 5}; + + private double[] PRTableOfFreq = new double[]{ + 915.25, 915.75, 916.25, 916.75, 917.25, + 917.75, 918.25, 918.75, 919.25, 919.75, 920.25, 920.75, 921.25, 921.75, 922.25, + 922.75, 923.25, 923.75, 924.25, 924.75, 925.25, 925.75, 926.25, 926.75, 927.25}; + + private final int VZ_CHN_CNT = 10; + private final double[] VZTableOfFreq = new double[]{ + 922.75, 923.25, 923.75, 924.25, 924.75, + 925.25, 925.75, 926.25, 926.75, 927.25}; + private final int[] vzFreqTable = new int[]{ + 0x00180E77, // 925.75 MHz + 0x00180E6B, // 922.75MHz + 0x00180E7D, // 927.25 MHz + 0x00180E75, // 925.25MHz + 0x00180E6D, // 923.25MHz + 0x00180E7B, // 926.75 MHz + 0x00180E73, // 924.75MHz + 0x00180E6F, // 923.75MHz + 0x00180E79, // 926.25 MHz + 0x00180E71, // 924.25MHz + }; + private final int[] vzFreqSortedIdx = new int[]{ + 6, 0, 9, 5, 1, + 8, 4, 2, 7, 3}; + + private final int BR1_CHN_CNT = 24; + private final double[] BR1TableOfFreq = new double[]{ + //902.75, 903.25, 903.75, 904.25, 904.75, + //905.25, 905.75, 906.25, 906.75, 907.25, + //907.75, 908.25, 908.75, 909.25, 909.75, + //910.25, 910.75, 911.25, 911.75, 912.25, + //912.75, 913.25, 913.75, 914.25, 914.75, + //915.25, + 915.75, 916.25, 916.75, 917.25, 917.75, + 918.25, 918.75, 919.25, 919.75, 920.25, + 920.75, 921.25, 921.75, 922.25, 922.75, + 923.25, 923.75, 924.25, 924.75, 925.25, + 925.75, 926.25, 926.75, 927.25}; + private final int[] br1FreqTable = new int[]{ + 0x00180E4F, //915.75 MHz + //0x00180E4D, //915.25 MHz + //0x00180E1D, //903.25 MHz + 0x00180E7B, //926.75 MHz + 0x00180E79, //926.25 MHz + //0x00180E21, //904.25 MHz + 0x00180E7D, //927.25 MHz + 0x00180E61, //920.25 MHz + 0x00180E5D, //919.25 MHz + //0x00180E35, //909.25 MHz + 0x00180E5B, //918.75 MHz + 0x00180E57, //917.75 MHz + //0x00180E25, //905.25 MHz + //0x00180E23, //904.75 MHz + 0x00180E75, //925.25 MHz + 0x00180E67, //921.75 MHz + //0x00180E4B, //914.75 MHz + //0x00180E2B, //906.75 MHz + //0x00180E47, //913.75 MHz + 0x00180E69, //922.25 MHz + //0x00180E3D, //911.25 MHz + //0x00180E3F, //911.75 MHz + //0x00180E1F, //903.75 MHz + //0x00180E33, //908.75 MHz + //0x00180E27, //905.75 MHz + //0x00180E41, //912.25 MHz + //0x00180E29, //906.25 MHz + 0x00180E55, //917.25 MHz + //0x00180E49, //914.25 MHz + //0x00180E2D, //907.25 MHz + 0x00180E59, //918.25 MHz + 0x00180E51, //916.25 MHz + //0x00180E39, //910.25 MHz + //0x00180E3B, //910.75 MHz + //0x00180E2F, //907.75 MHz + 0x00180E73, //924.75 MHz + //0x00180E37, //909.75 MHz + 0x00180E5F, //919.75 MHz + 0x00180E53, //916.75 MHz + //0x00180E45, //913.25 MHz + 0x00180E6F, //923.75 MHz + //0x00180E31, //908.25 MHz + 0x00180E77, //925.75 MHz + //0x00180E43, //912.75 MHz + 0x00180E71, //924.25 MHz + 0x00180E65, //921.25 MHz + 0x00180E63, //920.75 MHz + 0x00180E6B, //922.75 MHz + //0x00180E1B, //902.75 MHz + 0x00180E6D, //923.25 MHz + }; + private final int[] br1FreqSortedIdx = new int[]{ + 0, 22, 21, 23, 9, + 7, 6, 4, 19, 12, + 13, 3, 5, 1, 18, + 8, 2, 16, 20, 17, + 11, 10, 14, 15}; + + private final int BR2_CHN_CNT = 33; + private double[] BR2TableOfFreq = new double[]{ + 902.75, 903.25, 903.75, 904.25, 904.75, + 905.25, 905.75, 906.25, 906.75, + //907.25, 907.75, 908.25, 908.75, 909.25, + //909.75, 910.25, 910.75, 911.25, 911.75, + //912.25, 912.75, 913.25, 913.75, 914.25, + //914.75, 915.25, + 915.75, 916.25, 916.75, 917.25, 917.75, + 918.25, 918.75, 919.25, 919.75, 920.25, + 920.75, 921.25, 921.75, 922.25, 922.75, + 923.25, 923.75, 924.25, 924.75, 925.25, + 925.75, 926.25, 926.75, 927.25}; + private final int[] br2FreqTable = new int[]{ + 0x00180E4F, //915.75 MHz + //0x00180E4D, //915.25 MHz + 0x00180E1D, //903.25 MHz + 0x00180E7B, //926.75 MHz + 0x00180E79, //926.25 MHz + 0x00180E21, //904.25 MHz + 0x00180E7D, //927.25 MHz + 0x00180E61, //920.25 MHz + 0x00180E5D, //919.25 MHz + //0x00180E35, //909.25 MHz + 0x00180E5B, //918.75 MHz + 0x00180E57, //917.75 MHz + 0x00180E25, //905.25 MHz + 0x00180E23, //904.75 MHz + 0x00180E75, //925.25 MHz + 0x00180E67, //921.75 MHz + //0x00180E4B, //914.75 MHz + 0x00180E2B, //906.75 MHz + //0x00180E47, //913.75 MHz + 0x00180E69, //922.25 MHz + //0x00180E3D, //911.25 MHz + //0x00180E3F, //911.75 MHz + 0x00180E1F, //903.75 MHz + //0x00180E33, //908.75 MHz + 0x00180E27, //905.75 MHz + //0x00180E41, //912.25 MHz + 0x00180E29, //906.25 MHz + 0x00180E55, //917.25 MHz + //0x00180E49, //914.25 MHz + //0x00180E2D, //907.25 MHz + 0x00180E59, //918.25 MHz + 0x00180E51, //916.25 MHz + //0x00180E39, //910.25 MHz + //0x00180E3B, //910.75 MHz + //0x00180E2F, //907.75 MHz + 0x00180E73, //924.75 MHz + //0x00180E37, //909.75 MHz + 0x00180E5F, //919.75 MHz + 0x00180E53, //916.75 MHz + //0x00180E45, //913.25 MHz + 0x00180E6F, //923.75 MHz + //0x00180E31, //908.25 MHz + 0x00180E77, //925.75 MHz + //0x00180E43, //912.75 MHz + 0x00180E71, //924.25 MHz + 0x00180E65, //921.25 MHz + 0x00180E63, //920.75 MHz + 0x00180E6B, //922.75 MHz + 0x00180E1B, //902.75 MHz + 0x00180E6D, //923.25 MHz + }; + private final int[] br2FreqSortedIdx = new int[]{ + 9, 1, 31, 30, 3, + 32, 18, 16, 15, 13, + 5, 4, 28, 21, 8, + 22, 2, 6, 7, 12, + 14, 10, 27, 17, 11, + 25, 29, 26, 20, 19, + 23, 0, 24, + }; - private final int VZ_CHN_CNT = 10; - private final double[] VZTableOfFreq = new double[] { - 922.75, 923.25, 923.75, 924.25, 924.75, - 925.25, 925.75, 926.25, 926.75, 927.25 }; - private final int[] vzFreqTable = new int[] { - 0x00180E77, // 925.75 MHz - 0x00180E6B, // 922.75MHz - 0x00180E7D, // 927.25 MHz - 0x00180E75, // 925.25MHz - 0x00180E6D, // 923.25MHz - 0x00180E7B, // 926.75 MHz - 0x00180E73, // 924.75MHz - 0x00180E6F, // 923.75MHz - 0x00180E79, // 926.25 MHz - 0x00180E71, // 924.25MHz - }; - private final int[] vzFreqSortedIdx = new int[] { - 6, 0, 9, 5, 1, - 8, 4, 2, 7, 3 }; - - private final int BR1_CHN_CNT = 24; - private final double[] BR1TableOfFreq = new double[] { - //902.75, 903.25, 903.75, 904.25, 904.75, - //905.25, 905.75, 906.25, 906.75, 907.25, - //907.75, 908.25, 908.75, 909.25, 909.75, - //910.25, 910.75, 911.25, 911.75, 912.25, - //912.75, 913.25, 913.75, 914.25, 914.75, - //915.25, - 915.75, 916.25, 916.75, 917.25, 917.75, - 918.25, 918.75, 919.25, 919.75, 920.25, - 920.75, 921.25, 921.75, 922.25, 922.75, - 923.25, 923.75, 924.25, 924.75, 925.25, - 925.75, 926.25, 926.75, 927.25 }; - private final int[] br1FreqTable = new int[] { - 0x00180E4F, //915.75 MHz - //0x00180E4D, //915.25 MHz - //0x00180E1D, //903.25 MHz - 0x00180E7B, //926.75 MHz - 0x00180E79, //926.25 MHz - //0x00180E21, //904.25 MHz - 0x00180E7D, //927.25 MHz - 0x00180E61, //920.25 MHz - 0x00180E5D, //919.25 MHz - //0x00180E35, //909.25 MHz - 0x00180E5B, //918.75 MHz - 0x00180E57, //917.75 MHz - //0x00180E25, //905.25 MHz - //0x00180E23, //904.75 MHz - 0x00180E75, //925.25 MHz - 0x00180E67, //921.75 MHz - //0x00180E4B, //914.75 MHz - //0x00180E2B, //906.75 MHz - //0x00180E47, //913.75 MHz - 0x00180E69, //922.25 MHz - //0x00180E3D, //911.25 MHz - //0x00180E3F, //911.75 MHz - //0x00180E1F, //903.75 MHz - //0x00180E33, //908.75 MHz - //0x00180E27, //905.75 MHz - //0x00180E41, //912.25 MHz - //0x00180E29, //906.25 MHz - 0x00180E55, //917.25 MHz - //0x00180E49, //914.25 MHz - //0x00180E2D, //907.25 MHz - 0x00180E59, //918.25 MHz - 0x00180E51, //916.25 MHz - //0x00180E39, //910.25 MHz - //0x00180E3B, //910.75 MHz - //0x00180E2F, //907.75 MHz - 0x00180E73, //924.75 MHz - //0x00180E37, //909.75 MHz - 0x00180E5F, //919.75 MHz - 0x00180E53, //916.75 MHz - //0x00180E45, //913.25 MHz - 0x00180E6F, //923.75 MHz - //0x00180E31, //908.25 MHz - 0x00180E77, //925.75 MHz - //0x00180E43, //912.75 MHz - 0x00180E71, //924.25 MHz - 0x00180E65, //921.25 MHz - 0x00180E63, //920.75 MHz - 0x00180E6B, //922.75 MHz - //0x00180E1B, //902.75 MHz - 0x00180E6D, //923.25 MHz - }; - private final int[] br1FreqSortedIdx = new int[] { - 0, 22, 21, 23, 9, - 7, 6, 4, 19, 12, - 13, 3, 5, 1, 18, - 8, 2, 16, 20, 17, - 11, 10, 14, 15 }; - - private final int BR2_CHN_CNT = 33; - private double[] BR2TableOfFreq = new double[] { - 902.75, 903.25, 903.75, 904.25, 904.75, - 905.25, 905.75, 906.25, 906.75, - //907.25, 907.75, 908.25, 908.75, 909.25, - //909.75, 910.25, 910.75, 911.25, 911.75, - //912.25, 912.75, 913.25, 913.75, 914.25, - //914.75, 915.25, - 915.75, 916.25, 916.75, 917.25, 917.75, - 918.25, 918.75, 919.25, 919.75, 920.25, - 920.75, 921.25, 921.75, 922.25, 922.75, - 923.25, 923.75, 924.25, 924.75, 925.25, - 925.75, 926.25, 926.75, 927.25 }; - private final int[] br2FreqTable = new int[] { - 0x00180E4F, //915.75 MHz - //0x00180E4D, //915.25 MHz - 0x00180E1D, //903.25 MHz - 0x00180E7B, //926.75 MHz - 0x00180E79, //926.25 MHz - 0x00180E21, //904.25 MHz - 0x00180E7D, //927.25 MHz - 0x00180E61, //920.25 MHz - 0x00180E5D, //919.25 MHz - //0x00180E35, //909.25 MHz - 0x00180E5B, //918.75 MHz - 0x00180E57, //917.75 MHz - 0x00180E25, //905.25 MHz - 0x00180E23, //904.75 MHz - 0x00180E75, //925.25 MHz - 0x00180E67, //921.75 MHz - //0x00180E4B, //914.75 MHz - 0x00180E2B, //906.75 MHz - //0x00180E47, //913.75 MHz - 0x00180E69, //922.25 MHz - //0x00180E3D, //911.25 MHz - //0x00180E3F, //911.75 MHz - 0x00180E1F, //903.75 MHz - //0x00180E33, //908.75 MHz - 0x00180E27, //905.75 MHz - //0x00180E41, //912.25 MHz - 0x00180E29, //906.25 MHz - 0x00180E55, //917.25 MHz - //0x00180E49, //914.25 MHz - //0x00180E2D, //907.25 MHz - 0x00180E59, //918.25 MHz - 0x00180E51, //916.25 MHz - //0x00180E39, //910.25 MHz - //0x00180E3B, //910.75 MHz - //0x00180E2F, //907.75 MHz - 0x00180E73, //924.75 MHz - //0x00180E37, //909.75 MHz - 0x00180E5F, //919.75 MHz - 0x00180E53, //916.75 MHz - //0x00180E45, //913.25 MHz - 0x00180E6F, //923.75 MHz - //0x00180E31, //908.25 MHz - 0x00180E77, //925.75 MHz - //0x00180E43, //912.75 MHz - 0x00180E71, //924.25 MHz - 0x00180E65, //921.25 MHz - 0x00180E63, //920.75 MHz - 0x00180E6B, //922.75 MHz - 0x00180E1B, //902.75 MHz - 0x00180E6D, //923.25 MHz - }; - private final int[] br2FreqSortedIdx = new int[] { - 9, 1, 31, 30, 3, - 32, 18, 16, 15, 13, - 5, 4, 28, 21, 8, - 22, 2, 6, 7, 12, - 14, 10, 27, 17, 11, - 25, 29, 26, 20, 19, - 23, 0, 24, - }; - - private final int BR3_CHN_CNT = 9; - private final double[] BR3TableOfFreq = new double[] { - 902.75, 903.25, 903.75, 904.25, 904.75, // 4 - 905.25, 905.75, 906.25, 906.75 }; - private final int[] br3FreqTable = new int[] { - 0x00180E1D, //903.25 MHz - 0x00180E21, //904.25 MHz - 0x00180E25, //905.25 MHz - 0x00180E23, //904.75 MHz - 0x00180E2B, //906.75 MHz - 0x00180E1F, //903.75 MHz - 0x00180E27, //905.75 MHz - 0x00180E29, //906.25 MHz - 0x00180E1B, //902.75 MHz - }; - private final int[] br3FreqSortedIdx = new int[] { - 1, 3, 5, 4, 8, - 2, 6, 7, 0 }; - - private final int BR4_CHN_CNT = 4; - private final double[] BR4TableOfFreq = new double[] { - 902.75, 903.25, 903.75, 904.25 }; - private final int[] br4FreqTable = new int[] { - 0x00180E1D, //903.25 MHz - 0x00180E21, //904.25 MHz - 0x00180E1F, //903.75 MHz - 0x00180E1B, //902.75 MHz - }; - private final int[] br4FreqSortedIdx = new int[] { - 1, 3, 2, 0 }; - - private final int BR5_CHN_CNT = 14; - private final double[] BR5TableOfFreq = new double[] { - 917.75, 918.25, 918.75, 919.25, 919.75, // 4 - 920.25, 920.75, 921.25, 921.75, 922.25, // 9 - 922.75, 923.25, 923.75, 924.25 }; - private final int[] br5FreqTable = new int[] { - 0x00180E61, //920.25 MHz - 0x00180E5D, //919.25 MHz - 0x00180E5B, //918.75 MHz - 0x00180E57, //917.75 MHz - 0x00180E67, //921.75 MHz - 0x00180E69, //922.25 MHz - 0x00180E59, //918.25 MHz - 0x00180E5F, //919.75 MHz - 0x00180E6F, //923.75 MHz - 0x00180E71, //924.25 MHz - 0x00180E65, //921.25 MHz - 0x00180E63, //920.75 MHz - 0x00180E6B, //922.75 MHz - 0x00180E6D, //923.25 MHz - }; - private final int[] br5FreqSortedIdx = new int[] { - 5, 3, 2, 0, 8, - 9, 1, 4, 12, 13, - 7, 6, 10, 11 }; - - private final int HK_CHN_CNT = 8; - private final double[] HKTableOfFreq = new double[] { - 920.75, 921.25, 921.75, 922.25, 922.75, - 923.25, 923.75, 924.25 }; - private final int[] hkFreqTable = new int[] { - 0x00180E63, //920.75MHz - 0x00180E69, //922.25MHz - 0x00180E71, //924.25MHz - 0x00180E65, //921.25MHz - 0x00180E6B, //922.75MHz - 0x00180E6D, //923.25MHz - 0x00180E6F, //923.75MHz - 0x00180E67, //921.75MHz - }; - private final int[] hkFreqSortedIdx = new int[] { - 0, 3, 7, 1, 4, - 5, 6, 2 }; - - private final int BD_CHN_CNT = 4; - private final double[] BDTableOfFreq = new double[] { - 925.25, 925.75, 926.25, 926.75 }; - private final int[] bdFreqTable = new int[] { - 0x00180E75, //925.25MHz - 0x00180E77, //925.75MHz - 0x00180E79, //926.25MHz - 0x00180E7B, //926.75MHz - }; - private final int[] bdFreqSortedIdx = new int[] { - 0, 3, 1, 2 }; - - private final int TW_CHN_CNT = 12; - private final double[] TWTableOfFreq = new double[] { - 922.25, 922.75, 923.25, 923.75, 924.25, - 924.75, 925.25, 925.75, 926.25, 926.75, - 927.25, 927.75 }; - private int[] twFreqTable = new int[] { - 0x00180E7D, //927.25MHz 10 - 0x00180E73, //924.75MHz 5 - 0x00180E6B, //922.75MHz 1 - 0x00180E75, //925.25MHz 6 - 0x00180E7F, //927.75MHz 11 - 0x00180E71, //924.25MHz 4 - 0x00180E79, //926.25MHz 8 - 0x00180E6D, //923.25MHz 2 - 0x00180E7B, //926.75MHz 9 - 0x00180E69, //922.25MHz 0 - 0x00180E77, //925.75MHz 7 - 0x00180E6F, //923.75MHz 3 - }; - private final int[] twFreqSortedIdx = new int[] { - 10, 5, 1, 6, 11, - 4, 8, 2, 9, 0, - 7, 3 }; - - private final int MYS_CHN_CNT = 8; - private final double[] MYSTableOfFreq = new double[] { - 919.75, 920.25, 920.75, 921.25, 921.75, - 922.25, 922.75, 923.25 }; - private final int[] mysFreqTable = new int[] { - 0x00180E5F, //919.75MHz - 0x00180E65, //921.25MHz - 0x00180E6B, //922.75MHz - 0x00180E61, //920.25MHz - 0x00180E67, //921.75MHz - 0x00180E6D, //923.25MHz - 0x00180E63, //920.75MHz - 0x00180E69, //922.25MHz - }; - private final int[] mysFreqSortedIdx = new int[] { - 0, 3, 6, 1, 4, - 7, 2, 5 }; - - private final int ZA_CHN_CNT = 16; - private final double[] ZATableOfFreq = new double[] { - 915.7, 915.9, 916.1, 916.3, 916.5, - 916.7, 916.9, 917.1, 917.3, 917.5, - 917.7, 917.9, 918.1, 918.3, 918.5, - 918.7 }; - private final int[] zaFreqTable = new int[] { - 0x003C23C5, //915.7 MHz - 0x003C23C7, //915.9 MHz - 0x003C23C9, //916.1 MHz - 0x003C23CB, //916.3 MHz - 0x003C23CD, //916.5 MHz - 0x003C23CF, //916.7 MHz - 0x003C23D1, //916.9 MHz - 0x003C23D3, //917.1 MHz - 0x003C23D5, //917.3 MHz - 0x003C23D7, //917.5 MHz - 0x003C23D9, //917.7 MHz - 0x003C23DB, //917.9 MHz - 0x003C23DD, //918.1 MHz - 0x003C23DF, //918.3 MHz - 0x003C23E1, //918.5 MHz - 0x003C23E3, //918.7 MHz - }; - private final int[] zaFreqSortedIdx = new int[] { - 0, 1, 2, 3, 4, - 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, - 15 }; - - final int ID_CHN_CNT = 4; - private final double[] IDTableOfFreq = new double[] { - 923.25, 923.75, 924.25, 924.75 }; - private final int[] indonesiaFreqTable = new int[] { - 0x00180E6D, //923.25 MHz - 0x00180E6F,//923.75 MHz - 0x00180E71,//924.25 MHz - 0x00180E73,//924.75 MHz - }; - private final int[] indonesiaFreqSortedIdx = new int[] { - 0, 1, 2, 3 }; - - private final int IL_CHN_CNT = 7; - private final double[] ILTableOfFreq = new double[] { - 915.25, 915.5, 915.75, 916.0, 916.25, // 4 - 916.5, 916.75 }; - private final int[] ilFreqTable = new int[] { - 0x00180E4D, //915.25 MHz - 0x00180E51, //916.25 MHz - 0x00180E4E, //915.5 MHz - 0x00180E52, //916.5 MHz - 0x00180E4F, //915.75 MHz - 0x00180E53, //916.75 MHz - 0x00180E50, //916.0 MHz - }; - private final int[] ilFreqSortedIdx = new int[] { - 0, 4, 1, 5, 2, 6, 3 }; - - private final int IL2019RW_CHN_CNT = 5; - private final double[] IL2019RWTableOfFreq = new double[] { - 915.9, 916.025, 916.15, 916.275, 916.4 }; - private final int[] il2019RwFreqTable = new int[] { - 0x003C23C7, //915.9 MHz - 0x003C23C8, //916.025 MHz - 0x003C23C9, //916.15 MHz - 0x003C23CA, //916.275 MHz - 0x003C23CB, //916.4 MHz - }; - private final int[] il2019RwFreqSortedIdx = new int[] { - 0, 4, 1, 2, 3 }; - - private final int PH_CHN_CNT = 8; - private final double[] PHTableOfFreq = new double[] { - 918.125, 918.375, 918.625, 918.875, 919.125, // 5 - 919.375, 919.625, 919.875 }; - private final int[] phFreqTable = new int[] { - 0x00301CB1, //918.125MHz Channel 0 - 0x00301CBB, //919.375MHz Channel 5 - 0x00301CB7, //918.875MHz Channel 3 - 0x00301CBF, //919.875MHz Channel 7 - 0x00301CB3, //918.375MHz Channel 1 - 0x00301CBD, //919.625MHz Channel 6 - 0x00301CB5, //918.625MHz Channel 2 - 0x00301CB9, //919.125MHz Channel 4 - }; - private final int[] phFreqSortedIdx = new int[] { - 0, 5, 3, 7, 1, 6, 2, 4 }; - - private int NZ_CHN_CNT = 11; - private final double[] NZTableOfFreq = new double[] { - 922.25, 922.75, 923.25, 923.75, 924.25,// 4 - 924.75, 925.25, 925.75, 926.25, 926.75,// 9 - 927.25 }; - private final int[] nzFreqTable = new int[] { - 0x00180E71, //924.25 MHz - 0x00180E77, //925.75 MHz - 0x00180E69, //922.25 MHz - 0x00180E7B, //926.75 MHz - 0x00180E6D, //923.25 MHz - 0x00180E7D, //927.25 MHz - 0x00180E75, //925.25 MHz - 0x00180E6B, //922.75 MHz - 0x00180E79, //926.25 MHz - 0x00180E6F, //923.75 MHz - 0x00180E73, //924.75 MHz - }; - private final int[] nzFreqSortedIdx = new int[] { - 4, 7, 0, 9, 2, 10, 6, 1, 8, 3, 5 }; - - private final int CN_CHN_CNT = 16; - private final double[] CHNTableOfFreq = new double[] { - 920.625, 920.875, 921.125, 921.375, 921.625, 921.875, 922.125, 922.375, 922.625, 922.875, - 923.125, 923.375, 923.625, 923.875, 924.125, 924.375 }; - private final int[] cnFreqTable = new int[] { - 0x00301CD3, //922.375MHz - 0x00301CD1, //922.125MHz - 0x00301CCD, //921.625MHz - 0x00301CC5, //920.625MHz - 0x00301CD9, //923.125MHz - 0x00301CE1, //924.125MHz - 0x00301CCB, //921.375MHz - 0x00301CC7, //920.875MHz - 0x00301CD7, //922.875MHz - 0x00301CD5, //922.625MHz - 0x00301CC9, //921.125MHz - 0x00301CDF, //923.875MHz - 0x00301CDD, //923.625MHz - 0x00301CDB, //923.375MHz - 0x00301CCF, //921.875MHz - 0x00301CE3, //924.375MHz - }; - private final int[] cnFreqSortedIdx = new int[] { - 7, 6, 4, 0, 10, - 14, 3, 1, 9, 8, - 2, 13, 12, 11, 5, - 15 }; - - private final int UH1_CHN_CNT = 10; - private final double[] UH1TableOfFreq = new double[] { - 915.25, 915.75, 916.25, 916.75, 917.25, - 917.75, 918.25, 918.75, 919.25, 919.75 }; - private final int[] uh1FreqTable = new int[] { - 0x00180E4F, //915.75 MHz - 0x00180E4D, //915.25 MHz - 0x00180E5D, //919.25 MHz - 0x00180E5B, //918.75 MHz - 0x00180E57, //917.75 MHz - 0x00180E55, //917.25 MHz - 0x00180E59, //918.25 MHz - 0x00180E51, //916.25 MHz - 0x00180E5F, //919.75 MHz - 0x00180E53, //916.75 MHz - }; - private final int[] uh1FreqSortedIdx = new int[] { - 1, 0, 8, 7, 5, - 4, 6, 2, 9, 3 }; - - private final int UH2_CHN_CNT = 15; - private final double[] UH2TableOfFreq = new double[] { - 920.25, 920.75, 921.25, 921.75, 922.25, // 4 - 922.75, 923.25, 923.75, 924.25, 924.75, // 9 - 925.25, 925.75, 926.25, 926.75, 927.25 }; - private final int[] uh2FreqTable = new int[] { - 0x00180E7B, //926.75 MHz - 0x00180E79, //926.25 MHz - 0x00180E7D, //927.25 MHz - 0x00180E61, //920.25 MHz - 0x00180E75, //925.25 MHz - 0x00180E67, //921.75 MHz - 0x00180E69, //922.25 MHz - 0x00180E73, //924.75 MHz - 0x00180E6F, //923.75 MHz - 0x00180E77, //925.75 MHz - 0x00180E71, //924.25 MHz - 0x00180E65, //921.25 MHz - 0x00180E63, //920.75 MHz - 0x00180E6B, //922.75 MHz - 0x00180E6D, //923.25 MHz - }; - private final int[] uh2FreqSortedIdx = new int[]{ - 13, 12, 14, 0, 10, - 3, 4, 9, 7, 11, - 8, 2, 1, 5, 6, }; - - private final int LH_CHN_CNT = 26; - private double[] LHTableOfFreq = new double[] { - 902.75, 903.25, 903.75, 904.25, 904.75, // 4 - 905.25, 905.75, 906.25, 906.75, 907.25, // 9 - 907.75, 908.25, 908.75, 909.25, 909.75, // 14 - 910.25, 910.75, 911.25, 911.75, 912.25, // 19 - 912.75, 913.25, 913.75, 914.25, 914.75, // 24 - 915.25, // 25 - //915.75, 916.25, 916.75, 917.25, 917.75, - //918.25, 918.75, 919.25, 919.75, 920.25, - //920.75, 921.25, 921.75, 922.25, 922.75, - //923.25, 923.75, 924.25, 924.75, 925.25, - //925.75, 926.25, 926.75, 927.25, - }; - private final int[] lhFreqTable = new int[] { - 0x00180E1B, //902.75 MHz - 0x00180E35, //909.25 MHz - 0x00180E1D, //903.25 MHz - 0x00180E37, //909.75 MHz - 0x00180E1F, //903.75 MHz - 0x00180E39, //910.25 MHz - 0x00180E21, //904.25 MHz - 0x00180E3B, //910.75 MHz - 0x00180E23, //904.75 MHz - 0x00180E3D, //911.25 MHz - 0x00180E25, //905.25 MHz - 0x00180E3F, //911.75 MHz - 0x00180E27, //905.75 MHz - 0x00180E41, //912.25 MHz - 0x00180E29, //906.25 MHz - 0x00180E43, //912.75 MHz - 0x00180E2B, //906.75 MHz - 0x00180E45, //913.25 MHz - 0x00180E2D, //907.25 MHz - 0x00180E47, //913.75 MHz - 0x00180E2F, //907.75 MHz - 0x00180E49, //914.25 MHz - 0x00180E31, //908.25 MHz - 0x00180E4B, //914.75 MHz - 0x00180E33, //908.75 MHz - 0x00180E4D, //915.25 MHz - - - //0x00180E4F, //915.75 MHz - //0x00180E7B, //926.75 MHz - //0x00180E79, //926.25 MHz - //0x00180E7D, //927.25 MHz - //0x00180E61, //920.25 MHz - //0x00180E5D, //919.25 MHz - //0x00180E5B, //918.75 MHz - //0x00180E57, //917.75 MHz - //0x00180E75, //925.25 MHz - //0x00180E67, //921.75 MHz - //0x00180E69, //922.25 MHz - //0x00180E55, //917.25 MHz - //0x00180E59, //918.25 MHz - //0x00180E51, //916.25 MHz - //0x00180E73, //924.75 MHz - //0x00180E5F, //919.75 MHz - //0x00180E53, //916.75 MHz - //0x00180E6F, //923.75 MHz - //0x00180E77, //925.75 MHz - //0x00180E71, //924.25 MHz - //0x00180E65, //921.25 MHz - //0x00180E63, //920.75 MHz - //0x00180E6B, //922.75 MHz - //0x00180E6D, //923.25 MHz - }; - private final int[] lhFreqSortedIdx = new int[] { - 0, 13, 1, 14, 2, - 15, 3, 16, 4, 17, - 5, 18, 6, 19, 7, - 20, 8, 21, 9, 22, - 10, 23, 11, 24, 12, - 25 }; - - private final int LH1_CHN_CNT = 14; - private double[] LH1TableOfFreq = new double[] { - 902.75, 903.25, 903.75, 904.25, 904.75, // 4 - 905.25, 905.75, 906.25, 906.75, 907.25, // 9 - 907.75, 908.25, 908.75, 909.25, // 13 - }; - private final int[] lh1FreqTable = new int[] { - 0x00180E1B, //902.75 MHz - 0x00180E35, //909.25 MHz - 0x00180E1D, //903.25 MHz - 0x00180E1F, //903.75 MHz - 0x00180E21, //904.25 MHz - 0x00180E23, //904.75 MHz - 0x00180E25, //905.25 MHz - 0x00180E27, //905.75 MHz - 0x00180E29, //906.25 MHz - 0x00180E2B, //906.75 MHz - 0x00180E2D, //907.25 MHz - 0x00180E2F, //907.75 MHz - 0x00180E31, //908.25 MHz - 0x00180E33, //908.75 MHz - }; - private final int[] lh1FreqSortedIdx = new int[] { - 0, 13, 1, 2, 3, - 4, 5, 6, 7, 8, - 9, 10, 11, 12 }; - - private final int LH2_CHN_CNT = 11; - private double[] LH2TableOfFreq = new double[] { - 909.75, 910.25, 910.75, 911.25, 911.75, // 4 - 912.25, 912.75, 913.25, 913.75, 914.25, // 9 - 914.75 }; - private final int[] lh2FreqTable = new int[] { - 0x00180E37, //909.75 MHz - 0x00180E39, //910.25 MHz - 0x00180E3B, //910.75 MHz - 0x00180E3D, //911.25 MHz - 0x00180E3F, //911.75 MHz - 0x00180E41, //912.25 MHz - 0x00180E43, //912.75 MHz - 0x00180E45, //913.25 MHz - 0x00180E47, //913.75 MHz - 0x00180E49, //914.25 MHz - 0x00180E4B, //914.75 MHz - }; - private final int[] lh2FreqSortedIdx = new int[] { - 0, 1, 2, 3, 4, - 5, 6, 7, 8, 9, - 10 }; - - private final int ETSI_CHN_CNT = 4; - private final double[] ETSITableOfFreq = new double[] { - 865.70, 866.30, 866.90, 867.50 }; - private final int[] etsiFreqTable = new int[] { - 0x003C21D1, //865.700MHz - 0x003C21D7, //866.300MHz - 0x003C21DD, //866.900MHz - 0x003C21E3, //867.500MHz + private final int BR3_CHN_CNT = 9; + private final double[] BR3TableOfFreq = new double[]{ + 902.75, 903.25, 903.75, 904.25, 904.75, // 4 + 905.25, 905.75, 906.25, 906.75}; + private final int[] br3FreqTable = new int[]{ + 0x00180E1D, //903.25 MHz + 0x00180E21, //904.25 MHz + 0x00180E25, //905.25 MHz + 0x00180E23, //904.75 MHz + 0x00180E2B, //906.75 MHz + 0x00180E1F, //903.75 MHz + 0x00180E27, //905.75 MHz + 0x00180E29, //906.25 MHz + 0x00180E1B, //902.75 MHz + }; + private final int[] br3FreqSortedIdx = new int[]{ + 1, 3, 5, 4, 8, + 2, 6, 7, 0}; + + private final int BR4_CHN_CNT = 4; + private final double[] BR4TableOfFreq = new double[]{ + 902.75, 903.25, 903.75, 904.25}; + private final int[] br4FreqTable = new int[]{ + 0x00180E1D, //903.25 MHz + 0x00180E21, //904.25 MHz + 0x00180E1F, //903.75 MHz + 0x00180E1B, //902.75 MHz + }; + private final int[] br4FreqSortedIdx = new int[]{ + 1, 3, 2, 0}; + + private final int BR5_CHN_CNT = 14; + private final double[] BR5TableOfFreq = new double[]{ + 917.75, 918.25, 918.75, 919.25, 919.75, // 4 + 920.25, 920.75, 921.25, 921.75, 922.25, // 9 + 922.75, 923.25, 923.75, 924.25}; + private final int[] br5FreqTable = new int[]{ + 0x00180E61, //920.25 MHz + 0x00180E5D, //919.25 MHz + 0x00180E5B, //918.75 MHz + 0x00180E57, //917.75 MHz + 0x00180E67, //921.75 MHz + 0x00180E69, //922.25 MHz + 0x00180E59, //918.25 MHz + 0x00180E5F, //919.75 MHz + 0x00180E6F, //923.75 MHz + 0x00180E71, //924.25 MHz + 0x00180E65, //921.25 MHz + 0x00180E63, //920.75 MHz + 0x00180E6B, //922.75 MHz + 0x00180E6D, //923.25 MHz + }; + private final int[] br5FreqSortedIdx = new int[]{ + 5, 3, 2, 0, 8, + 9, 1, 4, 12, 13, + 7, 6, 10, 11}; + + private final int HK_CHN_CNT = 8; + private final double[] HKTableOfFreq = new double[]{ + 920.75, 921.25, 921.75, 922.25, 922.75, + 923.25, 923.75, 924.25}; + private final int[] hkFreqTable = new int[]{ + 0x00180E63, //920.75MHz + 0x00180E69, //922.25MHz + 0x00180E71, //924.25MHz + 0x00180E65, //921.25MHz + 0x00180E6B, //922.75MHz + 0x00180E6D, //923.25MHz + 0x00180E6F, //923.75MHz + 0x00180E67, //921.75MHz + }; + private final int[] hkFreqSortedIdx = new int[]{ + 0, 3, 7, 1, 4, + 5, 6, 2}; + + private final int BD_CHN_CNT = 4; + private final double[] BDTableOfFreq = new double[]{ + 925.25, 925.75, 926.25, 926.75}; + private final int[] bdFreqTable = new int[]{ + 0x00180E75, //925.25MHz + 0x00180E77, //925.75MHz + 0x00180E79, //926.25MHz + 0x00180E7B, //926.75MHz + }; + private final int[] bdFreqSortedIdx = new int[]{ + 0, 3, 1, 2}; + + private final int TW_CHN_CNT = 12; + private final double[] TWTableOfFreq = new double[]{ + 922.25, 922.75, 923.25, 923.75, 924.25, + 924.75, 925.25, 925.75, 926.25, 926.75, + 927.25, 927.75}; + private int[] twFreqTable = new int[]{ + 0x00180E7D, //927.25MHz 10 + 0x00180E73, //924.75MHz 5 + 0x00180E6B, //922.75MHz 1 + 0x00180E75, //925.25MHz 6 + 0x00180E7F, //927.75MHz 11 + 0x00180E71, //924.25MHz 4 + 0x00180E79, //926.25MHz 8 + 0x00180E6D, //923.25MHz 2 + 0x00180E7B, //926.75MHz 9 + 0x00180E69, //922.25MHz 0 + 0x00180E77, //925.75MHz 7 + 0x00180E6F, //923.75MHz 3 + }; + private final int[] twFreqSortedIdx = new int[]{ + 10, 5, 1, 6, 11, + 4, 8, 2, 9, 0, + 7, 3}; + + private final int MYS_CHN_CNT = 8; + private final double[] MYSTableOfFreq = new double[]{ + 919.75, 920.25, 920.75, 921.25, 921.75, + 922.25, 922.75, 923.25}; + private final int[] mysFreqTable = new int[]{ + 0x00180E5F, //919.75MHz + 0x00180E65, //921.25MHz + 0x00180E6B, //922.75MHz + 0x00180E61, //920.25MHz + 0x00180E67, //921.75MHz + 0x00180E6D, //923.25MHz + 0x00180E63, //920.75MHz + 0x00180E69, //922.25MHz + }; + private final int[] mysFreqSortedIdx = new int[]{ + 0, 3, 6, 1, 4, + 7, 2, 5}; + + private final int ZA_CHN_CNT = 16; + private final double[] ZATableOfFreq = new double[]{ + 915.7, 915.9, 916.1, 916.3, 916.5, + 916.7, 916.9, 917.1, 917.3, 917.5, + 917.7, 917.9, 918.1, 918.3, 918.5, + 918.7}; + private final int[] zaFreqTable = new int[]{ + 0x003C23C5, //915.7 MHz + 0x003C23C7, //915.9 MHz + 0x003C23C9, //916.1 MHz + 0x003C23CB, //916.3 MHz + 0x003C23CD, //916.5 MHz + 0x003C23CF, //916.7 MHz + 0x003C23D1, //916.9 MHz + 0x003C23D3, //917.1 MHz + 0x003C23D5, //917.3 MHz + 0x003C23D7, //917.5 MHz + 0x003C23D9, //917.7 MHz + 0x003C23DB, //917.9 MHz + 0x003C23DD, //918.1 MHz + 0x003C23DF, //918.3 MHz + 0x003C23E1, //918.5 MHz + 0x003C23E3, //918.7 MHz + }; + private final int[] zaFreqSortedIdx = new int[]{ + 0, 1, 2, 3, 4, + 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, + 15}; + + final int ID_CHN_CNT = 4; + private final double[] IDTableOfFreq = new double[]{ + 923.25, 923.75, 924.25, 924.75}; + private final int[] indonesiaFreqTable = new int[]{ + 0x00180E6D, //923.25 MHz + 0x00180E6F,//923.75 MHz + 0x00180E71,//924.25 MHz + 0x00180E73,//924.75 MHz + }; + private final int[] indonesiaFreqSortedIdx = new int[]{ + 0, 1, 2, 3}; + + private final int IL_CHN_CNT = 7; + private final double[] ILTableOfFreq = new double[]{ + 915.25, 915.5, 915.75, 916.0, 916.25, // 4 + 916.5, 916.75}; + private final int[] ilFreqTable = new int[]{ + 0x00180E4D, //915.25 MHz + 0x00180E51, //916.25 MHz + 0x00180E4E, //915.5 MHz + 0x00180E52, //916.5 MHz + 0x00180E4F, //915.75 MHz + 0x00180E53, //916.75 MHz + 0x00180E50, //916.0 MHz + }; + private final int[] ilFreqSortedIdx = new int[]{ + 0, 4, 1, 5, 2, 6, 3}; + + private final int IL2019RW_CHN_CNT = 5; + private final double[] IL2019RWTableOfFreq = new double[]{ + 915.9, 916.025, 916.15, 916.275, 916.4}; + private final int[] il2019RwFreqTable = new int[]{ + 0x003C23C7, //915.9 MHz + 0x003C23C8, //916.025 MHz + 0x003C23C9, //916.15 MHz + 0x003C23CA, //916.275 MHz + 0x003C23CB, //916.4 MHz + }; + private final int[] il2019RwFreqSortedIdx = new int[]{ + 0, 4, 1, 2, 3}; + + private final int PH_CHN_CNT = 8; + private final double[] PHTableOfFreq = new double[]{ + 918.125, 918.375, 918.625, 918.875, 919.125, // 5 + 919.375, 919.625, 919.875}; + private final int[] phFreqTable = new int[]{ + 0x00301CB1, //918.125MHz Channel 0 + 0x00301CBB, //919.375MHz Channel 5 + 0x00301CB7, //918.875MHz Channel 3 + 0x00301CBF, //919.875MHz Channel 7 + 0x00301CB3, //918.375MHz Channel 1 + 0x00301CBD, //919.625MHz Channel 6 + 0x00301CB5, //918.625MHz Channel 2 + 0x00301CB9, //919.125MHz Channel 4 + }; + private final int[] phFreqSortedIdx = new int[]{ + 0, 5, 3, 7, 1, 6, 2, 4}; + + private int NZ_CHN_CNT = 11; + private final double[] NZTableOfFreq = new double[]{ + 922.25, 922.75, 923.25, 923.75, 924.25,// 4 + 924.75, 925.25, 925.75, 926.25, 926.75,// 9 + 927.25}; + private final int[] nzFreqTable = new int[]{ + 0x00180E71, //924.25 MHz + 0x00180E77, //925.75 MHz + 0x00180E69, //922.25 MHz + 0x00180E7B, //926.75 MHz + 0x00180E6D, //923.25 MHz + 0x00180E7D, //927.25 MHz + 0x00180E75, //925.25 MHz + 0x00180E6B, //922.75 MHz + 0x00180E79, //926.25 MHz + 0x00180E6F, //923.75 MHz + 0x00180E73, //924.75 MHz + }; + private final int[] nzFreqSortedIdx = new int[]{ + 4, 7, 0, 9, 2, 10, 6, 1, 8, 3, 5}; + + private final int CN_CHN_CNT = 16; + private final double[] CHNTableOfFreq = new double[]{ + 920.625, 920.875, 921.125, 921.375, 921.625, 921.875, 922.125, 922.375, 922.625, 922.875, + 923.125, 923.375, 923.625, 923.875, 924.125, 924.375}; + private final int[] cnFreqTable = new int[]{ + 0x00301CD3, //922.375MHz + 0x00301CD1, //922.125MHz + 0x00301CCD, //921.625MHz + 0x00301CC5, //920.625MHz + 0x00301CD9, //923.125MHz + 0x00301CE1, //924.125MHz + 0x00301CCB, //921.375MHz + 0x00301CC7, //920.875MHz + 0x00301CD7, //922.875MHz + 0x00301CD5, //922.625MHz + 0x00301CC9, //921.125MHz + 0x00301CDF, //923.875MHz + 0x00301CDD, //923.625MHz + 0x00301CDB, //923.375MHz + 0x00301CCF, //921.875MHz + 0x00301CE3, //924.375MHz + }; + private final int[] cnFreqSortedIdx = new int[]{ + 7, 6, 4, 0, 10, + 14, 3, 1, 9, 8, + 2, 13, 12, 11, 5, + 15}; + + private final int UH1_CHN_CNT = 10; + private final double[] UH1TableOfFreq = new double[]{ + 915.25, 915.75, 916.25, 916.75, 917.25, + 917.75, 918.25, 918.75, 919.25, 919.75}; + private final int[] uh1FreqTable = new int[]{ + 0x00180E4F, //915.75 MHz + 0x00180E4D, //915.25 MHz + 0x00180E5D, //919.25 MHz + 0x00180E5B, //918.75 MHz + 0x00180E57, //917.75 MHz + 0x00180E55, //917.25 MHz + 0x00180E59, //918.25 MHz + 0x00180E51, //916.25 MHz + 0x00180E5F, //919.75 MHz + 0x00180E53, //916.75 MHz + }; + private final int[] uh1FreqSortedIdx = new int[]{ + 1, 0, 8, 7, 5, + 4, 6, 2, 9, 3}; + + private final int UH2_CHN_CNT = 15; + private final double[] UH2TableOfFreq = new double[]{ + 920.25, 920.75, 921.25, 921.75, 922.25, // 4 + 922.75, 923.25, 923.75, 924.25, 924.75, // 9 + 925.25, 925.75, 926.25, 926.75, 927.25}; + private final int[] uh2FreqTable = new int[]{ + 0x00180E7B, //926.75 MHz + 0x00180E79, //926.25 MHz + 0x00180E7D, //927.25 MHz + 0x00180E61, //920.25 MHz + 0x00180E75, //925.25 MHz + 0x00180E67, //921.75 MHz + 0x00180E69, //922.25 MHz + 0x00180E73, //924.75 MHz + 0x00180E6F, //923.75 MHz + 0x00180E77, //925.75 MHz + 0x00180E71, //924.25 MHz + 0x00180E65, //921.25 MHz + 0x00180E63, //920.75 MHz + 0x00180E6B, //922.75 MHz + 0x00180E6D, //923.25 MHz + }; + private final int[] uh2FreqSortedIdx = new int[]{ + 13, 12, 14, 0, 10, + 3, 4, 9, 7, 11, + 8, 2, 1, 5, 6,}; + + private final int LH_CHN_CNT = 26; + private double[] LHTableOfFreq = new double[]{ + 902.75, 903.25, 903.75, 904.25, 904.75, // 4 + 905.25, 905.75, 906.25, 906.75, 907.25, // 9 + 907.75, 908.25, 908.75, 909.25, 909.75, // 14 + 910.25, 910.75, 911.25, 911.75, 912.25, // 19 + 912.75, 913.25, 913.75, 914.25, 914.75, // 24 + 915.25, // 25 + //915.75, 916.25, 916.75, 917.25, 917.75, + //918.25, 918.75, 919.25, 919.75, 920.25, + //920.75, 921.25, 921.75, 922.25, 922.75, + //923.25, 923.75, 924.25, 924.75, 925.25, + //925.75, 926.25, 926.75, 927.25, + }; + private final int[] lhFreqTable = new int[]{ + 0x00180E1B, //902.75 MHz + 0x00180E35, //909.25 MHz + 0x00180E1D, //903.25 MHz + 0x00180E37, //909.75 MHz + 0x00180E1F, //903.75 MHz + 0x00180E39, //910.25 MHz + 0x00180E21, //904.25 MHz + 0x00180E3B, //910.75 MHz + 0x00180E23, //904.75 MHz + 0x00180E3D, //911.25 MHz + 0x00180E25, //905.25 MHz + 0x00180E3F, //911.75 MHz + 0x00180E27, //905.75 MHz + 0x00180E41, //912.25 MHz + 0x00180E29, //906.25 MHz + 0x00180E43, //912.75 MHz + 0x00180E2B, //906.75 MHz + 0x00180E45, //913.25 MHz + 0x00180E2D, //907.25 MHz + 0x00180E47, //913.75 MHz + 0x00180E2F, //907.75 MHz + 0x00180E49, //914.25 MHz + 0x00180E31, //908.25 MHz + 0x00180E4B, //914.75 MHz + 0x00180E33, //908.75 MHz + 0x00180E4D, //915.25 MHz + + + //0x00180E4F, //915.75 MHz + //0x00180E7B, //926.75 MHz + //0x00180E79, //926.25 MHz + //0x00180E7D, //927.25 MHz + //0x00180E61, //920.25 MHz + //0x00180E5D, //919.25 MHz + //0x00180E5B, //918.75 MHz + //0x00180E57, //917.75 MHz + //0x00180E75, //925.25 MHz + //0x00180E67, //921.75 MHz + //0x00180E69, //922.25 MHz + //0x00180E55, //917.25 MHz + //0x00180E59, //918.25 MHz + //0x00180E51, //916.25 MHz + //0x00180E73, //924.75 MHz + //0x00180E5F, //919.75 MHz + //0x00180E53, //916.75 MHz + //0x00180E6F, //923.75 MHz + //0x00180E77, //925.75 MHz + //0x00180E71, //924.25 MHz + //0x00180E65, //921.25 MHz + //0x00180E63, //920.75 MHz + //0x00180E6B, //922.75 MHz + //0x00180E6D, //923.25 MHz + }; + private final int[] lhFreqSortedIdx = new int[]{ + 0, 13, 1, 14, 2, + 15, 3, 16, 4, 17, + 5, 18, 6, 19, 7, + 20, 8, 21, 9, 22, + 10, 23, 11, 24, 12, + 25}; + + private final int LH1_CHN_CNT = 14; + private double[] LH1TableOfFreq = new double[]{ + 902.75, 903.25, 903.75, 904.25, 904.75, // 4 + 905.25, 905.75, 906.25, 906.75, 907.25, // 9 + 907.75, 908.25, 908.75, 909.25, // 13 + }; + private final int[] lh1FreqTable = new int[]{ + 0x00180E1B, //902.75 MHz + 0x00180E35, //909.25 MHz + 0x00180E1D, //903.25 MHz + 0x00180E1F, //903.75 MHz + 0x00180E21, //904.25 MHz + 0x00180E23, //904.75 MHz + 0x00180E25, //905.25 MHz + 0x00180E27, //905.75 MHz + 0x00180E29, //906.25 MHz + 0x00180E2B, //906.75 MHz + 0x00180E2D, //907.25 MHz + 0x00180E2F, //907.75 MHz + 0x00180E31, //908.25 MHz + 0x00180E33, //908.75 MHz + }; + private final int[] lh1FreqSortedIdx = new int[]{ + 0, 13, 1, 2, 3, + 4, 5, 6, 7, 8, + 9, 10, 11, 12}; + + private final int LH2_CHN_CNT = 11; + private double[] LH2TableOfFreq = new double[]{ + 909.75, 910.25, 910.75, 911.25, 911.75, // 4 + 912.25, 912.75, 913.25, 913.75, 914.25, // 9 + 914.75}; + private final int[] lh2FreqTable = new int[]{ + 0x00180E37, //909.75 MHz + 0x00180E39, //910.25 MHz + 0x00180E3B, //910.75 MHz + 0x00180E3D, //911.25 MHz + 0x00180E3F, //911.75 MHz + 0x00180E41, //912.25 MHz + 0x00180E43, //912.75 MHz + 0x00180E45, //913.25 MHz + 0x00180E47, //913.75 MHz + 0x00180E49, //914.25 MHz + 0x00180E4B, //914.75 MHz + }; + private final int[] lh2FreqSortedIdx = new int[]{ + 0, 1, 2, 3, 4, + 5, 6, 7, 8, 9, + 10}; + + private final int ETSI_CHN_CNT = 4; + private final double[] ETSITableOfFreq = new double[]{ + 865.70, 866.30, 866.90, 867.50}; + private final int[] etsiFreqTable = new int[]{ + 0x003C21D1, //865.700MHz + 0x003C21D7, //866.300MHz + 0x003C21DD, //866.900MHz + 0x003C21E3, //867.500MHz + }; + private final int[] etsiFreqSortedIdx = new int[]{ + 0, 1, 2, 3}; + + private final int IDA_CHN_CNT = 3; + private final double[] IDATableOfFreq = new double[]{ + 865.70, 866.30, 866.90}; + private final int[] indiaFreqTable = new int[]{ + 0x003C21D1, //865.700MHz + 0x003C21D7, //866.300MHz + 0x003C21DD, //866.900MHz + }; + private final int[] indiaFreqSortedIdx = new int[]{ + 0, 1, 2}; + + private final int KR_CHN_CNT = 19; + private final double[] KRTableOfFreq = new double[]{ + 910.20, 910.40, 910.60, 910.80, 911.00, 911.20, 911.40, 911.60, 911.80, 912.00, + 912.20, 912.40, 912.60, 912.80, 913.00, 913.20, 913.40, 913.60, 913.80}; + private int[] krFreqTable = new int[]{ + 0x003C23A8, //912.8MHz 13 + 0x003C23A0, //912.0MHz 9 + 0x003C23AC, //913.2MHz 15 + 0x003C239E, //911.8MHz 8 + 0x003C23A4, //912.4MHz 11 + 0x003C23B2, //913.8MHz 18 + 0x003C2392, //910.6MHz 2 + 0x003C23B0, //913.6MHz 17 + 0x003C2390, //910.4MHz 1 + 0x003C239C, //911.6MHz 7 + 0x003C2396, //911.0MHz 4 + 0x003C23A2, //912.2MHz 10 + 0x003C238E, //910.2MHz 0 + 0x003C23A6, //912.6MHz 12 + 0x003C2398, //911.2MHz 5 + 0x003C2394, //910.8MHz 3 + 0x003C23AE, //913.4MHz 16 + 0x003C239A, //911.4MHz 6 + 0x003C23AA, //913.0MHz 14 }; - private final int[] etsiFreqSortedIdx = new int[] { - 0, 1, 2, 3 }; - - private final int IDA_CHN_CNT = 3; - private final double[] IDATableOfFreq = new double[] { - 865.70, 866.30, 866.90 }; - private final int[] indiaFreqTable = new int[] { - 0x003C21D1, //865.700MHz - 0x003C21D7, //866.300MHz - 0x003C21DD, //866.900MHz - }; - private final int[] indiaFreqSortedIdx = new int[] { - 0, 1, 2 }; - - private final int KR_CHN_CNT = 19; - private final double[] KRTableOfFreq = new double[] { - 910.20, 910.40, 910.60, 910.80, 911.00, 911.20, 911.40, 911.60, 911.80, 912.00, - 912.20, 912.40, 912.60, 912.80, 913.00, 913.20, 913.40, 913.60, 913.80 }; - private int[] krFreqTable = new int[] { - 0x003C23A8, //912.8MHz 13 - 0x003C23A0, //912.0MHz 9 - 0x003C23AC, //913.2MHz 15 - 0x003C239E, //911.8MHz 8 - 0x003C23A4, //912.4MHz 11 - 0x003C23B2, //913.8MHz 18 - 0x003C2392, //910.6MHz 2 - 0x003C23B0, //913.6MHz 17 - 0x003C2390, //910.4MHz 1 - 0x003C239C, //911.6MHz 7 - 0x003C2396, //911.0MHz 4 - 0x003C23A2, //912.2MHz 10 - 0x003C238E, //910.2MHz 0 - 0x003C23A6, //912.6MHz 12 - 0x003C2398, //911.2MHz 5 - 0x003C2394, //910.8MHz 3 - 0x003C23AE, //913.4MHz 16 - 0x003C239A, //911.4MHz 6 - 0x003C23AA, //913.0MHz 14 + private final int[] krFreqSortedIdx = new int[]{ + 13, 9, 15, 8, 11, + 18, 2, 17, 1, 7, + 4, 10, 0, 12, 5, + 3, 16, 6, 14}; + + private final int KR2017RW_CHN_CNT = 6; + private final double[] KR2017RwTableOfFreq = new double[]{ + 917.30, 917.90, 918.50, 919.10, 919.70, 920.30}; + private int[] kr2017RwFreqTable = new int[]{ + 0x003C23D5, // 917.3 -> 917.25 MHz Channel 1 + 0x003C23DB, //917.9 -> 918 MHz Channel 2 + 0x003C23E1, //918.5 MHz Channel 3 + 0x003C23E7, //919.1 -> 919 MHz Channel 4 + 0x003C23ED, //919.7 -> 919.75 MHz Channel 5 + 0x003C23F3 // 920.3 -> 920.25 MHz Channel 6 }; - private final int[] krFreqSortedIdx = new int[] { - 13, 9, 15, 8, 11, - 18, 2, 17, 1, 7, - 4, 10, 0, 12, 5, - 3, 16, 6, 14 }; - - private final int KR2017RW_CHN_CNT = 6; - private final double[] KR2017RwTableOfFreq = new double[] { - 917.30, 917.90, 918.50, 919.10, 919.70, 920.30 }; - private int[] kr2017RwFreqTable = new int[] { - 0x003C23D5, // 917.3 -> 917.25 MHz Channel 1 - 0x003C23DB, //917.9 -> 918 MHz Channel 2 - 0x003C23E1, //918.5 MHz Channel 3 - 0x003C23E7, //919.1 -> 919 MHz Channel 4 - 0x003C23ED, //919.7 -> 919.75 MHz Channel 5 - 0x003C23F3 // 920.3 -> 920.25 MHz Channel 6 + private final int[] kr2017RwFreqSortedIdx = new int[]{ + 3, 0, 5, 1, 4, 2}; + + private final int JPN2012_CHN_CNT = 4; + private final double[] JPN2012TableOfFreq = new double[]{ + 916.80, 918.00, 919.20, 920.40}; + private final int[] jpn2012FreqTable = new int[]{ + 0x003C23D0, //916.800MHz Channel 1 + 0x003C23DC, //918.000MHz Channel 2 + 0x003C23E8, //919.200MHz Channel 3 + 0x003C23F4, //920.400MHz Channel 4 + //0x003C23F6, //920.600MHz Channel 5 + //0x003C23F8, //920.800MHz Channel 6 }; - private final int[] kr2017RwFreqSortedIdx = new int[] { - 3, 0, 5, 1, 4, 2 }; - - private final int JPN2012_CHN_CNT = 4; - private final double[] JPN2012TableOfFreq = new double[] { - 916.80, 918.00, 919.20, 920.40 }; - private final int[] jpn2012FreqTable = new int[] { - 0x003C23D0, //916.800MHz Channel 1 - 0x003C23DC, //918.000MHz Channel 2 - 0x003C23E8, //919.200MHz Channel 3 - 0x003C23F4, //920.400MHz Channel 4 - //0x003C23F6, //920.600MHz Channel 5 - //0x003C23F8, //920.800MHz Channel 6 - }; - private final int[] jpn2012FreqSortedIdx = new int[] { - 0, 1, 2, 3 }; - - private final int JPN2012A_CHN_CNT = 6; - private final double[] JPN2012ATableOfFreq = new double[] { - 916.80, 918.00, 919.20, 920.40, 920.60, 920.80 }; - private final int[] jpn2012AFreqTable = new int[] { - 0x003C23D0, //916.800MHz Channel 1 - 0x003C23DC, //918.000MHz Channel 2 - 0x003C23E8, //919.200MHz Channel 3 - 0x003C23F4, //920.400MHz Channel 4 - 0x003C23F6, //920.600MHz Channel 5 - 0x003C23F8, //920.800MHz Channel 6 - }; - private final int[] jpn2012AFreqSortedIdx = new int[] { - 0, 1, 2, 3, 4, 5 }; - - private final int ETSIUPPERBAND_CHN_CNT = 4; - private final double[] ETSIUPPERBANDTableOfFreq = new double[] { - 916.3, 917.5, 918.7, 919.9 }; - private final int[] etsiupperbandFreqTable = new int[] { - 0x003C23CB, //916.3 MHz - 0x003C23D7, //917.5 MHz - 0x003C23E3, //918.7 MHz - 0x003C23EF, //919.9 MHz + private final int[] jpn2012FreqSortedIdx = new int[]{ + 0, 1, 2, 3}; + + private final int JPN2012A_CHN_CNT = 6; + private final double[] JPN2012ATableOfFreq = new double[]{ + 916.80, 918.00, 919.20, 920.40, 920.60, 920.80}; + private final int[] jpn2012AFreqTable = new int[]{ + 0x003C23D0, //916.800MHz Channel 1 + 0x003C23DC, //918.000MHz Channel 2 + 0x003C23E8, //919.200MHz Channel 3 + 0x003C23F4, //920.400MHz Channel 4 + 0x003C23F6, //920.600MHz Channel 5 + 0x003C23F8, //920.800MHz Channel 6 }; - private final int[] etsiupperbandFreqSortedIdx = new int[] { - 0, 1, 2, 3 }; - - private final int VN1_CHN_CNT = 3; - private final double[] VN1TableOfFreq = new double[] { - 866.30, 866.90, 867.50 }; - private final int[] vietnam1FreqTable = new int[] { - 0x003C21D7, //866.300MHz - 0x003C21DD, //866.900MHz - 0x003C21E3, //867.500MHz + private final int[] jpn2012AFreqSortedIdx = new int[]{ + 0, 1, 2, 3, 4, 5}; + + private final int ETSIUPPERBAND_CHN_CNT = 4; + private final double[] ETSIUPPERBANDTableOfFreq = new double[]{ + 916.3, 917.5, 918.7, 919.9}; + private final int[] etsiupperbandFreqTable = new int[]{ + 0x003C23CB, //916.3 MHz + 0x003C23D7, //917.5 MHz + 0x003C23E3, //918.7 MHz + 0x003C23EF, //919.9 MHz }; - private final int[] vietnam1FreqSortedIdx = new int[] { - 0, 1, 2 }; - - private final int VN2_CHN_CNT = 8; - private final double[] VN2TableOfFreq = new double[] { - 918.75, 919.25, 919.75, 920.25, 920.75, 921.25, 921.75, 922.25 }; - private final int[] vietnam2FreqTable = new int[] { - 0x00180E61, //920.25 MHz - 0x00180E5D, //919.25 MHz - 0x00180E5B, //918.75 MHz - 0x00180E67, //921.75 MHz - 0x00180E69, //922.25 MHz - 0x00180E5F, //919.75 MHz - 0x00180E65, //921.25 MHz - 0x00180E63, //920.75 MHz + private final int[] etsiupperbandFreqSortedIdx = new int[]{ + 0, 1, 2, 3}; + + private final int VN1_CHN_CNT = 3; + private final double[] VN1TableOfFreq = new double[]{ + 866.30, 866.90, 867.50}; + private final int[] vietnam1FreqTable = new int[]{ + 0x003C21D7, //866.300MHz + 0x003C21DD, //866.900MHz + 0x003C21E3, //867.500MHz }; - private final int[] vietnam2FreqSortedIdx = new int[] { - 3, 1, 0, 6, 7, 2, 5, 4 }; - - private final int VN3_CHN_CNT = 4; - private final double[] VN3TableOfFreq = new double[] { - 920.75, 921.25, 921.75, 922.25 }; - private final int[] vietnam3FreqTable = new int[] { - 0x00180E67, //921.75 MHz - 0x00180E69, //922.25 MHz - 0x00180E65, //921.25 MHz - 0x00180E63, //920.75 MHz + private final int[] vietnam1FreqSortedIdx = new int[]{ + 0, 1, 2}; + + private final int VN2_CHN_CNT = 8; + private final double[] VN2TableOfFreq = new double[]{ + 918.75, 919.25, 919.75, 920.25, 920.75, 921.25, 921.75, 922.25}; + private final int[] vietnam2FreqTable = new int[]{ + 0x00180E61, //920.25 MHz + 0x00180E5D, //919.25 MHz + 0x00180E5B, //918.75 MHz + 0x00180E67, //921.75 MHz + 0x00180E69, //922.25 MHz + 0x00180E5F, //919.75 MHz + 0x00180E65, //921.25 MHz + 0x00180E63, //920.75 MHz }; - private final int[] vietnam3FreqSortedIdx = new int[] { - 2, 3, 1, 0 }; + private final int[] vietnam2FreqSortedIdx = new int[]{ + 3, 1, 0, 6, 7, 2, 5, 4}; + + private final int VN3_CHN_CNT = 4; + private final double[] VN3TableOfFreq = new double[]{ + 920.75, 921.25, 921.75, 922.25}; + private final int[] vietnam3FreqTable = new int[]{ + 0x00180E67, //921.75 MHz + 0x00180E69, //922.25 MHz + 0x00180E65, //921.25 MHz + 0x00180E63, //920.75 MHz + }; + private final int[] vietnam3FreqSortedIdx = new int[]{ + 2, 3, 1, 0}; + + public final int iCountryEnumInfoColumn = 7; + public String[] strCountryEnumInfo = { + "1", "Albania1", "-1", "4", "Fixed", "600", "865.7", + "2", "Albania2", "-2 RW", "23", "Hop", "250", "915.25", + "3", "Algeria1", "-1", "4", "Fixed", "600", "871.6", + "4", "Algeria2", "-1", "4", "Fixed", "600", "881.6", + "5", "Algeria3", "-9", "3", "Fixed", "1200", "916.3", + "6", "Algeria4", "-7", "2", "Fixed", "500", "925.25", + "7", "Argentina", "-2 RW", "50", "Hop", "500", "902.75", + "8", "Armenia", "-1", "4", "Fixed", "600", "865.7", + "9", "Australia1", "-2 AS", "10", "Hop", "500", "920.75", + "10", "Australia2", "-2 AS", "14", "Hop", "500", "918.75", + "11", "Austria1", "-1", "4", "Fixed", "600", "865.7", + "12", "Austria2", "-9", "3", "Fixed", "1200", "916.3", + "13", "Azerbaijan", "-1", "4", "Fixed", "600", "865.7", + "14", "Bahrain", "-1", "4", "Fixed", "600", "865.7", + "15", "Bangladesh", "-1", "4", "Fixed", "600", "865.7", + "16", "Belarus", "-1", "4", "Fixed", "600", "865.7", + "17", "Belgium1", "-1", "4", "Fixed", "600", "865.7", + "18", "Belgium2", "-9", "3", "Fixed", "1200", "916.3", + "19", "Bolivia", "-2", "50", "Hop", "500", "902.75", + "20", "Bosnia", "-1", "4", "Fixed", "600", "865.7", + "21", "Botswana", "-1", "4", "Fixed", "600", "865.7", + "22", "Brazil1", "-2 RW", "9", "Fixed", "500", "902.75", + "23", "Brazil2", "-2 RW", "24", "Fixed", "500", "915.75", + "24", "Brunei1", "-1", "4", "Fixed", "600", "865.7", + "25", "Brunei2", "-7", "7", "Fixed", "250", "923.25", + "26", "Blgaria1", "-1", "4", "Fixed", "600", "865.7", + "27", "Bulgaria2", "-9", "3", "Fixed", "1200", "916.3", + "28", "Cambodia", "-7", "16", "Hop", "250", "920.625", + "29", "Cameroon", "-1", "4", "Fixed", "600", "865.7", + "30", "Canada", "-2", "50", "Hop", "500", "902.75", + "31", "Chile1", "-2 RW", "3", "Fixed", "1200", "916.3", + "32", "Chile2", "-2 RW", "24", "Hop", "500", "915.75", + "33", "Chile3", "-2 RW", "4", "Hop", "500", "925.75", + "34", "China", "-7", "16", "Hop", "250", "920.625", + "35", "Colombia", "-2 RW", "50", "Hop", "500", "902.75", + "36", "Congo", "-1", "4", "Fixed", "600", "865.7", + "37", "CostaRica", "-2 RW", "50", "Hop", "500", "902.75", + "38", "Cotedlvoire", "-1", "4", "Fixed", "600", "865.7", + "39", "Croatia", "-1", "4", "Fixed", "600", "865.7", + "40", "Cuba", "-2 RW", "50", "Hop", "500", "902.75", + "41", "Cyprus1", "-1", "4", "Fixed", "600", "865.7", + "42", "Cyprus2", "-9", "3", "Fixed", "1200", "916.3", + "43", "Czech1", "-1", "4", "Fixed", "600", "865.7", + "44", "Czech2", "-9", "3", "Fixed", "1200", "916.3", + "45", "Denmark1", "-1", "4", "Fixed", "600", "865.7", + "46", "Denmark2", "-9", "3", "Fixed", "1200", "916.3", + "47", "Dominican", "-2 RW", "50", "Hop", "500", "902.75", + "48", "Ecuador", "-2 RW", "50", "Hop", "500", "902.75", + "49", "Egypt", "-1", "4", "Fixed", "600", "865.7", + "50", "ElSalvador", "-2 RW", "50", "Hop", "500", "902.75", + "51", "Estonia", "-1", "4", "Fixed", "600", "865.7", + "52", "Finland1", "-1", "4", "Fixed", "600", "865.7", + "53", "Finland2", "-9", "3", "Fixed", "1200", "916.3", + "54", "France", "-1", "4", "Fixed", "600", "865.7", + "55", "Georgia", "-1", "4", "Fixed", "600", "865.7", + "56", "Germany", "-1", "4", "Fixed", "600", "865.7", + "57", "Ghana", "-1", "4", "Fixed", "600", "865.7", + "58", "Greece", "-1", "4", "Fixed", "600", "865.7", + "59", " Guatemala", "-2 RW", "50", "Hop", "500", "902.75", + "60", "HongKong1", "-1", "4", "Fixed", "600", "865.7", + "61", "HongKong2", "-2 OFCA", "50", "Hop", "50", "921.25", + "62", "Hungary1", "-1", "4", "Fixed", "600", "865.7", + "63", "Hungary2", "-9", "3", "Fixed", "1200", "916.3", + "64", "Iceland", "-1", "4", "Fixed", "600", "865.7", + "65", "India", "-1", "3", "Fixed", "600", "865.7", + "66", "Indonesia", "-7", "4", "Hop", "500", "923.75", + "67", "Iran", "-1", "4", "Fixed", "600", "865.7", + "68", "Ireland1", "-1", "4", "Fixed", "600", "865.7", + "69", "Ireland2", "-9", "3", "Fixed", "1200", "916.3", + "70", "Israel", "-9", "3", "Fixed", "500", "915.5", + "71", "Italy", "-1", "4", "Fixed", "600", "865.7", + "72", "Jamaica", "-2 RW", "50", "Hop", "500", "902.75", + "73", "Japan4", "-8", "4", "Fixed", "1200", "916.8", + "74", "Japan6", "-8", "6", "Fixed", "1200", "916.8", + "75", "Jordan", "-1", "4", "Fixed", "600", "865.7", + "76", "Kazakhstan", "-1", "4", "Fixed", "600", "865.7", + "77", "Kenya", "-1", "4", "Fixed", "600", "865.7", + "78", "Korea", "-6", "6", "Hop", "600", "917.3", + "79", "KoreaDPR", "-7", "16", "Hop", "250", "920.625", + "80", "Kuwait", "-1", "4", "Fixed", "600", "865.7", + "81", "Kyrgyz", "-1", "4", "Fixed", "600", "865.7", + "82", "Latvia", "-1", "4", "Fixed", "600", "865.7", + "83", "Lebanon", "-1", "4", "Fixed", "600", "865.7", + "84", "Libya", "-1", "4", "Fixed", "600", "865.7", + "85", "Liechtenstein1", "-1", "4", "Fixed", "600", "865.7", + "86", "Liechtenstein2", "-9", "3", "Fixed", "1200", "916.3", + "87", "Lithuania1", "-1", "4", "Fixed", "600", "865.7", + "88", "Lithuania2", "-9", "3", "Fixed", "1200", "916.3", + "89", "Luxembourg1", "-1", "4", "Fixed", "600", "865.7", + "90", "Luxembourg2", "-9", "3", "Fixed", "1200", "916.3", + "91", "Macao", "-7", "16", "Hop", "250", "920.625", + "92", "Macedonia", "-1", "4", "Fixed", "600", "865.7", + "93", "Malaysia", "-7", "6", "Hop", "500", "919.75", + "94", "Malta1", "-1", "4", "Fixed", "600", "865.7", + "95", "Malta2", "-9", "3", "Fixed", "1200", "916.3", + "96", "Mauritius", "-1", "4", "Fixed", "600", "865.7", + "97", "Mexico", "-2", "50", "Hop", "500", "902.75", + "98", "Moldova1", "-1", "4", "Fixed", "600", "865.7", + "99", "Moldova2", "-9", "3", "Fixed", "1200", "916.3", + "100", "Mongolia", "-7", "16", "Hop", "250", "920.625", + "101", "Montenegro", "-1", "4", "Fixed", "600", "865.7", + "102", "Morocco", "-1", "4", "Fixed", "600", "865.7", + "103", "Netherlands", "-1", "4", "Fixed", "600", "865.7", + "104", "NewZealand1", "-1", "4", "Hop", "500", "864.75", + "105", "NewZealand2", "-2 NZ", "14", "Hop", "500", "920.75", + "106", "Nicaragua", "-2 RW", "50", "Hop", "500", "902.75", + "107", "Nigeria", "-1", "4", "Fixed", "600", "865.7", + "108", "Norway1", "-1", "4", "Fixed", "600", "865.7", + "109", "Norway2", "-9", "3", "Fixed", "1200", "916.3", + "110", "Oman", "-1", "4", "Fixed", "600", "865.7", + "111", "Pakistan", "-1", "4", "Fixed", "600", "865.7", + "112", "Panama", "-2 RW", "50", "Hop", "500", "902.75", + "113", "Paraguay", "-2 RW", "50", "Hop", "500", "902.75", + "114", "Peru", "-2 RW", "24", "Hop", "500", "915.75", + "115", "Philippines", "-2 RW", "50", "Hop", "250", "918.125", + "116", "Poland", "-1", "4", "Fixed", "600", "865.7", + "117", "Portugal", "-1", "4", "Fixed", "600", "865.7", + "118", "Romania", "-1", "4", "Fixed", "600", "865.7", + "119", "Russia1", "-1", "4", "Fixed", "600", "866.3", + "120", "Russia3", "-9", "4", "Fixed", "1200", "915.6", + "121", "Senegal", "-1", "4", "Fixed", "600", "865.7", + "122", "Serbia", "-1", "4", "Fixed", "600", "865.7", + "123", "Singapore1", "-1", "4", "Fixed", "600", "865.7", + "124", "Singapore2", "-2 RW", "8", "Hop", "500", "920.75", + "125", "Slovak1", "-1", "4", "Fixed", "600", "865.7", + "126", "Slovak2", "-9", "3", "Fixed", "1200", "916.3", + "127", "Slovenia1", "-1", "4", "Fixed", "600", "865.7", + "128", "Solvenia2", "-9", "3", "Fixed", "1200", "916.3", + "129", "SAfrica1", "-1", "4", "Fixed", "600", "865.7", + "130", "SAfrica2", "-9", "7", "Fixed", "500", "915.7", + "131", "Spain", "-1", "4", "Fixed", "600", "865.7", + "132", "SriLanka", "-1", "4", "Fixed", "600", "865.7", + "133", "Sudan", "-1", "4", "Fixed", "600", "865.7", + "134", "Sweden1", "-1", "4", "Fixed", "600", "865.7", + "135", "Sweden2", "-9", "3", "Fixed", "1200", "916.3", + "136", "Switzerland1", "-1", "4", "Fixed", "600", "865.7", + "137", "Switzerland2", "-9", "3", "Fixed", "1200", "916.3", + "138", "Syria", "-1", "4", "Fixed", "600", "865.7", + "139", "Taiwan1", "-4", "12", "Hop", "375", "922.875", + "140", "Taiwan2", "-4", "12", "Hop", "375", "922.875", + "141", "Tajikistan", "-1", "4", "Fixed", "600", "865.7", + "142", "Tanzania", "-1", "4", "Fixed", "600", "865.7", + "143", "Thailand", "-2 RW", "8", "Hop", "500", "920.75", + "144", "Trinidad", "-2 RW", "50", "Hop", "500", "902.75", + "145", "Tunisia", "-1", "4", "Fixed", "600", "865.7", + "146", "Turkey", "-1", "4", "Fixed", "600", "865.7", + "147", "Turkmenistan", "-1", "4", "Fixed", "600", "865.7", + "148", "Uganda", "-1", "4", "Fixed", "600", "865.7", + "149", "Ukraine", "-1", "4", "Fixed", "600", "865.7", + "150", "UAE", "-1", "4", "Fixed", "600", "865.7", + "151", "UK1", "-1", "4", "Fixed", "600", "865.7", + "152", "UK2", "-9", "3", "Fixed", "1200", "916.3", + "153", "USA", "-2", "50", "Hop", "500", "902.75", + "154", "Uruguay", "-2 RW", "50", "Hop", "500", "902.75", + "155", "Venezuela", "-2 RW", "50", "Hop", "500", "902.75", + "156", "Vietnam1", "-1", "4", "Fixed", "600", "866.3", + "157", "Vietnam2", "-7", "16", "Hop", "500", "918.75", + "158", "Yemen", "-1", "4", "Fixed", "600", "865.7", + "159", "Zimbabwe", "-1", "4", "Fixed", "600", "865.7", + "160", "Vietnam3", "-7", "4", "Hop", "500", "920.75" + }; + } /* boolean setChannelData(RegionCodes regionCode) { return true; @@ -990,81 +1387,81 @@ public double[] GetAvailableFrequencyTable(RegionCodes regionCode) { // default: // return FCCTableOfFreq; // } - return FCCTableOfFreq; + return countryChannelData.FCCTableOfFreq; case PR: - return PRTableOfFreq; + return countryChannelData.PRTableOfFreq; case VZ: - return VZTableOfFreq; + return countryChannelData.VZTableOfFreq; case AU: - return AUSTableOfFreq; + return countryChannelData.AUSTableOfFreq; case BR1: - return BR1TableOfFreq; + return countryChannelData.BR1TableOfFreq; case BR2: - return BR2TableOfFreq; + return countryChannelData.BR2TableOfFreq; case BR3: - return BR3TableOfFreq; + return countryChannelData.BR3TableOfFreq; case BR4: - return BR4TableOfFreq; + return countryChannelData.BR4TableOfFreq; case BR5: - return BR5TableOfFreq; + return countryChannelData.BR5TableOfFreq; case HK: case SG: case TH: case VN: - return HKTableOfFreq; + return countryChannelData.HKTableOfFreq; case VN1: - return VN1TableOfFreq; + return countryChannelData.VN1TableOfFreq; case VN2: - return VN2TableOfFreq; + return countryChannelData.VN2TableOfFreq; case VN3: - return VN3TableOfFreq; + return countryChannelData.VN3TableOfFreq; case BD: - return BDTableOfFreq; + return countryChannelData.BDTableOfFreq; case TW: - return TWTableOfFreq; + return countryChannelData.TWTableOfFreq; case MY: - return MYSTableOfFreq; + return countryChannelData.MYSTableOfFreq; case ZA: - return ZATableOfFreq; + return countryChannelData.ZATableOfFreq; case ID: - return IDTableOfFreq; + return countryChannelData.IDTableOfFreq; case IL: - return ILTableOfFreq; + return countryChannelData.ILTableOfFreq; case IL2019RW: - return IL2019RWTableOfFreq; + return countryChannelData.IL2019RWTableOfFreq; case PH: - return PHTableOfFreq; + return countryChannelData.PHTableOfFreq; case NZ: - return NZTableOfFreq; + return countryChannelData.NZTableOfFreq; case CN: - return CHNTableOfFreq; + return countryChannelData.CHNTableOfFreq; case UH1: - return UH1TableOfFreq; + return countryChannelData.UH1TableOfFreq; case UH2: - return UH2TableOfFreq; + return countryChannelData.UH2TableOfFreq; case LH: - return LHTableOfFreq; + return countryChannelData.LHTableOfFreq; case LH1: - return LH1TableOfFreq; + return countryChannelData.LH1TableOfFreq; case LH2: - return LH2TableOfFreq; + return countryChannelData.LH2TableOfFreq; case ETSI: appendToLog("Got ETSI Table of Frequencies"); - return ETSITableOfFreq; + return countryChannelData.ETSITableOfFreq; case IN: - return IDATableOfFreq; + return countryChannelData.IDATableOfFreq; case KR: - return KRTableOfFreq; + return countryChannelData.KRTableOfFreq; case KR2017RW: - return KR2017RwTableOfFreq; + return countryChannelData.KR2017RwTableOfFreq; case JP: - return JPN2012TableOfFreq; + return countryChannelData.JPN2012TableOfFreq; case JP6: - return JPN2012ATableOfFreq; + return countryChannelData.JPN2012ATableOfFreq; case ETSIUPPERBAND: - return ETSIUPPERBANDTableOfFreq; + return countryChannelData.ETSIUPPERBANDTableOfFreq; default: return new double[0]; @@ -1073,21 +1470,21 @@ public double[] GetAvailableFrequencyTable(RegionCodes regionCode) { int iRegionEnum = regionCode.ordinal() - RegionCodes.Albania1.ordinal() + 1; if (DEBUG) appendToLog("regionCode = " + regionCode.toString() + ", iRegionEnum = " + iRegionEnum); - String strChannelCount = strCountryEnumInfo[(iRegionEnum - 1) * iCountryEnumInfoColumn + 3]; + String strChannelCount = countryChannelData.strCountryEnumInfo[(iRegionEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 3]; int iChannelCount = -1; try { iChannelCount = Integer.parseInt(strChannelCount); } catch (Exception ex) { } if (DEBUG) appendToLog("strChannelCount = " + strChannelCount + ", iChannelCount = " + iChannelCount); - String strChannelSeparation = strCountryEnumInfo[(iRegionEnum - 1) * iCountryEnumInfoColumn + 5]; + String strChannelSeparation = countryChannelData.strCountryEnumInfo[(iRegionEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 5]; int iChannelSeparation = -1; try { iChannelSeparation = Integer.parseInt(strChannelSeparation); } catch (Exception ex) { } if (DEBUG) appendToLog("strChannelSeparation = " + strChannelSeparation + ",iChannelSeparation = " + iChannelSeparation); - String strChannelFirst = strCountryEnumInfo[(iRegionEnum - 1) * iCountryEnumInfoColumn + 6]; + String strChannelFirst = countryChannelData.strCountryEnumInfo[(iRegionEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 6]; double dChannelFirst = -1; try { dChannelFirst = Double.parseDouble(strChannelFirst); @@ -1124,10 +1521,10 @@ public int[] FreqIndex(RegionCodes regionCode) { // default: // return fccFreqSortedIdx; // } - return fccFreqSortedIdx; + return countryChannelData.fccFreqSortedIdx; case PR: if (freqSortedIdx == null) { - freqSortedIdx = new int[PRTableOfFreq.length]; + freqSortedIdx = new int[countryChannelData.PRTableOfFreq.length]; if (DEBUG) appendToLog("PR: freqSortedIdx size = " + freqSortedIdx.length); ArrayList list = new ArrayList(); for (int i = 0; i < freqSortedIdx.length; i++) list.add(new Integer(i)); @@ -1139,76 +1536,76 @@ public int[] FreqIndex(RegionCodes regionCode) { } return freqSortedIdx; case VZ: - return vzFreqSortedIdx; + return countryChannelData.vzFreqSortedIdx; case AU: - return ausFreqSortedIdx; + return countryChannelData.ausFreqSortedIdx; case BR1: - return br1FreqSortedIdx; + return countryChannelData.br1FreqSortedIdx; case BR2: - return br2FreqSortedIdx; + return countryChannelData.br2FreqSortedIdx; case BR3: - return br3FreqSortedIdx; + return countryChannelData.br3FreqSortedIdx; case BR4: - return br4FreqSortedIdx; + return countryChannelData.br4FreqSortedIdx; case BR5: - return br5FreqSortedIdx; + return countryChannelData.br5FreqSortedIdx; case HK: case SG: case TH: case VN: - return hkFreqSortedIdx; + return countryChannelData.hkFreqSortedIdx; case VN1: - return vietnam1FreqSortedIdx; + return countryChannelData.vietnam1FreqSortedIdx; case VN2: - return vietnam2FreqSortedIdx; + return countryChannelData.vietnam2FreqSortedIdx; case VN3: - return vietnam3FreqSortedIdx; + return countryChannelData.vietnam3FreqSortedIdx; case BD: - return bdFreqSortedIdx; + return countryChannelData.bdFreqSortedIdx; case TW: - return twFreqSortedIdx; + return countryChannelData.twFreqSortedIdx; case MY: - return mysFreqSortedIdx; + return countryChannelData.mysFreqSortedIdx; case ZA: - return zaFreqSortedIdx; + return countryChannelData.zaFreqSortedIdx; case ID: - return indonesiaFreqSortedIdx; + return countryChannelData.indonesiaFreqSortedIdx; case IL: - return ilFreqSortedIdx; + return countryChannelData.ilFreqSortedIdx; case IL2019RW: - return il2019RwFreqSortedIdx; + return countryChannelData.il2019RwFreqSortedIdx; case PH: - return phFreqSortedIdx; + return countryChannelData.phFreqSortedIdx; case NZ: - return nzFreqSortedIdx; + return countryChannelData.nzFreqSortedIdx; case CN: - return cnFreqSortedIdx; + return countryChannelData.cnFreqSortedIdx; case UH1: - return uh1FreqSortedIdx; + return countryChannelData.uh1FreqSortedIdx; case UH2: - return uh2FreqSortedIdx; + return countryChannelData.uh2FreqSortedIdx; case LH: - return lhFreqSortedIdx; + return countryChannelData.lhFreqSortedIdx; case LH1: - return lh1FreqSortedIdx; + return countryChannelData.lh1FreqSortedIdx; case LH2: - return lh2FreqSortedIdx; + return countryChannelData.lh2FreqSortedIdx; case ETSI: - return etsiFreqSortedIdx; + return countryChannelData.etsiFreqSortedIdx; case IN: - return indiaFreqSortedIdx; + return countryChannelData.indiaFreqSortedIdx; case KR: - return krFreqSortedIdx; + return countryChannelData.krFreqSortedIdx; case KR2017RW: - return kr2017RwFreqSortedIdx; + return countryChannelData.kr2017RwFreqSortedIdx; case JP: - return jpn2012FreqSortedIdx; + return countryChannelData.jpn2012FreqSortedIdx; case JP6: - return jpn2012AFreqSortedIdx; + return countryChannelData.jpn2012AFreqSortedIdx; case ETSIUPPERBAND: - return etsiupperbandFreqSortedIdx; + return countryChannelData.etsiupperbandFreqSortedIdx; default: return null; @@ -1257,7 +1654,7 @@ public int[] FreqTable(RegionCodes regionCode) { // if (DEBUG) appendToLog("i = " + i + ", freqSortedIdx = " + freqSortedIdx[i] + ", fccFreqTableIdx = " + fccFreqTableIdx[freqSortedIdx[i]] + ", freqTable[" + i + "] = " + freqTable[i]); // } // return freqTable; - return fccFreqTable; + return countryChannelData.fccFreqTable; case PR: int[] freqSortedIndex = FreqIndex(regionCode); int[] freqTable = null; @@ -1265,88 +1662,88 @@ public int[] FreqTable(RegionCodes regionCode) { freqTable = new int[freqSortedIndex.length]; for (int i = 0; i < freqSortedIndex.length; i++) { int j = 0; - for (; j < FCCTableOfFreq.length; j++) { - if (FCCTableOfFreq[j] == PRTableOfFreq[freqSortedIndex[i]]) break; + for (; j < countryChannelData.FCCTableOfFreq.length; j++) { + if (countryChannelData.FCCTableOfFreq[j] == countryChannelData.PRTableOfFreq[freqSortedIndex[i]]) break; } - freqTable[i] = fccFreqTable[fccFreqTableIdx[j]]; + freqTable[i] = countryChannelData.fccFreqTable[countryChannelData.fccFreqTableIdx[j]]; } } else if (DEBUG) appendToLog("NULL freqSortedIndex"); return freqTable; // return prFreqTable; case VZ: - return vzFreqTable; + return countryChannelData.vzFreqTable; case AU: - return AusFreqTable; + return countryChannelData.AusFreqTable; case BR1: - return br1FreqTable; + return countryChannelData.br1FreqTable; case BR2: - return br2FreqTable; + return countryChannelData.br2FreqTable; case BR3: - return br3FreqTable; + return countryChannelData.br3FreqTable; case BR4: - return br4FreqTable; + return countryChannelData.br4FreqTable; case BR5: - return br5FreqTable; + return countryChannelData.br5FreqTable; case HK: case SG: case TH: case VN: - return hkFreqTable; + return countryChannelData.hkFreqTable; case VN1: - return vietnam1FreqTable; + return countryChannelData.vietnam1FreqTable; case VN2: - return vietnam2FreqTable; + return countryChannelData.vietnam2FreqTable; case VN3: - return vietnam3FreqTable; + return countryChannelData.vietnam3FreqTable; case BD: - return bdFreqTable; + return countryChannelData.bdFreqTable; case TW: - return twFreqTable; + return countryChannelData.twFreqTable; case MY: - return mysFreqTable; + return countryChannelData.mysFreqTable; case ZA: - return zaFreqTable; + return countryChannelData.zaFreqTable; case ID: - return indonesiaFreqTable; + return countryChannelData.indonesiaFreqTable; case IL: - return ilFreqTable; + return countryChannelData.ilFreqTable; case IL2019RW: - return il2019RwFreqTable; + return countryChannelData.il2019RwFreqTable; case PH: - return phFreqTable; + return countryChannelData.phFreqTable; case NZ: - return nzFreqTable; + return countryChannelData.nzFreqTable; case CN: - return cnFreqTable; + return countryChannelData.cnFreqTable; case UH1: - return uh1FreqTable; + return countryChannelData.uh1FreqTable; case UH2: - return uh2FreqTable; + return countryChannelData.uh2FreqTable; case LH: - return lhFreqTable; + return countryChannelData.lhFreqTable; case LH1: - return lh1FreqTable; + return countryChannelData.lh1FreqTable; case LH2: - return lh2FreqTable; + return countryChannelData.lh2FreqTable; case ETSI: - return etsiFreqTable; + return countryChannelData.etsiFreqTable; case IN: - return indiaFreqTable; + return countryChannelData.indiaFreqTable; case KR: - return krFreqTable; + return countryChannelData.krFreqTable; case KR2017RW: - return kr2017RwFreqTable; + return countryChannelData.kr2017RwFreqTable; case JP: - return jpn2012FreqTable; + return countryChannelData.jpn2012FreqTable; case JP6: - return jpn2012AFreqTable; + return countryChannelData.jpn2012AFreqTable; case ETSIUPPERBAND: - return etsiupperbandFreqTable; + return countryChannelData.etsiupperbandFreqTable; default: return null; @@ -1508,19 +1905,24 @@ public boolean setOnlyPowerLevel(long pwrlevel) { boolean[] bSelectEnabled = { false, false, false }; boolean setSelectCriteria3(int index, boolean enable, int target, int action, int delay, int bank, int offset, String mask, int maskblen) { boolean DEBUG = false; + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectCriteria3 with index = " + index + ", enable = " + enable + ", bSelectEnable = " + bSelectEnabled[index] + + ", target = " + target + ", action = " + action + ", delay = " + delay + + ", bank = " + bank + ", offset = " + offset + ", mask = " + mask + ", maskbitlen = " + maskblen); if (!enable) { if (bSelectEnabled[index] = false) return true; } - if (DEBUG || true) appendToLog("setSelectCriteria 3 with index = " + index + ", enable = " + enable + ", target = " + target + ", action = " + action + ", delay = " + delay + ", bank = " + bank + ", offset = " + offset + ", mask = " + mask + ", maskbitlen = " + maskblen); int maskbytelen = maskblen / 4; if ((maskblen % 4) != 0) maskbytelen++; if (maskbytelen > 64) maskbytelen = 64; + if (mask == null) mask = ""; if (mask.length() > maskbytelen ) mask = mask.substring(0, maskbytelen); if (index == 0) preMatchData = new RfidReader.PreMatchData(enable, target, action, bank, offset, mask, maskblen, (bis108 ? rfidReaderChipR2000.rx000Setting.getQuerySelect() : rfidReaderChipE710.rx000Setting.getQuerySelect()), getPwrlevel(), getInvAlgo(), getQValue()); boolean result = true; if (index != (bis108 ? rfidReaderChipR2000.rx000Setting.getInvSelectIndex() : rfidReaderChipE710.rx000Setting.getInvSelectIndex())) { + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectCriteria3 goes to setInvSelectIndex"); result = (bis108 ? rfidReaderChipR2000.rx000Setting.setInvSelectIndex(index) : rfidReaderChipE710.rx000Setting.setInvSelectIndex(index)); if (DEBUG) appendToLog("After setInvSelectIndex, result = " + result); } + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectCriteria3 goes to setSelectEnable"); if (result) result = (bis108 ? rfidReaderChipR2000.rx000Setting.setSelectEnable(enable ? 1 : 0, target, action, delay) : rfidReaderChipE710.rx000Setting.setSelectEnable(enable ? 1 : 0, target, action, delay)); if (DEBUG) appendToLog("After setSelectEnable, result = " + result); if (result) result = (bis108 ? rfidReaderChipR2000.rx000Setting.setSelectMaskBank(bank) : rfidReaderChipE710.rx000Setting.setSelectMaskBank(bank)); @@ -1533,6 +1935,7 @@ boolean setSelectCriteria3(int index, boolean enable, int target, int action, in if (result) result = (bis108 ? rfidReaderChipR2000.rx000Setting.setSelectMaskData(mask) : rfidReaderChipE710.rx000Setting.setSelectMaskData(mask)); if (DEBUG) appendToLog("After setSelectMaskData, result = " + result); if (result) { + if (DEBUG) appendToLog("RfidReader.setSelectCriteria3 with enable = " + enable); if (enable) { result = (bis108 ? rfidReaderChipR2000.rx000Setting.setTagSelect(1) : rfidReaderChipE710.rx000Setting.setTagSelect(1)); if (DEBUG) appendToLog("After setTagSelect[1], result = " + result); @@ -1552,9 +1955,11 @@ boolean setSelectCriteria3(int index, boolean enable, int target, int action, in } public PostMatchData postMatchDataOld; public boolean postMatchDataChanged = false; public RfidReader.PreMatchData preMatchDataOld; public boolean preMatchDataChanged = false; - public boolean setSelectedTag1(String selectMask, int selectBank, int selectOffset, int delay, long pwrlevel, int qValue, int matchRep) { - appendToLog("setSelectCriteria selectMask = " + selectMask + ", selectBank = " + selectBank + ", selectOffset = " + selectOffset + ", delay = " + delay + ", pwrlevel = " + pwrlevel + ", qValue = " + qValue + ", matchRep = " + matchRep); - boolean setSuccess = true, DEBUG = true; + public boolean setSelectedTag1(boolean selectOne, String selectMask, int selectBank, int selectOffset, int delay, long pwrlevel, int qValue, int matchRep) { + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectedTag1[selectOne = " + selectOne + ", selectMask = " + + selectMask + ", selectBank = " + selectBank + ", selectOffset = " + selectOffset + ", delay = " + + delay + ", pwrlevel = " + pwrlevel + ", qValue = " + qValue + ", matchRep = " + matchRep); + boolean setSuccess = true, DEBUG = false; if (selectMask == null) selectMask = ""; if (preMatchDataChanged == false) { @@ -1566,17 +1971,19 @@ public boolean setSelectedTag1(String selectMask, int selectBank, int selectOffs } preMatchDataOld = preMatchData; } - int index = 0; int indexCurrent = (bis108 ? rfidReaderChipR2000.rx000Setting.invSelectIndex : rfidReaderChipE710.rx000Setting.invSelectIndex); for (int i = 0; i < 7; i++) { + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectedTag1 1 goes to setInvSelectIndex with i = " + i); if (bis108) rfidReaderChipR2000.rx000Setting.setInvSelectIndex(i); else rfidReaderChipE710.rx000Setting.setInvSelectIndex(i); - if ((bis108 ? rfidReaderChipR2000.rx000Setting.getSelectEnable() : rfidReaderChipE710.rx000Setting.getSelectEnable()) == 0) { - appendToLog("free select when i = " + i + ". Going to setSelectCriteria"); + int isEnabled = (bis108 ? rfidReaderChipR2000.rx000Setting.getSelectEnable() : rfidReaderChipE710.rx000Setting.getSelectEnable()); + if (isEnabled == 0 || selectOne) { + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectedTag1. goes to setSelectCriteria3"); setSuccess = setSelectCriteria3(i, true, 4, 0, delay, selectBank, selectOffset, selectMask, selectMask.length() * 4); if (DEBUG) appendToLog("setSelectCriteria after setSelectCriteria, setSuccess = " + setSuccess); break; } } + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectedTag1 2 goes to setInvSelectIndex with indexCurrent = " + indexCurrent); if (bis108) rfidReaderChipR2000.rx000Setting.setInvSelectIndex(indexCurrent); else rfidReaderChipE710.rx000Setting.setInvSelectIndex(indexCurrent); if (setSuccess) setSuccess = setOnlyPowerLevel(pwrlevel); @@ -1590,16 +1997,37 @@ public boolean setSelectedTag1(String selectMask, int selectBank, int selectOffs if (DEBUG) appendToLog("setSelectCriteria after setInvAlgo1, setSuccess = " + setSuccess); } - if (setSuccess) setSuccess = (bis108 ? rfidReaderChipR2000.rx000Setting.setMatchRep(matchRep) : rfidReaderChipE710.rx000Setting.setMatchRep(matchRep)); + if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReader.setSelectTag1 goes to setMatchRep with matchRep = " + matchRep); + if (setSuccess) setSuccess = setMatchRep(matchRep); if (DEBUG) appendToLog("setSelectCriteria after setMatchRep, setSuccess = " + setSuccess); - if (setSuccess) setSuccess = (bis108 ? rfidReaderChipR2000.rx000Setting.setTagDelay(tagDelayDefaultNormalSetting) : rfidReaderChipE710.rx000Setting.setTagDelay(tagDelayDefaultNormalSetting)); + if (setSuccess) setSuccess = setTagDelay2RfidReader(tagDelayDefaultNormalSetting); if (DEBUG) appendToLog("setSelectCriteria after setTagDelay, setSuccess = " + setSuccess); if (setSuccess) setSuccess = (bis108 ? rfidReaderChipR2000.rx000Setting.setCycleDelay(cycleDelaySetting) : rfidReaderChipE710.rx000Setting.setCycleDelay(cycleDelaySetting)); if (DEBUG) appendToLog("setSelectCriteria after setCycleDelay, setSuccess = " + setSuccess); - if (setSuccess) setSuccess = (bis108 ? rfidReaderChipR2000.rx000Setting.setInvModeCompact(false) : rfidReaderChipE710.rx000Setting.setInvModeCompact(false)); + if (utility.DEBUG_COMPACT) appendToLog("Debug_Compact 3: RfidReadder.setSelectedTag1 goes to setInvModeCompact"); + if (setSuccess) setSuccess = setInvModeCompact(false); if (DEBUG) appendToLog("setSelectCriteria after setInvModeCompact, setSuccess = " + setSuccess); return setSuccess; } + public boolean setSelectedTag4Access(boolean selectOne, String selectMask, int selectBank, int selectOffset, long pwrlevel, int qValue, int matchRep) { + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectedTag long goes to setSelectedTag1"); + return setSelectedTag1(selectOne, selectMask, selectBank, selectOffset, 0, pwrlevel, qValue, matchRep); + } + public boolean setSelectedTag(String selectMask, int selectBank, long pwrlevel) { + boolean isValid = false; + if (selectBank < 0 || selectBank > 3) return false; + int selectOffset = (selectBank == 1 ? 32 : 0); + //appendToLog("BtDataOut: RfidReader.setSelectTag"); + //isValid = setSelectCriteriaDisable(-1); + appendToLog("BtDataOut: RfidReader.setSelectedTag short goes to setSelectedTag1"); + isValid = setSelectedTag1(true, selectMask, selectBank, selectOffset, 0, pwrlevel, 0, 0); + return isValid; + } + public boolean setSelectedTagByTID(String selectMask, long pwrlevel) { + if (pwrlevel < 0) pwrlevel = pwrlevelSetting; + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectedTagByTID goes to setSelectedTag1"); + return setSelectedTag1(false, selectMask, 2, 0, 0, pwrlevel, 0, 0); + } public final int modifyCodeAA = 0xAA; public enum RegionCodes { @@ -1629,7 +2057,7 @@ public enum RegionCodes { Tajikistan, Tanzania, Thailand, Trinidad, Tunisia, Turkey, Turkmenistan, Uganda, Ukraine, UAE, UK1, UK2, USA, Uruguay, Venezuela, Vietnam1, Vietnam2, Yemen, Zimbabwe, Vietnam3 } - public String regionCode2StringArray(RegionCodes region) { + public String regionCode2StringArray(@NonNull RegionCodes region) { switch (region) { case AG: return "Argentina"; @@ -1979,189 +2407,26 @@ public boolean getChannelHoppingDefault() { return true; } } - public final int iCountryEnumInfoColumn = 7; - public String[] strCountryEnumInfo = { - "1", "Albania1", "-1", "4", "Fixed", "600", "865.7", - "2", "Albania2", "-2 RW", "23", "Hop", "250", "915.25", - "3", "Algeria1", "-1", "4", "Fixed", "600", "871.6", - "4", "Algeria2", "-1", "4", "Fixed", "600", "881.6", - "5", "Algeria3", "-9", "3", "Fixed", "1200", "916.3", - "6", "Algeria4", "-7", "2", "Fixed", "500", "925.25", - "7", "Argentina", "-2 RW", "50", "Hop", "500", "902.75", - "8", "Armenia", "-1", "4", "Fixed", "600", "865.7", - "9", "Australia1", "-2 AS", "10", "Hop", "500", "920.75", - "10", "Australia2", "-2 AS", "14", "Hop", "500", "918.75", - "11", "Austria1", "-1", "4", "Fixed", "600", "865.7", - "12", "Austria2", "-9", "3", "Fixed", "1200", "916.3", - "13", "Azerbaijan", "-1", "4", "Fixed", "600", "865.7", - "14", "Bahrain", "-1", "4", "Fixed", "600", "865.7", - "15", "Bangladesh", "-1", "4", "Fixed", "600", "865.7", - "16", "Belarus", "-1", "4", "Fixed", "600", "865.7", - "17", "Belgium1", "-1", "4", "Fixed", "600", "865.7", - "18", "Belgium2", "-9", "3", "Fixed", "1200", "916.3", - "19", "Bolivia", "-2", "50", "Hop", "500", "902.75", - "20", "Bosnia", "-1", "4", "Fixed", "600", "865.7", - "21", "Botswana", "-1", "4", "Fixed", "600", "865.7", - "22", "Brazil1", "-2 RW", "9", "Fixed", "500", "902.75", - "23", "Brazil2", "-2 RW", "24", "Fixed", "500", "915.75", - "24", "Brunei1", "-1", "4", "Fixed", "600", "865.7", - "25", "Brunei2", "-7", "7", "Fixed", "250", "923.25", - "26", "Blgaria1", "-1", "4", "Fixed", "600", "865.7", - "27", "Bulgaria2", "-9", "3", "Fixed", "1200", "916.3", - "28", "Cambodia", "-7", "16", "Hop", "250", "920.625", - "29", "Cameroon", "-1", "4", "Fixed", "600", "865.7", - "30", "Canada", "-2", "50", "Hop", "500", "902.75", - "31", "Chile1", "-2 RW", "3", "Fixed", "1200", "916.3", - "32", "Chile2", "-2 RW", "24", "Hop", "500", "915.75", - "33", "Chile3", "-2 RW", "4", "Hop", "500", "925.75", - "34", "China", "-7", "16", "Hop", "250", "920.625", - "35", "Colombia", "-2 RW", "50", "Hop", "500", "902.75", - "36", "Congo", "-1", "4", "Fixed", "600", "865.7", - "37", "CostaRica", "-2 RW", "50", "Hop", "500", "902.75", - "38", "Cotedlvoire", "-1", "4", "Fixed", "600", "865.7", - "39", "Croatia", "-1", "4", "Fixed", "600", "865.7", - "40", "Cuba", "-2 RW", "50", "Hop", "500", "902.75", - "41", "Cyprus1", "-1", "4", "Fixed", "600", "865.7", - "42", "Cyprus2", "-9", "3", "Fixed", "1200", "916.3", - "43", "Czech1", "-1", "4", "Fixed", "600", "865.7", - "44", "Czech2", "-9", "3", "Fixed", "1200", "916.3", - "45", "Denmark1", "-1", "4", "Fixed", "600", "865.7", - "46", "Denmark2", "-9", "3", "Fixed", "1200", "916.3", - "47", "Dominican", "-2 RW", "50", "Hop", "500", "902.75", - "48", "Ecuador", "-2 RW", "50", "Hop", "500", "902.75", - "49", "Egypt", "-1", "4", "Fixed", "600", "865.7", - "50", "ElSalvador", "-2 RW", "50", "Hop", "500", "902.75", - "51", "Estonia", "-1", "4", "Fixed", "600", "865.7", - "52", "Finland1", "-1", "4", "Fixed", "600", "865.7", - "53", "Finland2", "-9", "3", "Fixed", "1200", "916.3", - "54", "France", "-1", "4", "Fixed", "600", "865.7", - "55", "Georgia", "-1", "4", "Fixed", "600", "865.7", - "56", "Germany", "-1", "4", "Fixed", "600", "865.7", - "57", "Ghana", "-1", "4", "Fixed", "600", "865.7", - "58", "Greece", "-1", "4", "Fixed", "600", "865.7", - "59", " Guatemala", "-2 RW", "50", "Hop", "500", "902.75", - "60", "HongKong1", "-1", "4", "Fixed", "600", "865.7", - "61", "HongKong2", "-2 OFCA", "50", "Hop", "50", "921.25", - "62", "Hungary1", "-1", "4", "Fixed", "600", "865.7", - "63", "Hungary2", "-9", "3", "Fixed", "1200", "916.3", - "64", "Iceland", "-1", "4", "Fixed", "600", "865.7", - "65", "India", "-1", "3", "Fixed", "600", "865.7", - "66", "Indonesia", "-7", "4", "Hop", "500", "923.75", - "67", "Iran", "-1", "4", "Fixed", "600", "865.7", - "68", "Ireland1", "-1", "4", "Fixed", "600", "865.7", - "69", "Ireland2", "-9", "3", "Fixed", "1200", "916.3", - "70", "Israel", "-9", "3", "Fixed", "500", "915.5", - "71", "Italy", "-1", "4", "Fixed", "600", "865.7", - "72", "Jamaica", "-2 RW", "50", "Hop", "500", "902.75", - "73", "Japan4", "-8", "4", "Fixed", "1200", "916.8", - "74", "Japan6", "-8", "6", "Fixed", "1200", "916.8", - "75", "Jordan", "-1", "4", "Fixed", "600", "865.7", - "76", "Kazakhstan", "-1", "4", "Fixed", "600", "865.7", - "77", "Kenya", "-1", "4", "Fixed", "600", "865.7", - "78", "Korea", "-6", "6", "Hop", "600", "917.3", - "79", "KoreaDPR", "-7", "16", "Hop", "250", "920.625", - "80", "Kuwait", "-1", "4", "Fixed", "600", "865.7", - "81", "Kyrgyz", "-1", "4", "Fixed", "600", "865.7", - "82", "Latvia", "-1", "4", "Fixed", "600", "865.7", - "83", "Lebanon", "-1", "4", "Fixed", "600", "865.7", - "84", "Libya", "-1", "4", "Fixed", "600", "865.7", - "85", "Liechtenstein1", "-1", "4", "Fixed", "600", "865.7", - "86", "Liechtenstein2", "-9", "3", "Fixed", "1200", "916.3", - "87", "Lithuania1", "-1", "4", "Fixed", "600", "865.7", - "88", "Lithuania2", "-9", "3", "Fixed", "1200", "916.3", - "89", "Luxembourg1", "-1", "4", "Fixed", "600", "865.7", - "90", "Luxembourg2", "-9", "3", "Fixed", "1200", "916.3", - "91", "Macao", "-7", "16", "Hop", "250", "920.625", - "92", "Macedonia", "-1", "4", "Fixed", "600", "865.7", - "93", "Malaysia", "-7", "6", "Hop", "500", "919.75", - "94", "Malta1", "-1", "4", "Fixed", "600", "865.7", - "95", "Malta2", "-9", "3", "Fixed", "1200", "916.3", - "96", "Mauritius", "-1", "4", "Fixed", "600", "865.7", - "97", "Mexico", "-2", "50", "Hop", "500", "902.75", - "98", "Moldova1", "-1", "4", "Fixed", "600", "865.7", - "99", "Moldova2", "-9", "3", "Fixed", "1200", "916.3", - "100", "Mongolia", "-7", "16", "Hop", "250", "920.625", - "101", "Montenegro", "-1", "4", "Fixed", "600", "865.7", - "102", "Morocco", "-1", "4", "Fixed", "600", "865.7", - "103", "Netherlands", "-1", "4", "Fixed", "600", "865.7", - "104", "NewZealand1", "-1", "4", "Hop", "500", "864.75", - "105", "NewZealand2", "-2 NZ", "14", "Hop", "500", "920.75", - "106", "Nicaragua", "-2 RW", "50", "Hop", "500", "902.75", - "107", "Nigeria", "-1", "4", "Fixed", "600", "865.7", - "108", "Norway1", "-1", "4", "Fixed", "600", "865.7", - "109", "Norway2", "-9", "3", "Fixed", "1200", "916.3", - "110", "Oman", "-1", "4", "Fixed", "600", "865.7", - "111", "Pakistan", "-1", "4", "Fixed", "600", "865.7", - "112", "Panama", "-2 RW", "50", "Hop", "500", "902.75", - "113", "Paraguay", "-2 RW", "50", "Hop", "500", "902.75", - "114", "Peru", "-2 RW", "24", "Hop", "500", "915.75", - "115", "Philippines", "-2 RW", "50", "Hop", "250", "918.125", - "116", "Poland", "-1", "4", "Fixed", "600", "865.7", - "117", "Portugal", "-1", "4", "Fixed", "600", "865.7", - "118", "Romania", "-1", "4", "Fixed", "600", "865.7", - "119", "Russia1", "-1", "4", "Fixed", "600", "866.3", - "120", "Russia3", "-9", "4", "Fixed", "1200", "915.6", - "121", "Senegal", "-1", "4", "Fixed", "600", "865.7", - "122", "Serbia", "-1", "4", "Fixed", "600", "865.7", - "123", "Singapore1", "-1", "4", "Fixed", "600", "865.7", - "124", "Singapore2", "-2 RW", "8", "Hop", "500", "920.75", - "125", "Slovak1", "-1", "4", "Fixed", "600", "865.7", - "126", "Slovak2", "-9", "3", "Fixed", "1200", "916.3", - "127", "Slovenia1", "-1", "4", "Fixed", "600", "865.7", - "128", "Solvenia2", "-9", "3", "Fixed", "1200", "916.3", - "129", "SAfrica1", "-1", "4", "Fixed", "600", "865.7", - "130", "SAfrica2", "-9", "7", "Fixed", "500", "915.7", - "131", "Spain", "-1", "4", "Fixed", "600", "865.7", - "132", "SriLanka", "-1", "4", "Fixed", "600", "865.7", - "133", "Sudan", "-1", "4", "Fixed", "600", "865.7", - "134", "Sweden1", "-1", "4", "Fixed", "600", "865.7", - "135", "Sweden2", "-9", "3", "Fixed", "1200", "916.3", - "136", "Switzerland1", "-1", "4", "Fixed", "600", "865.7", - "137", "Switzerland2", "-9", "3", "Fixed", "1200", "916.3", - "138", "Syria", "-1", "4", "Fixed", "600", "865.7", - "139", "Taiwan1", "-4", "12", "Hop", "375", "922.875", - "140", "Taiwan2", "-4", "12", "Hop", "375", "922.875", - "141", "Tajikistan", "-1", "4", "Fixed", "600", "865.7", - "142", "Tanzania", "-1", "4", "Fixed", "600", "865.7", - "143", "Thailand", "-2 RW", "8", "Hop", "500", "920.75", - "144", "Trinidad", "-2 RW", "50", "Hop", "500", "902.75", - "145", "Tunisia", "-1", "4", "Fixed", "600", "865.7", - "146", "Turkey", "-1", "4", "Fixed", "600", "865.7", - "147", "Turkmenistan", "-1", "4", "Fixed", "600", "865.7", - "148", "Uganda", "-1", "4", "Fixed", "600", "865.7", - "149", "Ukraine", "-1", "4", "Fixed", "600", "865.7", - "150", "UAE", "-1", "4", "Fixed", "600", "865.7", - "151", "UK1", "-1", "4", "Fixed", "600", "865.7", - "152", "UK2", "-9", "3", "Fixed", "1200", "916.3", - "153", "USA", "-2", "50", "Hop", "500", "902.75", - "154", "Uruguay", "-2 RW", "50", "Hop", "500", "902.75", - "155", "Venezuela", "-2 RW", "50", "Hop", "500", "902.75", - "156", "Vietnam1", "-1", "4", "Fixed", "600", "866.3", - "157", "Vietnam2", "-7", "16", "Hop", "500", "918.75", - "158", "Yemen", "-1", "4", "Fixed", "600", "865.7", - "159", "Zimbabwe", "-1", "4", "Fixed", "600", "865.7", - "160", "Vietnam3", "-7", "4", "Hop", "500", "920.75" - }; public int getCountryCode() { if (bis108) return rfidReaderChipR2000.rx000OemSetting.getCountryCode(); final boolean DEBUG = false; int iCountrycode = -1; int iValue = rfidReaderChipE710.rx000Setting.getCountryEnum(); if (DEBUG) appendToLog("getCountryEnum 0x3014 = " + iValue); - if (iValue > 0 && iValue < strCountryEnumInfo.length/iCountryEnumInfoColumn) { + if (iValue > 0 && iValue < countryChannelData.strCountryEnumInfo.length/countryChannelData.iCountryEnumInfoColumn) { if (DEBUG) { for (int i = 1; i <= 160; i++) { - appendToLog("i = " + i + ", " + strCountryEnumInfo[(i - 1) * iCountryEnumInfoColumn + 0] - + ", " + strCountryEnumInfo[(i - 1) * iCountryEnumInfoColumn + 1] - + ", " + strCountryEnumInfo[(i - 1) * iCountryEnumInfoColumn + 2] - + ", " + strCountryEnumInfo[(i - 1) * iCountryEnumInfoColumn + 3] - + ", " + strCountryEnumInfo[(i - 1) * iCountryEnumInfoColumn + 4] - + ", " + strCountryEnumInfo[(i - 1) * iCountryEnumInfoColumn + 5] - + ", " + strCountryEnumInfo[(i - 1) * iCountryEnumInfoColumn + 6] + appendToLog("i = " + i + ", " + countryChannelData.strCountryEnumInfo[(i - 1) * countryChannelData.iCountryEnumInfoColumn + 0] + + ", " + countryChannelData.strCountryEnumInfo[(i - 1) * countryChannelData.iCountryEnumInfoColumn + 1] + + ", " + countryChannelData.strCountryEnumInfo[(i - 1) * countryChannelData.iCountryEnumInfoColumn + 2] + + ", " + countryChannelData.strCountryEnumInfo[(i - 1) * countryChannelData.iCountryEnumInfoColumn + 3] + + ", " + countryChannelData.strCountryEnumInfo[(i - 1) * countryChannelData.iCountryEnumInfoColumn + 4] + + ", " + countryChannelData.strCountryEnumInfo[(i - 1) * countryChannelData.iCountryEnumInfoColumn + 5] + + ", " + countryChannelData.strCountryEnumInfo[(i - 1) * countryChannelData.iCountryEnumInfoColumn + 6] ); } } - String strCountryCode = strCountryEnumInfo[(iValue - 1) * iCountryEnumInfoColumn + 2]; + String strCountryCode = countryChannelData.strCountryEnumInfo[(iValue - 1) * countryChannelData.iCountryEnumInfoColumn + 2]; if (DEBUG) appendToLog("strCountryCode 0 = " + strCountryCode); String[] countryCodePart = strCountryCode.split(" "); strCountryCode = countryCodePart[0].substring(1); @@ -2314,11 +2579,15 @@ public boolean setPowerLevel(long pwrlevel) { } public int getQueryTarget() { int iValue; boolean DEBUG = false; - if (DEBUG) appendToLog("1 getQueryTarget"); iValue = (bis108 ? rfidReaderChipR2000.rx000Setting.getAlgoAbFlip() : rfidReaderChipE710.rx000Setting.getQueryTarget()); + if (DEBUG) appendToLog("getQueryTarget with bis108 = " + bis108 + ", iValue = " + iValue); if (bis108) { - if (iValue > 0) return 2; + if (iValue > 0) { + rfidReaderChipR2000.rx000Setting.getQueryTarget(); + return 2; + } else { + if (DEBUG) appendToLog("getQueryTarget"); iValue = rfidReaderChipR2000.rx000Setting.getQueryTarget(); if (iValue > 0) return 1; return 0; @@ -2340,6 +2609,7 @@ public boolean setTagGroup(int sL, int session, int target1) { if (false) appendToLog("Hello6: invAlgo = " + rfidReaderChipR2000.rx000Setting.getInvAlgo()); if (false) appendToLog("setTagGroup: going to setAlgoSelect with invAlgo = " + rfidReaderChipR2000.rx000Setting.getInvAlgo()); rfidReaderChipR2000.rx000Setting.setAlgoSelect(rfidReaderChipR2000.rx000Setting.getInvAlgo()); //Must not delete this line + if (false) appendToLog("RfidReader.setTagGroup[" + target1 + ", " + session + ", " + sL); return rfidReaderChipR2000.rx000Setting.setQueryTarget(target1, session, sL); } else { //appendToLog("1d"); @@ -2540,80 +2810,80 @@ public int FreqChnCnt(RegionCodes regionCode) { case MX: case PM: case UG: - return FCC_CHN_CNT; + return countryChannelData.FCC_CHN_CNT; case PR: - return PRTableOfFreq.length; + return countryChannelData.PRTableOfFreq.length; case VZ: - return VZ_CHN_CNT; + return countryChannelData.VZ_CHN_CNT; case AU: - return AUS_CHN_CNT; + return countryChannelData.AUS_CHN_CNT; case BR1: - return BR1_CHN_CNT; + return countryChannelData.BR1_CHN_CNT; case BR2: - return BR2_CHN_CNT; + return countryChannelData.BR2_CHN_CNT; case BR3: - return BR3_CHN_CNT; + return countryChannelData.BR3_CHN_CNT; case BR4: - return BR4_CHN_CNT; + return countryChannelData.BR4_CHN_CNT; case BR5: - return BR5_CHN_CNT; + return countryChannelData.BR5_CHN_CNT; case HK: case SG: case TH: case VN: - return HK_CHN_CNT; + return countryChannelData.HK_CHN_CNT; case VN1: - return VN1_CHN_CNT; + return countryChannelData.VN1_CHN_CNT; case VN2: - return VN2_CHN_CNT; + return countryChannelData.VN2_CHN_CNT; case VN3: - return VN3_CHN_CNT; + return countryChannelData.VN3_CHN_CNT; case BD: - return BD_CHN_CNT; + return countryChannelData.BD_CHN_CNT; case TW: - return TW_CHN_CNT; + return countryChannelData.TW_CHN_CNT; case MY: - return MYS_CHN_CNT; + return countryChannelData.MYS_CHN_CNT; case ZA: - return ZA_CHN_CNT; + return countryChannelData.ZA_CHN_CNT; case ID: - return ID_CHN_CNT; + return countryChannelData.ID_CHN_CNT; case IL: - return IL_CHN_CNT; + return countryChannelData.IL_CHN_CNT; case IL2019RW: - return IL2019RW_CHN_CNT; + return countryChannelData.IL2019RW_CHN_CNT; case PH: - return PH_CHN_CNT; + return countryChannelData.PH_CHN_CNT; case NZ: - return NZ_CHN_CNT; + return countryChannelData.NZ_CHN_CNT; case CN: - return CN_CHN_CNT; + return countryChannelData.CN_CHN_CNT; case UH1: - return UH1_CHN_CNT; + return countryChannelData.UH1_CHN_CNT; case UH2: - return UH2_CHN_CNT; + return countryChannelData.UH2_CHN_CNT; case LH: - return LH_CHN_CNT; + return countryChannelData.LH_CHN_CNT; case LH1: - return LH1_CHN_CNT; + return countryChannelData.LH1_CHN_CNT; case LH2: - return LH2_CHN_CNT; + return countryChannelData.LH2_CHN_CNT; case ETSI: - return ETSI_CHN_CNT; + return countryChannelData.ETSI_CHN_CNT; case IN: - return IDA_CHN_CNT; + return countryChannelData.IDA_CHN_CNT; case KR: - return KR_CHN_CNT; + return countryChannelData.KR_CHN_CNT; case KR2017RW: - return KR2017RW_CHN_CNT; + return countryChannelData.KR2017RW_CHN_CNT; case JP: - return JPN2012_CHN_CNT; + return countryChannelData.JPN2012_CHN_CNT; case JP6: - return JPN2012A_CHN_CNT; + return countryChannelData.JPN2012A_CHN_CNT; case ETSIUPPERBAND: - return ETSIUPPERBAND_CHN_CNT; + return countryChannelData.ETSIUPPERBAND_CHN_CNT; default: return 0; @@ -2624,7 +2894,7 @@ public int FreqChnCnt(RegionCodes regionCode) { iValue = regionCode.ordinal() - RegionCodes.Albania1.ordinal() + 1; if (DEBUG) appendToLog("regionCode = " + regionCode.toString() + ", regionCodeEnum = " + iValue); if (iValue > 0) { - String strFreqChnCnt = strCountryEnumInfo[(iValue - 1) * iCountryEnumInfoColumn + 3]; + String strFreqChnCnt = countryChannelData.strCountryEnumInfo[(iValue - 1) * countryChannelData.iCountryEnumInfoColumn + 3]; if (DEBUG) appendToLog("strFreqChnCnt = " + strFreqChnCnt); try { iFreqChnCnt = Integer.parseInt(strFreqChnCnt); @@ -2667,6 +2937,9 @@ public boolean setTagDelay(byte tagDelay) { tagDelaySetting = tagDelay; return true; } + boolean setTagDelay2RfidReader(int tagDelay) { + return (bis108 ? rfidReaderChipR2000.rx000Setting.setTagDelay2RfidReader(tagDelay) : rfidReaderChipE710.rx000Setting.setTagDelay(tagDelay)); + } public byte getIntraPkDelay() { return (bis108 ? rfidReaderChipR2000.rx000Setting.getIntraPacketDelay() : rfidReaderChipE710.rx000Setting.getIntraPacketDelay()); } @@ -2693,6 +2966,7 @@ public void getAuthenticateReplyLength() { } public boolean setTamConfiguration(boolean header, String matchData) { appendToLog("header = " + header + ", matchData.length = " + matchData.length() + ", matchData = " + matchData); + if (matchData == null) matchData = ""; if (matchData.length() != 12) return false; boolean retValue = false; String preChallenge = matchData.substring(0, 2); int iValue = Integer.parseInt(preChallenge, 16); @@ -2730,6 +3004,7 @@ public boolean setTamConfiguration(boolean header, String matchData) { public boolean setTam1Configuration(int keyId, String matchData) { appendToLog("keyId = " + keyId + ", matchData = " + matchData); if (keyId > 255) return false; + if (matchData == null) matchData = ""; if (matchData.length() != 20) return false; boolean retValue = false; String preChallenge = "00"; @@ -2766,6 +3041,7 @@ public boolean setTam1Configuration(int keyId, String matchData) { } public boolean setTam2Configuration(int keyId, String matchData, int profile, int offset, int blockId, int protMode) { if (keyId > 255) return false; + if (matchData == null) matchData = ""; if (matchData.length() != 20) return false; if (profile > 15) return false; if (offset > 0xFFF) return false; @@ -2820,7 +3096,8 @@ public boolean setUntraceable(int range, boolean user, int tid, int epcLength, b return (bis108 ? rfidReaderChipR2000.rx000Setting.setHST_UNTRACEABLE_CFG(range, user, tid, epcLength, epc, uxpc) : rfidReaderChipE710.rx000Setting.setHST_UNTRACEABLE_CFG(range, user, tid, epcLength, epc, uxpc)); } public boolean setAuthenticateConfiguration() { - boolean bValue = (bis108 ? rfidReaderChipR2000.rx000Setting.setHST_AUTHENTICATE_CFG(true, true, 1, 48) + boolean bValue = (bis108 ? + rfidReaderChipR2000.rx000Setting.setHST_AUTHENTICATE_CFG(true, true, 1, 48) : rfidReaderChipE710.rx000Setting.setAuthenticateConfig((48 << 10) | (1 << 2) | 0x03)); if (bis108) { if (bValue) { @@ -2862,7 +3139,9 @@ public int getInvSelectIndex() { return (bis108 ? rfidReaderChipR2000.rx000Setting.getInvSelectIndex(): rfidReaderChipE710.rx000Setting.getInvSelectIndex()); } public boolean getSelectEnable() { - int iValue = (bis108 ? rfidReaderChipR2000.rx000Setting.getSelectEnable() : rfidReaderChipE710.rx000Setting.getSelectEnable()); + int iValue = (bis108 ? + rfidReaderChipR2000.rx000Setting.getSelectEnable() : + rfidReaderChipE710.rx000Setting.getSelectEnable()); return iValue > 0 ? true : false; } public int getSelectTarget() { @@ -2890,11 +3169,27 @@ public String getSelectMaskData() { return strValue.substring(0, strLength); } public boolean setInvSelectIndex(int invSelect) { + if (false) appendToLog("BtDataOut: RfidReader.setSelectIndex goes to setInvSelectIndex"); return (bis108 ? rfidReaderChipR2000.rx000Setting.setInvSelectIndex(invSelect) : rfidReaderChipE710.rx000Setting.setInvSelectIndex(invSelect)); } + public int findFirstEmptySelect() { + int iValue = -1, iSelectEnable; + for (int i = 0; i < 3; i++) { + if (false) appendToLog("RfidReader.findFirstEmptySelect goes to setInvSelectIndex with i = " + i); + if (bis108) rfidReaderChipR2000.rx000Setting.setInvSelectIndex(i); + iSelectEnable = (bis108 ? rfidReaderChipR2000.rx000Setting.getSelectEnable() : rfidReaderChipE710.rx000Setting.selectConfiguration[i][0]); + if (iSelectEnable == 0) { + iValue = i; + appendToLog("cs710Library4A: setSelectCriteria 1 with New index = " + iValue); + break; + } + } + return iValue; + } public boolean setSelectCriteriaDisable(int index) { if (bis108) rfidReaderChipR2000.rx000Setting.setQuerySelect(0); else rfidReaderChipE710.rx000Setting.setQuerySelect(0); + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectCriteriaDisable[" + index + "] goes to setSelectCriteria"); boolean bValue = false; if (index < 0) { for (int i = 0; i < 3; i++) { @@ -2904,24 +3199,10 @@ public boolean setSelectCriteriaDisable(int index) { } } } else { - appendToLog("setSelectCriteria loop ends"); bValue = setSelectCriteria(index, false, 0, 0, 0, 0, 0, ""); } return bValue; } - public int findFirstEmptySelect() { - int iValue = -1, iSelectEnable; - for (int i = 0; i < 3; i++) { - if (bis108) rfidReaderChipR2000.rx000Setting.setInvSelectIndex(i); - iSelectEnable = (bis108 ? rfidReaderChipR2000.rx000Setting.getSelectEnable() : rfidReaderChipE710.rx000Setting.selectConfiguration[i][0]); - if (iSelectEnable == 0) { - iValue = i; - appendToLog("cs710Library4A: setSelectCriteria 1 with New index = " + iValue); - break; - } - } - return iValue; - } public boolean setSelectCriteria(int index, boolean enable, int target, int action, int bank, int offset, String mask, boolean maskbit) { if (index == 0) settingData.preFilterData = new SettingData.PreFilterData(enable, target, action, bank, offset, mask, maskbit); if (index < 0) index = findFirstEmptySelect(); @@ -2929,6 +3210,8 @@ public boolean setSelectCriteria(int index, boolean enable, int target, int acti appendToLog("cs710Library4A: no index is available !!!"); return false; } + appendToLog("mask = " + mask + ", maskbit = " + maskbit); + if (mask == null) mask = ""; int maskblen = mask.length() * 4; String maskHex = ""; int iHex = 0; if (maskbit) { @@ -2947,14 +3230,16 @@ public boolean setSelectCriteria(int index, boolean enable, int target, int acti maskblen = mask.length(); mask = maskHex; } + if (false) appendToLog("RfidReader.setSelectCriteria goes to setSelectCriteria3"); return setSelectCriteria3(index, enable, target, action, 0, bank, offset, mask, maskblen); } public boolean setSelectCriteria(int index, boolean enable, int target, int action, int delay, int bank, int offset, String mask) { + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectCriteria with index = " + index + ", enable = " + enable + ", bSelectedEnable[" + index + "] = " + bSelectEnabled[index]); if (bis108) { if (!enable) { if (bSelectEnabled[index] == enable) return true; } - appendToLog("cs108Library4A: setSelectCriteria 2 with index = " + index + ", enable = " + enable + ", target = " + target + ", action = " + action + ", delay = " + delay + ", bank = " + bank + ", offset = " + offset + ", mask = " + mask); + if (false) appendToLog("cs108Library4A: setSelectCriteria 2 with index = " + index + ", enable = " + enable + ", target = " + target + ", action = " + action + ", delay = " + delay + ", bank = " + bank + ", offset = " + offset + ", mask = " + mask); if (index < 0) index = findFirstEmptySelect(); if (index < 0) { appendToLog("cs710Library4A: no index is available !!!"); @@ -2963,16 +3248,20 @@ public boolean setSelectCriteria(int index, boolean enable, int target, int acti if (index == 0) settingData.preFilterData = new SettingData.PreFilterData(enable, target, action, bank, offset, mask, false); + if (mask == null) mask = ""; if (mask.length() > 64) mask = mask.substring(0, 64); if (index == 0) preMatchData = new RfidReader.PreMatchData(enable, target, action, bank, offset, mask, mask.length() * 4, rfidReaderChipR2000.rx000Setting.getQuerySelect(), getPwrlevel(), getInvAlgo(), getQValue()); boolean result = true; - if (index != rfidReaderChipR2000.rx000Setting.getInvSelectIndex()) + if (index != rfidReaderChipR2000.rx000Setting.getInvSelectIndex()) { + if (false) appendToLog("RfidReader.setSelectCriteria goes to setInvSelectIndex"); result = rfidReaderChipR2000.rx000Setting.setInvSelectIndex(index); + } if (rfidReaderChipR2000.rx000Setting.getSelectEnable() == 0 && enable == false) { appendToLog("cs108Library4A: setSelectCriteria 2: no need to set as when index = " + index + ", getSelectEnable() = " + rfidReaderChipR2000.rx000Setting.getSelectEnable() + ", new enable = " + enable); result = true; } else { + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectCriteria goes to setSelectEnable with result = " + result); if (result) result = rfidReaderChipR2000.rx000Setting.setSelectEnable(enable ? 1 : 0, target, action, delay); if (result) result = rfidReaderChipR2000.rx000Setting.setSelectMaskBank(bank); @@ -2981,6 +3270,7 @@ public boolean setSelectCriteria(int index, boolean enable, int target, int acti if (result) result = rfidReaderChipR2000.rx000Setting.setSelectMaskLength(mask.length() * 4); if (result) result = rfidReaderChipR2000.rx000Setting.setSelectMaskData(mask); + if (false) appendToLog("RfidReader.setSelectCriteria with result = " + result + ", enable = " + enable); if (result) { if (enable) { rfidReaderChipR2000.rx000Setting.setTagSelect(1); @@ -3109,8 +3399,8 @@ String getSpecialCountryVersion() { String strSpecialCountryCode = null; int iValue = rfidReaderChipE710.rx000Setting.getCountryEnum(); if (DEBUG) appendToLog("getCountryEnum 0x3014 = " + iValue); - if (iValue > 0 && iValue < strCountryEnumInfo.length/iCountryEnumInfoColumn) { - String strCountryCode = strCountryEnumInfo[(iValue - 1) * iCountryEnumInfoColumn + 2]; + if (iValue > 0 && iValue < countryChannelData.strCountryEnumInfo.length/countryChannelData.iCountryEnumInfoColumn) { + String strCountryCode = countryChannelData.strCountryEnumInfo[(iValue - 1) * countryChannelData.iCountryEnumInfoColumn + 2]; if (DEBUG) appendToLog("strCountryCode 0 = " + strCountryCode); String[] countryCodePart = strCountryCode.split(" "); if (DEBUG) appendToLog("countryCodePart.length = " + countryCodePart.length); @@ -3166,28 +3456,29 @@ public boolean startOperation(RfidReaderChipData.OperationTypes operationTypes) case TAG_INVENTORY: case TAG_SEARCHING: //setInventoring(true); + if (utility.DEBUG_COMPACT) appendToLog("Debug_Compact 0: RfidReadder.startOperation operationTypes is " + operationTypes.toString()); if (operationTypes == RfidReaderChipData.OperationTypes.TAG_INVENTORY_COMPACT) { + setTagDelay2RfidReader(0); setMatchRep(0); if (false && tagFocus >= 1) { setTagGroup(-1, 1, 0); //Set Session S1, Target A + setTagDelay2RfidReader(0); if (bis108) { - rfidReaderChipR2000.rx000Setting.setTagDelay(0); rfidReaderChipR2000.rx000Setting.setAntennaDwell(2000); } else { - rfidReaderChipE710.rx000Setting.setTagDelay(0); rfidReaderChipE710.rx000Setting.setAntennaDwell(2000); } } - if (bis108) { rfidReaderChipR2000.rx000Setting.setInvModeCompact(true); } else { rfidReaderChipE710.rx000Setting.setInvModeCompact(true); } + if (utility.DEBUG_COMPACT) appendToLog("Debug_Compact 4: RfidReadder.startOperation goes to setInvModeCompact"); + setInvModeCompact(true); } else { + setTagDelay2RfidReader(tagDelayDefaultNormalSetting); if (bis108) { - rfidReaderChipR2000.rx000Setting.setTagDelay(tagDelayDefaultNormalSetting); rfidReaderChipR2000.rx000Setting.setCycleDelay(cycleDelaySetting); - rfidReaderChipR2000.rx000Setting.setInvModeCompact(false); } else { - rfidReaderChipE710.rx000Setting.setTagDelay(tagDelayDefaultNormalSetting); rfidReaderChipE710.rx000Setting.setCycleDelay(cycleDelaySetting); - rfidReaderChipE710.rx000Setting.setInvModeCompact(false); } + setInvModeCompact(false); + if (utility.DEBUG_COMPACT) appendToLog("Debug_Compact 5: RfidReadder.startOperation goes to setInvModeCompact"); if (operationTypes == RfidReaderChipData.OperationTypes.TAG_SEARCHING && bis108 == false) rfidReaderChipE710.rx000Setting.setDupElimRollWindow((byte)0); } if (bis108) { @@ -3222,22 +3513,6 @@ public boolean abortOperation() { setInventoring(false); return bRetValue; } - public boolean setSelectedTagByTID(String strTagId, long pwrlevel) { - if (pwrlevel < 0) pwrlevel = pwrlevelSetting; - return setSelectedTag1(strTagId, 2, 0, 0, pwrlevel, 0, 0); - } - public boolean setSelectedTag(String strTagId, int selectBank, long pwrlevel) { - boolean isValid = false; - if (selectBank < 0 || selectBank > 3) return false; - int selectOffset = (selectBank == 1 ? 32 : 0); - isValid = setSelectCriteriaDisable(-1); - if (isValid) isValid = setSelectedTag1(strTagId, selectBank, selectOffset, 0, pwrlevel, 0, 0); - return isValid; - } - public boolean setSelectedTag(String selectMask, int selectBank, int selectOffset, long pwrlevel, int qValue, int matchRep) { - appendToLog("cs108LibraryA: setSelectCriteria strTagId = " + selectMask + ", selectBank = " + selectBank + ", selectOffset = " + selectOffset + ", pwrlevel = " + pwrlevel + ", qValue = " + qValue + ", matchRep = " + matchRep); - return setSelectedTag1(selectMask, selectBank, selectOffset, 0, pwrlevel, qValue, matchRep); - } public boolean setMatchRep(int matchRep) { return (bis108 ? rfidReaderChipR2000.rx000Setting.setMatchRep(matchRep) : rfidReaderChipE710.rx000Setting.setMatchRep(matchRep)); } @@ -3377,7 +3652,7 @@ public boolean getChannelHoppingStatus() { int iValue = rfidReaderChipE710.rx000Setting.getCountryEnum(); //iValue--; if (DEBUG) appendToLog("getChannelHoppingStatus: countryEnum = " + iValue); if (iValue > 0) { - String strFixedHop = strCountryEnumInfo[(iValue - 1) * iCountryEnumInfoColumn + 4]; + String strFixedHop = countryChannelData.strCountryEnumInfo[(iValue - 1) * countryChannelData.iCountryEnumInfoColumn + 4]; if (DEBUG) appendToLog("getChannelHoppingStatus: FixedHop = " + strFixedHop); if (strFixedHop.matches("Hop")) { if (DEBUG) appendToLog("getChannelHoppingStatus: matched"); @@ -3437,17 +3712,17 @@ public String[] getChannelFrequencyList() { boolean DEBUG = true; int iCountryEnum = rfidReaderChipE710.rx000Setting.getCountryEnum(); appendToLog("countryEnum = " + iCountryEnum); - appendToLog("i = " + iCountryEnum + ", " + strCountryEnumInfo[(iCountryEnum - 1) * iCountryEnumInfoColumn + 0] - + ", " + strCountryEnumInfo[(iCountryEnum - 1) * iCountryEnumInfoColumn + 1] - + ", " + strCountryEnumInfo[(iCountryEnum - 1) * iCountryEnumInfoColumn + 2] - + ", " + strCountryEnumInfo[(iCountryEnum - 1) * iCountryEnumInfoColumn + 3] - + ", " + strCountryEnumInfo[(iCountryEnum - 1) * iCountryEnumInfoColumn + 4] - + ", " + strCountryEnumInfo[(iCountryEnum - 1) * iCountryEnumInfoColumn + 5] - + ", " + strCountryEnumInfo[(iCountryEnum - 1) * iCountryEnumInfoColumn + 6] + appendToLog("i = " + iCountryEnum + ", " + countryChannelData.strCountryEnumInfo[(iCountryEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 0] + + ", " + countryChannelData.strCountryEnumInfo[(iCountryEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 1] + + ", " + countryChannelData.strCountryEnumInfo[(iCountryEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 2] + + ", " + countryChannelData.strCountryEnumInfo[(iCountryEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 3] + + ", " + countryChannelData.strCountryEnumInfo[(iCountryEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 4] + + ", " + countryChannelData.strCountryEnumInfo[(iCountryEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 5] + + ", " + countryChannelData.strCountryEnumInfo[(iCountryEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 6] ); - int iFrequencyCount = Integer.valueOf(strCountryEnumInfo[(iCountryEnum - 1) * iCountryEnumInfoColumn + 3]); - int iFrequencyInterval = Integer.valueOf(strCountryEnumInfo[(iCountryEnum - 1) * iCountryEnumInfoColumn + 5]); - float iFrequencyStart = Float.valueOf(strCountryEnumInfo[(iCountryEnum - 1) * iCountryEnumInfoColumn + 6]); + int iFrequencyCount = Integer.valueOf(countryChannelData.strCountryEnumInfo[(iCountryEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 3]); + int iFrequencyInterval = Integer.valueOf(countryChannelData.strCountryEnumInfo[(iCountryEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 5]); + float iFrequencyStart = Float.valueOf(countryChannelData.strCountryEnumInfo[(iCountryEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 6]); appendToLog("iFrequencyCount = " + iFrequencyCount + ", interval = " + iFrequencyInterval + ", start = " + iFrequencyStart); String[] strChannnelFrequencyList = new String[iFrequencyCount]; @@ -3670,6 +3945,7 @@ public boolean setAccessRetry(boolean accessVerfiy, int accessRetry) { return (bis108 ? rfidReaderChipR2000.rx000Setting.setAccessRetry(accessVerfiy, accessRetry) : rfidReaderChipE710.rx000Setting.setAccessRetry(accessVerfiy, accessRetry)); } public boolean setInvModeCompact(boolean invModeCompact) { + if (utility.DEBUG_COMPACT) appendToLog("Debug_Compact: RfidReader.setInvModeCompact as " + invModeCompact); return (bis108 ? rfidReaderChipR2000.rx000Setting.setInvModeCompact(invModeCompact) : rfidReaderChipE710.rx000Setting.setInvModeCompact(invModeCompact)); } public boolean setAccessLockAction(int accessLockAction, int accessLockMask) { @@ -3750,6 +4026,7 @@ public void setImpinJExtension(boolean tagFocus, boolean fastId) { int iValue = 0; if (tagFocus) iValue |= 0x10; if (fastId) iValue |= 0x20; + if (false) appendToLog("ivalue = " + iValue + ", impinjExtensionValue = " + rfidReaderChipR2000.rx000Setting.impinjExtensionValue); boolean bRetValue; bRetValue = macWrite(0x203, iValue); } else { @@ -3773,14 +4050,13 @@ public void setInventoring(boolean enable) { if (bis108) rfidReaderChipR2000.setInventoring(enable); else rfidReaderChipE710.setInventoring(enable); } - void addRfidToWrite(RfidConnector.CsReaderRfidData csReaderRfidData) { if (bis108) rfidReaderChipR2000.addRfidToWrite(csReaderRfidData); else rfidReaderChipE710.addRfidToWrite(csReaderRfidData); } - void mRx000UplinkHandler() { - if (bis108) rfidReaderChipR2000.mRx000UplinkHandler(); - else rfidReaderChipE710.mRx000UplinkHandler(); + void uplinkHandler() { + if (bis108) rfidReaderChipR2000.uplinkHandler(); + else rfidReaderChipE710.uplinkHandler(); } public int getAntennaCycle() { return (bis108 ? rfidReaderChipR2000.rx000Setting.getAntennaCycle() : rfidReaderChipE710.rx000Setting.getAntennaCycle()); diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipE710.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipE710.java index 4e470c2..cfb3dac 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipE710.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipE710.java @@ -5,10 +5,6 @@ import android.content.Context; -import com.csl.cslibrary4a.RfidConnector; -import com.csl.cslibrary4a.RfidReaderChipData; -import com.csl.cslibrary4a.Utility; - import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; @@ -454,35 +450,8 @@ public int getFreqModifyCode() { return iValue; } long mac_last_command_duration; - long getMacLastCommandDuration(boolean request) { - if (request) { - if (true) readMAC(9); - //byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 9, 0, 0, 0, 0, 0}; - //mRfidDevice.mRx000Device.sendHostRegRequest(HostRegRequests.MAC_LAST_COMMAND_DURATION, false, msgBuffer); - } - return mac_last_command_duration; - } - final int DIAGCFG_INVALID = -1; final int DIAGCFG_MIN = 0; final int DIAGCFG_MAX = 0x3FF; int diagnosticCfg = DIAGCFG_INVALID; - int getDiagnosticConfiguration() { - if (diagnosticCfg < DIAGCFG_MIN || diagnosticCfg > DIAGCFG_MAX) { - if (true) readMAC(0x201); - //byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 1, 2, 0, 0, 0, 0}; - //mRfidDevice.mRx000Device.sendHostRegRequest(HostRegRequests.HST_CMNDIAGS, false, msgBuffer); - } - return diagnosticCfg; - } - boolean setDiagnosticConfiguration(boolean bCommmandActive) { -// byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, 2, (byte)0x10, 0, 0, 0}; -// if (bCommmandActive) msgBuffer[5] |= 0x20; - int diagnosticCfgNew; - diagnosticCfgNew = 0x10; if (bCommmandActive) diagnosticCfgNew |= 0x20; - appendToLog("diagnosticCfg = " + diagnosticCfg + ", diagnosticCfgNew = " + diagnosticCfgNew); - if (diagnosticCfg == diagnosticCfgNew && sameCheck) return true; - diagnosticCfg = diagnosticCfgNew; - return writeMAC(0x201, diagnosticCfgNew); //mRfidDevice.mRx000Device.sendHostRegRequest(HostRegRequests.HST_CMNDIAGS, true, msgBuffer); - } public int getAntennaPort() { if (false) appendToLog("2 iAntennaPort = " + antennaSelect); return antennaSelect; @@ -665,57 +634,12 @@ void getPwrMgmtStatus() { final int MBPADDR_INVALID = -1; final int MBPADDR_MIN = 0; final int MBPADDR_MAX = 0x1FFF; long mbpAddress = MBPADDR_INVALID; - boolean setMBPAddress(long mbpAddress) { - //byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 0, 4, 0, 0, 0, 0}; - if (mbpAddress < MBPADDR_MIN || mbpAddress > MBPADDR_MAX) return false; - //mbpAddress = mDefault.mbpAddress; - if (this.mbpAddress == mbpAddress && sameCheck) return true; - //msgBuffer[4] = (byte) (mbpAddress % 256); - //msgBuffer[5] = (byte) ((mbpAddress >> 8) % 256); - this.mbpAddress = mbpAddress; - if (false) appendToLog("Going to writeMAC"); - appendToLog("3 setRxGain"); - return writeMAC(0x400, (int) mbpAddress); //mRfidDevice.mRx000Device.sendHostRegRequest(HostRegRequests.HST_MBP_ADDR, true, msgBuffer); - } - final int MBPDATA_INVALID = -1; final int MBPDATA_MIN = 0; final int MBPDATA_MAX = 0x1FFF; long mbpData = MBPDATA_INVALID; - boolean setMBPData(long mbpData) { - //byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, 4, 0, 0, 0, 0}; - if (mbpData < MBPADDR_MIN || mbpData > MBPADDR_MAX) return false; - //mbpData = mDefault.mbpData; - if (this.mbpData == mbpData && sameCheck) return true; - //msgBuffer[4] = (byte) (mbpData % 256); - //msgBuffer[5] = (byte) ((mbpData >> 8) % 256); - this.mbpData = mbpData; - return writeMAC(0x401, (int) mbpData); //mRfidDevice.mRx000Device.sendHostRegRequest(HostRegRequests.HST_MBP_DATA, true, msgBuffer); - } - final int OEMADDR_INVALID = -1; final int OEMADDR_MIN = 0; final int OEMADDR_MAX = 0x1FFF; long oemAddress = OEMADDR_INVALID; - boolean setOEMAddress(long oemAddress) { - //byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 0, 5, 0, 0, 0, 0}; - if (oemAddress < OEMADDR_MIN || oemAddress > OEMADDR_MAX) return false; - //oemAddress = mDefault.oemAddress; - if (this.oemAddress == oemAddress && sameCheck) return true; - //msgBuffer[4] = (byte) (oemAddress % 256); - //msgBuffer[5] = (byte) ((oemAddress >> 8) % 256); - this.oemAddress = oemAddress; - return writeMAC(0x500, (int) oemAddress); //mRfidDevice.mRx000Device.sendHostRegRequest(HostRegRequests.HST_OEM_ADDR, true, msgBuffer); - } - final int OEMDATA_INVALID = -1; final int OEMDATA_MIN = 0; final int OEMDATA_MAX = 0x1FFF; long oemData = OEMDATA_INVALID; - boolean setOEMData(long oemData) { - //byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, 5, 0, 0, 0, 0}; - if (oemData < OEMADDR_MIN || oemData > OEMADDR_MAX) return false; - //oemData = mDefault.oemData; - if (this.oemData == oemData && sameCheck) return true; - //msgBuffer[4] = (byte) (oemData % 256); - //msgBuffer[5] = (byte) ((oemData >> 8) % 256); - this.oemData = oemData; - return writeMAC(0x501, (int) oemData); //mRfidDevice.mRx000Device.sendHostRegRequest(HostRegRequests.HST_OEM_DATA, true, msgBuffer); - } // Antenna block parameters final int ANTCYCLE_INVALID = -1; final int ANTCYCLE_MIN = 0; final int ANTCYCLE_MAX = 0xFFFF; @@ -819,112 +743,6 @@ public boolean setAntennaEnable(int antennaEnable) { if (DEBUG) appendToLog("2d getAntennaEnable: bValue = " + bValue); return bValue; } - boolean setAntennaEnable(int antennaEnable, int antennaInventoryMode, int antennaLocalAlgo, int antennaLocalStartQ, - int antennaProfileMode, int antennaLocalProfile, int antennaFrequencyMode, int antennaLocalFrequency) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } - return antennaSelectedData[antennaSelect].setAntennaEnable(antennaEnable, antennaInventoryMode, antennaLocalAlgo, antennaLocalStartQ, - antennaProfileMode, antennaLocalProfile, antennaFrequencyMode, antennaLocalFrequency); - } - - int getAntennaInventoryMode() { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { - return ANTSELECT_INVALID; - } else { - return antennaSelectedData[antennaSelect].getAntennaInventoryMode(); - } - } - boolean setAntennaInventoryMode(int antennaInventoryMode) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } - return antennaSelectedData[antennaSelect].setAntennaInventoryMode(antennaInventoryMode); - } - - int getAntennaLocalAlgo() { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { - return ANTSELECT_INVALID; - } else { - return antennaSelectedData[antennaSelect].getAntennaLocalAlgo(); - } - } - boolean setAntennaLocalAlgo(int antennaLocalAlgo) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } - return antennaSelectedData[antennaSelect].setAntennaLocalAlgo(antennaLocalAlgo); - } - - int getAntennaLocalStartQ() { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { - return ANTSELECT_INVALID; - } else { - return antennaSelectedData[antennaSelect].getAntennaLocalStartQ(); - } - } - boolean setAntennaLocalStartQ(int antennaLocalStartQ) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } - return antennaSelectedData[antennaSelect].setAntennaLocalStartQ(antennaLocalStartQ); - } - - int getAntennaProfileMode() { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { - return ANTSELECT_INVALID; - } else { - return antennaSelectedData[antennaSelect].getAntennaProfileMode(); - } - } - boolean setAntennaProfileMode(int antennaProfileMode) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } - return antennaSelectedData[antennaSelect].setAntennaProfileMode(antennaProfileMode); - } - - int getAntennaLocalProfile() { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { - return ANTSELECT_INVALID; - } else { - return antennaSelectedData[antennaSelect].getAntennaLocalProfile(); - } - } - boolean setAntennaLocalProfile(int antennaLocalProfile) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } - return antennaSelectedData[antennaSelect].setAntennaLocalProfile(antennaLocalProfile); - } - - int getAntennaFrequencyMode() { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { - return ANTSELECT_INVALID; - } else { - return antennaSelectedData[antennaSelect].getAntennaFrequencyMode(); - } - } - boolean setAntennaFrequencyMode(int antennaFrequencyMode) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } - return antennaSelectedData[antennaSelect].setAntennaFrequencyMode(antennaFrequencyMode); - } - - int getAntennaLocalFrequency() { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { - return ANTSELECT_INVALID; - } else { - return antennaSelectedData[antennaSelect].getAntennaLocalFrequency(); - } - } - boolean setAntennaLocalFrequency(int antennaLocalFrequency) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } - return antennaSelectedData[antennaSelect].setAntennaLocalFrequency(antennaLocalFrequency); - } - - int getAntennaStatus() { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { - return ANTSELECT_INVALID; - } else { - return antennaSelectedData[antennaSelect].getAntennaStatus(); - } - } - - int getAntennaDefine() { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { - return ANTSELECT_INVALID; - } else { - return antennaSelectedData[antennaSelect].getAntennaDefine(); - } - } public long getAntennaDwell() { boolean DEBUG = false; @@ -1012,13 +830,6 @@ else if (getAntennaPower(antennaSelect) == antennaPower && sameCheck) { } long antennaInvCount = -1; - long getAntennaInvCount() { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { - return ANTSELECT_INVALID; - } else { - return antennaSelectedData[antennaSelect].getAntennaInvCount(); - } - } public boolean setAntennaInvCount(long antennaInvCount) { if (antennaInvCount == this.antennaInvCount) return true; this.antennaInvCount = antennaInvCount; appendToLog(String.format("!!! Skip setAntennaInvCount[0x%X]", antennaInvCount)); @@ -1233,9 +1044,6 @@ public boolean setSelectMaskData(String maskData) { } - //Inventtory block paraameters - final int QUERYTARGET_INVALID = -1; final int QUERYTARGET_MIN = 0; final int QUERYTARGET_MAX = 1; - //int queryTarget = QUERYTARGET_INVALID; public int getQueryTarget() { int iValue = -1; boolean DEBUG = false; if (DEBUG) appendToLog("2 getQueryTarget: iAntennaPort = " + antennaSelect); @@ -1251,10 +1059,6 @@ public int getQueryTarget() { } return iValue; } - boolean setQueryTarget(int queryTarget) { - appendToLog("!!! Skip setQueryTarget"); - return true; //setQueryTarget(queryTarget, querySession, querySelect); - } public boolean setQueryTarget(int queryTarget, int querySession, int querySelect) { boolean bValue = false, DEBUG = false; if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); @@ -1303,8 +1107,6 @@ public boolean setQueryTarget(int queryTarget, int querySession, int querySelect } return bValue; } - final int QUERYSESSION_INVALID = -1; final int QUERYSESSION_MIN = 0; final int QUERYSESSION_MAX = 3; - //int querySession = QUERYSESSION_INVALID; public int getQuerySession() { int iValue = -1; boolean DEBUG = true; if (DEBUG) appendToLog("2 getQuerySession: iAntennaPort = " + antennaSelect); @@ -1316,13 +1118,7 @@ public int getQuerySession() { } return iValue; } - boolean setQuerySession(int querySession) { - appendToLog("!!! Skip setQuerySession"); - return true; //setQueryTarget(queryTarget, querySession, querySelect); - } - final int QUERYSELECT_INVALID = -1; final int QUERYSELECT_MIN = 0; final int QUERYSELECT_MAX = 3; - //int querySelect = QUERYSELECT_INVALID; public int getQuerySelect() { int iValue = -1; boolean DEBUG = false; if (DEBUG) appendToLog("2 getQuerySession: iAntennaPort = " + antennaSelect); @@ -1377,11 +1173,6 @@ public boolean setQuerySelect(int querySelect) { return bValue; } - private boolean getHST_QUERY_CFG() { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 0, 9, 0, 0, 0, 0}; - return sendHostRegRequest(HostRegRequests.HST_QUERY_CFG, false, msgBuffer); - } - final int INVALGO_INVALID = -1; final int INVALGO_MIN = 0; final int INVALGO_MAX = 3; int invAlgo = INVALGO_INVALID; public int getInvAlgo() { @@ -1418,10 +1209,6 @@ public boolean setInvAlgo(int invAlgo) { final int MATCHREP_INVALID = -1; final int MATCHREP_MIN = 0; final int MATCHREP_MAX = 255; int matchRep = MATCHREP_INVALID; - int getMatchRep() { - if (matchRep < MATCHREP_MIN || matchRep > MATCHREP_MAX) getHST_INV_CFG(); - return matchRep; - } public boolean setMatchRep(int matchRep) { if (matchRep == this.matchRep) return true; if (this.matchRep == matchRep && sameCheck) { @@ -1434,10 +1221,6 @@ public boolean setMatchRep(int matchRep) { final int TAGSELECT_INVALID = -1; final int TAGSELECT_MIN = 0; final int TAGSELECT_MAX = 1; int tagSelect = TAGSELECT_INVALID; - int getTagSelect() { - if (tagSelect < TAGSELECT_MIN || tagSelect > TAGSELECT_MAX) getHST_INV_CFG(); - return tagSelect; - } public boolean setTagSelect(int tagSelect) { if (tagSelect == this.tagSelect) return true; this.tagSelect = tagSelect; appendToLog(String.format("!!! Skip setTagSelect[%d]", tagSelect)); @@ -1446,14 +1229,6 @@ public boolean setTagSelect(int tagSelect) { final int NOINVENTORY_INVALID = -1; final int NOINVENTORY_MIN = 0; final int NOINVENTORY_MAX = 1; int noInventory = NOINVENTORY_INVALID; - int getNoInventory() { - if (noInventory < NOINVENTORY_MIN || noInventory > NOINVENTORY_MAX) getHST_INV_CFG(); - return noInventory; - } - boolean setNoInventory(int noInventory) { - appendToLog("1b setInvAlgo"); - return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, invBrandId); - } final int TAGREAD_INVALID = -1; final int TAGREAD_MIN = 0; final int TAGREAD_MAX = 2; int tagRead = TAGREAD_INVALID; @@ -1526,10 +1301,6 @@ else if (rx000Setting.multibankReadConfig[1] == null) final int TAGDELAY_INVALID = -1; final int TAGDELAY_MIN = 0; final int TAGDELAY_MAX = 63; int tagDelay = TAGDELAY_INVALID; - int getTagDelay() { - if (tagDelay < TAGDELAY_MIN || tagDelay > TAGDELAY_MAX) getHST_INV_CFG(); - return tagDelay; - } public boolean setTagDelay(int tagDelay) { if (tagDelay == this.tagDelay) return true; if (this.tagDelay == tagDelay && sameCheck) { @@ -1540,7 +1311,6 @@ public boolean setTagDelay(int tagDelay) { return true; } - final int DUPELIM_INVALID = -1; final int DUPELIM_MIN = 0; final int DUPELIM_MAX = 63; byte[] dupElimRollWindow = null; public byte getDupElimRollWindow() { if (dupElimRollWindow != null && dupElimRollWindow.length == 1) return dupElimRollWindow[0]; @@ -1674,43 +1444,6 @@ public String getAuthMatchData() { if (strValue.length() < 16) strValue = null; return strValue; } - boolean setAuthMatchData(String matchData) { - int length = matchData.length(); - for (int i = 0; i < 6; i++) { - if (length > 0) { - length -= 8; - - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, (byte)0x0F, 0, 0, 0, 0}; - String hexString = "0123456789ABCDEF"; - for (int j = 0; j < 8; j++) { - if (i * 8 + j + 1 <= matchData.length()) { - String subString = matchData.substring(i * 8 + j, i * 8 + j + 1).toUpperCase(); - int k = 0; - for (k = 0; k < 16; k++) { - if (subString.matches(hexString.substring(k, k + 1))) { - break; - } - } - if (k == 16) return false; - if ((j / 2) * 2 == j) { - msgBuffer[7 - j / 2] |= (byte) (k << 4); - } else { - msgBuffer[7 - j / 2] |= (byte) (k); - } - } - } - msgBuffer[2] = (byte) ((msgBuffer[2] & 0xFF) + i); - if (sendHostRegRequest(HostRegRequests.HST_AUTHENTICATE_MSG, true, msgBuffer) == false) - return false; - else { - //authMatchDataReady |= (0x01 << i); - System.arraycopy(msgBuffer, 4, authMatchData0_63, i * 4, 4); //appendToLog("Data=" + byteArrayToString(mRx000Setting.invMatchData0_63)); -// appendToLog("invMatchDataReady=" + Integer.toString(mRx000Setting.invMatchDataReady, 16) + ", message=" + byteArrayToString(msgBuffer)); - } - } - } - return true; - } final int UNTRACEABLE_CFG_INVALID = -1; final int UNTRACEABLE_CFG_MIN = 0; final int UNTRACEABLE_CFG_MAX = 3; int untraceableRange = UNTRACEABLE_CFG_INVALID; @@ -1747,10 +1480,6 @@ public boolean setHST_UNTRACEABLE_CFG(int range, boolean user, int tid, int epcL final int TAGJOIN_INVALID = -1; final int TAGJOIN_MIN = 0; final int TAGJOIN_MAX = 1; int invModeCompact = TAGJOIN_INVALID; - boolean getInvModeCompact() { - if (invModeCompact < TAGDELAY_MIN || invModeCompact > TAGDELAY_MAX) { getHST_INV_CFG(); return false; } - return (invModeCompact == 1 ? true : false); - } public boolean setInvModeCompact(boolean bInvModeCompact) { int invModeCompact = (bInvModeCompact ? 1 : 0); if (invModeCompact == this.invModeCompact && sameCheck) { @@ -1777,69 +1506,8 @@ private boolean getHST_INV_CFG() { byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 1, 9, 0, 0, 0, 0}; return sendHostRegRequest(HostRegRequests.HST_INV_CFG, false, msgBuffer); } - boolean setInvAlgo(int invAlgo, int matchRep, int tagSelect, int noInventory, int tagRead, int tagDelay, int invModeCompact, int invBrandId) { - appendToLog("0 setInvAlgo with invAlgo = " + invAlgo + ", matchRep = " + matchRep + ", tagSelect = " + tagSelect - + ", noInventory = " + noInventory + ", tagRead = " + tagRead + ", tagDelay = " + tagDelay + ", invModeCompact = " + invModeCompact + ", invBrandId = " + invBrandId); - - - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, 9, 0, 0, 0, 0}; - if (invAlgo < INVALGO_MIN || invAlgo > INVALGO_MAX) invAlgo = mDefault.invAlgo; - if (matchRep < MATCHREP_MIN || matchRep > MATCHREP_MAX) matchRep = mDefault.matchRep; - if (tagSelect < TAGSELECT_MIN || tagSelect > TAGSELECT_MAX) tagSelect = mDefault.tagSelect; - if (noInventory < NOINVENTORY_MIN || noInventory > NOINVENTORY_MAX) noInventory = mDefault.noInventory; - if (tagDelay < TAGDELAY_MIN || tagDelay > TAGDELAY_MAX) tagDelay = mDefault.tagDelay; - if (invModeCompact < TAGJOIN_MIN || invModeCompact > TAGJOIN_MAX) invModeCompact = mDefault.tagJoin; - if (invBrandId < BRANDID_MIN || invBrandId > BRANDID_MAX) invBrandId = mDefault.brandid; - if (tagRead < TAGREAD_MIN || tagRead > TAGREAD_MAX) tagRead = mDefault.tagRead; - if (DEBUG) appendToLog("Old invAlgo = " + this.invAlgo + ", matchRep = " + this.matchRep + ", tagSelect =" + this.tagSelect + ", noInventory = " + this.noInventory + ", tagRead = " + this.tagRead + ", tagDelay = " + this.tagDelay + ", invModeCompact = " + this.invModeCompact + ", invBrandId = " + this.invBrandId); - if (DEBUG) appendToLog("New invAlgo = " + invAlgo + ", matchRep = " + matchRep + ", tagSelect =" + tagSelect + ", noInventory = " + noInventory + ", tagRead = " + tagRead + ", tagDelay = " + tagDelay + ", invModeCompact = " + invModeCompact + ", invBrandId = " + invBrandId + ", sameCheck = " + sameCheck); - if (this.invAlgo == invAlgo && this.matchRep == matchRep && this.tagSelect == tagSelect && this.noInventory == noInventory && this.tagRead == tagRead && this.tagDelay == tagDelay && this.invModeCompact == invModeCompact && this.invBrandId == invBrandId && sameCheck) return true; - if (DEBUG) appendToLog("There is difference"); - msgBuffer[4] |= invAlgo; - msgBuffer[4] |= (byte) ((matchRep & 0x03) << 6); - msgBuffer[5] |= (byte) (matchRep >> 2); - if (tagSelect != 0) { - msgBuffer[5] |= 0x40; - } - if (noInventory != 0) { - msgBuffer[5] |= 0x80; - } - if ((tagRead & 0x03) != 0) { - msgBuffer[6] |= (tagRead & 0x03); - } - if ((tagDelay & 0x0F) != 0) { - msgBuffer[6] |= ((tagDelay & 0x0F) << 4); - } - if ((tagDelay & 0x30) != 0) { - msgBuffer[7] |= ((tagDelay & 0x30) >> 4); - } - if (invModeCompact == 1) { - msgBuffer[7] |= 0x04; - } - if (invBrandId == 1) { - msgBuffer[7] |= 0x08; - } - this.invAlgo = invAlgo; - this.matchRep = matchRep; - this.tagSelect = tagSelect; - this.noInventory = noInventory; - this.tagRead = tagRead; - this.tagDelay = tagDelay; - this.invModeCompact = invModeCompact; - this.invBrandId = invBrandId; - return sendHostRegRequest(HostRegRequests.HST_INV_CFG, true, msgBuffer); - } - final int ALGOSELECT_INVALID = -1; final int ALGOSELECT_MIN = 0; final int ALGOSELECT_MAX = 3; //DataSheet says Max=1 int algoSelect = ALGOSELECT_INVALID; - int getAlgoSelect() { - if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 2, 9, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_INV_SEL, false, msgBuffer); - } - return algoSelect; - } - boolean dummyAlgoSelected = false; public boolean setAlgoSelect(int algoSelect) { boolean bValue = false, DEBUG = false; if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); @@ -1922,17 +1590,6 @@ public int getAlgoMaxQ(int algoSelect) { return algoSelectedData[algoSelect].getAlgoMaxQ(); } } - int getAlgoMaxQ() { - if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) { - return ALGOSELECT_INVALID; - } else { - return algoSelectedData[algoSelect].getAlgoMaxQ(); - } - } - boolean setAlgoMaxQ(int algoMaxQ) { - if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) return false; - return algoSelectedData[algoSelect].setAlgoMaxQ(algoMaxQ); - } public int getAlgoMinQ(int algoSelect) { if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) { @@ -1941,53 +1598,6 @@ public int getAlgoMinQ(int algoSelect) { return algoSelectedData[algoSelect].getAlgoMinQ(); } } - int getAlgoMinQ() { - if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) { - return ALGOSELECT_INVALID; - } else { - return algoSelectedData[algoSelect].getAlgoMinQ(); - } - } - boolean setAlgoMinQ(int algoMinQ) { - if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) return false; - return algoSelectedData[algoSelect].setAlgoMinQ(algoMinQ); - } - - int getAlgoMaxRep() { - if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) { - return ALGOSELECT_INVALID; - } else { - return algoSelectedData[algoSelect].getAlgoMaxRep(); - } - } - boolean setAlgoMaxRep(int algoMaxRep) { - if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) return false; - return algoSelectedData[algoSelect].setAlgoMaxRep(algoMaxRep); - } - - int getAlgoHighThres() { - if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) { - return ALGOSELECT_INVALID; - } else { - return algoSelectedData[algoSelect].getAlgoHighThres(); - } - } - boolean setAlgoHighThres(int algoHighThre) { - if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) return false; - return algoSelectedData[algoSelect].setAlgoHighThres(algoHighThre); - } - - int getAlgoLowThres() { - if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) { - return ALGOSELECT_INVALID; - } else { - return algoSelectedData[algoSelect].getAlgoLowThres(); - } - } - boolean setAlgoLowThres(int algoLowThre) { - if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) return false; - return algoSelectedData[algoSelect].setAlgoLowThres(algoLowThre); - } final int ALGORETRY_INVALID = -1, ALGORETRY_MIN = 0, ALGORETRY_MAX = 255, ALGORETRY_DEFAULT = 1; int algoRetry = ALGORETRY_INVALID; @@ -2227,13 +1837,6 @@ public boolean setInvMatchData(String matchData) { boolean accessVerfiy; final int ACCRETRY_INVALID = -1; final int ACCRETRY_MIN = 0; final int ACCRETRY_MAX = 7; int accessRetry = ACCRETRY_INVALID; - int getAccessRetry() { - if (accessRetry < ACCRETRY_MIN || accessRetry > ACCRETRY_MAX) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 1, (byte) 0x0A, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_TAGACC_DESC_CFG, false, msgBuffer); - } - return accessRetry; - } public boolean setAccessRetry(boolean accessVerfiy, int accessRetry) { if (accessVerfiy == this.accessVerfiy && accessRetry == this.accessRetry) return true; this.accessVerfiy = accessVerfiy; this.accessRetry = accessRetry; appendToLog("!!! Skip setAccessRetry[" + accessVerfiy + ", " + accessRetry + "]"); @@ -2304,8 +1907,7 @@ else if (bValue && accessBank2 >= 0 && accessBank2 <= 3) { return bValue; } - final int ACCOFFSET_INVALID = -1; final int ACCOFFSET_MIN = 0; final int ACCOFFSET_MAX = 0xFFFF; - int accessOffset = ACCOFFSET_INVALID; int accessOffset2 = ACCOFFSET_INVALID; + final int ACCOFFSET_INVALID = -1; int getAccessOffset() { boolean DEBUG = false; int iValue = -1; if (accessBank >= 0 && accessBank <= 3 && rx000Setting.multibankReadConfig[0] == null) appendToLog("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); @@ -2362,13 +1964,6 @@ public boolean setAccessOffset(int accessOffset, int accessOffset2) { final int ACCCOUNT_INVALID = -1; final int ACCCOUNT_MIN = 0; final int ACCCOUNT_MAX = 255; int accessCount = ACCCOUNT_INVALID; int accessCount2 = ACCCOUNT_INVALID; - int getAccessCount() { - if (accessCount < ACCCOUNT_MIN || accessCount > ACCCOUNT_MAX) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 4, (byte) 0x0A, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_TAGACC_CNT, false, msgBuffer); - } - return accessCount; - } public boolean setAccessCount(int accessCount) { setAccessEnable(((accessCount != 0) ? 1 : 0), 0); return setAccessCount(accessCount, 0); } @@ -2402,25 +1997,8 @@ else if (bValue) { final int ACCLOCKACTION_INVALID = -1; final int ACCLOCKACTION_MIN = 0; final int ACCLOCKACTION_MAX = 0x3FF; int accessLockAction = ACCLOCKACTION_INVALID; - int getAccessLockAction() { - if (accessLockAction < ACCLOCKACTION_MIN || accessLockAction > ACCLOCKACTION_MAX) - getHST_TAGACC_LOCKCFG(); - return accessLockAction; - } - boolean setAccessLockAction(int accessLockAction) { - return setAccessLockAction(accessLockAction, accessLockMask); - } - final int ACCLOCKMASK_INVALID = -1; final int ACCLOCKMASK_MIN = 0; final int ACCLOCKMASK_MAX = 0x3FF; int accessLockMask = ACCLOCKMASK_INVALID; - int getAccessLockMask() { - if (accessLockMask < ACCLOCKMASK_MIN || accessLockMask > ACCLOCKMASK_MAX) - getHST_TAGACC_LOCKCFG(); - return accessLockMask; - } - boolean setAccessLockMask(int accessLockMask) { - return setAccessLockAction(accessLockAction, accessLockMask); - } boolean getHST_TAGACC_LOCKCFG() { byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 5, (byte) 0x0A, 0, 0, 0, 0}; @@ -2446,7 +2024,6 @@ public boolean setAccessLockAction(int accessLockAction, int accessLockMask) { return bValue; } - final int ACCPWD_INVALID = 0; final long ACCPWD_MIN = 0; final long ACCPWD_MAX = 0x0FFFFFFFF; byte[] accessPassword = null; public boolean getRx000AccessPassword() { return readMAC(0x38A6, 4); @@ -2519,50 +2096,8 @@ public boolean setRx000KillPassword(String password) { final int ACCWRITEDATSEL_INVALID = -1; final int ACCWRITEDATSEL_MIN = 0; final int ACCWRITEDATSEL_MAX = 7; int accessWriteDataSelect = ACCWRITEDATSEL_INVALID; - int getAccessWriteDataSelect() { - if (accessWriteDataSelect < ACCWRITEDATSEL_MIN || accessWriteDataSelect > ACCWRITEDATSEL_MAX) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 8, (byte) 0x0A, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_TAGWRDAT_SEL, false, msgBuffer); - } - return accessWriteDataSelect; - } - boolean setAccessWriteDataSelect(int accessWriteDataSelect) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 8, 0x0A, 0, 0, 0, 0}; - if (accessWriteDataSelect < ACCWRITEDATSEL_MIN || accessWriteDataSelect > ACCWRITEDATSEL_MAX) - accessWriteDataSelect = mDefault.accessWriteDataSelect; - if (this.accessWriteDataSelect == accessWriteDataSelect && sameCheck) return true; - accWriteDataReady = 0; - msgBuffer[4] = (byte) (accessWriteDataSelect & 0x07); - this.accessWriteDataSelect = accessWriteDataSelect; - return sendHostRegRequest(HostRegRequests.HST_TAGWRDAT_SEL, true, msgBuffer); - } byte[] accWriteData0_63; int accWriteDataReady = 0; - String getAccessWriteData() { - int length = accessCount; - if (length > 32) { - length = 32; - } - String strValue = ""; - for (int i = 0; i < 32; i++) { - if (length > 0) { - if ((accWriteDataReady & (0x01 << i)) == 0) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 9, (byte) 0x0A, 0, 0, 0, 0}; - msgBuffer[2] += i; - sendHostRegRequest(HostRegRequests.HST_TAGWRDAT_0, false, msgBuffer); - - strValue = null; - break; - } else { - for (int j = 0; j < 4; j++) { - strValue += String.format("%02X", accWriteData0_63[i * 4 + j]); - } - } - length -= 2; - } - } - return strValue; - } public boolean setAccessWriteData(String dataInput) { boolean bVAlue = false, DEBUG = false; if (DEBUG) appendToLog("Start with dataInput = " + dataInput); @@ -2665,60 +2200,15 @@ public boolean setCurrentProfile(int currentProfile) { return bValue; } - final int COUNTRYENUM_INVALID = -1; final int COUNTRYENUM_MIN = 1; final int COUNTRYENUM_MAX = 109; - final int COUNTRYCODE_INVALID = -1; final int COUNTRYCODE_MIN = 1; final int COUNTRYCODE_MAX = 9; - int countryCode = COUNTRYCODE_INVALID; // OemAddress = 0x02 - final int FREQCHANSEL_INVALID = -1; final int FREQCHANSEL_MIN = 0; final int FREQCHANSEL_MAX = 49; - int freqChannelSelect = FREQCHANSEL_INVALID; + final int COUNTRYCODE_INVALID = -1; + final int FREQCHANSEL_INVALID = -1; final int FREQCHANCONFIG_INVALID = -1; final int FREQCHANCONFIG_MIN = 0; final int FREQCHANCONFIG_MAX = 1; int freqChannelConfig = FREQCHANCONFIG_INVALID; - int getFreqChannelConfig() { - if (freqChannelConfig < FREQCHANCONFIG_MIN || freqChannelConfig > FREQCHANCONFIG_MAX) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 2, 0x0C, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_RFTC_FRQCH_CFG, false, msgBuffer); - } - appendToLog("freqChannelConfig = " + freqChannelConfig); - return freqChannelConfig; - } final int FREQPLLMULTIPLIER_INVALID = -1; - int freqPllMultiplier = FREQPLLMULTIPLIER_INVALID; - int getFreqPllMultiplier() { - if (freqPllMultiplier == FREQPLLMULTIPLIER_INVALID) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 3, 0x0C, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_RFTC_FRQCH_DESC_PLLDIVMULT, false, msgBuffer); - } - return freqPllMultiplier; - } - boolean setFreqPllMultiplier(int freqPllMultiplier) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 3, 0x0C, 0, 0, 0, 0}; - msgBuffer[4] = (byte)(freqPllMultiplier & 0xFF); - msgBuffer[5] = (byte)((freqPllMultiplier >> 8) & 0xFF); - msgBuffer[6] = (byte)((freqPllMultiplier >> 16) & 0xFF); - msgBuffer[7] = (byte)((freqPllMultiplier >> 24) & 0xFF); - this.freqPllMultiplier = freqPllMultiplier; - return sendHostRegRequest(HostRegRequests.HST_RFTC_FRQCH_DESC_PLLDIVMULT, true, msgBuffer); - } final int FREQPLLDAC_INVALID = -1; - int freqPllDac = FREQPLLDAC_INVALID; - int getFreqPllDac() { - if (freqPllDac == FREQPLLDAC_INVALID) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 4, 0x0C, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_RFTC_FRQCH_DESC_PLLDACCTL, false, msgBuffer); - } - return freqPllDac; - } - - boolean setFreqChannelOverride(int freqStart) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 8, 0x0C, 0, 0, 0, 0}; - msgBuffer[4] = (byte)(freqStart & 0xFF); - msgBuffer[5] = (byte)((freqStart >> 8) & 0xFF); - msgBuffer[6] = (byte)((freqStart >> 16) & 0xFF); - msgBuffer[7] = (byte)((freqStart >> 24) & 0xFF); - return sendHostRegRequest(HostRegRequests.HST_RFTC_FRQCH_CMDSTART, true, msgBuffer); - } } class AntennaSelectedData { AntennaSelectedData(boolean set_default_setting, int default_setting_type) { @@ -2794,16 +2284,6 @@ private class AntennaSelectedData_defaultArray { //0 for invalid default, 1 final int ANTENABLE_INVALID = -1; final int ANTENABLE_MIN = 0; final int ANTENABLE_MAX = 1; int antennaEnable = ANTENABLE_INVALID; - int getAntennaEnable() { - appendToLog("3 getAntennaEnable"); - if (antennaEnable < ANTENABLE_MIN || antennaEnable > ANTENABLE_MAX) - getHST_ANT_DESC_CFG(); - return antennaEnable; - } - boolean setAntennaEnable(int antennaEnable) { - return setAntennaEnable(antennaEnable, antennaInventoryMode, antennaLocalAlgo, antennaLocalStartQ, - antennaProfileMode, antennaLocalProfile, antennaFrequencyMode, antennaLocalFrequency); - } final int ANTINVMODE_INVALID = 0; final int ANTINVMODE_MIN = 0; final int ANTINVMODE_MAX = 1; int antennaInventoryMode = ANTINVMODE_INVALID; @@ -2940,76 +2420,15 @@ boolean setAntennaEnable(int antennaEnable, int antennaInventoryMode, int antenn final int ANTSTATUS_INVALID = -1; final int ANTSTATUS_MIN = 0; final int ANTSTATUS_MAX = 0xFFFFF; int antennaStatus = ANTSTATUS_INVALID; - int getAntennaStatus() { - if (antennaStatus < ANTSTATUS_MIN || antennaStatus > ANTSTATUS_MAX) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 3, 7, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.MAC_ANT_DESC_STAT, false, msgBuffer); - } - return antennaStatus; - } final int ANTDEFINE_INVALID = -1; final int ANTDEFINE_MIN = 0; final int ANTDEFINE_MAX = 3; int antennaDefine = ANTDEFINE_INVALID; - int getAntennaDefine() { - if (antennaDefine < ANTDEFINE_MIN || antennaDefine > ANTDEFINE_MAX) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 4, 7, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_ANT_DESC_PORTDEF, false, msgBuffer); - } - return antennaDefine; - } - final long ANTDWELL_INVALID = -1; final long ANTDWELL_MIN = 0; final long ANTDWELL_MAX = 0xFFFF; + final long ANTDWELL_INVALID = -1; long antennaDwell = ANTDWELL_INVALID; - long getAntennaDwell() { - if (antennaDwell < ANTDWELL_MIN || antennaDwell > ANTDWELL_MAX) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 5, 7, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_ANT_DESC_DWELL, false, msgBuffer); - } - return antennaDwell; - } - boolean setAntennaDwell(long antennaDwell) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 5, 7, 0, 0, 0, 0}; - if (antennaDwell < ANTDWELL_MIN || antennaDwell > ANTDWELL_MAX) - antennaDwell = mDefault.antennaDwell; - if (this.antennaDwell == antennaDwell && sameCheck) return true; - msgBuffer[4] = (byte) (antennaDwell % 256); - msgBuffer[5] = (byte) ((antennaDwell >> 8) % 256); - msgBuffer[6] = (byte) ((antennaDwell >> 16) % 256); - msgBuffer[7] = (byte) ((antennaDwell >> 24) % 256); - this.antennaDwell = antennaDwell; - return sendHostRegRequest(HostRegRequests.HST_ANT_DESC_DWELL, true, msgBuffer); - } - - final int ANTARGET_INVALID = -1; final int ANTARGET_MIN = 0; final int ANTARGET_MAX = 1; - int antennaTarget = ANTARGET_INVALID; - byte[] antennaInventoryRoundControl = null; - final int ANTOGGLE_INVALID = -1; final int ANTOGGLE_MIN = 0; final int ANTOGGLE_MAX = 100; - int antennaToggle = ANTOGGLE_INVALID; - final int ANTRFMODE_INVALID = -1; final int ANTRFMODE_MIN = 1; final int ANTRFMODE_MAX = 15; - int antennaRfMode = ANTRFMODE_INVALID; final long ANTPOWER_INVALID = -1; final long ANTPOWER_MIN = 0; final long ANTPOWER_MAX = 330; //Maximum 330\ long antennaPower = ANTPOWER_INVALID; //default value = 300 - long getAntennaPower() { - if (antennaPower < ANTPOWER_MIN || antennaPower > ANTPOWER_MAX) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 6, 7, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_ANT_DESC_RFPOWER, false, msgBuffer); - } - return antennaPower; - } - boolean antennaPowerSet = false; - boolean setAntennaPower(long antennaPower) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 6, 7, 0, 0, 0, 0}; - if (antennaPower < ANTPOWER_MIN || antennaPower > ANTPOWER_MAX) - antennaPower = mDefault.antennaPower; - if (this.antennaPower == antennaPower && sameCheck) return true; - msgBuffer[4] = (byte) (antennaPower % 256); - msgBuffer[5] = (byte) ((antennaPower >> 8) % 256); - this.antennaPower = antennaPower; - antennaPowerSet = true; - appendToLog("3 setPowerLevel"); - return sendHostRegRequest(HostRegRequests.HST_ANT_DESC_RFPOWER, true, msgBuffer); - } final long ANTINVCOUNT_INVALID = -1; final long ANTINVCOUNT_MIN = 0; final long ANTINVCOUNT_MAX = 0xFFFFFFFFL; long antennaInvCount = ANTINVCOUNT_INVALID; @@ -3020,18 +2439,6 @@ long getAntennaInvCount() { } return antennaInvCount; } - boolean setAntennaInvCount(long antennaInvCount) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 7, 7, 0, 0, 0, 0}; - if (antennaInvCount < ANTINVCOUNT_MIN || antennaInvCount > ANTINVCOUNT_MAX) - antennaInvCount = mDefault.antennaInvCount; - if (this.antennaInvCount == antennaInvCount && sameCheck) return true; - msgBuffer[4] = (byte) (antennaInvCount % 256); - msgBuffer[5] = (byte) ((antennaInvCount >> 8) % 256); - msgBuffer[6] = (byte) ((antennaInvCount >> 16) % 256); - msgBuffer[7] = (byte) ((antennaInvCount >> 24) % 256); - this.antennaInvCount = antennaInvCount; - return sendHostRegRequest(HostRegRequests.HST_ANT_DESC_INV_CNT, true, msgBuffer); - } } class InvSelectData { InvSelectData(boolean set_default_setting) { @@ -3043,7 +2450,6 @@ class InvSelectData { selectMaskBank = mDefault.selectMaskBank; selectMaskOffset = mDefault.selectMaskOffset; selectMaskLength = mDefault.selectMaskLength; - selectMaskDataReady = mDefault.selectMaskDataReady; } } @@ -3055,207 +2461,29 @@ private class InvSelectData_default { int selectMaskBank = 0; int selectMaskOffset = 0; int selectMaskLength = 0; - byte[] selectMaskData0_31 = new byte[4 * 8]; byte selectMaskDataReady = 0; } InvSelectData.InvSelectData_default mDefault = new InvSelectData.InvSelectData_default(); final int INVSELENABLE_INVALID = 0; final int INVSELENABLE_MIN = 0; final int INVSELENABLE_MAX = 1; int selectEnable = INVSELENABLE_INVALID; - int getSelectEnable() { - getRx000HostReg_HST_TAGMSK_DESC_CFG(); - return selectEnable; - } - boolean setSelectEnable(int selectEnable) { - appendToLog("1 setRx000HostReg_HST_TAGMSK_DESC_CFG: selectEnable = " + selectEnable); - return setRx000HostReg_HST_TAGMSK_DESC_CFG(selectEnable, this.selectTarget, this.selectAction, this.selectDelay); - } final int INVSELTARGET_INVALID = -1; final int INVSELTARGET_MIN = 0; final int INVSELTARGET_MAX = 7; int selectTarget = INVSELTARGET_INVALID; - int getSelectTarget() { - getRx000HostReg_HST_TAGMSK_DESC_CFG(); - return selectTarget; - } final int INVSELACTION_INVALID = -1; final int INVSELACTION_MIN = 0; final int INVSELACTION_MAX = 7; int selectAction = INVSELACTION_INVALID; - int getSelectAction() { - getRx000HostReg_HST_TAGMSK_DESC_CFG(); - return selectAction; - } final int INVSELDELAY_INVALID = -1; final int INVSELDELAY_MIN = 0; final int INVSELDELAY_MAX = 255; int selectDelay = INVSELDELAY_INVALID; - int getSelectDelay() { - getRx000HostReg_HST_TAGMSK_DESC_CFG(); - return selectDelay; - } - - boolean getRx000HostReg_HST_TAGMSK_DESC_CFG() { - if (selectEnable < INVSELENABLE_MIN || selectEnable > INVSELENABLE_MAX - || selectTarget < INVSELTARGET_MIN || selectTarget > INVSELTARGET_MAX - || selectAction < INVSELACTION_MIN || selectAction > INVSELACTION_MAX - || selectDelay < INVSELDELAY_MIN || selectDelay > INVSELDELAY_MAX - ) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 1, 8, 0, 0, 0, 0}; - return sendHostRegRequest(HostRegRequests.HST_TAGMSK_DESC_CFG, false, msgBuffer); - } else { - return false; - } - } - boolean setRx000HostReg_HST_TAGMSK_DESC_CFG(int selectEnable, int selectTarget, int selectAction, int selectDelay) { - appendToLog("0 setRx000HostReg_HST_TAGMSK_DESC_CFG: selectEnable = " + selectEnable + ", selectTarget" + selectTarget + ", selectAction = " + selectAction + ", selectDelay = " + selectDelay); - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, 8, 0, 0, 0, 0}; - if (selectEnable < INVSELENABLE_MIN || selectEnable > INVSELENABLE_MAX) - selectEnable = mDefault.selectEnable; - if (selectTarget < INVSELTARGET_MIN || selectTarget > INVSELTARGET_MAX) - selectTarget = mDefault.selectTarget; - if (selectAction < INVSELACTION_MIN || selectAction > INVSELACTION_MAX) - selectAction = mDefault.selectAction; - int selectDalay0 = selectDelay; - if (selectDelay < INVSELDELAY_MIN || selectDelay > INVSELDELAY_MAX) - selectDelay = mDefault.selectDelay; - if (this.selectEnable == selectEnable && this.selectTarget == selectTarget && this.selectAction == selectAction && this.selectDelay == selectDelay && sameCheck) return true; - msgBuffer[4] |= (byte) (selectEnable & 0x1); - msgBuffer[4] |= (byte) ((selectTarget & 0x07) << 1); - msgBuffer[4] |= (byte) ((selectAction & 0x07) << 4); - msgBuffer[5] |= (byte) (selectDelay & 0xFF); - this.selectEnable = selectEnable; - this.selectTarget = selectTarget; - this.selectAction = selectAction; - this.selectDelay = selectDelay; - return sendHostRegRequest(HostRegRequests.HST_TAGMSK_DESC_CFG, true, msgBuffer); - } final int INVSELMBANK_INVALID = -1; final int INVSELMBANK_MIN = 0; final int INVSELMBANK_MAX = 3; int selectMaskBank = INVSELMBANK_INVALID; - int getSelectMaskBank() { - if (selectMaskBank < INVSELMBANK_MIN || selectMaskBank > INVSELMBANK_MAX) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 2, 8, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_TAGMSK_BANK, false, msgBuffer); - } - return selectMaskBank; - } - boolean setSelectMaskBank(int selectMaskBank) { - appendToLog("0 setSelectMaskBank with selectMaskBank = " + selectMaskBank); - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 2, 8, 0, 0, 0, 0}; - if (selectMaskBank < INVSELMBANK_MIN || selectMaskBank > INVSELMBANK_MAX) - selectMaskBank = mDefault.selectMaskBank; - if (this.selectMaskBank == selectMaskBank && sameCheck) return true; - msgBuffer[4] |= (byte) (selectMaskBank & 0x3); - this.selectMaskBank = selectMaskBank; - return sendHostRegRequest(HostRegRequests.HST_TAGMSK_BANK, true, msgBuffer); - } final int INVSELMOFFSET_INVALID = -1; final int INVSELMOFFSET_MIN = 0; final int INVSELMOFFSET_MAX = 0xFFFF; int selectMaskOffset = INVSELMOFFSET_INVALID; - int getSelectMaskOffset() { - if (selectMaskOffset < INVSELMOFFSET_MIN || selectMaskOffset > INVSELMOFFSET_MAX) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 3, 8, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_TAGMSK_PTR, false, msgBuffer); - } - return selectMaskOffset; - } - boolean setSelectMaskOffset(int selectMaskOffset) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 3, 8, 0, 0, 0, 0}; - if (selectMaskOffset < INVSELMOFFSET_MIN || selectMaskOffset > INVSELMOFFSET_MAX) - selectMaskOffset = mDefault.selectMaskOffset; - if (this.selectMaskOffset == selectMaskOffset && sameCheck) return true; - msgBuffer[4] |= (byte) (selectMaskOffset & 0xFF); - msgBuffer[5] |= (byte) ((selectMaskOffset >> 8) & 0xFF); - this.selectMaskOffset = selectMaskOffset; - return sendHostRegRequest(HostRegRequests.HST_TAGMSK_PTR, true, msgBuffer); - } final int INVSELMLENGTH_INVALID = -1; final int INVSELMLENGTH_MIN = 0; final int INVSELMLENGTH_MAX = 255; int selectMaskLength = INVSELMLENGTH_INVALID; - int getSelectMaskLength() { - appendToLog("getSelectMaskData with selectMaskLength = " + selectMaskLength); - if (selectMaskLength < INVSELMLENGTH_MIN || selectMaskOffset > INVSELMLENGTH_MAX) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 4, 8, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_TAGMSK_LEN, false, msgBuffer); - } - return selectMaskLength; - } - boolean setSelectMaskLength(int selectMaskLength) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 4, 8, 0, 0, 0, 0}; - 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; if (false) appendToLog("getSelectMaskData with saved selectMaskLength = " + selectMaskLength); - return sendHostRegRequest(HostRegRequests.HST_TAGMSK_PTR, true, msgBuffer); - } - - byte[] selectMaskData0_31 = new byte[4 * 8]; byte selectMaskDataReady = 0; - String getRx000SelectMaskData() { - appendToLog("getSelectMaskData with selectMaskData0_31 = " + byteArrayToString(selectMaskData0_31)); - int length = selectMaskLength; - String strValue = ""; - if (length < 0) { - getSelectMaskLength(); - } else { - for (int i = 0; i < 8; i++) { - if (length > 0) { - if ((selectMaskDataReady & (0x01 << i)) == 0) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 5, 8, 0, 0, 0, 0}; - msgBuffer[2] += i; - sendHostRegRequest(HostRegRequests.HST_TAGMSK_0_3, false, msgBuffer); - - strValue = null; - break; - } else { - for (int j = 0; j < 4; j++) { - if (DEBUG) appendToLog("i = " + i + ", j = " + j + ", selectMaskData0_31 = " + selectMaskData0_31[i * 4 + j]); - strValue += String.format("%02X", selectMaskData0_31[i * 4 + j]); - } - } - length -= 32; - } - } - } - return strValue; - } - boolean setRx000SelectMaskData(String maskData) { - int length = maskData.length(); - for (int i = 0; i < 8; i++) { - if (length > 0) { - length -= 8; - - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 5, 8, 0, 0, 0, 0}; - String hexString = "0123456789ABCDEF"; - for (int j = 0; j < 8; j++) { - if (i * 8 + j + 1 <= maskData.length()) { - String subString = maskData.substring(i * 8 + j, i * 8 + j + 1).toUpperCase(); - int k = 0; - for (k = 0; k < 16; k++) { - if (subString.matches(hexString.substring(k, k + 1))) { - break; - } - } - if (k == 16) return false; -// appendToLog("setSelectMaskData(" + maskData +"): i=" + i + ", j=" + j + ", k=" + k); - if ((j / 2) * 2 == j) { - msgBuffer[4 + j / 2] |= (byte) (k << 4); - } else { - msgBuffer[4 + j / 2] |= (byte) (k); - } - } - } - msgBuffer[2] = (byte) ((msgBuffer[2] & 0xFF) + i); - if (sendHostRegRequest(HostRegRequests.HST_TAGMSK_0_3, true, msgBuffer) == false) - return false; - else { - selectMaskDataReady |= (0x01 << i); - if (DEBUG) appendToLog("Old selectMaskData0_31 = " + byteArrayToString(selectMaskData0_31)); - System.arraycopy(msgBuffer, 4, selectMaskData0_31, i * 4, 4); - if (DEBUG) appendToLog("New selectMaskData0_31 = " + byteArrayToString(selectMaskData0_31)); - } - } - } - return true; - } } class AlgoSelectedData { AlgoSelectedData(boolean set_default_setting, int default_setting_type) { @@ -3341,45 +2569,15 @@ int getAlgoMinQ() { if (algoMinQ < ALGOMINQ_MIN || algoMinQ > ALGOMINQ_MAX) getHST_INV_ALG_PARM_0(); return algoMinQ; } - boolean setAlgoMinQ(int algoMinQ) { - appendToLog("1C setAlgoStartQ"); - return setAlgoStartQ(algoStartQ, algoMaxQ, algoMinQ, algoMaxRep, algoHighThres, algoLowThres); - } final int ALGOMAXREP_INVALID = -1; final int ALGOMAXREP_MIN = 0; final int ALGOMAXREP_MAX = 255; int algoMaxRep = ALGOMAXREP_INVALID; - int getAlgoMaxRep() { - if (algoMaxRep < ALGOMAXREP_MIN || algoMaxRep > ALGOMAXREP_MAX) getHST_INV_ALG_PARM_0(); - return algoMaxRep; - } - boolean setAlgoMaxRep(int algoMaxRep) { - appendToLog("1d setAlgoStartQ"); - return setAlgoStartQ(algoStartQ, algoMaxQ, algoMinQ, algoMaxRep, algoHighThres, algoLowThres); - } final int ALGOHIGHTHRES_INVALID = -1; final int ALGOHIGHTHRES_MIN = 0; final int ALGOHIGHTHRES_MAX = 15; int algoHighThres = ALGOHIGHTHRES_INVALID; - int getAlgoHighThres() { - if (algoHighThres < ALGOHIGHTHRES_MIN || algoHighThres > ALGOHIGHTHRES_MAX) - getHST_INV_ALG_PARM_0(); - return algoHighThres; - } - boolean setAlgoHighThres(int algoHighThres) { - appendToLog("1E setAlgoStartQ"); - return setAlgoStartQ(algoStartQ, algoMaxQ, algoMinQ, algoMaxRep, algoHighThres, algoLowThres); - } final int ALGOLOWTHRES_INVALID = -1; final int ALGOLOWTHRES_MIN = 0; final int ALGOLOWTHRES_MAX = 15; int algoLowThres = ALGOLOWTHRES_INVALID; - int getAlgoLowThres() { - if (algoLowThres < ALGOLOWTHRES_MIN || algoLowThres > ALGOLOWTHRES_MAX) - getHST_INV_ALG_PARM_0(); - return algoLowThres; - } - boolean setAlgoLowThres(int algoLowThres) { - appendToLog("1F setAlgoStartQ"); - return setAlgoStartQ(algoStartQ, algoMaxQ, algoMinQ, algoMaxRep, algoHighThres, algoLowThres); - } private boolean getHST_INV_ALG_PARM_0() { byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 3, 9, 0, 0, 0, 0}; @@ -3419,23 +2617,6 @@ boolean setAlgoStartQ(int startQ, int algoMaxQ, int algoMinQ, int algoMaxRep, in final int ALGORETRY_INVALID = -1; final int ALGORETRY_MIN = 0; final int ALGORETRY_MAX = 255; int algoRetry = ALGORETRY_INVALID; - int getAlgoRetry() { - if (algoRetry < ALGORETRY_MIN || algoRetry > ALGORETRY_MAX) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 4, 9, 0, 0, 0, 0}; - sendHostRegRequest(HostRegRequests.HST_INV_ALG_PARM_1, false, msgBuffer); - } - return algoRetry; - } - boolean setAlgoRetry(int algoRetry) { - appendToLog("2 setAlgoRetry[" + algoRetry + "]"); - if (algoRetry < ALGORETRY_MIN || algoRetry > ALGORETRY_MAX) - algoRetry = mDefault.algoRetry; - if (false && this.algoRetry == algoRetry && sameCheck) return true; - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 4, 9, 0, 0, 0, 0}; - msgBuffer[4] = (byte) algoRetry; - this.algoRetry = algoRetry; - return sendHostRegRequest(HostRegRequests.HST_INV_ALG_PARM_1, true, msgBuffer); - } final int ALGOABFLIP_INVALID = -1; final int ALGOABFLIP_MIN = 0; final int ALGOABFLIP_MAX = 1; int algoAbFlip = ALGOABFLIP_INVALID; @@ -3443,9 +2624,6 @@ int getAlgoAbFlip() { if (algoAbFlip < ALGOABFLIP_MIN || algoAbFlip > ALGOABFLIP_MAX) getHST_INV_ALG_PARM_2(); return algoAbFlip; } - boolean setAlgoAbFlip(int algoAbFlip) { - return setAlgoAbFlip(algoAbFlip, algoRunTilZero); - } final int ALGORUNTILZERO_INVALID = -1; final int ALGORUNTILZERO_MIN = 0; final int ALGORUNTILZERO_MAX = 1; int algoRunTilZero = ALGORUNTILZERO_INVALID; @@ -3482,1258 +2660,915 @@ boolean setAlgoAbFlip(int algoAbFlip, int algoRunTilZero) { } public class Rx000EngSetting { int narrowRSSI = -1, wideRSSI = -1; - int getwideRSSI() { - if (wideRSSI < 0) { - setPwrManagementMode(false); - rx000Setting.writeMAC(0x100, 0x05); //sub-command: 0x05, Arg0: reserved - rx000Setting.writeMAC(0x101, 3 + 0x20000); //Arg1: 15-0: number of RSSI sample - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_ENGTEST); - } else appendToLog("Hello123: wideRSSI = " + wideRSSI); - return wideRSSI; - } - int getnarrowRSSI() { - if (narrowRSSI < 0) { - setPwrManagementMode(false); - rx000Setting.writeMAC(0x100, 0x05); //sub-command: 0x05, Arg0: reserved - rx000Setting.writeMAC(0x101, 3 + 0x20000); //Arg1: 15-0: number of RSSI sample - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_ENGTEST); - } else appendToLog("Hello123: narrowRSSI = " + wideRSSI); - return wideRSSI; - } public void resetRSSI() { narrowRSSI = -1; wideRSSI = -1; } } - class Rx000MbpSetting { - final int RXGAIN_INVALID = -1; final int RXGAIN_MIN = 0; final int RXGAIN_MAX = 0x1FF; - int rxGain = RXGAIN_INVALID; - int getHighCompression() { - int iRetValue = -1; - if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { - setPwrManagementMode(false); - rx000Setting.setMBPAddress(0x450); appendToLog("70010004: getHighCompression"); - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_MBPRDREG); - } else iRetValue = (rxGain >> 8); - return iRetValue; - } - int getRflnaGain() { - int iRetValue = -1; - if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { - setPwrManagementMode(false); - rx000Setting.setMBPAddress(0x450); appendToLog("70010004: getRflnaGain"); - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_MBPRDREG); - } else iRetValue = ((rxGain & 0xC0) >> 6); - return iRetValue; - } - int getIflnaGain() { - int iRetValue = -1; - if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { - setPwrManagementMode(false); - rx000Setting.setMBPAddress(0x450); appendToLog("70010004: getIflnaGain"); - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_MBPRDREG); - } else iRetValue = ((rxGain & 0x38) >> 3); - return iRetValue; - } - int getAgcGain() { - int iRetValue = -1; - if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { - setPwrManagementMode(false); - rx000Setting.setMBPAddress(0x450); appendToLog("70010004: getAgcGain"); - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_MBPRDREG); - } else iRetValue = (rxGain & 0x07); - return iRetValue; - } - int getRxGain() { - int iRetValue = -1; - if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { - setPwrManagementMode(false); - rx000Setting.setMBPAddress(0x450); - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_MBPRDREG); - } else iRetValue = rxGain; - return iRetValue; - } - boolean setRxGain(int highCompression, int rflnagain, int iflnagain, int agcgain) { - int rxGain_new = ((highCompression & 0x01) << 8) | ((rflnagain & 0x3) << 6) | ((iflnagain & 0x7) << 3) | (agcgain & 0x7); - return setRxGain(rxGain_new); - } - boolean setRxGain(int rxGain_new) { - boolean bRetValue = true; - if ((rxGain_new != rxGain) || (sameCheck == false)) { - setPwrManagementMode(false); - appendToLog("2 setRxGain"); - bRetValue = rx000Setting.setMBPAddress(0x450); if (false) appendToLog("70010004: setRxGain"); - if (bRetValue != false) bRetValue = rx000Setting.setMBPData(rxGain_new); - if (bRetValue != false) bRetValue = sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_MBPWRREG); - if (bRetValue != false) rxGain = rxGain_new; - } - return bRetValue; - } - } - class Rx000OemSetting { - final int COUNTRYCODE_INVALID = -1; final int COUNTRYCODE_MIN = 1; final int COUNTRYCODE_MAX = 9; - int countryCode = COUNTRYCODE_INVALID; // OemAddress = 0x02 - int getCountryCode() { - if (countryCode < COUNTRYCODE_MIN || countryCode > COUNTRYCODE_MAX) { - setPwrManagementMode(false); - rx000Setting.setOEMAddress(2); - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_RDOEM); - } - return countryCode; - } - - final int SERIALCODE_INVALID = -1; - byte[] serialNumber = new byte[] { SERIALCODE_INVALID, 0, 0, 0, SERIALCODE_INVALID, 0, 0, 0, SERIALCODE_INVALID, 0, 0, 0, SERIALCODE_INVALID, 0, 0, 0 }; - String getSerialNumber() { - boolean invalid = false; - int length = serialNumber.length / 4; - if (serialNumber.length % 4 != 0) length++; - for (int i = 0; i < length; i++) { - if (serialNumber[4 * i] == SERIALCODE_INVALID) { // OemAddress = 0x04 - 7 - invalid = true; - setPwrManagementMode(false); - rx000Setting.setOEMAddress(0x04 + i); - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_RDOEM); - } - } - if (invalid) return null; - appendToLog("retValue = " + byteArrayToString(serialNumber)); - byte[] retValue = new byte[serialNumber.length]; - for (int i = 0; i < retValue.length; i++) { - int j = (i/4)*4 + 3 - i%4; - if (j >= serialNumber.length) retValue[i] = serialNumber[i]; - else retValue[i] = serialNumber[j]; - if (retValue[i] == 0) retValue[i] = 0x30; - } - appendToLog("retValue = " + byteArrayToString(retValue) + ", String = " + new String(retValue)); - return new String(retValue); - } - - final int PRODUCT_SERIALCODE_INVALID = -1; - byte[] productserialNumber = new byte[] { SERIALCODE_INVALID, 0, 0, 0, SERIALCODE_INVALID, 0, 0, 0, SERIALCODE_INVALID, 0, 0, 0, SERIALCODE_INVALID, 0, 0, 0 }; - String getProductSerialNumber() { - boolean invalid = false; - int length = productserialNumber.length / 4; - if (productserialNumber.length % 4 != 0) length++; - for (int i = 0; i < length; i++) { - if (productserialNumber[4 * i] == PRODUCT_SERIALCODE_INVALID) { // OemAddress = 0x04 - 7 - invalid = true; - appendToLog(i + " start setOEMAddress"); - setPwrManagementMode(false); - rx000Setting.setOEMAddress(0x08 + i); - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_RDOEM); - } - } - if (invalid) return null; - appendToLog("retValue = " + byteArrayToString(productserialNumber)); - byte[] retValue = new byte[productserialNumber.length]; - for (int i = 0; i < retValue.length; i++) { - int j = (i/4)*4 + 3 - i%4; - if (j >= productserialNumber.length) retValue[i] = productserialNumber[i]; - else retValue[i] = productserialNumber[j]; - if (retValue[i] == 0) retValue[i] = 0x30; - } - appendToLog("retValue = " + byteArrayToString(retValue) + ", String = " + new String(retValue)); - return new String(retValue); - } - final int VERSIONCODE_INVALID = -1; final int VERSIONCODE_MIN = 1; final int VERSIONCODE_MAX = 9; - int versionCode = VERSIONCODE_INVALID; // OemAddress = 0x02 - int getVersionCode() { - if (versionCode < VERSIONCODE_MIN || versionCode > VERSIONCODE_MAX) { - setPwrManagementMode(false); - rx000Setting.setOEMAddress(0x0B); - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_RDOEM); - } - return versionCode; - } + public boolean bFirmware_reset_before = false; + final int RFID_READING_BUFFERSIZE = 600; //1024; - String spcialCountryVersion = null; - String getSpecialCountryVersion() { - if (spcialCountryVersion == null) { - setPwrManagementMode(false); - rx000Setting.setOEMAddress(0x8E); - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_RDOEM); - return ""; - } - return spcialCountryVersion.replaceAll("[^A-Za-z0-9]", ""); - } + byte[] mRfidToReading = new byte[RFID_READING_BUFFERSIZE]; + int mRfidToReadingOffset = 0; + ArrayList mRx000ToWrite = new ArrayList<>(); - final int FREQMODIFYCODE_INVALID = -1; final int FREQMODIFYCODE_MIN = 0; final int FREQMODIFYCODE_MAX = 0xAA; - int freqModifyCode = FREQMODIFYCODE_INVALID; // OemAddress = 0x8A - int getFreqModifyCode() { - if (freqModifyCode < FREQMODIFYCODE_MIN || freqModifyCode > FREQMODIFYCODE_MAX) { - setPwrManagementMode(false); - rx000Setting.setOEMAddress(0x8F); - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_RDOEM); - } - return freqModifyCode; - } + public Rx000Setting rx000Setting = new Rx000Setting(true); + public Rx000EngSetting rx000EngSetting = new Rx000EngSetting(); - void writeOEM(int address, int value) { - setPwrManagementMode(false); - rx000Setting.setOEMAddress(address); - rx000Setting.setOEMData(value); - sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_WROEM); - } - } - public boolean bFirmware_reset_before = false; - final int RFID_READING_BUFFERSIZE = 600; //1024; -// class RfidReaderChip { - byte[] mRfidToReading = new byte[RFID_READING_BUFFERSIZE]; - int mRfidToReadingOffset = 0; - ArrayList mRx000ToWrite = new ArrayList<>(); - - public Rx000Setting rx000Setting = new Rx000Setting(true); - public Rx000EngSetting rx000EngSetting = new Rx000EngSetting(); - Rx000MbpSetting rx000MbpSetting = new Rx000MbpSetting(); - Rx000OemSetting rx000OemSetting = new Rx000OemSetting(); - - public ArrayList mRx000ToRead = new ArrayList<>(); - private boolean clearTempDataIn_request = false; - boolean commandOperating; - - public double decodeNarrowBandRSSI(byte byteRSSI) { - byte mantissa = byteRSSI; - mantissa &= 0x07; - byte exponent = byteRSSI; - exponent >>= 3; - double dValue = 20 * log10(pow(2, exponent) * (1 + (mantissa / pow(2, 3)))); - if (false) appendToLog("byteRSSI = " + String.format("%X", byteRSSI) + ", mantissa = " + mantissa + ", exponent = " + exponent + "dValue = " + dValue); - return dValue; - } - int encodeNarrowBandRSSI(double dRSSI) { - double dValue = dRSSI / 20; - dValue = pow(10, dValue); - int exponent = 0; - if (false) appendToLog("exponent = " + exponent + ", dValue = " + dValue); - while ((dValue + 0.062) >= 2) { - dValue /= 2; exponent++; - if (false) appendToLog("exponent = " + exponent + ", dValue = " + dValue); - } - dValue--; - int mantissa = (int)((dValue * 8) + 0.5); - while (mantissa >= 8) { - mantissa -= 8; exponent++; - } - int iValue = ((exponent & 0x1F) << 3) | (mantissa & 0x7); - if (false) appendToLog("dRssi = " + dRSSI + ", exponent = " + exponent + ", mantissa = " + mantissa + ", iValue = " + String.format("%X", iValue)); - return iValue; - } + public ArrayList mRx000ToRead = new ArrayList<>(); + boolean commandOperating; - long firmware_ontime_ms = 0; long date_time_ms = 0; public boolean bRx000ToReading = false; - int getBytes2EpcLength(byte[] bytes) { - int iValue = ((bytes[0] & 0xFF) >> 3) * 2; - if (false) appendToLog("bytes = " + byteArrayToString(bytes) + ", iValue = " + iValue); - return iValue; - } - void mRx000UplinkHandler() { - boolean DEBUG = false; - if (bRx000ToReading) return; - bRx000ToReading = true; - int startIndex = 0, startIndexOld = 0, startIndexNew = 0; - boolean packageFound = false; - int packageType = 0; - long lTime = System.currentTimeMillis(); - if (csReaderConnector.rfidConnector.mRfidToRead.size() != 0) { if (DEBUGTHREAD) appendToLog("mRx000UplinkHandler(): START with mRfidToRead size = " + csReaderConnector.rfidConnector.mRfidToRead.size() + ", mRx000ToRead size = " + mRx000ToRead.size()); } - else if (DEBUGTHREAD) appendToLog("START AAA with mRx000ToRead size = " + mRx000ToRead.size()); - if (false && mRx000ToRead.size() != 0) appendToLog("START AAA with mRx000ToRead size = " + mRx000ToRead.size()); - boolean bFirst = true; - while (csReaderConnector.rfidConnector.mRfidToRead.size() != 0) { - if (DEBUG) appendToLog("Looping with mRfidToRead.size = " + csReaderConnector.rfidConnector.mRfidToRead.size() + " with bleConnected = " + csReaderConnector.isBleConnected()); - if (csReaderConnector.isBleConnected() == false) { - csReaderConnector.rfidConnector.mRfidToRead.clear(); - appendToLog("BLE DISCONNECTED !!! mRfidToRead.size() = " + csReaderConnector.rfidConnector.mRfidToRead.size()); - } else if (System.currentTimeMillis() - lTime > (intervalRx000UplinkHandler/2)) { - writeDebug2File("D" + String.valueOf(intervalRx000UplinkHandler) + ", " + System.currentTimeMillis() + ", Timeout"); - appendToLogView("TIMEOUT !!! mRfidToRead.size() = " + csReaderConnector.rfidConnector.mRfidToRead.size()); - break; - } else { - if (DEBUG) appendToLog("Check bFirst = " + bFirst); - if (bFirst) { bFirst = false; writeDebug2File("D" + String.valueOf(intervalRx000UplinkHandler) + ", " + System.currentTimeMillis()); } - byte[] dataIn = csReaderConnector.rfidConnector.mRfidToRead.get(0).dataValues; - long tagMilliSeconds = csReaderConnector.rfidConnector.mRfidToRead.get(0).milliseconds; - boolean invalidSequence = csReaderConnector.rfidConnector.mRfidToRead.get(0).invalidSequence; - if (DEBUG_APDATA) appendToLog("ApData: found mRfidToRead data with invalidSequence= " + invalidSequence + ", bytes= " + byteArrayToString(dataIn)); - csReaderConnector.rfidConnector.mRfidToRead.remove(0); - - if (DEBUG) appendToLog("Check buffer size: data.length = " + dataIn.length+ ", mRfidToReading.length = " + mRfidToReading.length + ", mRfidToReadingOffset = " + mRfidToReadingOffset); - if (dataIn.length >= mRfidToReading.length - mRfidToReadingOffset) { - if (mRfidToReadingOffset != 0) { - byte[] unhandledBytes = new byte[mRfidToReadingOffset]; - System.arraycopy(mRfidToReading, 0, unhandledBytes, 0, unhandledBytes.length); - appendToLogView("!!! ERROR insufficient buffer, mRfidToReadingOffset=" + mRfidToReadingOffset + ", dataIn.length=" + dataIn.length + ", clear mRfidToReading: " + byteArrayToString(unhandledBytes)); - byte[] mRfidToReadingNew = new byte[RFID_READING_BUFFERSIZE]; - mRfidToReading = mRfidToReadingNew; - mRfidToReadingOffset = 0; - csReaderConnector.invalidUpdata++; - } - if (dataIn.length >= mRfidToReading.length - mRfidToReadingOffset) { - appendToLogView("!!! ERROR insufficient buffer, mRfidToReading.length=" + mRfidToReading.length + ", dataIn.length=" + dataIn.length + ", clear mRfidToReading: " + byteArrayToString(dataIn)); - csReaderConnector.invalidata++; - break; - } - } + public double decodeNarrowBandRSSI(byte byteRSSI) { + byte mantissa = byteRSSI; + mantissa &= 0x07; + byte exponent = byteRSSI; + exponent >>= 3; + double dValue = 20 * log10(pow(2, exponent) * (1 + (mantissa / pow(2, 3)))); + if (false) appendToLog("byteRSSI = " + String.format("%X", byteRSSI) + ", mantissa = " + mantissa + ", exponent = " + exponent + "dValue = " + dValue); + return dValue; + } - if (DEBUG) appendToLog("Check invalidSequence = " + invalidSequence + " with mRfidToReadingOffset = " + mRfidToReadingOffset); - if (mRfidToReadingOffset != 0 && invalidSequence) { + public boolean bRx000ToReading = false; + int getBytes2EpcLength(byte[] bytes) { + int iValue = ((bytes[0] & 0xFF) >> 3) * 2; + if (false) appendToLog("bytes = " + byteArrayToString(bytes) + ", iValue = " + iValue); + return iValue; + } + void uplinkHandler() { + boolean DEBUG = false; + if (bRx000ToReading) return; + bRx000ToReading = true; + int startIndex = 0, startIndexOld = 0, startIndexNew = 0; + boolean packageFound = false; + int packageType = 0; + long lTime = System.currentTimeMillis(); + if (csReaderConnector.rfidConnector.mRfidToRead.size() != 0) { if (DEBUGTHREAD) appendToLog("mRx000UplinkHandler(): START with mRfidToRead size = " + csReaderConnector.rfidConnector.mRfidToRead.size() + ", mRx000ToRead size = " + mRx000ToRead.size()); } + else if (DEBUGTHREAD) appendToLog("START AAA with mRx000ToRead size = " + mRx000ToRead.size()); + if (false && mRx000ToRead.size() != 0) appendToLog("START AAA with mRx000ToRead size = " + mRx000ToRead.size()); + boolean bFirst = true; + while (csReaderConnector.rfidConnector.mRfidToRead.size() != 0) { + if (DEBUG) appendToLog("Looping with mRfidToRead.size = " + csReaderConnector.rfidConnector.mRfidToRead.size() + " with bleConnected = " + csReaderConnector.isBleConnected()); + if (csReaderConnector.isBleConnected() == false) { + csReaderConnector.rfidConnector.mRfidToRead.clear(); + appendToLog("BLE DISCONNECTED !!! mRfidToRead.size() = " + csReaderConnector.rfidConnector.mRfidToRead.size()); + } else if (System.currentTimeMillis() - lTime > (intervalRx000UplinkHandler/2)) { + writeDebug2File("D" + String.valueOf(intervalRx000UplinkHandler) + ", " + System.currentTimeMillis() + ", Timeout"); + appendToLogView("TIMEOUT !!! mRfidToRead.size() = " + csReaderConnector.rfidConnector.mRfidToRead.size()); + break; + } else { + if (DEBUG) appendToLog("Check bFirst = " + bFirst); + if (bFirst) { bFirst = false; writeDebug2File("D" + String.valueOf(intervalRx000UplinkHandler) + ", " + System.currentTimeMillis()); } + byte[] dataIn = csReaderConnector.rfidConnector.mRfidToRead.get(0).dataValues; + long tagMilliSeconds = csReaderConnector.rfidConnector.mRfidToRead.get(0).milliseconds; + boolean invalidSequence = csReaderConnector.rfidConnector.mRfidToRead.get(0).invalidSequence; + if (DEBUG_APDATA) appendToLog("ApData: found mRfidToRead data with invalidSequence= " + invalidSequence + ", bytes= " + byteArrayToString(dataIn)); + csReaderConnector.rfidConnector.mRfidToRead.remove(0); + + if (DEBUG) appendToLog("Check buffer size: data.length = " + dataIn.length+ ", mRfidToReading.length = " + mRfidToReading.length + ", mRfidToReadingOffset = " + mRfidToReadingOffset); + if (dataIn.length >= mRfidToReading.length - mRfidToReadingOffset) { + if (mRfidToReadingOffset != 0) { byte[] unhandledBytes = new byte[mRfidToReadingOffset]; System.arraycopy(mRfidToReading, 0, unhandledBytes, 0, unhandledBytes.length); - if (true) appendToLog("!!! ERROR invalidSequence with nonzero mRfidToReadingOffset=" + mRfidToReadingOffset + ", throw invalid unused data=" + unhandledBytes.length + ", " + byteArrayToString(unhandledBytes)); + appendToLogView("!!! ERROR insufficient buffer, mRfidToReadingOffset=" + mRfidToReadingOffset + ", dataIn.length=" + dataIn.length + ", clear mRfidToReading: " + byteArrayToString(unhandledBytes)); + byte[] mRfidToReadingNew = new byte[RFID_READING_BUFFERSIZE]; + mRfidToReading = mRfidToReadingNew; mRfidToReadingOffset = 0; - startIndex = 0; - startIndexNew = 0; + csReaderConnector.invalidUpdata++; + } + if (dataIn.length >= mRfidToReading.length - mRfidToReadingOffset) { + appendToLogView("!!! ERROR insufficient buffer, mRfidToReading.length=" + mRfidToReading.length + ", dataIn.length=" + dataIn.length + ", clear mRfidToReading: " + byteArrayToString(dataIn)); + csReaderConnector.invalidata++; + break; } + } - System.arraycopy(dataIn, 0, mRfidToReading, mRfidToReadingOffset, dataIn.length); - mRfidToReadingOffset += dataIn.length; - - int iPayloadSizeMin = 7; //boolean bprinted = false; - while (mRfidToReadingOffset - startIndex >= iPayloadSizeMin) { - //if (bprinted == false) { bprinted = true; appendToLog(byteArrayToString(mRfidToReading)); } - int packageLengthRead = (mRfidToReading[startIndex + 5] & 0xFF) * 256 + (mRfidToReading[startIndex + 6] & 0xFF); - int expectedLength = 7 + (mRfidToReading[startIndex + 5] & 0xFF) * 256 + (mRfidToReading[startIndex + 6] & 0xFF); - if (DEBUG) appendToLog("Looping with startIndex = " + startIndex + ", mRfidToReadingOffset = " + mRfidToReadingOffset + ", iPayloadSizeMin = " + iPayloadSizeMin + ", expectedLength = " + expectedLength); - if (true) { - if (mRfidToReading[startIndex + 0] == 0x49 - && mRfidToReading[startIndex + 1] == (byte) 0xdc - && (mRfidToReadingOffset - startIndex >= expectedLength) && (expectedLength > 7) - ) { - byte[] header = new byte[7], payload = new byte[expectedLength - 7]; - System.arraycopy(mRfidToReading, startIndex, header, 0, header.length); - System.arraycopy(mRfidToReading, startIndex + 7, payload, 0, payload.length); - int iUplinkPackageType = (mRfidToReading[startIndex + 2] & 0xFF) * 256 + (mRfidToReading[startIndex + 3] & 0xFF); - if (DEBUG_APDATA) appendToLog(String.format("ApData: found Rfid.Uplink.DataRead.UplinkPackage_%04X with payload = ", iUplinkPackageType) + byteArrayToString(payload)); - RfidReaderChipData.Rx000pkgData dataA = new RfidReaderChipData.Rx000pkgData(); - dataA.dataValues = new byte[expectedLength - 7]; - System.arraycopy(mRfidToReading, startIndex + 7, dataA.dataValues, 0, dataA.dataValues.length); - if (iUplinkPackageType == 0x3001 || iUplinkPackageType == 0x3003) { - dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_INVENTORY; - //mRfidDevice.setInventoring(true); - if (DEBUG) appendToLog("Check UplinkPackage_Event_csl_tag_read_epc_only_new data length = " + dataA.dataValues.length); - if ((iUplinkPackageType == 0x3001 && dataA.dataValues.length < 17) - || (iUplinkPackageType == 0x3003 && dataA.dataValues.length < 18)) { - appendToLog("!!! UplinkPackage_Event_csl_tag_read_epc_only_new data length has length equal or less than 15"); - dataA.decodedError = "Received UplinkPackage_Event_csl_tag_read_epc_only_new with length = " + String.valueOf(dataA.dataValues.length) + ", data = " + byteArrayToString(dataA.dataValues); + if (DEBUG) appendToLog("Check invalidSequence = " + invalidSequence + " with mRfidToReadingOffset = " + mRfidToReadingOffset); + if (mRfidToReadingOffset != 0 && invalidSequence) { + byte[] unhandledBytes = new byte[mRfidToReadingOffset]; + System.arraycopy(mRfidToReading, 0, unhandledBytes, 0, unhandledBytes.length); + if (true) appendToLog("!!! ERROR invalidSequence with nonzero mRfidToReadingOffset=" + mRfidToReadingOffset + ", throw invalid unused data=" + unhandledBytes.length + ", " + byteArrayToString(unhandledBytes)); + mRfidToReadingOffset = 0; + startIndex = 0; + startIndexNew = 0; + } + + System.arraycopy(dataIn, 0, mRfidToReading, mRfidToReadingOffset, dataIn.length); + mRfidToReadingOffset += dataIn.length; + + int iPayloadSizeMin = 7; //boolean bprinted = false; + while (mRfidToReadingOffset - startIndex >= iPayloadSizeMin) { + //if (bprinted == false) { bprinted = true; appendToLog(byteArrayToString(mRfidToReading)); } + int packageLengthRead = (mRfidToReading[startIndex + 5] & 0xFF) * 256 + (mRfidToReading[startIndex + 6] & 0xFF); + int expectedLength = 7 + (mRfidToReading[startIndex + 5] & 0xFF) * 256 + (mRfidToReading[startIndex + 6] & 0xFF); + if (DEBUG) appendToLog("Looping with startIndex = " + startIndex + ", mRfidToReadingOffset = " + mRfidToReadingOffset + ", iPayloadSizeMin = " + iPayloadSizeMin + ", expectedLength = " + expectedLength); + if (true) { + if (mRfidToReading[startIndex + 0] == 0x49 + && mRfidToReading[startIndex + 1] == (byte) 0xdc + && (mRfidToReadingOffset - startIndex >= expectedLength) && (expectedLength > 7) + ) { + byte[] header = new byte[7], payload = new byte[expectedLength - 7]; + System.arraycopy(mRfidToReading, startIndex, header, 0, header.length); + System.arraycopy(mRfidToReading, startIndex + 7, payload, 0, payload.length); + int iUplinkPackageType = (mRfidToReading[startIndex + 2] & 0xFF) * 256 + (mRfidToReading[startIndex + 3] & 0xFF); + if (DEBUG_APDATA) appendToLog(String.format("ApData: found Rfid.Uplink.DataRead.UplinkPackage_%04X with payload = ", iUplinkPackageType) + byteArrayToString(payload)); + RfidReaderChipData.Rx000pkgData dataA = new RfidReaderChipData.Rx000pkgData(); + dataA.dataValues = new byte[expectedLength - 7]; + System.arraycopy(mRfidToReading, startIndex + 7, dataA.dataValues, 0, dataA.dataValues.length); + if (iUplinkPackageType == 0x3001 || iUplinkPackageType == 0x3003) { + dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_INVENTORY; + //mRfidDevice.setInventoring(true); + if (DEBUG) appendToLog("Check UplinkPackage_Event_csl_tag_read_epc_only_new data length = " + dataA.dataValues.length); + if ((iUplinkPackageType == 0x3001 && dataA.dataValues.length < 17) + || (iUplinkPackageType == 0x3003 && dataA.dataValues.length < 18)) { + appendToLog("!!! UplinkPackage_Event_csl_tag_read_epc_only_new data length has length equal or less than 15"); + dataA.decodedError = "Received UplinkPackage_Event_csl_tag_read_epc_only_new with length = " + String.valueOf(dataA.dataValues.length) + ", data = " + byteArrayToString(dataA.dataValues); + } else { + dataA.decodedTime = System.currentTimeMillis(); + dataA.decodedRssi = get2BytesOfRssi(dataA.dataValues, 4); + if (DEBUG) appendToLog("decoded decodedRssi = " + dataA.decodedRssi); + dataA.decodedPhase = (dataA.dataValues[6] & 0xFF) * 256 + (dataA.dataValues[7] & 0xFF); + if (DEBUG) appendToLog("decoded decodedPhase = " + dataA.decodedPhase); + dataA.decodedPort = (dataA.dataValues[10] & 0xFF); + if (DEBUG) appendToLog("decoded decodedPort = " + dataA.decodedPort); + dataA.decodedChidx = 1; //(dataA.dataValues[13] & 0xFF) * 256 + (dataA.dataValues[14] & 0xFF); + if (DEBUG) appendToLog("decoded decodedChidx = " + dataA.decodedChidx); + dataA.decodedPc = new byte[2]; System.arraycopy(dataA.dataValues, 15, dataA.decodedPc, 0, dataA.decodedPc.length); + if (DEBUG) appendToLog("decoded decodedPc = " + byteArrayToString(dataA.decodedPc)); + if (iUplinkPackageType == 0x3001) { + dataA.decodedEpc = new byte[dataA.dataValues.length - 17]; + System.arraycopy(dataA.dataValues, 17, dataA.decodedEpc, 0, dataA.decodedEpc.length); } else { - dataA.decodedTime = System.currentTimeMillis(); - dataA.decodedRssi = get2BytesOfRssi(dataA.dataValues, 4); - if (DEBUG) appendToLog("decoded decodedRssi = " + dataA.decodedRssi); - dataA.decodedPhase = (dataA.dataValues[6] & 0xFF) * 256 + (dataA.dataValues[7] & 0xFF); - if (DEBUG) appendToLog("decoded decodedPhase = " + dataA.decodedPhase); - dataA.decodedPort = (dataA.dataValues[10] & 0xFF); - if (DEBUG) appendToLog("decoded decodedPort = " + dataA.decodedPort); - dataA.decodedChidx = 1; //(dataA.dataValues[13] & 0xFF) * 256 + (dataA.dataValues[14] & 0xFF); - if (DEBUG) appendToLog("decoded decodedChidx = " + dataA.decodedChidx); - dataA.decodedPc = new byte[2]; System.arraycopy(dataA.dataValues, 15, dataA.decodedPc, 0, dataA.decodedPc.length); - if (DEBUG) appendToLog("decoded decodedPc = " + byteArrayToString(dataA.decodedPc)); - if (iUplinkPackageType == 0x3001) { - dataA.decodedEpc = new byte[dataA.dataValues.length - 17]; - System.arraycopy(dataA.dataValues, 17, dataA.decodedEpc, 0, dataA.decodedEpc.length); - } else { - int iEpcLength = getBytes2EpcLength(dataA.decodedPc); - if (DEBUG) appendToLog("dataA.dataValues.length = " + dataA.dataValues.length + ", iEpcLength = " + iEpcLength + " for data " + byteArrayToString(dataA.dataValues)); - if (dataA.dataValues.length - 18 >= iEpcLength) { - dataA.decodedEpc = new byte[dataA.dataValues.length - 18]; - System.arraycopy(dataA.dataValues, 17, dataA.decodedEpc, 0, iEpcLength); - System.arraycopy(dataA.dataValues, iEpcLength + 18, dataA.decodedEpc, iEpcLength, dataA.dataValues.length - iEpcLength - 18); - if (DEBUG) appendToLog("decodedEpc = " + byteArrayToString(dataA.decodedEpc)); - - int iMbDataLength = dataA.dataValues.length - 18 - iEpcLength; - int iDataIndex = 0, iDataOffset = 0; - for (int i = 0; i < 3; i++) { - int iValue = rx000Setting.getMultibankReadLength(i); - if (DEBUG) appendToLog("i = " + i + ", getMultibankReadLength = " + iValue); - if (iValue != 0) { - int iBankLength = iValue * 2; - if (DEBUG) appendToLog("Check iDataIndex = " + iDataIndex + ", iDataOffset = " + iDataOffset + ", iBankLength = " + iBankLength + ", iMbDataLength = " + iMbDataLength); - if (iDataOffset + iBankLength > iMbDataLength) appendToLog("!!! iBankLength " + iBankLength + " is too long for iDataOffset " + iDataOffset + ", iMbDataLength = " + iMbDataLength); - else { - if (rx000Setting.getMultibankEnable(i) == 2) iDataIndex++; - else if (iDataIndex == 0) { - dataA.decodedData1 = new byte[iBankLength]; - System.arraycopy(dataA.dataValues, iEpcLength + 18 + iDataOffset, dataA.decodedData1, 0, dataA.decodedData1.length); - if (DEBUG) appendToLog("decodedData1 = " + byteArrayToString(dataA.decodedData1)); - iDataIndex++; iDataOffset += iBankLength; - } else if (iDataIndex == 1) { - dataA.decodedData2 = new byte[iBankLength]; - System.arraycopy(dataA.dataValues, iEpcLength + 18 + iDataOffset, dataA.decodedData2, 0, dataA.decodedData2.length); - if (DEBUG) appendToLog("decodedData2 = " + byteArrayToString(dataA.decodedData2)); - iDataIndex++; iDataOffset += iBankLength; - } else appendToLog("!!! CANNOT handle the third multibank data"); - } + int iEpcLength = getBytes2EpcLength(dataA.decodedPc); + if (DEBUG) appendToLog("dataA.dataValues.length = " + dataA.dataValues.length + ", iEpcLength = " + iEpcLength + " for data " + byteArrayToString(dataA.dataValues)); + if (dataA.dataValues.length - 18 >= iEpcLength) { + dataA.decodedEpc = new byte[dataA.dataValues.length - 18]; + System.arraycopy(dataA.dataValues, 17, dataA.decodedEpc, 0, iEpcLength); + System.arraycopy(dataA.dataValues, iEpcLength + 18, dataA.decodedEpc, iEpcLength, dataA.dataValues.length - iEpcLength - 18); + if (DEBUG) appendToLog("decodedEpc = " + byteArrayToString(dataA.decodedEpc)); + + int iMbDataLength = dataA.dataValues.length - 18 - iEpcLength; + int iDataIndex = 0, iDataOffset = 0; + for (int i = 0; i < 3; i++) { + int iValue = rx000Setting.getMultibankReadLength(i); + if (DEBUG) appendToLog("i = " + i + ", getMultibankReadLength = " + iValue); + if (iValue != 0) { + int iBankLength = iValue * 2; + if (DEBUG) appendToLog("Check iDataIndex = " + iDataIndex + ", iDataOffset = " + iDataOffset + ", iBankLength = " + iBankLength + ", iMbDataLength = " + iMbDataLength); + if (iDataOffset + iBankLength > iMbDataLength) appendToLog("!!! iBankLength " + iBankLength + " is too long for iDataOffset " + iDataOffset + ", iMbDataLength = " + iMbDataLength); + else { + if (rx000Setting.getMultibankEnable(i) == 2) iDataIndex++; + else if (iDataIndex == 0) { + dataA.decodedData1 = new byte[iBankLength]; + System.arraycopy(dataA.dataValues, iEpcLength + 18 + iDataOffset, dataA.decodedData1, 0, dataA.decodedData1.length); + if (DEBUG) appendToLog("decodedData1 = " + byteArrayToString(dataA.decodedData1)); + iDataIndex++; iDataOffset += iBankLength; + } else if (iDataIndex == 1) { + dataA.decodedData2 = new byte[iBankLength]; + System.arraycopy(dataA.dataValues, iEpcLength + 18 + iDataOffset, dataA.decodedData2, 0, dataA.decodedData2.length); + if (DEBUG) appendToLog("decodedData2 = " + byteArrayToString(dataA.decodedData2)); + iDataIndex++; iDataOffset += iBankLength; + } else appendToLog("!!! CANNOT handle the third multibank data"); } } - if (iDataOffset != iMbDataLength) appendToLog("!!! Some unhandled data as iDataOffset = " + iDataOffset + " for iMbDataLength = " + iMbDataLength); - else if (DEBUG) appendToLog("iDataOffset = iMbDataLength = " + iMbDataLength); - } else appendToLog("!!! iEpcLength " + iEpcLength + " is too long for the data " + byteArrayToString(dataA.dataValues)); - } - mRx000ToRead.add(dataA); - if (DEBUG) appendToLog("3001/3003 dataA.responseType = " + dataA.responseType.toString()); - if (DEBUG) appendToLog("decoded decodedEpc = " + byteArrayToString(dataA.decodedEpc) + " with mRx000ToRead.size = " + mRx000ToRead.size()); - if (DEBUG_APDATA) appendToLog("ApData: uplink data UplinkPackage_Event_csl_tag_read_epc_only_new tag with Epc = " + byteArrayToString(dataA.decodedEpc) + " is uploaded to mRx000ToRead with mRx000ToRead.size = " + mRx000ToRead.size()); - if (DEBUG_APDATA) appendToLog("ApData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_tag_read_epc_only_new has been processed"); + } + int extraLength = 0; + if (dataA.decodedData1 != null) extraLength += dataA.decodedData1.length; + if (dataA.decodedData2 != null) extraLength += dataA.decodedData2.length; + if (extraLength != 0) { + byte[] decodedEpcNew = new byte[dataA.decodedEpc.length - extraLength]; + System.arraycopy(dataA.decodedEpc, 0, decodedEpcNew, 0, decodedEpcNew.length); + dataA.decodedEpc = decodedEpcNew; + } + appendToLog("dataA.decodedPc,Epc = " + byteArrayToString(dataA.decodedPc) + "," + byteArrayToString(dataA.decodedEpc) + + ", decodedData1,2 = " + (dataA.decodedData1 == null ? "null" : byteArrayToString(dataA.decodedData1)) + + ", " + (dataA.decodedData2 == null ? "null" : byteArrayToString(dataA.decodedData2))); + if (iDataOffset != iMbDataLength) appendToLog("!!! Some unhandled data as iDataOffset = " + iDataOffset + " for iMbDataLength = " + iMbDataLength); + else if (DEBUG) appendToLog("iDataOffset = iMbDataLength = " + iMbDataLength); + } else appendToLog("!!! iEpcLength " + iEpcLength + " is too long for the data " + byteArrayToString(dataA.dataValues)); } - } else if (iUplinkPackageType == 0x3006) { - dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_INVENTORY_COMPACT; - //mRfidDevice.setInventoring(true); - if (DEBUG) appendToLog("Check UplinkPackage_Event_csl_tag_read_compact data length = " + dataA.dataValues.length); - if (dataA.dataValues.length < 10) { - appendToLog("!!! UplinkPackage_Event_csl_tag_read_compact data length has length equal or less than 6"); - dataA.decodedError = "Received Event_csl_tag_read_compact with length = " + String.valueOf(dataA.dataValues.length) + ", data = " + byteArrayToString(dataA.dataValues); - } else { - int index = 0; - byte[] dataHeader = new byte[6]; System.arraycopy(dataA.dataValues, 0, dataHeader, 0, dataHeader.length); - byte[] dataValuesFull = new byte[dataA.dataValues.length - 6]; System.arraycopy(dataA.dataValues, 6, dataValuesFull, 0, dataValuesFull.length); - if (DEBUG_APDATA) appendToLog("ApData: found Rfid.Uplink.DataRead.UplinkPackage_Event_csl_tag_read_compact with payload header = " + byteArrayToString(dataHeader) + ", dataValuesFull = " + byteArrayToString(dataValuesFull)); - while (index < dataValuesFull.length) { //change from while - if (DEBUG) appendToLog("Looping with index = " + index + ", dataValuesFull.length = " + dataValuesFull.length); - dataA.decodedTime = System.currentTimeMillis(); - if (dataValuesFull.length >= index + 2) { - dataA.decodedPc = new byte[2]; - System.arraycopy(dataValuesFull, index, dataA.decodedPc, 0, dataA.decodedPc.length); - index += 2; - } else break; - - int epcLength = getBytes2EpcLength(dataA.decodedPc); //((dataA.decodedPc[0] & 0xFF) >> 3) * 2; - if (DEBUG) appendToLog("decoded decodedPc = " + byteArrayToString(dataA.decodedPc) + " with epclength = " + epcLength); - if (dataValuesFull.length >= index + epcLength) { - dataA.decodedEpc = new byte[epcLength]; - System.arraycopy(dataValuesFull, index, dataA.decodedEpc, 0, epcLength); - index += epcLength; - } else break; - - if (DEBUG) appendToLog("decoded decodedEpc = " + byteArrayToString(dataA.decodedEpc)); - if (dataValuesFull.length >= index + 2) { - dataA.decodedRssi = get2BytesOfRssi(dataValuesFull, index); - if (DEBUG) appendToLog("decoded decodedRssi = " + dataA.decodedRssi); - index += 2; - } else break; + mRx000ToRead.add(dataA); + if (DEBUG) appendToLog("3001/3003 dataA.responseType = " + dataA.responseType.toString()); + if (DEBUG) appendToLog("decoded decodedEpc = " + byteArrayToString(dataA.decodedEpc) + " with mRx000ToRead.size = " + mRx000ToRead.size()); + if (DEBUG_APDATA) appendToLog("ApData: uplink data UplinkPackage_Event_csl_tag_read_epc_only_new tag with Epc = " + byteArrayToString(dataA.decodedEpc) + " is uploaded to mRx000ToRead with mRx000ToRead.size = " + mRx000ToRead.size()); + if (DEBUG_APDATA) appendToLog("ApData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_tag_read_epc_only_new has been processed"); + } + } else if (iUplinkPackageType == 0x3006) { + dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_INVENTORY_COMPACT; + //mRfidDevice.setInventoring(true); + if (DEBUG) appendToLog("Check UplinkPackage_Event_csl_tag_read_compact data length = " + dataA.dataValues.length); + if (dataA.dataValues.length < 10) { + appendToLog("!!! UplinkPackage_Event_csl_tag_read_compact data length has length equal or less than 6"); + dataA.decodedError = "Received Event_csl_tag_read_compact with length = " + String.valueOf(dataA.dataValues.length) + ", data = " + byteArrayToString(dataA.dataValues); + } else { + int index = 0; + byte[] dataHeader = new byte[6]; System.arraycopy(dataA.dataValues, 0, dataHeader, 0, dataHeader.length); + byte[] dataValuesFull = new byte[dataA.dataValues.length - 6]; System.arraycopy(dataA.dataValues, 6, dataValuesFull, 0, dataValuesFull.length); + if (DEBUG_APDATA) appendToLog("ApData: found Rfid.Uplink.DataRead.UplinkPackage_Event_csl_tag_read_compact with payload header = " + byteArrayToString(dataHeader) + ", dataValuesFull = " + byteArrayToString(dataValuesFull)); + while (index < dataValuesFull.length) { //change from while + if (DEBUG) appendToLog("Looping with index = " + index + ", dataValuesFull.length = " + dataValuesFull.length); + dataA.decodedTime = System.currentTimeMillis(); + if (dataValuesFull.length >= index + 2) { + dataA.decodedPc = new byte[2]; + System.arraycopy(dataValuesFull, index, dataA.decodedPc, 0, dataA.decodedPc.length); + index += 2; + } else break; + + int epcLength = getBytes2EpcLength(dataA.decodedPc); //((dataA.decodedPc[0] & 0xFF) >> 3) * 2; + if (DEBUG) appendToLog("decoded decodedPc = " + byteArrayToString(dataA.decodedPc) + " with epclength = " + epcLength); + if (dataValuesFull.length >= index + epcLength) { + dataA.decodedEpc = new byte[epcLength]; + System.arraycopy(dataValuesFull, index, dataA.decodedEpc, 0, epcLength); + index += epcLength; + } else break; + + if (DEBUG) appendToLog("decoded decodedEpc = " + byteArrayToString(dataA.decodedEpc)); + if (dataValuesFull.length >= index + 2) { + dataA.decodedRssi = get2BytesOfRssi(dataValuesFull, index); + if (DEBUG) appendToLog("decoded decodedRssi = " + dataA.decodedRssi); + index += 2; + } else break; - mRx000ToRead.add(dataA); - if (DEBUG) appendToLog("3006 dataA.responseType = " + dataA.responseType.toString()); - if (DEBUG_APDATA) appendToLog("ApData: uplink data UplinkPackage_Event_csl_tag_read_compact tag with Epc = " + byteArrayToString(dataA.decodedEpc) + " is uploaded to mRx000ToRead with mRx000ToRead.size = " + mRx000ToRead.size()); + mRx000ToRead.add(dataA); + if (DEBUG) appendToLog("3006 dataA.responseType = " + dataA.responseType.toString()); + if (DEBUG_APDATA) appendToLog("ApData: uplink data UplinkPackage_Event_csl_tag_read_compact tag with Epc = " + byteArrayToString(dataA.decodedEpc) + " is uploaded to mRx000ToRead with mRx000ToRead.size = " + mRx000ToRead.size()); - dataA = new RfidReaderChipData.Rx000pkgData(); - dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_INVENTORY_COMPACT; - } - if (DEBUG) appendToLog("Exit while loop with index = " + index + ", dataValuesFull.length = " + dataValuesFull.length); - if (index != dataValuesFull.length) { - byte[] bytesUnhandled = new byte[dataValuesFull.length - index]; - System.arraycopy(dataValuesFull, index, bytesUnhandled, 0, bytesUnhandled.length); - appendToLog("!!! unhandled data: " + byteArrayToString(bytesUnhandled)); - } - if (DEBUG_APDATA) appendToLog("ApData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_tag_read_compact has been processed"); + dataA = new RfidReaderChipData.Rx000pkgData(); + dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_INVENTORY_COMPACT; } - } else if (iUplinkPackageType == 0x3007) { - DEBUG = true; - if (DEBUG) appendToLog("Check UplinkPackage_Event_csl_miscellaneous_event data length = " + dataA.dataValues.length); - int iCommand = (dataA.dataValues[4] & 0xFF) * 256 + (dataA.dataValues[5] & 0xFF); - if (dataA.dataValues.length < 6 || (iCommand >= 3 && dataA.dataValues.length < 8)) { - appendToLog("!!! UplinkPackage_Event_csl_miscellaneous_event data length has length equal or less than 8"); - } else { - switch (iCommand) { - case 1: - rx000Setting.keepAliveTime = new Date(); - break; - case 2: - rx000Setting.inventoryRoundEndTime = new Date(); - break; - case 3: - rx000Setting.crcErrorRate = ((dataA.dataValues[6] & 0xFF) << 8) + (dataA.dataValues[7] & 0xFF); - break; - case 4: - rx000Setting.tagRate = ((dataA.dataValues[6] & 0xFF) << 8) + (dataA.dataValues[7] & 0xFF); - break; - default: - appendToLog("!!! iCommand cannot be recognised for the uplink data " + byteArrayToString(dataA.dataValues)); - break; - } - if (DEBUG_PKDATA) appendToLog("PkData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_miscellaneous_event has been processed"); + if (DEBUG) appendToLog("Exit while loop with index = " + index + ", dataValuesFull.length = " + dataValuesFull.length); + if (index != dataValuesFull.length) { + byte[] bytesUnhandled = new byte[dataValuesFull.length - index]; + System.arraycopy(dataValuesFull, index, bytesUnhandled, 0, bytesUnhandled.length); + appendToLog("!!! unhandled data: " + byteArrayToString(bytesUnhandled)); } - } else if (iUplinkPackageType == 0x3008) { - dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_COMMAND_END; - setInventoring(false); - appendToLogView("mRx000UplinkHandler_3008: " + byteArrayToString(dataA.dataValues)); - if (DEBUG) appendToLog("Check UplinkPackage_Event_csl_operation_complete data length = " + dataA.dataValues.length); - if (dataA.dataValues.length < 8) { - appendToLog("!!! UplinkPackage_Event_csl_operation_complete data length has length equal or less than 8"); - dataA.decodedError = "Received Event_csl_operation_complete with length = " + String.valueOf(dataA.dataValues.length) + ", data = " + byteArrayToString(dataA.dataValues); - } else { - int iCommand = (dataA.dataValues[4] & 0xFF) * 256 + (dataA.dataValues[5] & 0xFF); - int iStatus = (dataA.dataValues[6] & 0xFF) * 256 + (dataA.dataValues[7] & 0xFF); - if (DEBUG_APDATA) appendToLog("ApData: found Rfid.Uplink.DataRead.UplinkPackage_Event_csl_operation_complete"); - if (DEBUG) appendToLog("Check iStatus = " + iStatus); - switch (iStatus) { - case 0: - dataA.decodedError = null; - break; - case 1: - dataA.decodedError = "0x0001 Tag cache table buffer is overflowed"; - break; - case 2: - dataA.decodedError = "0x0002 Wrong register address"; - break; - case 3: - dataA.decodedError = "0x0003 Register length too large"; - break; - case 4: - dataA.decodedError = "0x0004 E710 not powered up"; - break; - case 5: - dataA.decodedError = "0x0005 Invalid parameter"; - break; - case 6: - dataA.decodedError = "0x0006 Event fifo full"; - break; - case 7: - dataA.decodedError = "0x0007 TX not ramped up"; - break; - case 8: - dataA.decodedError = "0x0008 Register read only"; - break; - case 9: - dataA.decodedError = "0x0009 Failed to halt"; - break; - case 10: - dataA.decodedError = "0x000A PLL not locked"; - break; - case 11: - dataA.decodedError = "0x000B Power control target failed"; - break; - case 12: - dataA.decodedError = "0x000C Radio power not enabled"; - break; - case 13: - dataA.decodedError = "0x000D E710 command error (e.g. battery low)"; - break; - case 14: - dataA.decodedError = "0x000E E710 Op timeout"; - break; - case 15: - dataA.decodedError = "0x000F E710 Aggregate error (e.g. battery low, metal reflection)"; - break; - case 0x10: - dataA.decodedError = "0x0010 E710 hardware link error"; - break; - case 0x11: - dataA.decodedError = "0x0011 E710 event fail to send error"; - break; - case 0x12: - dataA.decodedError = "0x0012 E710 antenna error (e.g. metal reflection)"; - break; - case 0x00FF: - dataA.decodedError = "0x00FF Other error (e.g. battery low)"; - break; - default: - dataA.decodedError = "Unknown error"; - appendToLog("!!! CANNOT handle status type with " + byteArrayToString(header) + "." + byteArrayToString(payload)); - break; - } - mRx000ToRead.add(dataA); - if (DEBUG) appendToLog("3008 dataA.responseType = " + dataA.responseType.toString()); - if (DEBUG_APDATA) appendToLog("ApData: uplink data UplinkPackage_Event_csl_operation_complete with decodedError = " + dataA.decodedError + " is uploaded to mRx000ToRead with mRx000ToRead.size = " + mRx000ToRead.size()); - if (DEBUG_APDATA) appendToLog("ApData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_operation_complete has been processed"); + if (DEBUG_APDATA) appendToLog("ApData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_tag_read_compact has been processed"); + } + } else if (iUplinkPackageType == 0x3007) { + DEBUG = true; + if (DEBUG) appendToLog("Check UplinkPackage_Event_csl_miscellaneous_event data length = " + dataA.dataValues.length); + int iCommand = (dataA.dataValues[4] & 0xFF) * 256 + (dataA.dataValues[5] & 0xFF); + if (dataA.dataValues.length < 6 || (iCommand >= 3 && dataA.dataValues.length < 8)) { + appendToLog("!!! UplinkPackage_Event_csl_miscellaneous_event data length has length equal or less than 8"); + } else { + switch (iCommand) { + case 1: + rx000Setting.keepAliveTime = new Date(); + break; + case 2: + rx000Setting.inventoryRoundEndTime = new Date(); + break; + case 3: + rx000Setting.crcErrorRate = ((dataA.dataValues[6] & 0xFF) << 8) + (dataA.dataValues[7] & 0xFF); + break; + case 4: + rx000Setting.tagRate = ((dataA.dataValues[6] & 0xFF) << 8) + (dataA.dataValues[7] & 0xFF); + break; + default: + appendToLog("!!! iCommand cannot be recognised for the uplink data " + byteArrayToString(dataA.dataValues)); + break; } - } else if (iUplinkPackageType == 0x3009) { - dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_TAG_ACCESS; - if (DEBUG) appendToLog("Check UplinkPackage_Event_csl_access_complete data length = " + dataA.dataValues.length); - if (dataA.dataValues.length < 12) { - appendToLog("!!! UplinkPackage_Event_csl_access_complete data length has length equal or less than 12"); - dataA.decodedError = "Received Event_csl_access_complete with length = " + String.valueOf(dataA.dataValues.length) + ", data = " + byteArrayToString(dataA.dataValues); - } else { - int iCommand = (dataA.dataValues[4] & 0xFF) * 256 + (dataA.dataValues[5] & 0xFF); - int iTagError = dataA.dataValues[6]; - int iMacError = dataA.dataValues[7]; - int iWriteCount = dataA.dataValues[8] * 256 + dataA.dataValues[9]; - byte[] bytesResponse = null, bytesHeader = new byte[12]; - System.arraycopy(dataA.dataValues, 0, bytesHeader, 0, bytesHeader.length); - if (dataA.dataValues.length > 12) { - bytesResponse = new byte[dataA.dataValues.length - 12]; - System.arraycopy(dataA.dataValues, 12, bytesResponse, 0, bytesResponse.length); - if (DEBUG) - appendToLog("bytesResponse = " + byteArrayToString(bytesResponse)); - } - String string = null; - switch (iTagError) { - case 0x00: - string = "Other error"; - break; - case 0x01: - string = "Not supported"; - break; - case 0x02: - string = "Insufficient privileges"; - break; - case 0x03: - string = "Memory overrun"; - break; - case 0x04: - string = "Memory locked"; - break; - case 0x05: - string = "Crypto suite error"; - break; - case 0x06: - string = "Command not encapsulated"; - break; - case 0x07: - string = "ResponseBuffer overflow"; - break; - case 0x08: - string = "Security timeout"; - break; - case 0x0B: - string = "Insufficient power"; - break; - case 0x0F: - string = "Non-specific error"; - break; - case 0x10: - //string = "No error"; - break; - default: - string = "OTHER errors"; - break; - } - if (string != null) - dataA.decodedError = "Tag Error: " + string; - string = null; - switch (iMacError) { - case 0x00: - //string = "No error"; - break; - case 0x01: - string = "No tag reply"; - break; - case 0x02: - string = "Invalid password"; - break; - case 0x03: - string = "Failed to send command"; - break; - case 0x04: - string = "No access reply"; - break; - default: - string = "OTHER errors"; - break; - } - if (string != null) { - if (dataA.decodedError == null) - dataA.decodedError = "Mac Error: " + string; - else dataA.decodedError += (", Mac Error: " + string); - } - if (iCommand == 0xC3 && iWriteCount == 0) { - string = "Write Error: nothing is written"; - if (dataA.decodedError == null) - dataA.decodedError = string; - else dataA.decodedError += (", " + string); - appendToLog(String.format("rx000pkgData: Command 0x%X with mRfidToWrite.size = %s", iCommand, csReaderConnector.rfidConnector.mRfidToWrite.size())); - } - if (DEBUG) - appendToLog("decodedError2 = " + dataA.decodedError); - appendToLog("bytesResponse is " + (bytesResponse == null ? "null" : byteArrayToString(bytesResponse))); - if (bytesResponse != null && bytesResponse.length != 0) { - for (int i = 0; i < bytesResponse.length; i++) { - string = String.format("%02X", (byte) ((bytesResponse[i] & 0xFF))); - if (dataA.decodedResult == null) - dataA.decodedResult = string; - else dataA.decodedResult += string; - } - } else dataA.decodedResult = ""; - if (DEBUG || true) - appendToLog("decodedResult = " + dataA.decodedResult); + if (DEBUG_PKDATA) appendToLog("PkData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_miscellaneous_event has been processed"); + } + } else if (iUplinkPackageType == 0x3008) { + dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_COMMAND_END; + setInventoring(false); + appendToLogView("mRx000UplinkHandler_3008: " + byteArrayToString(dataA.dataValues)); + if (DEBUG) appendToLog("Check UplinkPackage_Event_csl_operation_complete data length = " + dataA.dataValues.length); + if (dataA.dataValues.length < 8) { + appendToLog("!!! UplinkPackage_Event_csl_operation_complete data length has length equal or less than 8"); + dataA.decodedError = "Received Event_csl_operation_complete with length = " + String.valueOf(dataA.dataValues.length) + ", data = " + byteArrayToString(dataA.dataValues); + } else { + int iCommand = (dataA.dataValues[4] & 0xFF) * 256 + (dataA.dataValues[5] & 0xFF); + int iStatus = (dataA.dataValues[6] & 0xFF) * 256 + (dataA.dataValues[7] & 0xFF); + if (DEBUG_APDATA) appendToLog("ApData: found Rfid.Uplink.DataRead.UplinkPackage_Event_csl_operation_complete"); + if (DEBUG) appendToLog("Check iStatus = " + iStatus); + switch (iStatus) { + case 0: + dataA.decodedError = null; + break; + case 1: + dataA.decodedError = "0x0001 Tag cache table buffer is overflowed"; + break; + case 2: + dataA.decodedError = "0x0002 Wrong register address"; + break; + case 3: + dataA.decodedError = "0x0003 Register length too large"; + break; + case 4: + dataA.decodedError = "0x0004 E710 not powered up"; + break; + case 5: + dataA.decodedError = "0x0005 Invalid parameter"; + break; + case 6: + dataA.decodedError = "0x0006 Event fifo full"; + break; + case 7: + dataA.decodedError = "0x0007 TX not ramped up"; + break; + case 8: + dataA.decodedError = "0x0008 Register read only"; + break; + case 9: + dataA.decodedError = "0x0009 Failed to halt"; + break; + case 10: + dataA.decodedError = "0x000A PLL not locked"; + break; + case 11: + dataA.decodedError = "0x000B Power control target failed"; + break; + case 12: + dataA.decodedError = "0x000C Radio power not enabled"; + break; + case 13: + dataA.decodedError = "0x000D E710 command error (e.g. battery low)"; + break; + case 14: + dataA.decodedError = "0x000E E710 Op timeout"; + break; + case 15: + dataA.decodedError = "0x000F E710 Aggregate error (e.g. battery low, metal reflection)"; + break; + case 0x10: + dataA.decodedError = "0x0010 E710 hardware link error"; + break; + case 0x11: + dataA.decodedError = "0x0011 E710 event fail to send error"; + break; + case 0x12: + dataA.decodedError = "0x0012 E710 antenna error (e.g. metal reflection)"; + break; + case 0x00FF: + dataA.decodedError = "0x00FF Other error (e.g. battery low)"; + break; + default: + dataA.decodedError = "Unknown error"; + appendToLog("!!! CANNOT handle status type with " + byteArrayToString(header) + "." + byteArrayToString(payload)); + break; } mRx000ToRead.add(dataA); - if (DEBUG) appendToLog("3009 dataA.responseType = " + dataA.responseType.toString()); - if (DEBUG_APDATA) appendToLog("ApData: uplink data UplinkPackage_Event_csl_access_complete tag with data = " + byteArrayToString(dataA.dataValues) + " is uploaded to mRx000ToRead with mRx000ToRead.size = " + mRx000ToRead.size()); - if (DEBUG_APDATA) appendToLog("ApData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_access_complete has been processed"); + if (DEBUG) appendToLog("3008 dataA.responseType = " + dataA.responseType.toString()); + if (DEBUG_APDATA) appendToLog("ApData: uplink data UplinkPackage_Event_csl_operation_complete with decodedError = " + dataA.decodedError + " is uploaded to mRx000ToRead with mRx000ToRead.size = " + mRx000ToRead.size()); + if (DEBUG_APDATA) appendToLog("ApData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_operation_complete has been processed"); } - else appendToLog(String.format("!!! CANNOT handle UplinkPackageType 0x%X", iUplinkPackageType) + " with uplink data " + byteArrayToString(header) + "." + byteArrayToString(payload)); - packageFound = true; - packageType = 4; - startIndexNew = startIndex + expectedLength; - } - } - - if (packageFound) { - packageFound = false; - if (DEBUG) appendToLog("Found package with packageType = " + packageType + ", Check startIndex = " + startIndex + " with startIndexNew = " + startIndexNew + ", mRfidToReadingOffset = " + mRfidToReadingOffset); - if (DEBUG && startIndex != 0) { - byte[] unhandledBytes = new byte[startIndex]; - System.arraycopy(mRfidToReading, 0, unhandledBytes, 0, unhandledBytes.length); - appendToLog("!!! packageFound with invalid unused data: " + unhandledBytes.length + ", " + byteArrayToString(unhandledBytes)); - csReaderConnector.invalidUpdata++; - } - if (DEBUG) { - byte[] usedBytes = new byte[startIndexNew - startIndex]; - System.arraycopy(mRfidToReading, startIndex, usedBytes, 0, usedBytes.length); - if (DEBUG) appendToLog("used data = " + usedBytes.length + ", " + byteArrayToString(usedBytes)); - } - byte[] mRfidToReadingNew = new byte[RFID_READING_BUFFERSIZE]; - System.arraycopy(mRfidToReading, startIndexNew, mRfidToReadingNew, 0, mRfidToReadingOffset - startIndexNew); - mRfidToReading = mRfidToReadingNew; - mRfidToReadingOffset -= startIndexNew; - startIndex = 0; - startIndexNew = 0; - startIndexOld = 0; - if (DEBUG) appendToLog("Check new mRfidToReadingOffset = " + mRfidToReadingOffset + " with startIndex and startIndexNew = 0"); - if (DEBUG && mRfidToReadingOffset != 0) { - byte[] remainedBytes = new byte[mRfidToReadingOffset]; - System.arraycopy(mRfidToReading, 0, remainedBytes, 0, remainedBytes.length); - appendToLog("!!! moved with remained bytes=" + byteArrayToString(remainedBytes)); + } else if (iUplinkPackageType == 0x3009) { + dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_TAG_ACCESS; + if (DEBUG) appendToLog("Check UplinkPackage_Event_csl_access_complete data length = " + dataA.dataValues.length); + if (dataA.dataValues.length < 12) { + appendToLog("!!! UplinkPackage_Event_csl_access_complete data length has length equal or less than 12"); + dataA.decodedError = "Received Event_csl_access_complete with length = " + String.valueOf(dataA.dataValues.length) + ", data = " + byteArrayToString(dataA.dataValues); + } else { + int iCommand = (dataA.dataValues[4] & 0xFF) * 256 + (dataA.dataValues[5] & 0xFF); + int iTagError = dataA.dataValues[6]; + int iMacError = dataA.dataValues[7]; + int iWriteCount = dataA.dataValues[8] * 256 + dataA.dataValues[9]; + byte[] bytesResponse = null, bytesHeader = new byte[12]; + System.arraycopy(dataA.dataValues, 0, bytesHeader, 0, bytesHeader.length); + if (dataA.dataValues.length > 12) { + bytesResponse = new byte[dataA.dataValues.length - 12]; + System.arraycopy(dataA.dataValues, 12, bytesResponse, 0, bytesResponse.length); + if (DEBUG) + appendToLog("bytesResponse = " + byteArrayToString(bytesResponse)); + } + String string = null; + switch (iTagError) { + case 0x00: + string = "Other error"; + break; + case 0x01: + string = "Not supported"; + break; + case 0x02: + string = "Insufficient privileges"; + break; + case 0x03: + string = "Memory overrun"; + break; + case 0x04: + string = "Memory locked"; + break; + case 0x05: + string = "Crypto suite error"; + break; + case 0x06: + string = "Command not encapsulated"; + break; + case 0x07: + string = "ResponseBuffer overflow"; + break; + case 0x08: + string = "Security timeout"; + break; + case 0x0B: + string = "Insufficient power"; + break; + case 0x0F: + string = "Non-specific error"; + break; + case 0x10: + //string = "No error"; + break; + default: + string = "OTHER errors"; + break; + } + if (string != null) + dataA.decodedError = "Tag Error: " + string; + string = null; + switch (iMacError) { + case 0x00: + //string = "No error"; + break; + case 0x01: + string = "No tag reply"; + break; + case 0x02: + string = "Invalid password"; + break; + case 0x03: + string = "Failed to send command"; + break; + case 0x04: + string = "No access reply"; + break; + default: + string = "OTHER errors"; + break; + } + if (string != null) { + if (dataA.decodedError == null) + dataA.decodedError = "Mac Error: " + string; + else dataA.decodedError += (", Mac Error: " + string); + } + if (iCommand == 0xC3 && iWriteCount == 0) { + string = "Write Error: nothing is written"; + if (dataA.decodedError == null) + dataA.decodedError = string; + else dataA.decodedError += (", " + string); + appendToLog(String.format("rx000pkgData: Command 0x%X with mRfidToWrite.size = %s", iCommand, csReaderConnector.rfidConnector.mRfidToWrite.size())); + } + if (DEBUG) + appendToLog("decodedError2 = " + dataA.decodedError); + appendToLog("bytesResponse is " + (bytesResponse == null ? "null" : byteArrayToString(bytesResponse))); + if (bytesResponse != null && bytesResponse.length != 0) { + for (int i = 0; i < bytesResponse.length; i++) { + string = String.format("%02X", (byte) ((bytesResponse[i] & 0xFF))); + if (dataA.decodedResult == null) + dataA.decodedResult = string; + else dataA.decodedResult += string; + } + } else dataA.decodedResult = ""; + if (DEBUG || true) + appendToLog("decodedResult = " + dataA.decodedResult); + } + mRx000ToRead.add(dataA); + if (DEBUG) appendToLog("3009 dataA.responseType = " + dataA.responseType.toString()); + if (DEBUG_APDATA) appendToLog("ApData: uplink data UplinkPackage_Event_csl_access_complete tag with data = " + byteArrayToString(dataA.dataValues) + " is uploaded to mRx000ToRead with mRx000ToRead.size = " + mRx000ToRead.size()); + if (DEBUG_APDATA) appendToLog("ApData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_access_complete has been processed"); } - } else { - startIndex++; + else appendToLog(String.format("!!! CANNOT handle UplinkPackageType 0x%X", iUplinkPackageType) + " with uplink data " + byteArrayToString(header) + "." + byteArrayToString(payload)); + packageFound = true; + packageType = 4; + startIndexNew = startIndex + expectedLength; } } - if (DEBUG) appendToLog("Exit while loop with startIndex = " + startIndex + ", mRfidToReadingOffset = " + mRfidToReadingOffset + ", iPayloadSizeMin = " + iPayloadSizeMin); - if (startIndex != 0 && mRfidToReadingOffset != 0) { - //appendToLog("exit while(-8) loop with startIndex = " + startIndex + ( startIndex == 0 ? "" : "(NON-ZERO)" ) + ", mRfidToReadingOffset=" + mRfidToReadingOffset); - if (startIndex > mRfidToReadingOffset) appendToLog("!!! ERROR. startIndex = " + startIndex + " is greater than mRfidToReadingOffset = " + mRfidToReadingOffset); - else { - byte[] unhandled = new byte[startIndex]; - System.arraycopy(mRfidToReading, 0, unhandled, 0, unhandled.length); - appendToLog("!!! Unhandled data: " + byteArrayToString(unhandled)); - byte[] mRfidToReadingNew = new byte[RFID_READING_BUFFERSIZE]; - System.arraycopy(mRfidToReading, startIndex, mRfidToReadingNew, 0, mRfidToReadingOffset - startIndex); - mRfidToReading = mRfidToReadingNew; - mRfidToReadingOffset = mRfidToReadingOffset - startIndex; - startIndex = 0; - startIndexNew = 0; + + if (packageFound) { + packageFound = false; + if (DEBUG) appendToLog("Found package with packageType = " + packageType + ", Check startIndex = " + startIndex + " with startIndexNew = " + startIndexNew + ", mRfidToReadingOffset = " + mRfidToReadingOffset); + if (DEBUG && startIndex != 0) { + byte[] unhandledBytes = new byte[startIndex]; + System.arraycopy(mRfidToReading, 0, unhandledBytes, 0, unhandledBytes.length); + appendToLog("!!! packageFound with invalid unused data: " + unhandledBytes.length + ", " + byteArrayToString(unhandledBytes)); csReaderConnector.invalidUpdata++; } + if (DEBUG) { + byte[] usedBytes = new byte[startIndexNew - startIndex]; + System.arraycopy(mRfidToReading, startIndex, usedBytes, 0, usedBytes.length); + if (DEBUG) appendToLog("used data = " + usedBytes.length + ", " + byteArrayToString(usedBytes)); + } + byte[] mRfidToReadingNew = new byte[RFID_READING_BUFFERSIZE]; + System.arraycopy(mRfidToReading, startIndexNew, mRfidToReadingNew, 0, mRfidToReadingOffset - startIndexNew); + mRfidToReading = mRfidToReadingNew; + mRfidToReadingOffset -= startIndexNew; + startIndex = 0; + startIndexNew = 0; + startIndexOld = 0; + if (DEBUG) appendToLog("Check new mRfidToReadingOffset = " + mRfidToReadingOffset + " with startIndex and startIndexNew = 0"); + if (DEBUG && mRfidToReadingOffset != 0) { + byte[] remainedBytes = new byte[mRfidToReadingOffset]; + System.arraycopy(mRfidToReading, 0, remainedBytes, 0, remainedBytes.length); + appendToLog("!!! moved with remained bytes=" + byteArrayToString(remainedBytes)); + } + } else { + startIndex++; + } + } + if (DEBUG) appendToLog("Exit while loop with startIndex = " + startIndex + ", mRfidToReadingOffset = " + mRfidToReadingOffset + ", iPayloadSizeMin = " + iPayloadSizeMin); + if (startIndex != 0 && mRfidToReadingOffset != 0) { + //appendToLog("exit while(-8) loop with startIndex = " + startIndex + ( startIndex == 0 ? "" : "(NON-ZERO)" ) + ", mRfidToReadingOffset=" + mRfidToReadingOffset); + if (startIndex > mRfidToReadingOffset) appendToLog("!!! ERROR. startIndex = " + startIndex + " is greater than mRfidToReadingOffset = " + mRfidToReadingOffset); + else { + byte[] unhandled = new byte[startIndex]; + System.arraycopy(mRfidToReading, 0, unhandled, 0, unhandled.length); + appendToLog("!!! Unhandled data: " + byteArrayToString(unhandled)); + byte[] mRfidToReadingNew = new byte[RFID_READING_BUFFERSIZE]; + System.arraycopy(mRfidToReading, startIndex, mRfidToReadingNew, 0, mRfidToReadingOffset - startIndex); + mRfidToReading = mRfidToReadingNew; + mRfidToReadingOffset = mRfidToReadingOffset - startIndex; + startIndex = 0; + startIndexNew = 0; + csReaderConnector.invalidUpdata++; } } - } - if (DEBUG & bFirst == false) appendToLog("Exit while loop with mRfidToRead.size = " + csReaderConnector.rfidConnector.mRfidToRead.size()); - //if (DEBUG) appendToLog("mRfidToReadingOffset = " + mRfidToReadingOffset + ", startIndexNew = " + startIndexNew); - //if (mRfidToReadingOffset == startIndexNew && mRfidToReadingOffset != 0) { - // byte[] unusedData = new byte[mRfidToReadingOffset]; - // System.arraycopy(mRfidToReading, 0, unusedData, 0, unusedData.length); - // appendToLog("Ending with invaid unused data: " + mRfidToReadingOffset + ", " + byteArrayToString(unusedData)); - // mRfidToReading = new byte[RFID_READING_BUFFERSIZE]; - // mRfidToReadingOffset = 0; - //} - bRx000ToReading = false; - if (DEBUGTHREAD) { - if (mRx000ToRead.size() != 0) appendToLog("mRx000UplinkHandler(): END with mRx000ToRead size = " + mRx000ToRead.size()); } } - public boolean turnOn(boolean onStatus) { - RfidConnector.CsReaderRfidData csReaderRfidData = new RfidConnector.CsReaderRfidData(); - if (onStatus) { - csReaderRfidData.rfidPayloadEvent = RfidConnector.RfidPayloadEvents.RFID_POWER_ON; - csReaderRfidData.waitUplinkResponse = false; - clearTempDataIn_request = true; - addRfidToWrite(csReaderRfidData); - return true; - } else if (onStatus == false) { - csReaderRfidData.rfidPayloadEvent = RfidConnector.RfidPayloadEvents.RFID_POWER_OFF; - csReaderRfidData.waitUplinkResponse = false; - clearTempDataIn_request = true; - addRfidToWrite(csReaderRfidData); - return true; - } else { - return false; - } + if (DEBUG & bFirst == false) appendToLog("Exit while loop with mRfidToRead.size = " + csReaderConnector.rfidConnector.mRfidToRead.size()); + //if (DEBUG) appendToLog("mRfidToReadingOffset = " + mRfidToReadingOffset + ", startIndexNew = " + startIndexNew); + //if (mRfidToReadingOffset == startIndexNew && mRfidToReadingOffset != 0) { + // byte[] unusedData = new byte[mRfidToReadingOffset]; + // System.arraycopy(mRfidToReading, 0, unusedData, 0, unusedData.length); + // appendToLog("Ending with invaid unused data: " + mRfidToReadingOffset + ", " + byteArrayToString(unusedData)); + // mRfidToReading = new byte[RFID_READING_BUFFERSIZE]; + // mRfidToReadingOffset = 0; + //} + bRx000ToReading = false; + if (DEBUGTHREAD) { + if (mRx000ToRead.size() != 0) appendToLog("mRx000UplinkHandler(): END with mRx000ToRead size = " + mRx000ToRead.size()); } + } + public boolean turnOn(boolean onStatus) { + RfidConnector.CsReaderRfidData csReaderRfidData = new RfidConnector.CsReaderRfidData(); + if (onStatus) { + csReaderRfidData.rfidPayloadEvent = RfidConnector.RfidPayloadEvents.RFID_POWER_ON; + csReaderRfidData.waitUplinkResponse = false; + addRfidToWrite(csReaderRfidData); + return true; + } else if (onStatus == false) { + csReaderRfidData.rfidPayloadEvent = RfidConnector.RfidPayloadEvents.RFID_POWER_OFF; + csReaderRfidData.waitUplinkResponse = false; + addRfidToWrite(csReaderRfidData); + return true; + } else { + return false; + } + } - boolean sendControlCommand(ControlCommands controlCommands) { - byte[] msgBuffer = new byte[]{(byte) 0x40, 6, 0, 0, 0, 0, 0, 0}; - boolean needResponse = false; - if (csReaderConnector.isBleConnected() == false) return false; - switch (controlCommands) { - default: - msgBuffer = null; - case CANCEL: - msgBuffer[1] = 1; - commandOperating = false; - break; - case SOFTRESET: - msgBuffer[1] = 2; - needResponse = true; - break; - case ABORT: - msgBuffer[1] = 3; - needResponse = true; - commandOperating = false; - break; - case PAUSE: - msgBuffer[1] = 4; - break; - case RESUME: - msgBuffer[1] = 5; - break; - case GETSERIALNUMBER: - msgBuffer = new byte[]{(byte) 0xC0, 0x06, 0, 0, 0, 0, 0, 0}; - needResponse = true; - break; - case RESETTOBOOTLOADER: - msgBuffer[1] = 7; - needResponse = true; - break; - } + boolean bLowPowerStandby = false; + public boolean setPwrManagementMode(boolean bLowPowerStandby) { + if (csReaderConnector.isBleConnected() == false) return false; + if (this.bLowPowerStandby == bLowPowerStandby) return true; + this.bLowPowerStandby = bLowPowerStandby; appendToLog("!!! Skip setPwrManagementMode[" + bLowPowerStandby + "] with this.blowPowerStandby = " + this.bLowPowerStandby); + return true; + } - if (msgBuffer == null) { - if (DEBUG) appendToLog("Invalid control commands"); - return false; - } else { - clearTempDataIn_request = true; - - RfidConnector.CsReaderRfidData csReaderRfidData = new RfidConnector.CsReaderRfidData(); - csReaderRfidData.rfidPayloadEvent = RfidConnector.RfidPayloadEvents.RFID_COMMAND; - csReaderRfidData.dataValues = msgBuffer; - if (needResponse) { -// if (DEBUG) appendToLog("sendControlCommand() adds to mRx000ToWrite"); - csReaderRfidData.waitUplinkResponse = needResponse; - addRfidToWrite(csReaderRfidData); -// mRx000ToWrite.add(cs108RfidData); - } else { -// if (DEBUG) appendToLog("sendControlCommand() adds to mRfidToWrite"); - csReaderRfidData.waitUplinkResponse = needResponse; - addRfidToWrite(csReaderRfidData); - } - if (controlCommands == ControlCommands.ABORT) aborting = true; - return true; - } + int wideRSSI = -1; + public int getwideRSSI() { + if (wideRSSI < 0) { + setPwrManagementMode(false); + wideRSSI = 0; appendToLog("!!! Skip getwideRSSI with assumed value = 0"); } + return wideRSSI; + } - boolean sendHostRegRequestHST_RFTC_FRQCH_DESC_PLLDIVMULT(int freqChannel) { - long fccFreqTable[] = new long[]{ - 0x00180E4F, //915.75 MHz - 0x00180E4D, //915.25 MHz - 0x00180E1D, //903.25 MHz - 0x00180E7B, //926.75 MHz - 0x00180E79, //926.25 MHz - 0x00180E21, //904.25 MHz - 0x00180E7D, //927.25 MHz - 0x00180E61, //920.25 MHz - 0x00180E5D, //919.25 MHz - 0x00180E35, //909.25 MHz - 0x00180E5B, //918.75 MHz - 0x00180E57, //917.75 MHz - 0x00180E25, //905.25 MHz - 0x00180E23, //904.75 MHz - 0x00180E75, //925.25 MHz - 0x00180E67, //921.75 MHz - 0x00180E4B, //914.75 MHz - 0x00180E2B, //906.75 MHz - 0x00180E47, //913.75 MHz - 0x00180E69, //922.25 MHz - 0x00180E3D, //911.25 MHz - 0x00180E3F, //911.75 MHz - 0x00180E1F, //903.75 MHz - 0x00180E33, //908.75 MHz - 0x00180E27, //905.75 MHz - 0x00180E41, //912.25 MHz - 0x00180E29, //906.25 MHz - 0x00180E55, //917.25 MHz - 0x00180E49, //914.25 MHz - 0x00180E2D, //907.25 MHz - 0x00180E59, //918.25 MHz - 0x00180E51, //916.25 MHz - 0x00180E39, //910.25 MHz - 0x00180E3B, //910.75 MHz - 0x00180E2F, //907.75 MHz - 0x00180E73, //924.75 MHz - 0x00180E37, //909.75 MHz - 0x00180E5F, //919.75 MHz - 0x00180E53, //916.75 MHz - 0x00180E45, //913.25 MHz - 0x00180E6F, //923.75 MHz - 0x00180E31, //908.25 MHz - 0x00180E77, //925.75 MHz - 0x00180E43, //912.75 MHz - 0x00180E71, //924.25 MHz - 0x00180E65, //921.25 MHz - 0x00180E63, //920.75 MHz - 0x00180E6B, //922.75 MHz - 0x00180E1B, //902.75 MHz - 0x00180E6D, //923.25 MHz - }; - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 3, 0x0C, 0, 0, 0, 0}; - if (freqChannel >= 50) { - freqChannel = 49; - } - long freqData = fccFreqTable[freqChannel]; - msgBuffer[4] = (byte) (freqData % 256); - msgBuffer[5] = (byte) ((freqData >> 8) % 256); - msgBuffer[6] = (byte) ((freqData >> 16) % 256); - msgBuffer[7] = (byte) ((freqData >> 24) % 256); - return sendHostRegRequest(HostRegRequests.HST_RFTC_FRQCH_DESC_PLLDIVMULT, true, msgBuffer); - } - - boolean bLowPowerStandby = false; - public boolean setPwrManagementMode(boolean bLowPowerStandby) { - if (csReaderConnector.isBleConnected() == false) return false; - if (this.bLowPowerStandby == bLowPowerStandby) return true; - this.bLowPowerStandby = bLowPowerStandby; appendToLog("!!! Skip setPwrManagementMode[" + bLowPowerStandby + "] with this.blowPowerStandby = " + this.bLowPowerStandby); - return true; + final int RXGAIN_INVALID = -1, RXGAIN_MIN = 0, RXGAIN_MAX = 0x1FF, RXGAIN_DEFAULT = 0x104; + int rxGain = RXGAIN_INVALID; + public int getHighCompression() { + int iRetValue = -1; + if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { + setPwrManagementMode(false); + rxGain = RXGAIN_DEFAULT; appendToLog(String.format("!!! Skip getHighCompression with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); + } else iRetValue = (rxGain >> 8); + return iRetValue; + } + public int getRflnaGain() { + int iRetValue = -1; + if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { + setPwrManagementMode(false); + rxGain = RXGAIN_DEFAULT; appendToLog(String.format("!!! Skip getRflnaGain with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); + } else iRetValue = ((rxGain & 0xC0) >> 6); + return iRetValue; + } + public int getIflnaGain() { + int iRetValue = -1; + if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { + setPwrManagementMode(false); + rxGain = RXGAIN_DEFAULT; appendToLog(String.format("!!! Skip getIflnaGain with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); + } else iRetValue = ((rxGain & 0x38) >> 3); + return iRetValue; + } + public int getAgcGain() { + int iRetValue = -1; + if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { + setPwrManagementMode(false); + rxGain = RXGAIN_DEFAULT; appendToLog(String.format("!!! Skip getAgcGain with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); + } else iRetValue = (rxGain & 0x07); + return iRetValue; + } + public int getRxGain() { + int iRetValue = -1; + if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { + setPwrManagementMode(false); + rxGain = RXGAIN_DEFAULT; appendToLog(String.format("!!! Skip getRxGain with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); + } else iRetValue = rxGain; + return iRetValue; + } + public boolean setRxGain(int highCompression, int rflnagain, int iflnagain, int agcgain) { + int rxGain_new = ((highCompression & 0x01) << 8) | ((rflnagain & 0x3) << 6) | ((iflnagain & 0x7) << 3) | (agcgain & 0x7); + return setRxGain(rxGain_new); + } + public boolean setRxGain(int rxGain_new) { + boolean bRetValue = true; + if ((rxGain_new != rxGain) || (sameCheck == false)) { + setPwrManagementMode(false); + rxGain = rxGain_new; appendToLog(String.format("!!! Skip setRxGain[0x%X]", rxGain_new)); } + return bRetValue; + } - int wideRSSI = -1; - public int getwideRSSI() { - if (wideRSSI < 0) { - setPwrManagementMode(false); - wideRSSI = 0; appendToLog("!!! Skip getwideRSSI with assumed value = 0"); - } - return wideRSSI; - } - - final int RXGAIN_INVALID = -1, RXGAIN_MIN = 0, RXGAIN_MAX = 0x1FF, RXGAIN_DEFAULT = 0x104; - int rxGain = RXGAIN_INVALID; - public int getHighCompression() { - int iRetValue = -1; - if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { - setPwrManagementMode(false); - rxGain = RXGAIN_DEFAULT; appendToLog(String.format("!!! Skip getHighCompression with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); - } else iRetValue = (rxGain >> 8); - return iRetValue; - } - public int getRflnaGain() { - int iRetValue = -1; - if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { - setPwrManagementMode(false); - rxGain = RXGAIN_DEFAULT; appendToLog(String.format("!!! Skip getRflnaGain with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); - } else iRetValue = ((rxGain & 0xC0) >> 6); - return iRetValue; - } - public int getIflnaGain() { - int iRetValue = -1; - if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { - setPwrManagementMode(false); - rxGain = RXGAIN_DEFAULT; appendToLog(String.format("!!! Skip getIflnaGain with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); - } else iRetValue = ((rxGain & 0x38) >> 3); - return iRetValue; - } - public int getAgcGain() { - int iRetValue = -1; - if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { - setPwrManagementMode(false); - rxGain = RXGAIN_DEFAULT; appendToLog(String.format("!!! Skip getAgcGain with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); - } else iRetValue = (rxGain & 0x07); - return iRetValue; - } - public int getRxGain() { - int iRetValue = -1; - if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { - setPwrManagementMode(false); - rxGain = RXGAIN_DEFAULT; appendToLog(String.format("!!! Skip getRxGain with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); - } else iRetValue = rxGain; - return iRetValue; - } - public boolean setRxGain(int highCompression, int rflnagain, int iflnagain, int agcgain) { - int rxGain_new = ((highCompression & 0x01) << 8) | ((rflnagain & 0x3) << 6) | ((iflnagain & 0x7) << 3) | (agcgain & 0x7); - return setRxGain(rxGain_new); - } - public boolean setRxGain(int rxGain_new) { - boolean bRetValue = true; - if ((rxGain_new != rxGain) || (sameCheck == false)) { - setPwrManagementMode(false); - rxGain = rxGain_new; appendToLog(String.format("!!! Skip setRxGain[0x%X]", rxGain_new)); - } - return bRetValue; - } - - public boolean sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands hostCommand) { - appendToLog("!!! hostCommand = " + hostCommand.toString()); - long hostCommandData = -1; - switch (hostCommand) { - case CMD_18K6CINV: - hostCommandData = 0xA1; - if (rx000Setting.getQuerySelect() > 1 /*&& mRfidReaderChip.mRx000Setting.getImpinjExtension() == 0*/) hostCommandData = 0xA3; - break; - case CMD_18K6CINV_COMPACT: - hostCommandData = 0xA2; - if (rx000Setting.getQuerySelect() > 1 /*&& mRfidReaderChip.mRx000Setting.getImpinjExtension() == 0*/) hostCommandData = 0xA6; - break; - case CMD_18K6CINV_MB: - hostCommandData = 0xA4; - appendToLog("getQuerySelect = " + rx000Setting.getQuerySelect() + ", getImpinjExtension = " + rx000Setting.getImpinjExtension()); - if (rx000Setting.getQuerySelect() > 1 /*&& mRfidReaderChip.mRx000Setting.getImpinjExtension() == 0*/) hostCommandData = 0xA5; - break; - case NULL: - hostCommandData = 0xAE; - break; - case CMD_18K6CREAD: - hostCommandData = 0xB1; - break; - case CMD_18K6CWRITE: - hostCommandData = 0xB2; - break; - case CMD_18K6CLOCK: - hostCommandData = 0xB7; - break; - case CMD_18K6CKILL: - hostCommandData = 0xB8; - break; - case CMD_18K6CAUTHENTICATE: - hostCommandData = 0xB9; - break; - - case CMD_WROEM: - hostCommandData = 0x02; - break; - case CMD_RDOEM: - hostCommandData = 0x03; - break; - case CMD_ENGTEST: - hostCommandData = 0x04; - break; - case CMD_MBPRDREG: - hostCommandData = 0x05; - break; - case CMD_MBPWRREG: - hostCommandData = 0x06; - break; - case CMD_SETPWRMGMTCFG: - hostCommandData = 0x14; - break; - case CMD_UPDATELINKPROFILE: - hostCommandData = 0x19; - break; - case CMD_18K6CBLOCKWRITE: - hostCommandData = 0x1F; - break; - case CMD_CHANGEEAS: - hostCommandData = 0x26; - break; - case CMD_GETSENSORDATA: - hostCommandData = 0x3b; - break; - case CMD_READBUFFER: - hostCommandData = 0x51; - break; - case CMD_UNTRACEABLE: - hostCommandData = 0x52; - break; - case CMD_FDM_RDMEM: - hostCommandData = 0x53; break; - case CMD_FDM_WRMEM: - hostCommandData = 0x54; break; - case CMD_FDM_AUTH: - hostCommandData = 0x55; break; - case CMD_FDM_GET_TEMPERATURE: - hostCommandData = 0x56; break; - case CMD_FDM_START_LOGGING: - hostCommandData = 0x57; break; - case CMD_FDM_STOP_LOGGING: - hostCommandData = 0x58; break; - case CMD_FDM_WRREG: - hostCommandData = 0x59; break; - case CMD_FDM_RDREG: - hostCommandData = 0x5A; break; - case CMD_FDM_DEEP_SLEEP: - hostCommandData = 0x5B; break; - case CMD_FDM_OPMODE_CHECK: - hostCommandData = 0x5C; break; - case CMD_FDM_INIT_REGFILE: - hostCommandData = 0x5d; break; - case CMD_FDM_LED_CTRL: - hostCommandData = 0x5e; break; - default: - appendToLog("!!! CANNOT handle with hostCommand = " + hostCommand.toString()); - } - if (hostCommandData == -1) { - return false; - } else { - commandOperating = true; - byte[] msgBuffer = new byte[]{(byte)0x80, (byte)0xb3, (byte)0x10, (byte)0xA1, 0, 0, 0}; - msgBuffer[3] = (byte) (hostCommandData % 256); - if (true) appendToLog("3030 data = " + byteArrayToString(rx000Setting.antennaPortConfig[0])); - return sendHostRegRequest(HostRegRequests.HST_CMD, true, msgBuffer); + public boolean sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands hostCommand) { + appendToLog("!!! hostCommand = " + hostCommand.toString()); + long hostCommandData = -1; + switch (hostCommand) { + case CMD_18K6CINV: + hostCommandData = 0xA1; + if (rx000Setting.getQuerySelect() > 1 /*&& mRfidReaderChip.mRx000Setting.getImpinjExtension() == 0*/) hostCommandData = 0xA3; + break; + case CMD_18K6CINV_COMPACT: + hostCommandData = 0xA2; + if (rx000Setting.getQuerySelect() > 1 /*&& mRfidReaderChip.mRx000Setting.getImpinjExtension() == 0*/) hostCommandData = 0xA6; + break; + case CMD_18K6CINV_MB: + hostCommandData = 0xA4; + appendToLog("getQuerySelect = " + rx000Setting.getQuerySelect() + ", getImpinjExtension = " + rx000Setting.getImpinjExtension()); + if (rx000Setting.getQuerySelect() > 1 /*&& mRfidReaderChip.mRx000Setting.getImpinjExtension() == 0*/) hostCommandData = 0xA5; + break; + case NULL: + hostCommandData = 0xAE; + break; + case CMD_18K6CREAD: + hostCommandData = 0xB1; + break; + case CMD_18K6CWRITE: + hostCommandData = 0xB2; + break; + case CMD_18K6CLOCK: + hostCommandData = 0xB7; + break; + case CMD_18K6CKILL: + hostCommandData = 0xB8; + break; + case CMD_18K6CAUTHENTICATE: + hostCommandData = 0xB9; + break; + + case CMD_WROEM: + hostCommandData = 0x02; + break; + case CMD_RDOEM: + hostCommandData = 0x03; + break; + case CMD_ENGTEST: + hostCommandData = 0x04; + break; + case CMD_MBPRDREG: + hostCommandData = 0x05; + break; + case CMD_MBPWRREG: + hostCommandData = 0x06; + break; + case CMD_SETPWRMGMTCFG: + hostCommandData = 0x14; + break; + case CMD_UPDATELINKPROFILE: + hostCommandData = 0x19; + break; + case CMD_18K6CBLOCKWRITE: + hostCommandData = 0x1F; + break; + case CMD_CHANGEEAS: + hostCommandData = 0x26; + break; + case CMD_GETSENSORDATA: + hostCommandData = 0x3b; + break; + case CMD_READBUFFER: + hostCommandData = 0x51; + break; + case CMD_UNTRACEABLE: + hostCommandData = 0x52; + break; + case CMD_FDM_RDMEM: + hostCommandData = 0x53; break; + case CMD_FDM_WRMEM: + hostCommandData = 0x54; break; + case CMD_FDM_AUTH: + hostCommandData = 0x55; break; + case CMD_FDM_GET_TEMPERATURE: + hostCommandData = 0x56; break; + case CMD_FDM_START_LOGGING: + hostCommandData = 0x57; break; + case CMD_FDM_STOP_LOGGING: + hostCommandData = 0x58; break; + case CMD_FDM_WRREG: + hostCommandData = 0x59; break; + case CMD_FDM_RDREG: + hostCommandData = 0x5A; break; + case CMD_FDM_DEEP_SLEEP: + hostCommandData = 0x5B; break; + case CMD_FDM_OPMODE_CHECK: + hostCommandData = 0x5C; break; + case CMD_FDM_INIT_REGFILE: + hostCommandData = 0x5d; break; + case CMD_FDM_LED_CTRL: + hostCommandData = 0x5e; break; + default: + appendToLog("!!! CANNOT handle with hostCommand = " + hostCommand.toString()); + } + if (hostCommandData == -1) { + return false; + } else { + commandOperating = true; + byte[] msgBuffer = new byte[]{(byte)0x80, (byte)0xb3, (byte)0x10, (byte)0xA1, 0, 0, 0}; + msgBuffer[3] = (byte) (hostCommandData % 256); + if (true) appendToLog("3030 data = " + byteArrayToString(rx000Setting.antennaPortConfig[0])); + return sendHostRegRequest(HostRegRequests.HST_CMD, true, msgBuffer); + } + } + + ArrayList macAccessHistory = new ArrayList<>(); + void addMacAccessHistory(byte[] msgBuffer) { + byte[] msgBuffer4 = Arrays.copyOf(msgBuffer, 4); + for (int i = 0; i < macAccessHistory.size(); i++) { + byte[] macAccessHistory4 = Arrays.copyOf(macAccessHistory.get(i), 4); + if (Arrays.equals(msgBuffer4, macAccessHistory4)) { + appendToLog("macAccessHistory: deleted old record=" + byteArrayToString(macAccessHistory4)); + macAccessHistory.remove(i); + break; } } + appendToLog("macAccessHistory: added msgbuffer=" + byteArrayToString(msgBuffer)); + macAccessHistory.add(msgBuffer); + } - ArrayList macAccessHistory = new ArrayList<>(); - boolean bifMacAccessHistoryData(byte[] msgBuffer) { - if (sameCheck == false) return false; - if (msgBuffer.length != 8) return false; - if (msgBuffer[0] != (byte)0x70 || msgBuffer[1] != 1) return false; - if (msgBuffer[2] == 0 && msgBuffer[3] == (byte)0xF0) return false; + byte downlinkSequenceNumber = 0; + boolean sendHostRegRequest(HostRegRequests hostRegRequests, boolean writeOperation, byte[] msgBuffer) { + boolean needResponse = false; + boolean validRequest = false; + + if (hostRegRequests == HostRegRequests.HST_ANT_DESC_DWELL) appendToLog("setAntennaDwell 4"); + boolean bSkip = false; + if ( (hostRegRequests != HostRegRequests.HST_CMD && hostRegRequests != HostRegRequests.MAC_OPERATION) + || (hostRegRequests == HostRegRequests.HST_CMD + && msgBuffer[3] != (byte)0xA1 + && msgBuffer[3] != (byte)0xA2 + && msgBuffer[3] != (byte)0xA3 + && msgBuffer[3] != (byte)0xA4 + && msgBuffer[3] != (byte)0xA5 + && msgBuffer[3] != (byte)0xA6 + && msgBuffer[3] != (byte)0xAE + && msgBuffer[3] != (byte)0xB1 + && msgBuffer[3] != (byte)0xB2 + && msgBuffer[3] != (byte)0xB7 + && msgBuffer[3] != (byte)0xB8 + && msgBuffer[3] != (byte)0xB9 + ) || (hostRegRequests == HostRegRequests.MAC_OPERATION && writeOperation && msgBuffer[0] != (byte)0x80) + ) bSkip = true; + if (bSkip) { + appendToLog("!!! Skip sendingRegRequest with " + hostRegRequests.toString() + ", writeOperation = " + writeOperation + "." + byteArrayToString(msgBuffer)); return true; } - int findMacAccessHistory(byte[] msgBuffer) { - int i = -1; - for (i = 0; i < macAccessHistory.size(); i++) { -// appendToLog("macAccessHistory(" + i + ")=" + byteArrayToString(macAccessHistory.get(i))); - if (Arrays.equals(macAccessHistory.get(i), msgBuffer)) break; - } - if (i == macAccessHistory.size()) i = -1; - if (i >= 0) appendToLog("macAccessHistory: returnValue = " + i + ", msgBuffer=" + byteArrayToString(msgBuffer)); - return i; - } - void addMacAccessHistory(byte[] msgBuffer) { - byte[] msgBuffer4 = Arrays.copyOf(msgBuffer, 4); - for (int i = 0; i < macAccessHistory.size(); i++) { - byte[] macAccessHistory4 = Arrays.copyOf(macAccessHistory.get(i), 4); - if (Arrays.equals(msgBuffer4, macAccessHistory4)) { - appendToLog("macAccessHistory: deleted old record=" + byteArrayToString(macAccessHistory4)); - macAccessHistory.remove(i); - break; - } - } - appendToLog("macAccessHistory: added msgbuffer=" + byteArrayToString(msgBuffer)); - macAccessHistory.add(msgBuffer); - } - - byte downlinkSequenceNumber = 0; - boolean sendHostRegRequest(HostRegRequests hostRegRequests, boolean writeOperation, byte[] msgBuffer) { - boolean needResponse = false; - boolean validRequest = false; - - if (hostRegRequests == HostRegRequests.HST_ANT_DESC_DWELL) appendToLog("setAntennaDwell 4"); - boolean bSkip = false; - if ( (hostRegRequests != HostRegRequests.HST_CMD && hostRegRequests != HostRegRequests.MAC_OPERATION) - || (hostRegRequests == HostRegRequests.HST_CMD - && msgBuffer[3] != (byte)0xA1 - && msgBuffer[3] != (byte)0xA2 - && msgBuffer[3] != (byte)0xA3 - && msgBuffer[3] != (byte)0xA4 - && msgBuffer[3] != (byte)0xA5 - && msgBuffer[3] != (byte)0xA6 - && msgBuffer[3] != (byte)0xAE - && msgBuffer[3] != (byte)0xB1 - && msgBuffer[3] != (byte)0xB2 - && msgBuffer[3] != (byte)0xB7 - && msgBuffer[3] != (byte)0xB8 - && msgBuffer[3] != (byte)0xB9 - ) || (hostRegRequests == HostRegRequests.MAC_OPERATION && writeOperation && msgBuffer[0] != (byte)0x80) - ) bSkip = true; - if (bSkip) { - appendToLog("!!! Skip sendingRegRequest with " + hostRegRequests.toString() + ", writeOperation = " + writeOperation + "." + byteArrayToString(msgBuffer)); - return true; - } - if (csReaderConnector.isBleConnected() == false) { - appendToLog("!!! Skip sending as bleConnected is false"); - return false; - } - if (false) addMacAccessHistory(msgBuffer); - switch (hostRegRequests) { - case MAC_OPERATION: - case HST_ANT_CYCLES: - case HST_ANT_DESC_SEL: - case HST_ANT_DESC_CFG: - case MAC_ANT_DESC_STAT: - case HST_ANT_DESC_PORTDEF: - case HST_ANT_DESC_DWELL: - case HST_ANT_DESC_RFPOWER: - case HST_ANT_DESC_INV_CNT: - validRequest = true; - break; - case HST_TAGMSK_DESC_SEL: - case HST_TAGMSK_DESC_CFG: - case HST_TAGMSK_BANK: - case HST_TAGMSK_PTR: - case HST_TAGMSK_LEN: - case HST_TAGMSK_0_3: - validRequest = true; - break; - case HST_QUERY_CFG: - case HST_INV_CFG: - case HST_INV_SEL: - case HST_INV_ALG_PARM_0: - case HST_INV_ALG_PARM_1: - case HST_INV_ALG_PARM_2: - case HST_INV_ALG_PARM_3: - case HST_INV_RSSI_FILTERING_CONFIG: - case HST_INV_RSSI_FILTERING_THRESHOLD: - case HST_INV_RSSI_FILTERING_COUNT: - case HST_INV_EPC_MATCH_CFG: - case HST_INV_EPCDAT_0_3: - validRequest = true; - break; - case HST_TAGACC_DESC_CFG: - case HST_TAGACC_BANK: - case HST_TAGACC_PTR: - case HST_TAGACC_CNT: - case HST_TAGACC_LOCKCFG: - case HST_TAGACC_ACCPWD: - case HST_TAGACC_KILLPWD: - case HST_TAGWRDAT_SEL: - case HST_TAGWRDAT_0: - validRequest = true; - break; - case HST_RFTC_CURRENT_PROFILE: - case HST_RFTC_FRQCH_SEL: - case HST_RFTC_FRQCH_CFG: - case HST_RFTC_FRQCH_DESC_PLLDIVMULT: - case HST_RFTC_FRQCH_DESC_PLLDACCTL: - case HST_RFTC_FRQCH_CMDSTART: - validRequest = true; - break; - case HST_AUTHENTICATE_CFG: - case HST_AUTHENTICATE_MSG: - case HST_READBUFFER_LEN: - case HST_UNTRACEABLE_CFG: - validRequest = true; - break; - case HST_CMD: - validRequest = true; - needResponse = true; - break; - } - - if (msgBuffer == null || validRequest == false) { - appendToLog("invalid request for msgbuffer = " + (msgBuffer == null ? "NULL" : "Valid") + ", validRequst = " + validRequest); - return false; - } else { - RfidConnector.CsReaderRfidData csReaderRfidData = new RfidConnector.CsReaderRfidData(); - csReaderRfidData.rfidPayloadEvent = RfidConnector.RfidPayloadEvents.RFID_COMMAND; - csReaderRfidData.dataValues = msgBuffer; - csReaderRfidData.waitUplinkResponse = true; //(needResponse || writeOperation == false); - if (msgBuffer[0] == (byte)0x80 - && msgBuffer[1] == (byte)0xB3 - ) { - csReaderRfidData.dataValues[4] = downlinkSequenceNumber++; - if (msgBuffer[2] == 0x10 - && msgBuffer[3] != (byte)0xA1 - && msgBuffer[3] != (byte)0xA2 - && msgBuffer[3] != (byte)0xA3 - && msgBuffer[3] != (byte)0xA4 - && msgBuffer[3] != (byte)0xA5 - && msgBuffer[3] != (byte)0xA6 - && msgBuffer[3] != (byte)0xB1 - && msgBuffer[3] != (byte)0xB2 - && msgBuffer[3] != (byte)0xB7 - && msgBuffer[3] != (byte)0xB8 - && msgBuffer[3] != (byte)0xB9 - ) csReaderRfidData.waitUplink1Response = true; - } - addRfidToWrite(csReaderRfidData); - return true; - } + if (csReaderConnector.isBleConnected() == false) { + appendToLog("!!! Skip sending as bleConnected is false"); + return false; + } + if (false) addMacAccessHistory(msgBuffer); + switch (hostRegRequests) { + case MAC_OPERATION: + case HST_ANT_CYCLES: + case HST_ANT_DESC_SEL: + case HST_ANT_DESC_CFG: + case MAC_ANT_DESC_STAT: + case HST_ANT_DESC_PORTDEF: + case HST_ANT_DESC_DWELL: + case HST_ANT_DESC_RFPOWER: + case HST_ANT_DESC_INV_CNT: + validRequest = true; + break; + case HST_TAGMSK_DESC_SEL: + case HST_TAGMSK_DESC_CFG: + case HST_TAGMSK_BANK: + case HST_TAGMSK_PTR: + case HST_TAGMSK_LEN: + case HST_TAGMSK_0_3: + validRequest = true; + break; + case HST_QUERY_CFG: + case HST_INV_CFG: + case HST_INV_SEL: + case HST_INV_ALG_PARM_0: + case HST_INV_ALG_PARM_1: + case HST_INV_ALG_PARM_2: + case HST_INV_ALG_PARM_3: + case HST_INV_RSSI_FILTERING_CONFIG: + case HST_INV_RSSI_FILTERING_THRESHOLD: + case HST_INV_RSSI_FILTERING_COUNT: + case HST_INV_EPC_MATCH_CFG: + case HST_INV_EPCDAT_0_3: + validRequest = true; + break; + case HST_TAGACC_DESC_CFG: + case HST_TAGACC_BANK: + case HST_TAGACC_PTR: + case HST_TAGACC_CNT: + case HST_TAGACC_LOCKCFG: + case HST_TAGACC_ACCPWD: + case HST_TAGACC_KILLPWD: + case HST_TAGWRDAT_SEL: + case HST_TAGWRDAT_0: + validRequest = true; + break; + case HST_RFTC_CURRENT_PROFILE: + case HST_RFTC_FRQCH_SEL: + case HST_RFTC_FRQCH_CFG: + case HST_RFTC_FRQCH_DESC_PLLDIVMULT: + case HST_RFTC_FRQCH_DESC_PLLDACCTL: + case HST_RFTC_FRQCH_CMDSTART: + validRequest = true; + break; + case HST_AUTHENTICATE_CFG: + case HST_AUTHENTICATE_MSG: + case HST_READBUFFER_LEN: + case HST_UNTRACEABLE_CFG: + validRequest = true; + break; + case HST_CMD: + validRequest = true; + needResponse = true; + break; + } + + if (msgBuffer == null || validRequest == false) { + appendToLog("invalid request for msgbuffer = " + (msgBuffer == null ? "NULL" : "Valid") + ", validRequst = " + validRequest); + return false; + } else { + RfidConnector.CsReaderRfidData csReaderRfidData = new RfidConnector.CsReaderRfidData(); + csReaderRfidData.rfidPayloadEvent = RfidConnector.RfidPayloadEvents.RFID_COMMAND; + csReaderRfidData.dataValues = msgBuffer; + csReaderRfidData.waitUplinkResponse = true; //(needResponse || writeOperation == false); + if (msgBuffer[0] == (byte)0x80 + && msgBuffer[1] == (byte)0xB3 + ) { + csReaderRfidData.dataValues[4] = downlinkSequenceNumber++; + if (msgBuffer[2] == 0x10 + && msgBuffer[3] != (byte)0xA1 + && msgBuffer[3] != (byte)0xA2 + && msgBuffer[3] != (byte)0xA3 + && msgBuffer[3] != (byte)0xA4 + && msgBuffer[3] != (byte)0xA5 + && msgBuffer[3] != (byte)0xA6 + && msgBuffer[3] != (byte)0xB1 + && msgBuffer[3] != (byte)0xB2 + && msgBuffer[3] != (byte)0xB7 + && msgBuffer[3] != (byte)0xB8 + && msgBuffer[3] != (byte)0xB9 + ) csReaderRfidData.waitUplink1Response = true; + } + addRfidToWrite(csReaderRfidData); + return true; } + } - void addRfidToWrite(RfidConnector.CsReaderRfidData csReaderRfidData) { - boolean repeatRequest = false; - if (false && csReaderRfidData.rfidPayloadEvent == RfidConnector.RfidPayloadEvents.RFID_COMMAND) { - appendToLog("!!! Skip " + csReaderRfidData.rfidPayloadEvent.toString() + "." + byteArrayToString(csReaderRfidData.dataValues)); - return; - } - if (csReaderConnector.rfidConnector.mRfidToWrite.size() != 0 && sameCheck) { - RfidConnector.CsReaderRfidData csReaderRfidData1 = csReaderConnector.rfidConnector.mRfidToWrite.get(csReaderConnector.rfidConnector.mRfidToWrite.size() - 1); - if (csReaderRfidData.rfidPayloadEvent == csReaderRfidData1.rfidPayloadEvent) { - if (csReaderRfidData.dataValues == null && csReaderRfidData1.dataValues == null) { - repeatRequest = true; - } else if (csReaderRfidData.dataValues != null && csReaderRfidData1.dataValues != null) { - if (csReaderRfidData.dataValues.length == csReaderRfidData1.dataValues.length) { - if (compareArray(csReaderRfidData.dataValues, csReaderRfidData1.dataValues, csReaderRfidData.dataValues.length)) { - repeatRequest = true; - } + void addRfidToWrite(RfidConnector.CsReaderRfidData csReaderRfidData) { + boolean repeatRequest = false; + if (false && csReaderRfidData.rfidPayloadEvent == RfidConnector.RfidPayloadEvents.RFID_COMMAND) { + appendToLog("!!! Skip " + csReaderRfidData.rfidPayloadEvent.toString() + "." + byteArrayToString(csReaderRfidData.dataValues)); + return; + } + if (csReaderConnector.rfidConnector.mRfidToWrite.size() != 0 && sameCheck) { + RfidConnector.CsReaderRfidData csReaderRfidData1 = csReaderConnector.rfidConnector.mRfidToWrite.get(csReaderConnector.rfidConnector.mRfidToWrite.size() - 1); + if (csReaderRfidData.rfidPayloadEvent == csReaderRfidData1.rfidPayloadEvent) { + if (csReaderRfidData.dataValues == null && csReaderRfidData1.dataValues == null) { + repeatRequest = true; + } else if (csReaderRfidData.dataValues != null && csReaderRfidData1.dataValues != null) { + if (csReaderRfidData.dataValues.length == csReaderRfidData1.dataValues.length) { + if (compareArray(csReaderRfidData.dataValues, csReaderRfidData1.dataValues, csReaderRfidData.dataValues.length)) { + repeatRequest = true; } } } } - if (repeatRequest == false) { - csReaderConnector.rfidConnector.mRfidToWrite.add(csReaderRfidData); - if (DEBUG_PKDATA) appendToLog("PkData: add " + csReaderRfidData.rfidPayloadEvent + (csReaderRfidData.dataValues != null ? "." : "") + byteArrayToString(csReaderRfidData.dataValues) - + (csReaderRfidData.waitUplinkResponse ? " waitUplinkResponse" : "") + (csReaderRfidData.waitUplink1Response ? " waitUplink1Response" : "") - + " to mRfidToWrite with length = " + csReaderConnector.rfidConnector.mRfidToWrite.size()); - } else if (DEBUG_PKDATA) appendToLog("!!! Skip repeated sending " + csReaderRfidData.rfidPayloadEvent + (csReaderRfidData.dataValues != null ? "." : "") + byteArrayToString(csReaderRfidData.dataValues)); - } -// } + } + if (repeatRequest == false) { + csReaderConnector.rfidConnector.mRfidToWrite.add(csReaderRfidData); + if (DEBUG_PKDATA) appendToLog("PkData: add " + csReaderRfidData.rfidPayloadEvent + (csReaderRfidData.dataValues != null ? "." : "") + byteArrayToString(csReaderRfidData.dataValues) + + (csReaderRfidData.waitUplinkResponse ? " waitUplinkResponse" : "") + (csReaderRfidData.waitUplink1Response ? " waitUplink1Response" : "") + + " to mRfidToWrite with length = " + csReaderConnector.rfidConnector.mRfidToWrite.size()); + } else if (DEBUG_PKDATA) appendToLog("!!! Skip repeated sending " + csReaderRfidData.rfidPayloadEvent + (csReaderRfidData.dataValues != null ? "." : "") + byteArrayToString(csReaderRfidData.dataValues)); + } + boolean inventoring = false; public boolean isInventoring() { return inventoring; } void setInventoring(boolean enable) { inventoring = enable; utility.debugFileEnable(false); if (true) appendToLog("setInventoring E710 is set as " + inventoring);} diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipR2000.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipR2000.java index cba8ad8..e7d9830 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipR2000.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipR2000.java @@ -20,7 +20,7 @@ public class RfidReaderChipR2000 { Context context; Utility utility; CsReaderConnector csReaderConnector; public RfidReaderChipR2000(Context context, Utility utility, CsReaderConnector csReaderConnector) { this.context = context; - this.utility = utility; DEBUG_PKDATA = utility.DEBUG_PKDATA; + this.utility = utility; appendToLog("csReaderConnector 1 is " + (csReaderConnector == null ? "null" : "valid")); this.csReaderConnector = csReaderConnector; this.DEBUGTHREAD = csReaderConnector.DEBUGTHREAD; @@ -91,7 +91,7 @@ public class Rx000Setting { //querySession = mDefault.querySession; //querySelect = mDefault.querySelect; //appendToLog("BtDataOut: RfidReaderChipR2000.Rx000Setting new querySelect = " + querySelect); - invAlgo = mDefault.invAlgo; + //invAlgo = mDefault.invAlgo; matchRep = mDefault.matchRep; tagSelect = mDefault.tagSelect; noInventory = mDefault.noInventory; @@ -127,7 +127,7 @@ public class Rx000Setting { accessRetry = mDefault.accessRetry; accessBank = mDefault.accessBank; accessBank2 = mDefault.accessBank2; accessOffset = mDefault.accessOffset; accessOffset2 = mDefault.accessOffset2; - accessCount = mDefault.accessCount; accessCount2 = mDefault.accessCount2; + //accessCount = mDefault.accessCount; accessCount2 = mDefault.accessCount2; accessLockAction = mDefault.accessLockAction; accessLockMask = mDefault.accessLockMask; //long accessPassword = 0; @@ -275,6 +275,7 @@ public int getImpinjExtension() { public boolean setImpinjExtension(boolean tagFocus, boolean fastId) { int iValue = (tagFocus ? 0x10 : 0) | (fastId ? 0x20 : 0); if (impinjExtensionValue == iValue && sameCheck) return true; + appendToLog("BtDataOut 11: ivalue = " + iValue + ", impinjExtensionValue = " + rx000Setting.impinjExtensionValue); boolean bRetValue = writeMAC(0x203, iValue); if (bRetValue) impinjExtensionValue = iValue; return bRetValue; @@ -570,6 +571,7 @@ public int getInvSelectIndex() { return invSelectIndex; } public boolean setInvSelectIndex(int invSelect) { + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReaderChipR2000.setInvSelectIndex[" + invSelect); byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 0, 8, 0, 0, 0, 0}; if (invSelect < INVSELECT_MIN || invSelect > INVSELECT_MAX) invSelect = mDefault.invSelectIndex; if (this.invSelectIndex == invSelect && sameCheck) return true; @@ -584,7 +586,9 @@ public int getSelectEnable() { return invSelectData[invSelectIndex].getSelectEnable(); } public boolean setSelectEnable(int enable, int selectTarget, int selectAction, int selectDelay) { + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReaderChipR2000.Rx000Setting.setSelectEnable[" + enable); if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; + if (false) appendToLog("BtDataOut: RfidReaderChipR200.setSelectEnable goes to setRx000HostReg_HST_TAGMSK_DESC_CFG with index = " + invSelectIndex); return invSelectData[invSelectIndex].setRx000HostReg_HST_TAGMSK_DESC_CFG(enable, selectTarget, selectAction, selectDelay); } @@ -629,6 +633,7 @@ public int getSelectMaskLength() { } } public boolean setSelectMaskLength(int selectMaskLength) { + if (false) appendToLog("btDataOut: setSelectMaskLength with selectMaskLength = " + selectMaskLength); if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; return invSelectData[invSelectIndex].setSelectMaskLength(selectMaskLength); } @@ -657,32 +662,42 @@ public boolean setSelectMaskData(String maskData) { final int QUERYTARGET_INVALID = -1; final int QUERYTARGET_MIN = 0; final int QUERYTARGET_MAX = 1; int queryTarget = QUERYTARGET_INVALID; public int getQueryTarget() { - if (queryTarget < QUERYTARGET_MIN || queryTarget > QUERYTARGET_MAX) getHST_QUERY_CFG(); + if (DEBUG) appendToLog("RfidReaderChipR2000.getQueryTarget with queryTarget = " + queryTarget); + if (queryTarget == QUERYTARGET_INVALID) getHST_QUERY_CFG(); return queryTarget; } boolean setQueryTarget(int queryTarget) { + if (DEBUG || true) appendToLog("3 setQueryTarget is callled from RfidReaderChipR2000.setQueryTarget[" + queryTarget); return setQueryTarget(queryTarget, querySession, querySelect); } public boolean setQueryTarget(int queryTarget, int querySession, int querySelect) { + if (false) appendToLog("setQueryTarget[" + queryTarget + ", " + querySession + ", " + querySelect + "] with sameCheck = " + sameCheck + ", old queryTarget/Session/Select = " + this.queryTarget + ", " + this.querySession + ", " + this.querySelect); if (queryTarget >= 2) { rx000Setting.setAlgoAbFlip(1); } else if (queryTarget >= 0) { rx000Setting.setAlgoAbFlip(0); } byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 0, 9, 0, 0, 0, 0}; + /* if (queryTarget != 2 && (queryTarget < QUERYTARGET_MIN || queryTarget > QUERYTARGET_MAX)) { if (this.queryTarget >= QUERYTARGET_MIN && this.queryTarget <= QUERYTARGET_MAX) queryTarget = this.queryTarget; else queryTarget = mDefault.queryTarget; } + if (querySession < QUERYSESSION_MIN || querySession > QUERYSESSION_MAX) { if (this.querySession >= QUERYSESSION_MIN && this.querySession <= QUERYSESSION_MAX) querySession = this.querySession; else querySession = mDefault.querySession; } + if (querySelect < QUERYSELECT_MIN || querySelect > QUERYSELECT_MAX) { if (this.querySelect >= QUERYSELECT_MIN && this.querySelect <= QUERYSELECT_MAX) querySelect = this.querySelect; else querySelect = mDefault.querySelect; } - if (this.queryTarget == queryTarget && this.querySession == querySession && this.querySelect == querySelect && sameCheck) return true; + */ + + if ((this.queryTarget == queryTarget || queryTarget == 2 || queryTarget == -1) + && (this.querySession == querySession || querySession == -1) + && (this.querySelect == querySelect || querySelect == -1) && sameCheck) return true; msgBuffer[4] |= ((queryTarget == 2 ? 0 : queryTarget) << 4); msgBuffer[4] |= (byte) (querySession << 5); if ((querySelect & 0x01) != 0) { @@ -704,6 +719,7 @@ public int getQuerySession() { return ANTSELECT_INVALID; } else { { + //appendToLog("BtDataOut: RfidReaderChipR2000.getQuerySession with querySession = " + querySession); if (querySession < QUERYSESSION_MIN || querySession > QUERYSESSION_MAX) getHST_QUERY_CFG(); return querySession; @@ -712,22 +728,26 @@ public int getQuerySession() { } boolean setQuerySession(int querySession) { - return setQueryTarget(queryTarget, querySession, querySelect); + if (true) appendToLog("4 setQueryTargetis callled from BtDataOut: RfidReaderChipR2000.setQuerySession[" + querySession); + return setQueryTarget((getAlgoAbFlip() > 0 ? 2 : queryTarget), querySession, querySelect); } final int QUERYSELECT_INVALID = -1; final int QUERYSELECT_MIN = 0; final int QUERYSELECT_MAX = 3; int querySelect = QUERYSELECT_INVALID; public int getQuerySelect() { + if (false) appendToLog("BtDataOut: RfidReaderChipR2000.getQuerySelect with querySelect = " + querySelect); if (querySelect < QUERYSELECT_MIN || querySelect > QUERYSELECT_MAX) getHST_QUERY_CFG(); if (false) appendToLog("Stream querySelect = " + querySelect); return querySelect; } public boolean setQuerySelect(int querySelect) { + if (false) appendToLog("5 setQueryTarget is callled from RfidReaderChipR2000.setQuerySelect[" + querySelect); if (querySelect == this.querySelect) return true; - return setQueryTarget(queryTarget, querySession, querySelect); + return setQueryTarget((getAlgoAbFlip() > 0 ? 2 : queryTarget), querySession, querySelect); } private boolean getHST_QUERY_CFG() { + //appendToLog("BtDataOut: RfidReaderChipR2000.getHST_QUERY_CFG"); byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 0, 9, 0, 0, 0, 0}; return sendHostRegRequest(HostRegRequests.HST_QUERY_CFG, false, msgBuffer); } @@ -739,7 +759,7 @@ public int getInvAlgo() { return invAlgo; } public boolean setInvAlgo(int invAlgo) { - if (false) appendToLog("writeBleStreamOut: going to setInvAlgo with invAlgo = " + invAlgo); + if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setInvAlog goes to setInvAlgo with invAlgo = " + invAlgo); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact,invBrandId); } @@ -750,7 +770,7 @@ int getMatchRep() { return matchRep; } public boolean setMatchRep(int matchRep) { - appendToLog("writeBleStreamOut: going to setInvAlgo with invAlgo = " + invAlgo); + if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setMatchRep goes to setInvAlgo with matchRep = " + matchRep); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, invBrandId); } @@ -761,7 +781,7 @@ int getTagSelect() { return tagSelect; } public boolean setTagSelect(int tagSelect) { - if (false) appendToLog("writeBleStreamOut: going to setInvAlgo with invAlgo = " + invAlgo); + if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setTagSelect goes to setInvAlgo with tagSelect = " + tagSelect); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, invBrandId); } @@ -772,7 +792,7 @@ int getNoInventory() { return noInventory; } boolean setNoInventory(int noInventory) { - appendToLog("writeBleStreamOut: going to setInvAlgo with invAlgo = " + invAlgo); + if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setNoInventory goes to setInvAlgo with noInventory = " + noInventory); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, invBrandId); } @@ -783,8 +803,7 @@ int getTagRead() { return tagRead; } public boolean setTagRead(int tagRead) { - appendToLog("writeBleStreamOut: going to setInvAlgo with invAlgo = " + invAlgo); - appendToLog("01 tagRead is " + tagRead); + if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setTagRead goes to setInvAlgo with tagRead = " + tagRead); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, invBrandId); } @@ -794,8 +813,8 @@ int getTagDelay() { if (tagDelay < TAGDELAY_MIN || tagDelay > TAGDELAY_MAX) getHST_INV_CFG(); return tagDelay; } - public boolean setTagDelay(int tagDelay) { - if (false) appendToLog("writeBleStreamOut: going to setInvAlgo with invAlgo = " + invAlgo); + public boolean setTagDelay2RfidReader(int tagDelay) { + if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setTagDelay goes to setInvAlgo with tagDelay = " + tagDelay); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, invBrandId); } @@ -975,7 +994,7 @@ boolean getInvModeCompact() { return (invModeCompact == 1 ? true : false); } public boolean setInvModeCompact(boolean invModeCompact) { - if (false) appendToLog("writeBleStreamOut: going to setInvAlgo with invAlgo = " + invAlgo); + if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setInvModeCompact goes to setInvAlgo with invModeCompact = " + invModeCompact); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, (invModeCompact ? 1 : 0), invBrandId); } @@ -986,6 +1005,7 @@ boolean getInvBrandId() { return (invModeCompact == 1 ? true : false); } public boolean setInvBrandId(boolean invBrandId) { + if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setInvBrandId goes to setInvAlgo with invBrandId = " + invBrandId); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, (invBrandId ? 1 : 0)); } @@ -994,9 +1014,8 @@ private boolean getHST_INV_CFG() { return sendHostRegRequest(HostRegRequests.HST_INV_CFG, false, msgBuffer); } boolean setInvAlgo(int invAlgo, int matchRep, int tagSelect, int noInventory, int tagRead, int tagDelay, int invModeCompact, int invBrandId) { - boolean DEBUG = false; - appendToLog("0 tagRead is " + tagRead); - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, 9, 0, 0, 0, 0}; + boolean DEBUG = utility.DEBUG_INVCFG; + if (DEBUG) appendToLog("Debug_InvCfg: 0 tagRead is " + tagRead); if (invAlgo < INVALGO_MIN || invAlgo > INVALGO_MAX) invAlgo = mDefault.invAlgo; if (matchRep < MATCHREP_MIN || matchRep > MATCHREP_MAX) matchRep = mDefault.matchRep; if (tagSelect < TAGSELECT_MIN || tagSelect > TAGSELECT_MAX) tagSelect = mDefault.tagSelect; @@ -1005,10 +1024,30 @@ boolean setInvAlgo(int invAlgo, int matchRep, int tagSelect, int noInventory, in if (invModeCompact < TAGJOIN_MIN || invModeCompact > TAGJOIN_MAX) invModeCompact = mDefault.tagJoin; if (invBrandId < BRANDID_MIN || invBrandId > BRANDID_MAX) invBrandId = mDefault.brandid; if (tagRead < TAGREAD_MIN || tagRead > TAGREAD_MAX) tagRead = mDefault.tagRead; - if (DEBUG) appendToLog("Old invAlgo = " + this.invAlgo + ", matchRep = " + this.matchRep + ", tagSelect =" + this.tagSelect + ", noInventory = " + this.noInventory + ", tagRead = " + this.tagRead + ", tagDelay = " + this.tagDelay + ", invModeCompact = " + this.invModeCompact + ", invBrandId = " + this.invBrandId); - if (DEBUG) appendToLog("New invAlgo = " + invAlgo + ", matchRep = " + matchRep + ", tagSelect =" + tagSelect + ", noInventory = " + noInventory + ", tagRead = " + tagRead + ", tagDelay = " + tagDelay + ", invModeCompact = " + invModeCompact + ", invBrandId = " + invBrandId + ", sameCheck = " + sameCheck); - if (this.invAlgo == invAlgo && this.matchRep == matchRep && this.tagSelect == tagSelect && this.noInventory == noInventory && this.tagRead == tagRead && this.tagDelay == tagDelay && this.invModeCompact == invModeCompact && this.invBrandId == invBrandId && sameCheck) return true; - if (DEBUG) appendToLog("There is difference"); + if (DEBUG) appendToLog("Debug_InvCfg: Old invAlgo = " + this.invAlgo + ", matchRep = " + this.matchRep + ", tagSelect = " + this.tagSelect + ", noInventory = " + this.noInventory + ", tagRead = " + this.tagRead + ", tagDelay = " + this.tagDelay + ", invModeCompact = " + this.invModeCompact + ", invBrandId = " + this.invBrandId); + if (DEBUG) appendToLog("Debug_InvCfg: New invAlgo = " + invAlgo + ", matchRep = " + matchRep + ", tagSelect = " + tagSelect + ", noInventory = " + noInventory + ", tagRead = " + tagRead + ", tagDelay = " + tagDelay + ", invModeCompact = " + invModeCompact + ", invBrandId = " + invBrandId + ", sameCheck = " + sameCheck); + boolean bool1 = this.invAlgo == invAlgo; + boolean bool2 = this.matchRep == matchRep; + boolean bool3 = this.tagSelect == tagSelect; + boolean bool4 = this.noInventory == noInventory; + if (DEBUG) appendToLog("Debug_InvCfg: tagRead = " + tagRead + ", this.tagRead = " + this.tagRead); + boolean bool5 = (this.tagRead == tagRead) || (tagRead == -1); + boolean bool6 = this.tagDelay == tagDelay; + boolean bool7 = this.invModeCompact == invModeCompact; + boolean bool8 = this.invBrandId == invBrandId; + if (bool1 && bool2 && bool3 && bool4 && bool5 && bool6 && bool7 && bool8 && sameCheck) return true; + if (DEBUG) appendToLog("Debug_InvCfg: There is difference with " + bool1 + "," + bool2 + "," + bool3 + "," + bool4 + "," + bool5 + "," + bool6 + "," + bool7 + "," + bool8); + this.invAlgo = invAlgo; if (DEBUG) appendToLog("Hello6: invAlgo = " + invAlgo + ", queryTarget = " + queryTarget); + this.matchRep = matchRep; + this.tagSelect = tagSelect; + this.noInventory = noInventory; + this.tagRead = tagRead; + this.tagDelay = tagDelay; + this.invModeCompact = invModeCompact; + this.invBrandId = invBrandId; + if (DEBUG) appendToLog("Debug_InvCfg: Stored tagDelay = " + this.tagDelay); + + byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, 9, 0, 0, 0, 0}; msgBuffer[4] |= invAlgo; msgBuffer[4] |= (byte) ((matchRep & 0x03) << 6); msgBuffer[5] |= (byte) (matchRep >> 2); @@ -1033,15 +1072,6 @@ boolean setInvAlgo(int invAlgo, int matchRep, int tagSelect, int noInventory, in if (invBrandId == 1) { msgBuffer[7] |= 0x08; } - this.invAlgo = invAlgo; if (DEBUG) appendToLog("Hello6: invAlgo = " + invAlgo + ", queryTarget = " + queryTarget); - this.matchRep = matchRep; - this.tagSelect = tagSelect; - this.noInventory = noInventory; - this.tagRead = tagRead; - this.tagDelay = tagDelay; - this.invModeCompact = invModeCompact; - this.invBrandId = invBrandId; - if (DEBUG) appendToLog("Stored tagDelay = " + this.tagDelay); return sendHostRegRequest(HostRegRequests.HST_INV_CFG, true, msgBuffer); } @@ -1465,6 +1495,7 @@ int getAccessRetry() { } public boolean setAccessRetry(boolean accessVerfiy, int accessRetry) { byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, 0x0A, 0, 0, 0, 0}; + if (DEBUG) appendToLog("setAccessRetry[" + accessVerfiy + ", " + accessRetry + "] with tagRead = " + tagRead + ", sameCheck = " + sameCheck + ", old accessVerfiy = " + this.accessVerfiy + ", accessRetry = " + this.accessRetry); if (accessRetry < ACCRETRY_MIN || accessRetry > ACCRETRY_MAX) accessRetry = mDefault.accessRetry; if (this.accessVerfiy == accessVerfiy && this.accessRetry == accessRetry && sameCheck) return true; @@ -1486,6 +1517,7 @@ int getAccessBank() { } public boolean setAccessBank(int accessBank) { byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 2, 0x0A, 0, 0, 0, 0}; + if (DEBUG) appendToLog("setAccessBank[" + accessBank + "] with tagRead = " + tagRead + ", sameCheck = " + sameCheck + ", old accessBank = " + this.accessBank); if (accessBank < ACCBANK_MIN || accessBank > ACCBANK_MAX) accessBank = mDefault.accessBank; if (this.accessBank == accessBank && this.accessBank2 == 0 && sameCheck) return true; @@ -1495,7 +1527,7 @@ public boolean setAccessBank(int accessBank) { } public boolean setAccessBank(int accessBank, int accessBank2) { byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 2, 0x0A, 0, 0, 0, 0}; - if (DEBUG) appendToLog("setAccessBank(" + accessBank + ", " + accessBank2 + ") with tagRead = " + tagRead); + if (DEBUG) appendToLog("setAccessBank[" + accessBank + ", " + accessBank2 + "] with tagRead = " + tagRead + ", sameCheck = " + sameCheck + ", old accessBank = " + this.accessBank + ", " + this.accessBank2); if (tagRead != 2) accessBank2 = 0; if (accessBank < ACCBANK_MIN || accessBank > ACCBANK_MAX) accessBank = mDefault.accessBank; @@ -1519,6 +1551,7 @@ int getAccessOffset() { } public boolean setAccessOffset(int accessOffset) { byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 3, 0x0A, 0, 0, 0, 0}; + if (false) appendToLog("setAccessOffset[" + accessOffset + "] with tagRead = " + tagRead + ", sameCheck = " + sameCheck + ", old accessOffset = " + this.accessOffset); if (accessOffset < ACCOFFSET_MIN || accessOffset > ACCOFFSET_MAX) accessOffset = mDefault.accessOffset; if (this.accessOffset == accessOffset && this.accessOffset2 == 0 && sameCheck) return true; @@ -1531,6 +1564,7 @@ public boolean setAccessOffset(int accessOffset) { } public boolean setAccessOffset(int accessOffset, int accessOffset2) { byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 3, 0x0A, 0, 0, 0, 0}; + if (false) appendToLog("setAccessOffset[" + accessOffset + ", " + accessOffset2 + "] with tagRead = " + tagRead + ", sameCheck = " + sameCheck + ", old accessOffset = " + this.accessOffset + ", " + this.accessOffset2); if (tagRead != 2) accessOffset2 = 0; if (accessOffset < ACCOFFSET_MIN || accessOffset > ACCOFFSET_MAX) accessOffset = mDefault.accessOffset; @@ -1547,7 +1581,7 @@ public boolean setAccessOffset(int accessOffset, int accessOffset2) { final int ACCCOUNT_INVALID = -1; final int ACCCOUNT_MIN = 0; final int ACCCOUNT_MAX = 255; int accessCount = ACCCOUNT_INVALID; int accessCount2 = ACCCOUNT_INVALID; - int getAccessCount() { + public int getAccessCount() { if (accessCount < ACCCOUNT_MIN || accessCount > ACCCOUNT_MAX) { byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 4, (byte) 0x0A, 0, 0, 0, 0}; sendHostRegRequest(HostRegRequests.HST_TAGACC_CNT, false, msgBuffer); @@ -1556,15 +1590,17 @@ int getAccessCount() { } public boolean setAccessCount(int accessCount) { byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 4, 0x0A, 0, 0, 0, 0}; + if (DEBUG) appendToLog("BtDataOut: SetAccessCount[" + accessCount + "] with tagRead = " + tagRead + ", sameCheck = " + sameCheck + ", old accessCount = " + this.accessCount); if (accessCount < ACCCOUNT_MIN || accessCount > ACCCOUNT_MAX) accessCount = mDefault.accessCount; - if (this.accessCount == accessCount && this.accessCount2 == 0 && sameCheck) return true; + if ((this.accessCount == accessCount || accessCount == -1) && this.accessCount2 == 0 && sameCheck) return true; msgBuffer[4] = (byte) (accessCount & 0xFF); this.accessCount = accessCount; this.accessCount2 = 0; return sendHostRegRequest(HostRegRequests.HST_TAGACC_CNT, true, msgBuffer); } public boolean setAccessCount(int accessCount, int accessCount2) { byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 4, 0x0A, 0, 0, 0, 0}; + if (DEBUG) appendToLog("setAccessCount[" + accessCount + ", " + accessCount2 + "] with tagRead = " + tagRead + ", sameCheck = " + sameCheck + ", old accessCount = " + this.accessCount + ", " + this.accessCount2); if (tagRead != 2) accessCount2 = 0; if (accessCount < ACCCOUNT_MIN || accessCount > ACCCOUNT_MAX) accessCount = mDefault.accessCount; @@ -1621,8 +1657,9 @@ public boolean setAccessLockAction(int accessLockAction, int accessLockMask) { } final int ACCPWD_INVALID = 0; final long ACCPWD_MIN = 0; final long ACCPWD_MAX = 0x0FFFFFFFF; - String stringAccessPasword = ""; + String stringAccessPasword = "00000000"; public boolean setRx000AccessPassword(String password) { + //appendToLog("BtDataOut: setRx000AccessPassword with password = " + password + ", stringAccessPasword = " + stringAccessPasword); if (stringAccessPasword.matches(password) && sameCheck) return true; byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 6, (byte) 0x0A, 0, 0, 0, 0}; if (password == null) password = ""; @@ -1721,6 +1758,7 @@ String getAccessWriteData() { } return strValue; } + public boolean setAccessWriteData(String dataInput) { dataInput = dataInput.trim(); int writeBufLength = 16 * 2; //16 @@ -1731,11 +1769,16 @@ public boolean setAccessWriteData(String dataInput) { if (length > 0) { length -= wrieByteSize; if ((i / 16) * 16 == i) { - byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 8, (byte) 0x0A, 0, 0, 0, 0}; - msgBuffer[4] = (byte) (i / 16); - if (sendHostRegRequest(HostRegRequests.HST_TAGWRDAT_SEL, true, msgBuffer) == false) { - appendToLog("23"); - return false; + if (true) { + if (setAccessWriteDataSelect(i/16) == false) return false; + } + else { + byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 8, (byte) 0x0A, 0, 0, 0, 0}; + msgBuffer[4] = (byte) (i / 16); + if (sendHostRegRequest(HostRegRequests.HST_TAGWRDAT_SEL, true, msgBuffer) == false) { + appendToLog("23"); + return false; + } } } byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 9, (byte) 0x0A, 0, 0, 0, 0}; @@ -1766,15 +1809,25 @@ public boolean setAccessWriteData(String dataInput) { if (wrieByteSize == 4) { msgBuffer[6] = (byte)(i); } - if (sendHostRegRequest(HostRegRequests.HST_TAGWRDAT_0, true, msgBuffer) == false) { - appendToLog("3"); return false; - } else { - rx000Setting.accWriteDataReady |= (0x01 << i); - if (DEBUG) appendToLog("accWriteReady=" + accWriteDataReady); - for (int k = 0; k < 4; k++) { - accWriteData0_63[i * 4 + k] = msgBuffer[7 - k]; + byte[] debugBuffer = new byte[4]; + int k = 0; + for (; k < 4; k++) { + debugBuffer[k] = accWriteData0_63[i * 4 + k]; + if (accWriteData0_63[i * 4 + k] != msgBuffer[7 - k]) break; + } + if (k != 4) { + appendToLog("BtDataOut: RfidReaderChipR2000.setAccessWriteData msgBuffer = " + byteArrayToString(msgBuffer) + ", debugBuffer = " + byteArrayToString(debugBuffer)); + if (sendHostRegRequest(HostRegRequests.HST_TAGWRDAT_0, true, msgBuffer) == false) { + appendToLog("3"); + return false; + } else { + rx000Setting.accWriteDataReady |= (0x01 << i); + if (DEBUG) appendToLog("accWriteReady=" + accWriteDataReady); + for (int k1 = 0; k1 < 4; k1++) { + accWriteData0_63[i * 4 + k1] = msgBuffer[7 - k1]; + } + if (DEBUG) appendToLog("Data=" + byteArrayToString(accWriteData0_63)); } - if (DEBUG) appendToLog("Data=" + byteArrayToString(accWriteData0_63)); } } else break; } @@ -1840,6 +1893,7 @@ public boolean setFreqChannelSelect(int freqChannelSelect) { final int FREQCHANCONFIG_INVALID = -1; final int FREQCHANCONFIG_MIN = 0; final int FREQCHANCONFIG_MAX = 1; int freqChannelConfig = FREQCHANCONFIG_INVALID; public int getFreqChannelConfig() { + //appendToLog("BtDataOut: getFreqChannelConfig with freqChannelConfig = " + freqChannelConfig); if (freqChannelConfig < FREQCHANCONFIG_MIN || freqChannelConfig > FREQCHANCONFIG_MAX) { byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 2, 0x0C, 0, 0, 0, 0}; sendHostRegRequest(HostRegRequests.HST_RFTC_FRQCH_CFG, false, msgBuffer); @@ -2220,6 +2274,7 @@ class InvSelectData { selectMaskOffset = mDefault.selectMaskOffset; selectMaskLength = mDefault.selectMaskLength; selectMaskDataReady = mDefault.selectMaskDataReady; + //Log.i("Hello", "BtDataOut 123b"); } } @@ -2242,6 +2297,7 @@ int getSelectEnable() { return selectEnable; } boolean setSelectEnable(int selectEnable) { + appendToLog("BtDataOut: RfidReaderChipR200.setSelectEnable"); return setRx000HostReg_HST_TAGMSK_DESC_CFG(selectEnable, this.selectTarget, this.selectAction, this.selectDelay); } @@ -2280,6 +2336,9 @@ boolean getRx000HostReg_HST_TAGMSK_DESC_CFG() { } boolean setRx000HostReg_HST_TAGMSK_DESC_CFG(int selectEnable, int selectTarget, int selectAction, int selectDelay) { byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, 8, 0, 0, 0, 0}; + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReaderR2000.setRx000HostReg_HST_TAGMSK_DESC_CFG[" + + selectEnable + "," + selectTarget + "," + selectAction + "," + selectDelay + "] with old SelectEnable/Target/Action/Delay =" + + this.selectEnable + "," + this.selectTarget + "," + this.selectAction + "," + this.selectDelay); if (selectEnable < INVSELENABLE_MIN || selectEnable > INVSELENABLE_MAX) selectEnable = mDefault.selectEnable; if (selectTarget < INVSELTARGET_MIN || selectTarget > INVSELTARGET_MAX) @@ -2363,7 +2422,7 @@ boolean setSelectMaskLength(int selectMaskLength) { byte[] selectMaskData0_31 = new byte[4 * 8]; byte selectMaskDataReady = 0; String getRx000SelectMaskData() { - appendToLog("getSelectMaskData with selectMaskData0_31 = " + byteArrayToString(selectMaskData0_31)); + if (false) appendToLog("getSelectMaskData with selectMaskData0_31 = " + byteArrayToString(selectMaskData0_31)); int length = selectMaskLength; String strValue = ""; if (length < 0) { @@ -2437,6 +2496,7 @@ class AlgoSelectedData { mDefault = new AlgoSelectedData_default(default_setting_type); if (set_default_setting) { algoStartQ = mDefault.algoStartQ; + //Log.i("Hello", "BtDataOut: algoStartQ is set to default " + algoStartQ); algoMaxQ = mDefault.algoMaxQ; algoMinQ = mDefault.algoMinQ; algoMaxRep = mDefault.algoMaxRep; @@ -2474,7 +2534,7 @@ class AlgoSelectedData_default { AlgoSelectedData_default mDefault; class AlgoSelectedData_defaultArray { //0 for invalid default, 1 for 0, 2 for 1, 3 for 2, 4 for 3 - int[] algoStartQ = { -1, 0, 0, 0, 4 }; + int[] algoStartQ = { -1, 0, 0, 0, 7 }; int[] algoMaxQ = { -1, 0, 0, 0, 15 }; int[] algoMinQ = { -1, 0, 0, 0, 0 }; int[] algoMaxRep = { -1, 0, 0, 0, 4 }; @@ -2554,7 +2614,11 @@ private boolean getHST_INV_ALG_PARM_0() { } boolean setAlgoStartQ(int startQ, int algoMaxQ, int algoMinQ, int algoMaxRep, int algoHighThres, int algoLowThres) { boolean DEBUG = false; - if (DEBUG) appendToLog("startQ = " + startQ + ", algoStartQ = " + this.algoStartQ); + if (DEBUG) appendToLog("BtDataOut: startQ = " + startQ + ", algoMaxQ = " + algoMaxQ + ", algoMinQ = " + algoMinQ + ", algoMaxRep = " + algoMaxRep + + ", algoHighThres = " + algoHighThres + ", algoLowThres = " + algoLowThres + + ", Old = " + this.algoStartQ + ", " + this.algoMaxQ + ", " + this.algoMinQ + ", " + this.algoMaxRep + + ", " + this.algoHighThres + ", " + this.algoLowThres); + byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 3, 9, 0, 0, 0, 0}; if (startQ < ALGOSTARTQ_MIN || startQ > ALGOSTARTQ_MAX) startQ = mDefault.algoStartQ; if (algoMaxQ < ALGOMAXQ_MIN || algoMaxQ > ALGOMAXQ_MAX) algoMaxQ = mDefault.algoMaxQ; @@ -2578,6 +2642,7 @@ boolean setAlgoStartQ(int startQ, int algoMaxQ, int algoMinQ, int algoMaxRep, in msgBuffer[6] |= (byte) ((algoHighThres & 0x0F) << 4); msgBuffer[7] |= (byte) (algoLowThres & 0x0F); this.algoStartQ = startQ; + if (false) appendToLog("this.algoStartQ is updated as " + this.algoStartQ); this.algoMaxQ = algoMaxQ; this.algoMinQ = algoMinQ; this.algoMaxRep = algoMaxRep; @@ -2634,7 +2699,7 @@ boolean setAlgoAbFlip(int algoAbFlip, int algoRunTilZero) { algoAbFlip = mDefault.algoAbFlip; if (algoRunTilZero < ALGORUNTILZERO_MIN || algoRunTilZero > ALGORUNTILZERO_MAX) algoRunTilZero = mDefault.algoRunTilZero; - if (false) appendToLog("this.algoAbFlip = " + this.algoAbFlip + ", algoAbFlip = " + algoAbFlip + ", this.algoRunTilZero = " + this.algoRunTilZero + ", algoRunTilZero = " + algoRunTilZero); + if (true) appendToLog("this.algoAbFlip = " + this.algoAbFlip + ", algoAbFlip = " + algoAbFlip + ", this.algoRunTilZero = " + this.algoRunTilZero + ", algoRunTilZero = " + algoRunTilZero); if (this.algoAbFlip == algoAbFlip && this.algoRunTilZero == algoRunTilZero && sameCheck) return true; byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 5, 9, 0, 0, 0, 0}; if (algoAbFlip != 0) { @@ -2903,7 +2968,7 @@ public int encodeNarrowBandRSSI(double dRSSI) { long date_time_ms = 0; public boolean bRx000ToReading = false; - void mRx000UplinkHandler() { + void uplinkHandler() { boolean DEBUG = false; if (bRx000ToReading) return; bRx000ToReading = true; @@ -2921,30 +2986,34 @@ void mRx000UplinkHandler() { boolean bFirst = true; byte[] data1 = null; RfidDataReadTypes rfidDataReadTypes = null; + boolean bLooping = false; while (csReaderConnector.rfidConnector.mRfidToRead.size() != 0) { + if (utility.DEBUG_APDATA && bLooping == false) appendToLog("ApData: Entering loop with mRfidToRead.size as " + csReaderConnector.rfidConnector.mRfidToRead.size()); + bLooping = true; + if (csReaderConnector.isBleConnected() == false) { csReaderConnector.rfidConnector.mRfidToRead.clear(); } else if (System.currentTimeMillis() - lTime > (intervalRx000UplinkHandler / 2)) { writeDebug2File("Up4 " + String.valueOf(intervalRx000UplinkHandler) + "ms Timeout"); - if (DEBUG) - appendToLogView("mRx000UplinkHandler_TIMEOUT !!! mRfidToRead.size() = " + csReaderConnector.rfidConnector.mRfidToRead.size()); + if (utility.DEBUG_APDATA) + appendToLogView("ApData: TIMEOUT !!! mRfidToRead.size() = " + csReaderConnector.rfidConnector.mRfidToRead.size()); break; } else { if (bFirst) { bFirst = false; - } //writeDebug2File("D" + String.valueOf(intervalRx000UplinkHandler) + ", " + System.currentTimeMillis()); } + } byte[] dataIn = csReaderConnector.rfidConnector.mRfidToRead.get(0).dataValues; long tagMilliSeconds = csReaderConnector.rfidConnector.mRfidToRead.get(0).milliseconds; boolean invalidSequence = csReaderConnector.rfidConnector.mRfidToRead.get(0).invalidSequence; - if (DEBUG) - appendToLog("mRx000UplinkHandler(): invalidSequence = " + invalidSequence + ", Processing data = " + byteArrayToString(dataIn) + ", length=" + dataIn.length + ", mRfidToReading.length=" + mRfidToReading.length + ", startIndex=" + startIndex + ", startIndexNew=" + startIndexNew + ", mRfidToReadingOffset=" + mRfidToReadingOffset); + if (utility.DEBUG_APDATA) + appendToLog("ApData: mRfidToReadingOffset=" + mRfidToReadingOffset + ", mRfidToReading.length=" + mRfidToReading.length + ", dataIn.length=" + dataIn.length + ", dataIn=" + byteArrayToString(dataIn)); csReaderConnector.rfidConnector.mRfidToRead.remove(0); if (dataIn.length >= mRfidToReading.length - mRfidToReadingOffset) { byte[] unhandledBytes = new byte[mRfidToReadingOffset]; System.arraycopy(mRfidToReading, 0, unhandledBytes, 0, unhandledBytes.length); - if (true) - appendToLogView("mRx000UplinkHandler(): ERROR insufficient buffer, mRfidToReadingOffset=" + mRfidToReadingOffset + ", dataIn.length=" + dataIn.length + ", clear mRfidToReading: " + byteArrayToString(unhandledBytes)); + if (utility.DEBUG_APDATA) + appendToLogView("ApData: ERROR insufficient buffer, mRfidToReadingOffset=" + mRfidToReadingOffset + ", dataIn.length=" + dataIn.length + ", clear mRfidToReading: " + byteArrayToString(unhandledBytes)); byte[] mRfidToReadingNew = new byte[RFID_READING_BUFFERSIZE]; mRfidToReading = mRfidToReadingNew; mRfidToReadingOffset = 0; @@ -2954,8 +3023,8 @@ void mRx000UplinkHandler() { if (mRfidToReadingOffset != 0 && invalidSequence) { byte[] unhandledBytes = new byte[mRfidToReadingOffset]; System.arraycopy(mRfidToReading, 0, unhandledBytes, 0, unhandledBytes.length); - if (DEBUG) - appendToLog("mRx000UplinkHandler(): ERROR invalidSequence with nonzero mRfidToReadingOffset=" + mRfidToReadingOffset + ", throw invalid unused data=" + unhandledBytes.length + ", " + byteArrayToString(unhandledBytes)); + if (utility.DEBUG_APDATA) + appendToLog("ApData: ERROR invalidSequence with nonzero mRfidToReadingOffset=" + mRfidToReadingOffset + ", throw invalid unused data=" + unhandledBytes.length + ", " + byteArrayToString(unhandledBytes)); mRfidToReadingOffset = 0; startIndex = 0; startIndexNew = 0; @@ -2963,24 +3032,24 @@ void mRx000UplinkHandler() { } System.arraycopy(dataIn, 0, mRfidToReading, mRfidToReadingOffset, dataIn.length); mRfidToReadingOffset += dataIn.length; - if (true) { + if (utility.DEBUG_APDATA) { byte[] bufferData = new byte[mRfidToReadingOffset]; System.arraycopy(mRfidToReading, 0, bufferData, 0, bufferData.length); - if (DEBUG) - appendToLog("mRx000UplinkHandler(): mRfidToReadingOffset= " + mRfidToReadingOffset + ", mRfidToReading= " + byteArrayToString(bufferData)); + appendToLog("ApData: new mRfidToReadingOffset=" + mRfidToReadingOffset + ", mRfidToReading=" + byteArrayToString(bufferData)); } - if (DEBUG) - appendToLog("mRfidToReadingOffset = " + mRfidToReadingOffset + ", startIndex = " + startIndex); - int iPayloadSizeMin = 8; + int iPayloadSizeMin = 8; boolean bLooping2 = false; while (mRfidToReadingOffset - startIndex >= iPayloadSizeMin) { + if (utility.DEBUG_APDATA && bLooping2 == false) appendToLog("ApData: Entering second loop with mRfidToReadingOffset = " + mRfidToReadingOffset + ", startIndex = " + startIndex); + bLooping2 = true; + { int packageLengthRead = (mRfidToReading[startIndex + 5] & 0xFF) * 256 + (mRfidToReading[startIndex + 4] & 0xFF); int expectedLength = 8 + packageLengthRead * 4; if (mRfidToReading[startIndex + 0] == 0x04) expectedLength = 8 + packageLengthRead; - if (DEBUG) - appendToLog("loop: mRfidToReading.length=" + mRfidToReading.length + ", 1Byte=" + mRfidToReading[startIndex + 0] + ", mRfidToReadingOffset=" + mRfidToReadingOffset + ", startIndex=" + startIndex + ", expectedLength=" + expectedLength); + if (utility.DEBUG_APDATA) + appendToLog("ApData: loop: 1Byte=" + mRfidToReading[startIndex + 0] + ", mRfidToReadingOffset=" + mRfidToReadingOffset + ", expectedLength=" + expectedLength); if (mRfidToReadingOffset - startIndex >= 8) { if (mRfidToReading[startIndex + 0] == (byte) 0x40 && (mRfidToReading[startIndex + 1] == 2 || mRfidToReading[startIndex + 1] == 3 || mRfidToReading[startIndex + 1] == 7)) { //input as Control Command Response @@ -3045,7 +3114,7 @@ void mRx000UplinkHandler() { } } packageFound = true; - packageType = 1; + packageType = 1; //0x40 startIndexNew = startIndex + iPayloadSizeMin; } else if ((mRfidToReading[startIndex + 0] == (byte) 0x00 || mRfidToReading[startIndex + 0] == (byte) 0x70) && mRfidToReading[startIndex + 1] == 0 @@ -3176,6 +3245,7 @@ void mRx000UplinkHandler() { if (DEBUG) appendToLog("found inventory select configuration: " + byteArrayToString(dataInPayload) + ", but invalid index=" + dataIndex); } else { + appendToLog("BtDataOut 123A"); rx000Setting.invSelectData[dataIndex].selectEnable = (dataIn[startIndex + 4] & 0x01); rx000Setting.invSelectData[dataIndex].selectTarget = ((dataIn[startIndex + 4] & 0x0E) >> 1); rx000Setting.invSelectData[dataIndex].selectAction = ((dataIn[startIndex + 4] & 0x70) >> 4); @@ -3264,8 +3334,7 @@ void mRx000UplinkHandler() { rx000Setting.queryTarget = (dataIn[startIndex + 4] >> 4) & 0x01; rx000Setting.querySession = (dataIn[startIndex + 4] >> 5) & 0x03; rx000Setting.querySelect = (dataIn[startIndex + 4] >> 7) & 0x01 + ((dataIn[startIndex + 5] & 0x01) * 2); - if (DEBUG) - appendToLog("found query configuration: " + byteArrayToString(dataInPayload) + ", target=" + rx000Setting.queryTarget + ", session=" + rx000Setting.querySession + ", select=" + rx000Setting.querySelect); + //appendToLog("BtDataOut: found query configuration: " + byteArrayToString(dataInPayload) + ", target=" + rx000Setting.queryTarget + ", session=" + rx000Setting.querySession + ", select=" + rx000Setting.querySelect); break; case 0x0901: rx000Setting.invAlgo = dataIn[startIndex + 4] & 0x3F; @@ -3300,8 +3369,8 @@ void mRx000UplinkHandler() { rx000Setting.algoSelectedData[dataIndex].algoMaxRep = ((dataIn[startIndex + 5] & 0xF0) >> 4) + ((dataIn[startIndex + 6] & 0x0F) << 4); rx000Setting.algoSelectedData[dataIndex].algoHighThres = ((dataIn[startIndex + 6] & 0xF0) >> 4); rx000Setting.algoSelectedData[dataIndex].algoLowThres = (dataIn[startIndex + 7] & 0x0F); - if (DEBUG) - appendToLog("found inventory algo parameter 0: " + byteArrayToString(dataInPayload) + if (DEBUG || true) + appendToLog("BtDataOut: found inventory algo parameter 0: " + byteArrayToString(dataInPayload) + ", algoStartQ=" + rx000Setting.algoSelectedData[dataIndex].algoStartQ + ", algoMaxQ=" + rx000Setting.algoSelectedData[dataIndex].algoMaxQ + ", algoMinQ=" + rx000Setting.algoSelectedData[dataIndex].algoMinQ @@ -3510,7 +3579,7 @@ void mRx000UplinkHandler() { } } packageFound = true; - packageType = 2; + packageType = 2; //0x00, 0x70 startIndexNew = startIndex + 8; } else if ((mRfidToReading[startIndex + 0] >= 1 && mRfidToReading[startIndex + 0] <= 4) //02 for begin and end, 03 for inventory, 01 for access && (expectedLength >= 0 && expectedLength < mRfidToReading.length) @@ -3708,15 +3777,25 @@ void mRx000UplinkHandler() { dataA.decodedData2 = new byte[data2_count]; System.arraycopy(dataA.dataValues, dataA.dataValues.length - 2 - data2_count, dataA.decodedData2, 0, dataA.decodedData2.length); } + int iData12 = 0; + if (dataA.decodedData1 != null) iData12 += dataA.decodedData1.length; + if (dataA.decodedData2 != null) iData12 += dataA.decodedData2.length; + if (iData12 != 0) { + byte[] newEpc = new byte[dataA.decodedEpc.length - iData12]; + System.arraycopy(dataA.decodedEpc, 0, newEpc, 0, newEpc.length); + dataA.decodedEpc = newEpc; + } rfidDataReadTypes = RfidDataReadTypes.RFID_DATA_READ_COMMAND_INVENTORY; - if (DEBUG) - appendToLog("dataValues = " + byteArrayToString(dataA.dataValues) + ", 1 decodedRssi = " + dataA.decodedRssi + ", decodedPhase = " + dataA.decodedPhase + ", decodedChidx = " + dataA.decodedChidx + ", decodedPort = " + dataA.decodedPort + ", decodedPc = " + byteArrayToString(dataA.decodedPc) - + ", decodedCrc = " + byteArrayToString(dataA.decodedCrc) + ", decodedEpc = " + byteArrayToString(dataA.decodedEpc) + ", decodedData1 = " + byteArrayToString(dataA.decodedData1) + ", decodedData2 = " + byteArrayToString(dataA.decodedData2)); } } } int oldSize2 = mRx000ToRead.size(); mRx000ToRead.add(dataA); + if (utility.DEBUG_APDATA) { + appendToLog("ApData: dataValues = " + byteArrayToString(dataA.dataValues) + ", 1 decodedRssi = " + dataA.decodedRssi + ", decodedPhase = " + dataA.decodedPhase + ", decodedChidx = " + dataA.decodedChidx + ", decodedPort = " + dataA.decodedPort); + appendToLog("ApData: decodedPc/Epc/Crc = " + byteArrayToString(dataA.decodedPc) + ", " + byteArrayToString(dataA.decodedEpc) + ", " + byteArrayToString(dataA.decodedCrc) + + ", decodedData1/2 = " + byteArrayToString(dataA.decodedData1) + ", " + byteArrayToString(dataA.decodedData2)); + } if (DEBUG) appendToLog("oldSize = " + oldSize2 + ", after adding 8005 mRx000ToRead.size = " + mRx000ToRead.size()); } else { @@ -3750,6 +3829,7 @@ void mRx000UplinkHandler() { appendToLog((dataA.dataValues != null ? "mRfidToRead.size() = " + csReaderConnector.rfidConnector.mRfidToRead.size() + ", dataValues = " + byteArrayToString(dataA.dataValues) + ", " : "") + "2 decodedRssi = " + dataA.decodedRssi + ", decodedPc = " + byteArrayToString(dataA.decodedPc) + ", decodedEpc = " + byteArrayToString(dataA.decodedEpc)); if (dataValuesFull.length > index) { mRx000ToRead.add(dataA); + if (utility.DEBUG_APDATA) appendToLog("ApData: Got data to mRx000ToRead " + mRx000ToRead.size() + ", with decodedEpc = " + byteArrayToString(dataA.decodedEpc)); int iDecodedPortOld = dataA.decodedPort; dataA = new RfidReaderChipData.Rx000pkgData(); @@ -3762,6 +3842,7 @@ void mRx000UplinkHandler() { } int oldSize3 = mRx000ToRead.size(); mRx000ToRead.add(dataA); + if (utility.DEBUG_APDATA) appendToLog("ApData: Got data to mRx000ToRead " + mRx000ToRead.size() + ", with decodedEpc = " + byteArrayToString(dataA.decodedEpc)); if (DEBUG) appendToLog("oldSize = " + oldSize3 + ", after adding 8005 mRx000ToRead.size = " + mRx000ToRead.size()); } @@ -3951,6 +4032,11 @@ else if ((dataA.dataValues[12] == (byte) 0xC2) || (dataA.dataValues[12] == (byte case 0x08: case 0x09: case 0x0A: + if (true) { + byte[] bytes = new byte[4]; + System.arraycopy(dataIn, startIndex + 12, bytes, 0, 4); + appendToLog("product serial number, " + address + ": " + byteArrayToString(bytes)); + } System.arraycopy(dataIn, startIndex + 12, rx000OemSetting.productserialNumber, 4 * (address - 8), 4); break; case 0x0B: //VERSIONCODE_MAX @@ -4016,7 +4102,7 @@ else if ((dataA.dataValues[12] == (byte) 0xC2) || (dataA.dataValues[12] == (byte break; } packageFound = true; - packageType = 3; + packageType = 3; //0x01 to 0x04 startIndexNew = startIndex + expectedLength; } } @@ -4025,13 +4111,13 @@ else if ((dataA.dataValues[12] == (byte) 0xC2) || (dataA.dataValues[12] == (byte if (packageFound) { packageFound = false; - if (DEBUG) - appendToLog("mRx000UplinkHandler(): packageFound " + packageType + " with mRfidToReadingOffset=" + mRfidToReadingOffset + ", startIndexOld= " + startIndexOld + ", startIndex= " + startIndex + ", startIndexNew=" + startIndexNew); + if (false && utility.DEBUG_APDATA) + appendToLog("ApData: found packageType " + packageType + " with mRfidToReadingOffset=" + mRfidToReadingOffset + ", startIndexOld= " + startIndexOld + ", startIndex= " + startIndex + ", startIndexNew=" + startIndexNew); if (startIndex != startIndexOld) { byte[] unhandledBytes = new byte[startIndex - startIndexOld]; System.arraycopy(mRfidToReading, startIndexOld, unhandledBytes, 0, unhandledBytes.length); - if (DEBUG) - appendToLog("mRx000UplinkHandler(): packageFound with invalid unused data: " + unhandledBytes.length + ", " + byteArrayToString(unhandledBytes)); + if (utility.DEBUG_APDATA) + appendToLog("ApData: packageFound with invalid unused data: " + unhandledBytes.length + ", " + byteArrayToString(unhandledBytes)); invalidUpdata++; writeDebug2File("Up4 invalid " + unhandledBytes.length + ", " + byteArrayToString(unhandledBytes)); } else if (startIndexNew != startIndex) { @@ -4044,12 +4130,13 @@ else if ((dataA.dataValues[12] == (byte) 0xC2) || (dataA.dataValues[12] == (byte string += (byteArrayToString(data1).substring(0, 8) + " " + byteArrayToString(data1).substring(8, 16) + " " + (byteArrayToString(data1).substring(16))); } utility.writeDebug2File(string); - } - if (false) { - byte[] usedBytes = new byte[startIndexNew - startIndex]; - System.arraycopy(mRfidToReading, startIndex, usedBytes, 0, usedBytes.length); - if (DEBUG) - appendToLog("mRx000UplinkHandler(): used data = " + usedBytes.length + ", " + byteArrayToString(usedBytes)); + if (utility.DEBUG_APDATA) appendToLog("ApData: Found startIndexNew=" + startIndexNew + ", string=" + string); + if (false && utility.DEBUG_APDATA) { + byte[] usedBytes = new byte[startIndexNew - startIndex]; + System.arraycopy(mRfidToReading, startIndex, usedBytes, 0, usedBytes.length); + appendToLog("ApData: used data = " + usedBytes.length + ", " + byteArrayToString(usedBytes)); + } + } byte[] mRfidToReadingNew = new byte[RFID_READING_BUFFERSIZE]; System.arraycopy(mRfidToReading, startIndexNew, mRfidToReadingNew, 0, mRfidToReadingOffset - startIndexNew); @@ -4061,18 +4148,21 @@ else if ((dataA.dataValues[12] == (byte) 0xC2) || (dataA.dataValues[12] == (byte if (mRfidToReadingOffset != 0) { byte[] remainedBytes = new byte[mRfidToReadingOffset]; System.arraycopy(mRfidToReading, 0, remainedBytes, 0, remainedBytes.length); - if (DEBUG) - appendToLog("mRx000UplinkHandler(): moved with remained bytes=" + byteArrayToString(remainedBytes)); + if (utility.DEBUG_APDATA) + appendToLog("ApData: moved with remained bytes=" + byteArrayToString(remainedBytes)); } - //} } else { startIndex++; } } - if (startIndex != 0 && mRfidToReadingOffset != 0) if (DEBUG) - appendToLog("mRx000UplinkHandler(): exit while(-8) loop with startIndex = " + startIndex + (startIndex == 0 ? "" : "(NON-ZERO)") + ", mRfidToReadingOffset=" + mRfidToReadingOffset); + if (utility.DEBUG_APDATA && bLooping2) appendToLog("ApData: Exiting second loop with mRfidToReadingOffset = " + mRfidToReadingOffset + ", startIndex = " + startIndex); + if (startIndex != 0 && mRfidToReadingOffset != 0) { + if (utility.DEBUG_APDATA) + appendToLog("ApData: exit while(-8) loop with startIndex = " + startIndex + (startIndex == 0 ? "" : "(NON-ZERO)") + ", mRfidToReadingOffset=" + mRfidToReadingOffset); + } } } + if (utility.DEBUG_APDATA && bLooping) appendToLog("ApData: Exiting loop with mRfidToRead.size as " + csReaderConnector.rfidConnector.mRfidToRead.size()); if (mRfidToReadingOffset == startIndexNew && mRfidToReadingOffset != 0) { byte[] unusedData = new byte[mRfidToReadingOffset]; System.arraycopy(mRfidToReading, 0, unusedData, 0, unusedData.length); @@ -4234,8 +4324,7 @@ boolean sendHostRegRequestHST_RFTC_FRQCH_DESC_PLLDIVMULT(int freqChannel) { public boolean setPwrManagementMode(boolean bLowPowerStandby) { if (false) appendToLog("pwrMgmtStatus: setPwrManagementMode(" + bLowPowerStandby + ")"); - if (bLowPowerStandby == false) - return true; //for testing if setPwrManagementMode(false) is needed + if (true) return false; //ignore this setting if (this.bLowPowerStandby == bLowPowerStandby) return true; boolean result = rx000Setting.writeMAC(0x200, (bLowPowerStandby ? 1 : 0)); if (result) { @@ -4506,6 +4595,27 @@ void addRfidToWrite(RfidConnector.CsReaderRfidData csReaderRfidData) { if (repeatRequest == false) { if (false) appendToLog("add cs108RfidData to mRfidToWrite with rfidPayloadEvent = " + csReaderRfidData.rfidPayloadEvent); + //appendToLog("BtDataOut: addRfidToWrite csReaderRfidData " + byteArrayToString(csReaderRfidData.dataValues)); + byte[] bytesCmd = new byte[] { 0x70, 1, 0, 0x09 }; + byte[] bytesCmd1 = new byte[] { 0x70, 1, 1, 0x09 }; + if (csReaderRfidData.dataValues != null) { + byte[] bytesNew = new byte[4]; + System.arraycopy(csReaderRfidData.dataValues, 0, bytesNew, 0, bytesNew.length); + if (Arrays.equals(bytesCmd, bytesNew) || Arrays.equals(bytesCmd1, bytesNew)) { + int i = 0; + for (; i < csReaderConnector.rfidConnector.mRfidToWrite.size(); i++) { + if (csReaderConnector.rfidConnector.mRfidToWrite.get(i).dataValues != null) { + byte[] bytesOld = new byte[4]; + System.arraycopy(csReaderConnector.rfidConnector.mRfidToWrite.get(i).dataValues, 0, bytesOld, 0, bytesOld.length); + if (Arrays.equals(bytesNew, bytesOld)) { + //appendToLog("BtDataOut: matched data " + byteArrayToString(csReaderRfidData.dataValues)); + csReaderConnector.rfidConnector.mRfidToWrite.remove(i); + break; + } + } + } + } + } csReaderConnector.rfidConnector.mRfidToWrite.add(csReaderRfidData); } } @@ -4513,5 +4623,5 @@ void addRfidToWrite(RfidConnector.CsReaderRfidData csReaderRfidData) { boolean inventoring = false; public boolean isInventoring() { return inventoring; } - void setInventoring(boolean enable) { inventoring = enable; utility.debugFileEnable(false); if (true) appendToLog("setInventoring R2000 is set as " + inventoring);} + void setInventoring(boolean enable) { inventoring = enable; utility.debugFileEnable(false); if (false) appendToLog("setInventoring R2000 is set as " + inventoring);} } \ No newline at end of file diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/SettingData.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/SettingData.java index 9e6943d..2835c79 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/SettingData.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/SettingData.java @@ -27,7 +27,7 @@ public SettingData(Context context, Utility utility, BluetoothGatt bluetoothGatt + "\nthis.utility is " + (this.utility == null ? "null" : "valid") + "\nthis.context is " + (this.context == null ? "null" : "valid") ); - loadSettingFile0(); + loadForegroundSettingFile(); } public void setConnectedConnectors(NotificationConnector notificationConnector, RfidReader rfidReader) { this.notificationConnector = notificationConnector; @@ -67,7 +67,6 @@ private void appendToLog(String s) { // return true; //} - public int batteryDisplaySelectDefault = 1, batteryDisplaySelect = batteryDisplaySelectDefault; public int rssiDisplaySelectDefault = 1, rssiDisplaySelect = rssiDisplaySelectDefault; public boolean triggerReportingDefault = true, triggerReporting = triggerReportingDefault; @@ -128,7 +127,7 @@ public PreFilterData(boolean enable, int target, int action, int bank, int offse File file0; public String strForegroundReaderDefault = "", strForegroundReader = strForegroundReaderDefault; - boolean loadSettingFile0() { + boolean loadForegroundSettingFile() { File path = context.getFilesDir(); String fileName = "csReaderA_Foreground"; file0 = new File(path, fileName); @@ -161,7 +160,7 @@ boolean loadSettingFile0() { } return true; } - public void saveSetting2File0() { + public void saveForegroundSetting2File() { boolean DEBUG = true; if (DEBUG) appendToLog("Start"); @@ -264,7 +263,7 @@ void saveWedgeSetting2File() { } } - boolean loadSetting1File(String strlibraryVersion, boolean bChannelHoppingStatus, int iCurrentProfile) { + boolean loadSettingFile(String strlibraryVersion, boolean bChannelHoppingStatus, int iCurrentProfile) { File path = context.getFilesDir(); String fileName = bluetoothGatt.getmBluetoothDevice().getAddress(); @@ -449,10 +448,11 @@ boolean loadSetting1File(String strlibraryVersion, boolean bChannelHoppingStatus csReaderConnector.rfidReader.setTagGroup(querySelect, querySession, queryTarget); csReaderConnector.rfidReader.setTagFocus(csReaderConnector.rfidReader.tagFocus > 0 ? true : false); if (csReaderConnector.settingData.preFilterData != null && csReaderConnector.settingData.preFilterData.enable) { - appendToLog("preFilterData is valid. Going to setSelectCriteria"); + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: SettingData.loadingSettingFile. preFilterData is valid. Going to setSelectCriteria"); + appendToLog("BtDataOut BBB 5"); csReaderConnector.rfidReader.setSelectCriteria(0, csReaderConnector.settingData.preFilterData.enable, csReaderConnector.settingData.preFilterData.target, csReaderConnector.settingData.preFilterData.action, csReaderConnector.settingData.preFilterData.bank, csReaderConnector.settingData.preFilterData.offset, csReaderConnector.settingData.preFilterData.mask, csReaderConnector.settingData.preFilterData.maskbit); } else { - appendToLog("preFilterData is null or disabled. Going to setSelectCriteriaDisable"); + if (utility.DEBUG_SELECT) appendToLog("Debug_Select: SettingData.loadingSettingFile. preFilterData is null or disabled. Going to setSelectCriteriaDisable"); csReaderConnector.rfidReader.setSelectCriteriaDisable(0); } } @@ -471,7 +471,6 @@ boolean loadSetting1File(String strlibraryVersion, boolean bChannelHoppingStatus } return bNeedDefault; } - public void saveSetting2File(String strLibraryVersion, boolean bChannelHoppingStatus, int iCurrentProfile) { boolean DEBUG = true; if (DEBUG) appendToLog("Start"); @@ -549,6 +548,6 @@ public void saveSetting2File(String strLibraryVersion, boolean bChannelHoppingSt } catch (Exception ex){ // } - csReaderConnector.settingData.saveSetting2File0(); + csReaderConnector.settingData.saveForegroundSetting2File(); } } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/Utility.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Utility.java index 56bd59a..abff9df 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/Utility.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Utility.java @@ -26,8 +26,13 @@ import java.util.Locale; public class Utility { + public final boolean DEBUG_SELECT = false; + public final boolean DEBUG_INVCFG = false; + public final boolean DEBUG_BTDATA = false; + public final boolean DEBUG_FMDATA = false; public final boolean DEBUG_PKDATA = false; public final boolean DEBUG_APDATA = false; + public final boolean DEBUG_COMPACT = false; private Context mContext; private TextView mLogView; public Utility(Context context, TextView mLogView) { mContext = context;