diff --git a/app/src/main/java/com/csl/cs108ademoapp/AccessTask.java b/app/src/main/java/com/csl/cs108ademoapp/AccessTask.java index 54d8bf9..b668ef1 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/AccessTask.java +++ b/app/src/main/java/com/csl/cs108ademoapp/AccessTask.java @@ -6,6 +6,7 @@ import android.widget.TextView; import android.widget.Toast; +import com.csl.cslibrary4a.Logger; import com.csl.cslibrary4a.RfidReaderChipData; import java.util.ArrayList; @@ -57,7 +58,7 @@ public AccessTask(Button button, boolean invalidRequest, boolean selectOne, this.registerTagGot = registerTagGot; this.registerVoltageLevel = registerVoltageLevel; - this.invalidRequest = invalidRequest; MainActivity.csLibrary4A.appendToLog("invalidRequest = " + invalidRequest); + this.invalidRequest = invalidRequest; this.selectOne = selectOne; this.selectMask = selectMask; this.selectBank = selectBank; @@ -86,7 +87,7 @@ public AccessTask(Button button, TextView textViewWriteCount, boolean invalidReq this.registerYield = registerYieldView; this.registerTotal = registerTotalView; - this.invalidRequest = invalidRequest; MainActivity.csLibrary4A.appendToLog("invalidRequest = " + invalidRequest); + this.invalidRequest = invalidRequest; this.selectOne = selectOne; this.selectMask = selectMask; this.selectBank = selectBank; @@ -110,7 +111,8 @@ public void setRunnable(Runnable updateRunnable) { } void preExecute() { - accessResult = null; MainActivity.csLibrary4A.appendToLog("accessResult is set null"); + accessResult = null; + Logger.trace("accessResult is set null"); playerO = MainActivity.sharedObjects.playerO; playerN = MainActivity.sharedObjects.playerN; //playerN.start(); @@ -138,35 +140,40 @@ void preExecute() { accessError = 0; backscatterError = 0; timeoutError = false; crcError = false; success = false; - if (invalidRequest == false) { - if (strPassword.length() != 8) { invalidRequest = true; MainActivity.csLibrary4A.appendToLog("strPassword.length = " + strPassword.length() + " (not 8)."); } - else if (hostCommand == RfidReaderChipData.HostCommands.CMD_18K6CKILL) { - if (MainActivity.csLibrary4A.setRx000KillPassword(strPassword) == false) { - invalidRequest = true; MainActivity.csLibrary4A.appendToLog("setRx000KillPassword is failed"); + if (!invalidRequest) { + if (strPassword.length() != 8) { + invalidRequest = true; + Logger.trace("strPassword.length = {} (not 8).", strPassword.length()); + } else if (hostCommand == RfidReaderChipData.HostCommands.CMD_18K6CKILL) { + if (!MainActivity.csLibrary4A.setRx000KillPassword(strPassword)) { + invalidRequest = true; + Logger.trace("setRx000KillPassword is failed"); } - } else if (MainActivity.csLibrary4A.setRx000AccessPassword(strPassword) == false) { + } else if (!MainActivity.csLibrary4A.setRx000AccessPassword(strPassword)) { invalidRequest = true; - MainActivity.csLibrary4A.appendToLog("setRx000AccessPassword is failed"); + Logger.trace("setRx000AccessPassword is failed"); } } - if (invalidRequest == false) { - if (MainActivity.csLibrary4A.setAccessRetry(true, 7) == false) { - invalidRequest = true; MainActivity.csLibrary4A.appendToLog("setAccessRetry is failed"); + if (!invalidRequest) { + if (!MainActivity.csLibrary4A.setAccessRetry(true, 7)) { + invalidRequest = true; + Logger.trace("setAccessRetry is failed"); } } - if (invalidRequest == false) { - if (DEBUG) MainActivity.csLibrary4A.appendToLog("AccessTask(): powerLevel = " + powerLevel); + if (!invalidRequest) { + Logger.debug("AccessTask(): powerLevel = {}", powerLevel); int matchRep = 1; if (repeat > 1) matchRep = repeat; if (false && bSkipClearFilter == false) { - MainActivity.csLibrary4A.appendToLog("Going to setSelectCriteria disable"); + Logger.info("Going to setSelectCriteria disable"); MainActivity.csLibrary4A.setSelectCriteriaDisable(-1); } if (powerLevel < 0 || powerLevel > 330) invalidRequest = true; else if (skipSelect == false) { - MainActivity.csLibrary4A.appendToLog("AccessTask.preExecute goes to setSelectTag"); + Logger.info("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); + invalidRequest = true; + Logger.info("setSelectedTag is failed with selectMask = {}, selectBank = {}, selectOffset = {}, powerLevel = {}", selectMask, selectBank, selectOffset, powerLevel); } } } @@ -175,7 +182,7 @@ else if (skipSelect == false) { if (invalidRequest) { cancel(true); taskCancelReason = TaskCancelRReason.INVALD_REQUEST; - MainActivity.csLibrary4A.appendToLog("invalidRequest A= " + invalidRequest); + Logger.trace("invalidRequest A= {}", invalidRequest); } else { if (MainActivity.csLibrary4A.checkHostProcessorVersion(MainActivity.csLibrary4A.getMacVer(), 2, 6, 8)) { MainActivity.csLibrary4A.setInvModeCompact(false); @@ -211,11 +218,11 @@ else if (rx000pkgData != null) { publishProgress("null response"); } else if (rx000pkgData.responseType == RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_TAG_ACCESS) { accessCompleteReceived = true; - MainActivity.csLibrary4A.appendToLog("rx000pkgData.dataValues = " + MainActivity.csLibrary4A.byteArrayToString(rx000pkgData.dataValues)); + Logger.trace("rx000pkgData.dataValues = {}", MainActivity.csLibrary4A.byteArrayToString(rx000pkgData.dataValues)); if (rx000pkgData.decodedError == null) { if (done == false) { accessResult = rx000pkgData.decodedResult; - MainActivity.csLibrary4A.appendToLog("responseType = " + rx000pkgData.responseType.toString() + ", accessResult = " + accessResult); + Logger.trace("responseType = {}, accessResult = {}", rx000pkgData.responseType, accessResult); if (repeat > 0) repeat--; if (updateRunnable != null) mHandler.post(updateRunnable); publishProgress(null, rx000pkgData.decodedResult); @@ -225,11 +232,11 @@ else if (rx000pkgData != null) { iTimeOut = 1000; } else if (rx000pkgData.responseType == RfidReaderChipData.HostCmdResponseTypes.TYPE_COMMAND_END) { if (hostCommand == RfidReaderChipData.HostCommands.CMD_18K6CKILL && accessCompleteReceived == false) accessResult = ""; - MainActivity.csLibrary4A.appendToLog("BtData: repeat = " + repeat + ", decodedError = " + rx000pkgData.decodedError + ", resultError = " + resultError); + Logger.btdData("BtData: repeat = {}, decodedError = {}, resultError = {}", repeat, rx000pkgData.decodedError, resultError); 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); + Logger.invCfg("Debug_InvCfg: AccessTask.doInBackground goes to setMatchRep with repeat = {}", repeat); MainActivity.csLibrary4A.setMatchRep(repeat); MainActivity.csLibrary4A.sendHostRegRequestHST_CMD(hostCommand); } else { @@ -268,7 +275,7 @@ else if (notificationData != null) { @Override protected void onProgressUpdate(String... output) { if (output[0] != null) { - MainActivity.csLibrary4A.appendToLog("onProgressUpdate output[0] = " + output[0]); + Logger.trace("onProgressUpdate output[0] = {}", output[0]); if (output[0].length() == 2) { if (output[0].contains("TT")) { gotInventory = true; @@ -291,11 +298,10 @@ protected void onProgressUpdate(String... output) { } } else { resultError += output[0]; - if (true) - MainActivity.csLibrary4A.appendToLog("output[0]: " + output[0] + ", resultError = " + resultError); + Logger.trace("output[0]: {}, resultError = {}", output[0], resultError); } } else { - MainActivity.csLibrary4A.appendToLog("onProgressUpdate output[1] = " + output[1]); + Logger.trace("onProgressUpdate output[1] = {}", output[1]); if (registerYield != null) { if (tagInventoried != null) { tagList.add(tagInventoried); @@ -310,7 +316,7 @@ protected void onProgressUpdate(String... output) { @Override protected void onCancelled() { super.onCancelled(); - if (DEBUG) MainActivity.csLibrary4A.appendToLog("endingMesssage: taskCancelReason = " + taskCancelReason); + Logger.debug("endingMesssage: taskCancelReason = {}", taskCancelReason); MainActivity.csLibrary4A.abortOperation(); if (taskCancelReason == TaskCancelRReason.NULL) taskCancelReason = TaskCancelRReason.DESTORY; DeviceConnectTask4RegisterEnding(); @@ -318,7 +324,7 @@ protected void onCancelled() { @Override protected void onPostExecute(String result) { - if (DEBUG) MainActivity.csLibrary4A.appendToLog("AccessSecurityLockFragment.InventoryRfidTask.onPostExecute(): " + result); + Logger.debug("AccessSecurityLockFragment.InventoryRfidTask.onPostExecute(): {}", result); DeviceConnectTask4RegisterEnding(); } @@ -327,22 +333,24 @@ void DeviceConnectTask4RegisterEnding() { String strErrorMessage = ""; if (false) { boolean success = false; - MainActivity.csLibrary4A.appendToLog("repeat = " + repeat + ", taskCancelReason = " + taskCancelReason.toString() - + ", backscatterError = " + backscatterError + ", accessError =" + accessError + ", accessResult = " + accessResult + ", resultError = " + resultError); + Logger.trace("repeat = {}, taskCancelReason = {}, backscatterError = {}, accessError = {}, accessResult = {}, resultError = {}", + repeat, taskCancelReason, backscatterError, accessError, accessResult, resultError); if ((repeat <= 1 && taskCancelReason != TaskCancelRReason.NULL) || backscatterError != 0 || accessError != 0 || accessResult == null || resultError.length() != 0) { - MainActivity.csLibrary4A.appendToLog("FAILURE"); Toast.makeText(MainActivity.mContext, R.string.toast_abort_by_FAILURE, Toast.LENGTH_SHORT).show(); + Logger.info("FAILURE"); + Toast.makeText(MainActivity.mContext, R.string.toast_abort_by_FAILURE, Toast.LENGTH_SHORT).show(); playerO.start(); } else { - MainActivity.csLibrary4A.appendToLog("SUCCESS"); Toast.makeText(MainActivity.mContext, R.string.toast_abort_by_SUCCESS, Toast.LENGTH_SHORT).show(); + Logger.info("SUCCESS"); + Toast.makeText(MainActivity.mContext, R.string.toast_abort_by_SUCCESS, Toast.LENGTH_SHORT).show(); playerN.start(); } } else { strErrorMessage = ""; switch (taskCancelReason) { case NULL: - if (accessResult == null) MainActivity.csLibrary4A.appendToLog("taskCancelReason: NULL accessResult"); - if (resultError != null) MainActivity.csLibrary4A.appendToLog("taskCancelReason: resultError = " + resultError); - if (endingMessaage != null) MainActivity.csLibrary4A.appendToLog("taskCancelReason: endingMessaage = " + endingMessaage); + if (accessResult == null) Logger.info("taskCancelReason: NULL accessResult"); + if (resultError != null) Logger.info("taskCancelReason: resultError = {}", resultError); + if (endingMessaage != null) Logger.info("taskCancelReason: endingMessaage = {}", endingMessaage); if (accessResult == null || (resultError != null && resultError.length() != 0) || (endingMessaage != null && endingMessaage.length() != 0)) strErrorMessage += ("Finish as COMMAND END is received " + (gotInventory ? "WITH" : "WITHOUT") + " tag response"); //else Toast.makeText(MainActivity.mContext, R.string.toast_abort_by_SUCCESS, Toast.LENGTH_SHORT).show(); break; @@ -362,7 +370,8 @@ void DeviceConnectTask4RegisterEnding() { strErrorMessage += "Invalid request. Operation is cancelled. "; break; } - MainActivity.csLibrary4A.appendToLog("taskCancelReason = " + taskCancelReason.toString() + ", accessResult = " + (accessResult == null ? "NULL": accessResult) + ", endingMessaage = " + (endingMessaage == null ? "NULL" : endingMessaage) + ", resultError = " + (resultError == null ? "NULL" : resultError)); + Logger.trace("taskCancelReason = {}, accesResult = {}, endingMessaage = {}, resultError = {}", + taskCancelReason, accessResult == null ? "NULL": accessResult, endingMessaage == null ? "NULL" : endingMessaage, resultError == null ? "NULL" : resultError); if (resultError.length() != 0) { if (strErrorMessage.trim().length() == 0) strErrorMessage = resultError; else strErrorMessage += (". " + resultError); @@ -374,7 +383,7 @@ void DeviceConnectTask4RegisterEnding() { button.setText(buttonText); if (endingMessaage != null) { if (endingMessaage.length() != 0) { - MainActivity.csLibrary4A.appendToLog("endingMessage=" + endingMessaage); + Logger.trace("endingMessage={}", endingMessaage); if (bEnableErrorPopWindow) { CustomPopupWindow customPopupWindow = new CustomPopupWindow(MainActivity.mContext); customPopupWindow.popupStart(endingMessaage, false); diff --git a/app/src/main/java/com/csl/cs108ademoapp/AccessTask1.java b/app/src/main/java/com/csl/cs108ademoapp/AccessTask1.java index 91bb7f8..954ca1e 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/AccessTask1.java +++ b/app/src/main/java/com/csl/cs108ademoapp/AccessTask1.java @@ -4,6 +4,7 @@ import android.widget.Button; import android.widget.Toast; +import com.csl.cslibrary4a.Logger; import com.csl.cslibrary4a.RfidReaderChipData; public class AccessTask1 { @@ -24,7 +25,7 @@ public AccessTask1(Button button, boolean invalidRequest, String strPassword, int powerLevel, RfidReaderChipData.HostCommands hostCommand, Runnable updateRunnable) { this.button = button; this.invalidRequest = invalidRequest; - MainActivity.csLibrary4A.appendToLog("HelloK: invalidRequest=" + invalidRequest); + Logger.trace("HelloK: invalidRequest={}", invalidRequest); this.accBank = accBank; this.accOffset = accOffset; if (hostCommand == RfidReaderChipData.HostCommands.CMD_18K6CWRITE) { if (accBlockCount > 16) accBlockCount = 16; } @@ -32,7 +33,7 @@ public AccessTask1(Button button, boolean invalidRequest, this.accBlockCount = accBlockCount; if (accWriteData == null) accWriteData = ""; if (hostCommand == RfidReaderChipData.HostCommands.CMD_18K6CWRITE) { - MainActivity.csLibrary4A.appendToLog("strOut: accWriteData=" + accWriteData); + Logger.trace("strOut: accWriteData={}", accWriteData); accWriteData = deformatWriteAccessData(accWriteData); if (accWriteData.length() < accSize * 4) { accSize = accWriteData.length()/4; @@ -52,7 +53,7 @@ public AccessTask1(Button button, boolean invalidRequest, this.powerLevel = powerLevel; this.hostCommand = hostCommand; this.updateRunnable = updateRunnable; - MainActivity.csLibrary4A.appendToLog("HelloA, AccessTask1"); + Logger.trace("HelloA, AccessTask1"); CustomMediaPlayer playerN = MainActivity.sharedObjects.playerN; playerN.start(); setup(); @@ -73,18 +74,18 @@ public AsyncTask.Status getStatus() { } public String deformatWriteAccessData(String strIn) { - MainActivity.csLibrary4A.appendToLog("strOut: strIn=" + strIn); + Logger.trace("strOut: strIn={}", strIn); String strOut = strIn.replaceAll("\\P{Print}", ""); - MainActivity.csLibrary4A.appendToLog("strOut=" + strOut); + Logger.trace("strOut={}", strOut); while (strOut.indexOf(":") > 0) { int index = strOut.indexOf(":"); String writeDataTemp = ""; if (index > 4) writeDataTemp = strOut.substring(0, index - 3); writeDataTemp += strOut.substring(index + 1); strOut = writeDataTemp; - MainActivity.csLibrary4A.appendToLog("strOut=" + strOut); + Logger.trace("strOut={}", strOut); } - MainActivity.csLibrary4A.appendToLog("strOut=" + strOut); + Logger.trace("strOut={}", strOut); return strOut; } @@ -112,13 +113,13 @@ else if (isResultReady == false) { strAccessResult += accessTask.accessResult.substring(i * 4, (i + word4line) * 4); } strAccessResult += "\n"; - MainActivity.csLibrary4A.appendToLog("i=" + i + ", formatted accessTask.accessResult=" + strAccessResult); + Logger.trace("i={}, formatted accessTask.accessResult={}", i, strAccessResult); } } if (accessResult == null) accessResult = strAccessResult; else accessResult += strAccessResult; - MainActivity.csLibrary4A.appendToLog("HelloA: accessResult=" + accessTask.accessResult); + Logger.trace("HelloA: accessResult={}", accessTask.accessResult); if (accessTask.accessResult != null && accSizeNow >= accSize) { bValue = true; Toast.makeText(MainActivity.mContext, R.string.toast_abort_by_SUCCESS, Toast.LENGTH_SHORT).show(); @@ -130,31 +131,30 @@ else if (isResultReady == false) { if (accWriteData != null) { if (accWriteData.length() >= accSizeNow*4) accWriteData = accWriteData.substring(accSizeNow*4); } tryCount = 0; } - MainActivity.csLibrary4A.appendToLog("HelloA: Going to retry with TryCount=" + tryCount + ", resultError = " + accessTask.resultError); + Logger.trace("HelloA: Going to retry with TryCount={}, resultError = {}", tryCount, accessTask.resultError); if (tryCount < tryCountMax) { - MainActivity.csLibrary4A.appendToLog("HelloA: re-setup"); + Logger.trace("HelloA: re-setup"); setup(); execute(); } else bValue = true; } } else bValue = true; - //MainActivity.csLibrary4A.appendToLog("HelloA: bValue=" + bValue); isResultReady = bValue; return bValue; } public String accessResult; public String getResult() { - MainActivity.csLibrary4A.appendToLog("HelloA: accessResult = " + accessResult); + Logger.trace("HelloA: accessResult = {}", accessResult); if (accessTask == null) { - MainActivity.csLibrary4A.appendToLog("accessTask is null"); + Logger.trace("accessTask is null"); return null; } if (accessTask.getStatus() != AsyncTask.Status.FINISHED) { - MainActivity.csLibrary4A.appendToLog("accessTask.getStatus is not finished"); + Logger.trace("accessTask.getStatus is not finished"); return null; } if (button.getText().toString().indexOf("ING") > 0) { - MainActivity.csLibrary4A.appendToLog("button is still ing"); + Logger.trace("button is still ing"); return null; } return accessResult; @@ -164,24 +164,24 @@ void setup() { tryCount++; if (invalidRequest == false) { if (MainActivity.csLibrary4A.setAccessBank(accBank) == false) { - MainActivity.csLibrary4A.appendToLog("HelloK: accBank, invalidRequest=" + invalidRequest); + Logger.trace("HelloK: accBank, invalidRequest={}", invalidRequest); invalidRequest = true; } } if (invalidRequest == false) { if (MainActivity.csLibrary4A.setAccessOffset(accOffset) == false) { - MainActivity.csLibrary4A.appendToLog("HelloK: accOffset, invalidRequest=" + invalidRequest); + Logger.trace("HelloK: accOffset, invalidRequest={}", invalidRequest); invalidRequest = true; } } if (invalidRequest == false) { if (accSize == 0) { - MainActivity.csLibrary4A.appendToLog("HelloK: accSize0, invalidRequest=" + invalidRequest); + Logger.trace("HelloK: accSize0, invalidRequest={}", invalidRequest); invalidRequest = true; } else { if (accSize > accBlockCount) accSizeNow = accBlockCount; else accSizeNow = accSize; - MainActivity.csLibrary4A.appendToLog("HelloA: accSize=" + accSize + ", accSizeNow=" + accSizeNow); + Logger.trace("HelloA: accSize={}, accSizeNow={}", accSize, accSizeNow); if (MainActivity.csLibrary4A.setAccessCount(accSizeNow) == false) { invalidRequest = true; } @@ -194,8 +194,8 @@ void setup() { invalidRequest = true; } } - MainActivity.csLibrary4A.appendToLog("HelloA: accOffset=" + accOffset + ", accSizeNow=" + accSizeNow + ", accSize=" + accSize); - MainActivity.csLibrary4A.appendToLog("HelloK: invalidRequest=" + invalidRequest); + Logger.trace("HelloA: accOffset={}, accSizeNow={}, accSize={}", accOffset, accSizeNow, accSize); + Logger.trace("HelloK: invalidRequest={}", 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/CustomMediaPlayer.java b/app/src/main/java/com/csl/cs108ademoapp/CustomMediaPlayer.java index 9818e0a..f46fc10 100644 --- a/app/src/main/java/com/csl/cs108ademoapp/CustomMediaPlayer.java +++ b/app/src/main/java/com/csl/cs108ademoapp/CustomMediaPlayer.java @@ -5,6 +5,8 @@ import android.media.AudioManager; import android.media.MediaPlayer; +import com.csl.cslibrary4a.Logger; + import java.io.IOException; public class CustomMediaPlayer { @@ -24,11 +26,11 @@ public CustomMediaPlayer(Context context, String file) { @Override public void onCompletion(MediaPlayer mp) { starting = false; - if (DEBUG) MainActivity.csLibrary4A.appendToLog("MediaPlayer is completed."); + Logger.debug("MediaPlayer is completed."); } }); } catch (IOException e) { - MainActivity.csLibrary4A.appendToLog("mp3 setup FAIL"); + Logger.warn("mp3 setup FAIL"); } } @@ -48,7 +50,7 @@ void setVolume(int volume1, int volume2) { AudioManager audioManager = ((AudioManager) context.getSystemService(Context.AUDIO_SERVICE)); int iVolumeMax = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC); int currentVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC); - MainActivity.csLibrary4A.appendToLog("Hello8: currentVolume = " + currentVolume); + Logger.trace("Hello8: currentVolume = {}", currentVolume); if (currentVolume > 0) { int volume12 = volume1 + volume2; volume12 = ( volume12 * iVolumeMax ) / 600; diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/BarcodeConnector.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/BarcodeConnector.java index f8299a8..bd79db6 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/BarcodeConnector.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/BarcodeConnector.java @@ -1,13 +1,11 @@ package com.csl.cslibrary4a; import android.content.Context; -import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; public class BarcodeConnector { - boolean DEBUG_PKDATA; public boolean userDebugEnableDefault = false; public boolean userDebugEnable = userDebugEnableDefault; @@ -18,8 +16,6 @@ public BarcodeConnector(Context context, 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); } - private void appendToLog(String s) { utility.appendToLog(s); } - private void appendToLogView(String s) { utility.appendToLogView(s); } public enum BarcodePayloadEvents { BARCODE_NULL, @@ -87,75 +83,72 @@ private byte[] writeBarcode(CsReaderBarcodeData data) { if (arrayTypeSet(dataOut, 9, data.barcodePayloadEvent)) { if (false) { - appendToLog("BarStreamOut: " + byteArrayToString(dataOut)); - appendToLogView("BOut: " + byteArrayToString(dataOut)); + Logger.trace("BarStreamOut: {}", byteArrayToString(dataOut)); + Logger.toLogView("BOut: {}", byteArrayToString(dataOut)).trace(); } - if (DEBUG_PKDATA) appendToLog(String.format("PkData: write Barcode.%s.%s with mBarcodeDevice.sendDataToWriteSent = %d", data.barcodePayloadEvent.toString(), byteArrayToString(data.dataValues), sendDataToWriteSent)); - if (sendDataToWriteSent != 0) appendToLog("!!! mBarcodeDevice.sendDataToWriteSent = " + sendDataToWriteSent); + Logger.pkData("PkData: write Barcode.{}.{} with mBarcodeDevice.sendDataToWriteSent = {}", data.barcodePayloadEvent.toString(), byteArrayToString(data.dataValues), sendDataToWriteSent); + if (sendDataToWriteSent != 0) Logger.pkData("!!! mBarcodeDevice.sendDataToWriteSent = {}", sendDataToWriteSent); return dataOut; } return null; } public int barcodePowerOnTimeOut = 0; public boolean isMatchBarcodeToWrite(ConnectorData connectorData) { - boolean match = false, DEBUG = false; - if (barcodeToWrite.size() != 0 && connectorData.dataValues[0] == (byte)0x90) { - if (DEBUG) appendToLog("csReadData = " + byteArrayToString(connectorData.dataValues)); - //if (DEBUG) appendToLog("tempDisconnect: icsModel = " + bluetoothConnector.getCsModel() + ", barcodeToWrite.size = " + barcodeToWrite.size()); - if (barcodeToWrite.size() != 0) if (DEBUG) appendToLog("barcodeToWrite(0) = " + barcodeToWrite.get(0).barcodePayloadEvent.toString() + "," + byteArrayToString(barcodeToWrite.get(0).dataValues)); + boolean match = false; + if (!barcodeToWrite.isEmpty() && connectorData.dataValues[0] == (byte)0x90) { + Logger.debug("csReadData = {}", byteArrayToString(connectorData.dataValues)); + if (!barcodeToWrite.isEmpty()) Logger.debug("barcodeToWrite(0) = {}, {}", barcodeToWrite.get(0).barcodePayloadEvent, byteArrayToString(barcodeToWrite.get(0).dataValues)); byte[] dataInCompare = new byte[]{(byte) 0x90, 0}; if (arrayTypeSet(dataInCompare, 1, barcodeToWrite.get(0).barcodePayloadEvent) && (connectorData.dataValues.length == dataInCompare.length + 1)) { 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 Barcode.Reply with payload = " + byteArrayToString(connectorData.dataValues) + " for writeData Barcode." + barcodeToWrite.get(0).barcodePayloadEvent.toString()); + Logger.pkData("PkData: matched Barcode.Reply with payload = {} for writeData Barcode. {}", byteArrayToString(connectorData.dataValues), barcodeToWrite.get(0).barcodePayloadEvent); if (connectorData.dataValues[2] != 0) { - if (DEBUG) appendToLog("Barcode.reply data is found with error"); - } else if (true) { //testing bluetoothConnector.getCsModel() == 108) { + Logger.debug("Barcode.reply data is found with error"); + } else { //testing bluetoothConnector.getCsModel() == 108) { if (barcodeToWrite.get(0).barcodePayloadEvent == BarcodePayloadEvents.BARCODE_POWER_ON) { barcodePowerOnTimeOut = 1000; - if (DEBUG) appendToLog("tempDisconnect: BARCODE_POWER_ON"); + Logger.debug("tempDisconnect: BARCODE_POWER_ON"); onStatus = true; - if (DEBUG_PKDATA | connectorData.dataValues[2] != 0) appendToLog("PkData: matched Barcode.Reply.PowerOn with result = " + connectorData.dataValues[2] + " and onStatus = " + onStatus); + if (connectorData.dataValues[2] != 0) Logger.pkData("PkData: matched Barcode.Reply.PowerOn with result = {} and onStatus = {}", connectorData.dataValues[2], onStatus); bprocessed = true; } else if (barcodeToWrite.get(0).barcodePayloadEvent == BarcodePayloadEvents.BARCODE_POWER_OFF) { - if (DEBUG) appendToLog("tempDisconnect: BARCODE_POWER_OFF"); + Logger.debug("tempDisconnect: BARCODE_POWER_OFF"); onStatus = false; - if (DEBUG_PKDATA | connectorData.dataValues[2] != 0) appendToLog("PkData: matched Barcode.Reply.PowerOff with result = " + connectorData.dataValues[2] + " and onStatus = " + onStatus); + if (connectorData.dataValues[2] != 0) Logger.pkData("PkData: matched Barcode.Reply.PowerOff with result = {} and onStatus = {}", connectorData.dataValues[2], onStatus); bprocessed = true; } else if (barcodeToWrite.get(0).barcodePayloadEvent == BarcodePayloadEvents.BARCODE_VIBRATE_ON) { vibrateStatus = true; - if (DEBUG_PKDATA | connectorData.dataValues[2] != 0) appendToLog("PkData: matched Barcode.Reply.VibrateOn with result = " + connectorData.dataValues[2] + " and vibrateStatus = " + vibrateStatus); + if (connectorData.dataValues[2] != 0) Logger.pkData("PkData: matched Barcode.Reply.VibrateOn with result = {} and vibrateStatus = {}", connectorData.dataValues[2], vibrateStatus); bprocessed = true; } else if (barcodeToWrite.get(0).barcodePayloadEvent == BarcodePayloadEvents.BARCODE_VIBRATE_OFF) { vibrateStatus = false; - if (DEBUG_PKDATA | connectorData.dataValues[2] != 0) appendToLog("PkData: matched Barcode.Reply.VibrateOff with result = " + connectorData.dataValues[2] + " and vibrateStatus = " + vibrateStatus); + if (connectorData.dataValues[2] != 0) Logger.pkData("PkData: matched Barcode.Reply.VibrateOff with result = {} and vibrateStatus = {}", connectorData.dataValues[2], vibrateStatus); bprocessed = true; } else if (barcodeToWrite.get(0).barcodePayloadEvent == BarcodePayloadEvents.BARCODE_COMMAND) { barcodePowerOnTimeOut = 500; - if (DEBUG_PKDATA | connectorData.dataValues[2] != 0) appendToLog("PkData: matched Barcode.Reply.Command with result = " + connectorData.dataValues[2] + " and barcodePowerOnTimeOut = " + barcodePowerOnTimeOut); + if (connectorData.dataValues[2] != 0) Logger.pkData("PkData: matched Barcode.Reply.Command with result = {}, and barcodePowerOnTimeOut = {}", connectorData.dataValues[2], barcodePowerOnTimeOut); bprocessed = true; } else { bprocessed = true; - if (DEBUG_PKDATA) appendToLog("matched Barcode.Other.Reply data is found."); + Logger.pkData("matched Barcode.Other.Reply data is found."); } CsReaderBarcodeData csReaderBarcodeData = barcodeToWrite.get(0); if (csReaderBarcodeData.waitUplinkResponse) { csReaderBarcodeData.downlinkResponsed = true; iOkCount = 0; barcodeToWrite.set(0, csReaderBarcodeData); - if (DEBUG_PKDATA) appendToLog("PkData: barcodeToWrite.downlinkResponsed is set and waiting uplink data"); + Logger.pkData("PkData: barcodeToWrite.downlinkResponsed is set and waiting uplink data"); utility.writeDebug2File("Up31 " + barcodeToWrite.get(0).barcodePayloadEvent.toString() + ", " + byteArrayToString(data1)); return true; } - } else { - barcodeFailure = true; - appendToLog("Not matched Barcode.Reply"); } String string = "Up31 " + (bprocessed ? "" : "Unprocessed, ") + barcodeToWrite.get(0).barcodePayloadEvent.toString() + ", " + byteArrayToString(data1); utility.writeDebug2File(string); - barcodeToWrite.remove(0); sendDataToWriteSent = 0; mDataToWriteRemoved = true; appendToLog("barcodeToWrite remove0 with length = " + barcodeToWrite.size()); - if (DEBUG_PKDATA) appendToLog("PkData: new barcodeToWrite size = " + barcodeToWrite.size()); + barcodeToWrite.remove(0); sendDataToWriteSent = 0; mDataToWriteRemoved = true; + Logger.info("barcodeToWrite remove0 with length = {}", barcodeToWrite.size()); + Logger.pkData("PkData: new barcodeToWrite size = {}", barcodeToWrite.size()); } } } @@ -165,44 +158,44 @@ public boolean isMatchBarcodeToWrite(ConnectorData connectorData) { public int sendDataToWriteSent = 0; public boolean mDataToWriteRemoved = false; public boolean barcodeFailure = false; public byte[] sendBarcodeToWrite() { - boolean DEBUG = false; /*if (barcodePowerOnTimeOut != 0) { - if (DEBUG) appendToLog("barcodePowerOnTimeOut = " + barcodePowerOnTimeOut + ", barcodeToWrite.size() = " + barcodeToWrite.size()); + Logger.debug("barcodePowerOnTimeOut = " + barcodePowerOnTimeOut + ", barcodeToWrite.size() = " + barcodeToWrite.size()); return false; } if (barcodeToWrite.size() != 0) {*/ - //if (DEBUG) appendToLog("barcodeToWrite.size = " + barcodeToWrite.size()); - //appendToLog("testing 3"); appendToLog("testing 4"); + //Logger.debug("barcodeToWrite.size = " + barcodeToWrite.size()); + //Logger.trace("testing 3"); Logger.trace("testing 4"); //if (false) { //testing isBleConnected() == false) { // barcodeToWrite.clear(); //} else if (false) { //testing System.currentTimeMillis() - btSendTime > btSendTimeOut) { BarcodePayloadEvents barcodePayloadEvents = barcodeToWrite.get(0).barcodePayloadEvent; - //if (DEBUG) appendToLog("barcodePayloadEvents = " + barcodePayloadEvents.toString()); + //Logger.debug("barcodePayloadEvents = " + barcodePayloadEvents.toString()); boolean isBarcodeData = false; if (barcodePayloadEvents == BarcodePayloadEvents.BARCODE_SCAN_START || barcodePayloadEvents == BarcodePayloadEvents.BARCODE_COMMAND) isBarcodeData = true; - //appendToLog("BarcodePayloadEvents = " + barcodePayloadEvents.toString() + ", barcodeFailure = " + barcodeFailure + ", isBarcodeData = " + isBarcodeData + ", sendDataToWriteSent = " + sendDataToWriteSent); + //Logger.trace("BarcodePayloadEvents = " + barcodePayloadEvents.toString() + ", barcodeFailure = " + barcodeFailure + ", isBarcodeData = " + isBarcodeData + ", sendDataToWriteSent = " + sendDataToWriteSent); if (barcodeFailure && isBarcodeData) { - barcodeToWrite.remove(0); sendDataToWriteSent = 0; mDataToWriteRemoved = true; appendToLog("barcodeToWrite remove0 with length = " + barcodeToWrite.size()); + barcodeToWrite.remove(0); sendDataToWriteSent = 0; mDataToWriteRemoved = true; + Logger.info("barcodeToWrite remove0 with length = {}", barcodeToWrite.size()); } else if (sendDataToWriteSent >= 5 && isBarcodeData) { int oldSize = barcodeToWrite.size(); - barcodeToWrite.remove(0); sendDataToWriteSent = 0; mDataToWriteRemoved = true; appendToLog("barcodeToWrite remove0 with length = " + barcodeToWrite.size()); - if (DEBUG) appendToLog("Removed after sending count-out with oldSize = " + oldSize + ", updated barcodeToWrite.size() = " + barcodeToWrite.size()); - if (DEBUG) appendToLog("Removed after sending count-out."); + barcodeToWrite.remove(0); sendDataToWriteSent = 0; mDataToWriteRemoved = true; + Logger.info("barcodeToWrite remove0 with length = {}", barcodeToWrite.size()); + Logger.debug("Removed after sending count-out with oldSize = {}, updated barcodeToWrite.size() = {}", oldSize, barcodeToWrite.size()); + Logger.debug("Removed after sending count-out."); String string = "Problem in sending data to Barcode Module. Removed data sending after count-out"; if (userDebugEnable) Toast.makeText(context, string, Toast.LENGTH_SHORT).show(); - else appendToLogView(string); - //appendToLog("testing 5"); //testing if (bluetoothConnector.getCsModel() == 108) Toast.makeText(context, "No barcode present on Reader", Toast.LENGTH_LONG).show(); + else Logger.info(string); barcodeFailure = true; // disconnect(false); } else { - if (DEBUG) appendToLog("size = " + barcodeToWrite.size() + ", PayloadEvents = " + barcodeToWrite.get(0).barcodePayloadEvent.toString()); + Logger.debug("size = {}, PayloadEvents = {}", barcodeToWrite.size(), barcodeToWrite.get(0).barcodePayloadEvent); sendDataToWriteSent++; return writeBarcode(barcodeToWrite.get(0)); /*if (retValue) { sendDataToWriteSent++; mDataToWriteRemoved = false; } else { - //if (DEBUG) appendToLogView("failure to send " + barcodeToWrite.get(0).barcodePayloadEvent.toString()); - barcodeToWrite.remove(0); sendDataToWriteSent = 0; mDataToWriteRemoved = true; appendToLog("barcodeToWrite remove0 with length = " + barcodeToWrite.size()); + //Logger.debug("failure to send " + barcodeToWrite.get(0).barcodePayloadEvent.toString()); + barcodeToWrite.remove(0); sendDataToWriteSent = 0; mDataToWriteRemoved = true; Logger.trace("barcodeToWrite remove0 with length = " + barcodeToWrite.size()); } return true;*/ } @@ -213,17 +206,17 @@ public byte[] sendBarcodeToWrite() { int iOkCount = 0; public boolean isBarcodeToRead(ConnectorData connectorData) { - boolean found = false, DEBUG = false; + boolean found = false; if (connectorData.dataValues[0] == (byte) 0x91) { - if (DEBUG_PKDATA) appendToLog("PkData: found Barcode.Uplink with payload = " + byteArrayToString(connectorData.dataValues)); + Logger.pkData("PkData: found Barcode.Uplink with payload = {}", byteArrayToString(connectorData.dataValues)); CsReaderBarcodeData csReaderBarcodeData = new CsReaderBarcodeData(); switch (connectorData.dataValues[1]) { case 0: csReaderBarcodeData.barcodePayloadEvent = BarcodePayloadEvents.BARCODE_DATA_READ; byte[] dataValues = new byte[connectorData.dataValues.length - 2]; System.arraycopy(connectorData.dataValues, 2, dataValues, 0, dataValues.length); - if (DEBUG_PKDATA) appendToLog("PkData: found Barcode.Uplink.DataRead with payload = " + byteArrayToString(dataValues)); + Logger.pkData("PkData: found Barcode.Uplink.DataRead with payload = {}", byteArrayToString(dataValues)); //commandType = null; if (barcodeToWrite.size() > 0) { if (barcodeToWrite.get(0).downlinkResponsed) { @@ -239,20 +232,20 @@ public boolean isBarcodeToRead(ConnectorData connectorData) { }*/ csReaderBarcodeData.dataValues = dataValues; mBarcodeToRead.add(csReaderBarcodeData); - if (DEBUG_PKDATA) appendToLog("PkData: uplink data Barcode.DataRead." + byteArrayToString(dataValues) + " is added to mBarcodeToRead"); + Logger.pkData("PkData: uplink data Barcode.DataRead. {} is added to mBarcodeToRead", byteArrayToString(dataValues)); found = true; break; case 1: - if (DEBUG) appendToLog("BarStream: matched Barcode.good data is found"); + Logger.debug("BarStream: matched Barcode.good data is found"); csReaderBarcodeData.barcodePayloadEvent = BarcodePayloadEvents.BARCODE_GOOD_READ; csReaderBarcodeData.dataValues = null; mBarcodeToRead.add(csReaderBarcodeData); - if (DEBUG_PKDATA) appendToLog("PkData: uplink data Barcode.GoodRead is added to mBarcodeToRead"); + Logger.pkData("PkData: uplink data Barcode.GoodRead is added to mBarcodeToRead"); found = true; break; } } - if (found && DEBUG) appendToLog("found Barcode.read data = " + byteArrayToString(connectorData.dataValues)); + if (found) Logger.debug("found Barcode.read data = {}", byteArrayToString(connectorData.dataValues)); return found; } } \ No newline at end of file diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/BarcodeNewland.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/BarcodeNewland.java index 398ee01..649f933 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/BarcodeNewland.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/BarcodeNewland.java @@ -1,7 +1,6 @@ package com.csl.cslibrary4a; import android.content.Context; -import android.widget.TextView; import androidx.annotation.Keep; @@ -21,7 +20,6 @@ public BarcodeNewland(Context context, Utility utility, BarcodeConnector barcode this.utility = utility; } - void appendToLog(String s) { utility.appendToLog(s); } String byteArrayToString(byte[] packet) { return utility.byteArrayToString(packet); } public boolean barcodeSendCommand(byte[] barcodeCommandData) { @@ -29,11 +27,9 @@ public boolean barcodeSendCommand(byte[] barcodeCommandData) { csReaderBarcodeData.barcodePayloadEvent = BarcodeConnector.BarcodePayloadEvents.BARCODE_COMMAND; csReaderBarcodeData.waitUplinkResponse = true; csReaderBarcodeData.dataValues = barcodeCommandData; - barcodeConnector.barcodeToWrite.add(csReaderBarcodeData); appendToLog("barcodeToWrite added with size = " + barcodeConnector.barcodeToWrite.size()); - if (utility.DEBUG_PKDATA) { - //if (barcodeCommandData[0] == 'n') - appendToLog("PkData: add " + csReaderBarcodeData.barcodePayloadEvent.toString() + "." + byteArrayToString(csReaderBarcodeData.dataValues) + " to barcodeToWrite with length = " + barcodeConnector.barcodeToWrite.size()); - } + barcodeConnector.barcodeToWrite.add(csReaderBarcodeData); + Logger.info("barcodeToWrite added with size = {}", barcodeConnector.barcodeToWrite.size()); + Logger.pkData("PkData: add {}.{} to barcodeToWrite with length = ", csReaderBarcodeData.barcodePayloadEvent, byteArrayToString(csReaderBarcodeData.dataValues), barcodeConnector.barcodeToWrite.size()); return true; } @@ -44,13 +40,14 @@ boolean barcodeReadTriggerStart() { csReaderBarcodeData.barcodePayloadEvent = BarcodeConnector.BarcodePayloadEvents.BARCODE_SCAN_START; csReaderBarcodeData.waitUplinkResponse = false; barcode2TriggerMode = false; - boolean bValue = barcodeConnector.barcodeToWrite.add(csReaderBarcodeData); appendToLog("barcodeToWrite added with size = " + barcodeConnector.barcodeToWrite.size()); - appendToLog("add " + csReaderBarcodeData.barcodePayloadEvent.toString() + " to barcodeToWrite with length = " + barcodeConnector.barcodeToWrite.size()); + boolean bValue = barcodeConnector.barcodeToWrite.add(csReaderBarcodeData); + Logger.info("barcodeToWrite added with size = {}", barcodeConnector.barcodeToWrite.size()); + Logger.pkData("add {} to barcodeToWrite with length = {}", csReaderBarcodeData.barcodePayloadEvent, barcodeConnector.barcodeToWrite.size()); return bValue; } public boolean barcodeSendCommandTrigger() { boolean retValue = true; - barcode2TriggerMode = true; bBarcodeTriggerMode = 0x30; if (false) appendToLog("Set trigger reading mode to TRIGGER"); + barcode2TriggerMode = true; bBarcodeTriggerMode = 0x30; Logger.trace("Set trigger reading mode to TRIGGER"); if (retValue) retValue = barcodeSendCommand("nls0006010;".getBytes()); if (retValue) retValue = barcodeSendCommand("nls0302000;".getBytes()); if (retValue) retValue = barcodeSendCommand("nls0313000=3000;nls0313010=1000;nls0313040=1000;nls0302000;nls0007010;".getBytes()); @@ -62,15 +59,17 @@ public boolean barcodeSendCommandTrigger() { public byte[] suffixRef = { 0x05, 0x01, 0x11, 0x16, 0x03, 0x04 }; public boolean barcodeSendCommandSetPreSuffix() { boolean retValue = true; - appendToLog("BarStream: BarcodePrefix BarcodeSuffix are SET"); + Logger.info("BarStream: BarcodePrefix BarcodeSuffix are SET"); if (retValue) retValue = barcodeSendCommand("nls0006010;".getBytes()); if (retValue) retValue = barcodeSendCommand("nls0311010;".getBytes()); if (retValue) retValue = barcodeSendCommand("nls0317040;".getBytes()); if (retValue) retValue = barcodeSendCommand("nls0305010;".getBytes()); - String string = "nls0300000=0x" + byteArrayToString(prefixRef) + ";"; appendToLog("Set Prefix string = " + string); + String string = "nls0300000=0x" + byteArrayToString(prefixRef) + ";"; + Logger.info("Set Prefix string = {}", string); if (retValue) retValue = barcodeSendCommand(string.getBytes()); if (retValue) retValue = barcodeSendCommand("nls0306010;".getBytes()); - string = "nls0301000=0x" + byteArrayToString(suffixRef) + ";"; appendToLog("Set Suffix string = " + string); + string = "nls0301000=0x" + byteArrayToString(suffixRef) + ";"; + Logger.info("Set Suffix string = {}", string); if (retValue) retValue = barcodeSendCommand(string.getBytes()); if (retValue) retValue = barcodeSendCommand("nls0308030;".getBytes()); if (retValue) retValue = barcodeSendCommand("nls0307010;".getBytes()); @@ -130,7 +129,7 @@ boolean barcodeSendQuery(byte[] data) { for (int i = 2; i < data.length - 1; i++) { bytelrc ^= data[i]; } - if (false) appendToLog(String.format("BarStream: bytelrc = %02X, last = %02X", (byte)bytelrc, data[data.length-1])); + Logger.trace(String.format("BarStream: bytelrc = %02X, last = %02X", bytelrc, data[data.length-1])); data[data.length-1] = bytelrc; return barcodeSendCommand(data); } @@ -255,15 +254,15 @@ public boolean checkPreSuffix(byte[] prefix1, byte[] suffix1) { return result; } public boolean decodeBarcodeUplinkData(byte[] dataValues, BarcodeConnector.CsReaderBarcodeData csReaderBarcodeData) { - appendToLog("decodeBarcodeUplinkData starts"); - boolean found = false, DEBUG = false; + Logger.info("decodeBarcodeUplinkData starts"); + boolean found = false; int count = 0; boolean matched = true; if (barcodeConnector.barcodeToWrite.get(0).dataValues[0] == 0x1b) { commandType = BarcodeCommandTypes.COMMAND_COMMON; count = 1; - if (DEBUG) appendToLog("0x1b, Common response with count = " + count); + Logger.debug("0x1b, Common response with count = {}", count); } else if (barcodeConnector.barcodeToWrite.get(0).dataValues[0] == 0x7E) { - if (DEBUG) appendToLog("0x7E, Barcode response with 0x7E barcodeToWrite.get(0).dataValues[0] and response data = " + byteArrayToString(dataValues)); + Logger.debug("0x7E, Barcode response with 0x7E barcodeToWrite.get(0).dataValues[0] and response data = {}", byteArrayToString(dataValues)); matched = true; commandType = BarcodeCommandTypes.COMMAND_QUERY; int index = 0; @@ -276,7 +275,7 @@ public boolean decodeBarcodeUplinkData(byte[] dataValues, BarcodeConnector.CsRea System.arraycopy(dataValues, index + 5, bytes, 0, bytes.length); byte[] requestBytes = new byte[barcodeConnector.barcodeToWrite.get(0).dataValues.length - 6]; System.arraycopy(barcodeConnector.barcodeToWrite.get(0).dataValues, 5, requestBytes, 0, requestBytes.length); - if (utility.DEBUG_PKDATA) appendToLog("PkData: found Barcode.Uplink.DataRead.QueryResponse with payload data1 = " + byteArrayToString(bytes) + " for QueryInput data1 = " + byteArrayToString(requestBytes)); + Logger.pkData("PkData: found Barcode.Uplink.DataRead.QueryResponse with payload data1 = {} for QueryInput data1 = {}", byteArrayToString(bytes), byteArrayToString(requestBytes)); if (barcodeConnector.barcodeToWrite.get(0).dataValues[5] == 0x37 && length >= 5) { matched = true; int prefixLength = dataValues[index+6]; @@ -295,11 +294,11 @@ public boolean decodeBarcodeUplinkData(byte[] dataValues, BarcodeConnector.CsRea bytesBarcodeSuffix = new byte[suffixLength]; System.arraycopy(dataValues, index + 7 + prefixLength + 2, bytesBarcodeSuffix, 0, bytesBarcodeSuffix.length); } - if (DEBUG) appendToLog("BarStream: BarcodePrefix = " + byteArrayToString(bytesBarcodePrefix) + ", BarcodeSuffix = " + byteArrayToString(bytesBarcodeSuffix)); + Logger.debug("BarStream: BarcodePrefix = {}, BarcodeSuffix = {}", byteArrayToString(bytesBarcodePrefix), byteArrayToString(bytesBarcodeSuffix)); } - if (utility.DEBUG_PKDATA) appendToLog("PkData: Barcode.Uplink.DataRead.QueryResponse.SelfPrefix_SelfSuffix is processed as Barcode Prefix = " + byteArrayToString(bytesBarcodePrefix) + ", Suffix = " + byteArrayToString(bytesBarcodeSuffix)); + Logger.pkData("PkData: Barcode.Uplink.DataRead.QueryResponse.SelfPrefix_SelfSuffix is processed as Barcode Prefix = {}, Suffix = ", byteArrayToString(bytesBarcodePrefix), byteArrayToString(bytesBarcodeSuffix)); } else if (barcodeConnector.barcodeToWrite.get(0).dataValues[5] == 0x47 && length > 1) { - if (DEBUG) appendToLog("versionNumber is detected with length = " + length); + Logger.debug("versionNumber is detected with length = {}", length); matched = true; byte[] byteVersion = new byte[length - 1]; System.arraycopy(dataValues, index + 5, byteVersion, 0, byteVersion.length); @@ -310,7 +309,7 @@ public boolean decodeBarcodeUplinkData(byte[] dataValues, BarcodeConnector.CsRea versionNumber = null; } strVersion = versionNumber; - if (utility.DEBUG_PKDATA) appendToLog("PkData: uplink data " + byteArrayToString(byteVersion) + " is processsed as version = " + versionNumber); + Logger.pkData("PkData: uplink data {} is processsed as version = {}", byteArrayToString(byteVersion), versionNumber); } else if (barcodeConnector.barcodeToWrite.get(0).dataValues[5] == 0x48 && length >= 5) { if (dataValues[index+5] == barcodeConnector.barcodeToWrite.get(0).dataValues[6] && dataValues[index+6] == barcodeConnector.barcodeToWrite.get(0).dataValues[7]) { matched = true; //for ESN, S/N or Date @@ -320,15 +319,14 @@ public boolean decodeBarcodeUplinkData(byte[] dataValues, BarcodeConnector.CsRea try { serialNumber = new String(byteSN, "UTF-8"); int snLength = Integer.parseInt(serialNumber.substring(0, 2)); - if (DEBUG) - appendToLog("BarStream: serialNumber = " + serialNumber + ", snLength = " + snLength + ", serialNumber.length = " + serialNumber.length()); + Logger.debug("BarStream: serialNumber = {}, snLength = {}, serialNumber.length = {}", serialNumber, snLength, serialNumber.length()); if (snLength + 2 == serialNumber.length()) { serialNumber = serialNumber.substring(2); } else serialNumber = null; } catch (Exception e) { serialNumber = null; } - if (false) appendToLog("debug index = " + index + ", " + byteArrayToString(dataValues)); + Logger.trace("debug index = {}, {}", index, byteArrayToString(dataValues)); String strResponseType = ""; if (dataValues[index+6] == (byte)0x32) { strESN = serialNumber; @@ -340,11 +338,11 @@ public boolean decodeBarcodeUplinkData(byte[] dataValues, BarcodeConnector.CsRea strDate = serialNumber; strResponseType = "DataCode"; } - if (false) appendToLog("strResponseType = " + strResponseType); - if (utility.DEBUG_PKDATA) appendToLog(String.format("PkData: Barcode.Uplink.DataRead.QueryResponse.%s is processed as %s[%s]", strResponseType, byteArrayToString(byteSN).substring(4), serialNumber)); - } else appendToLog("Barcode.Uplink.DataRead.QueryResponse has mis-matched values"); + Logger.trace("strResponseType = {}", strResponseType); + Logger.pkData("PkData: Barcode.Uplink.DataRead.QueryResponse.{} is processed as {}[{}]", strResponseType, byteArrayToString(byteSN).substring(4), serialNumber); + } else Logger.info("Barcode.Uplink.DataRead.QueryResponse has mis-matched values"); } else if (barcodeConnector.barcodeToWrite.get(0).dataValues[5] == 0x44 && length >= 3) { - if (DEBUG) appendToLog("BarStream: dataValue = " + byteArrayToString(dataValues) + ", writeDataValue = " + byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); + Logger.debug("BarStream: dataValue = {}, writeDataValue = {}", byteArrayToString(dataValues), byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); if (dataValues[index+5] == barcodeConnector.barcodeToWrite.get(0).dataValues[6] && dataValues[index+6] == barcodeConnector.barcodeToWrite.get(0).dataValues[7]) { matched = true; if (barcodeConnector.barcodeToWrite.get(0).dataValues[6] == 0x30 && barcodeConnector.barcodeToWrite.get(0).dataValues[7] == 0x30 && barcodeConnector.barcodeToWrite.get(0).dataValues[8] == 0x30) { @@ -354,18 +352,18 @@ 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 (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"); + Logger.pkData(String.format("PkData: Barcode.Uplink.DataRead.QueryResponse.ReadingMode is processed as last 0x%X[%s]", dataValues[index+7], strModeType)); + } else Logger.info("Barcode.Uplink.DataRead.QueryResponse has mis-matched values"); + } else Logger.info("Barcode.Uplink.DataRead.QueryResponse has mis-matched values"); + } else Logger.info("Barcode.Uplink.DataRead.QueryResponse has mis-matched values"); index += (length + 5); } else break; } else index++; } - if (matched) { if (DEBUG) appendToLog("Matched Query response"); } - else { if (DEBUG) appendToLog("Mis-matched Query response"); } + if (matched) { Logger.debug("Matched Query response"); } + else { Logger.debug("Mis-matched Query response"); } } else { - if (DEBUG) appendToLog("BarStream: Barcode response with barcodeToWrite.get(0).dataValues[0] = Others"); + Logger.info("BarStream: Barcode response with barcodeToWrite.get(0).dataValues[0] = Others"); String strData = null; try { strData = new String(barcodeConnector.barcodeToWrite.get(0).dataValues, "UTF-8"); @@ -381,10 +379,10 @@ public boolean decodeBarcodeUplinkData(byte[] dataValues, BarcodeConnector.CsRea lastIndex += findStr.length(); } } - if (DEBUG) appendToLog("Setting strData = " + strData + ", count = " + count); + Logger.info("Setting strData = {}, count = {}", strData, count); } if (count != 0) { - if (false) appendToLog("dataValues.length = " + dataValues.length + ", okCount = " + barcodeConnector.iOkCount + ", count = " + count + " for barcodeToWrite data = " + byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); + Logger.trace("dataValues.length = {}, okCount = {}, count = {} for barcodeToWrite data = {}", dataValues.length, barcodeConnector.iOkCount, count, byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); matched = false; boolean foundOk = false; for (int k = 0; k < dataValues.length; k++) { boolean match06 = false; @@ -392,20 +390,21 @@ public boolean decodeBarcodeUplinkData(byte[] dataValues, BarcodeConnector.CsRea if (match06 == false) break; foundOk = true; found = true; } - if (false) appendToLog("00 matcched = " + matched); - 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)); } + Logger.trace("00 matcched = {}", matched); + if (matched) { Logger.pkData("PkData: Barcode.Uplink.DataRead.{} is processed with matched = {}, OkCount = {}, expected count = {} for {}", byteArrayToString(dataValues), matched, barcodeConnector.iOkCount, count, byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); } + else if (foundOk) { Logger.pkData("PkData: Barcode.Uplink.DataRead.{} is processed with matched = {}, but OkCount = {}, expected count = {} for {}", byteArrayToString(dataValues), matched, barcodeConnector.iOkCount, count, byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); } else { barcodeConnector.mBarcodeToRead.add(csReaderBarcodeData); - if (utility.DEBUG_PKDATA) appendToLog("PkData: uplink data Barcode.DataRead." + byteArrayToString(csReaderBarcodeData.dataValues) + " is added to mBarcodeToRead"); + Logger.pkData("PkData: uplink data Barcode.DataRead.{} is added to mBarcodeToRead", byteArrayToString(csReaderBarcodeData.dataValues)); } } if (matched) { found = true; - barcodeConnector.barcodeToWrite.remove(0); barcodeConnector.sendDataToWriteSent = 0; barcodeConnector.mDataToWriteRemoved = true; appendToLog("barcodeToWrite remove0 with length = " + barcodeConnector.barcodeToWrite.size()); - if (utility.DEBUG_PKDATA) appendToLog("PkData: new barcodeToWrite size = " + barcodeConnector.barcodeToWrite.size()); + barcodeConnector.barcodeToWrite.remove(0); barcodeConnector.sendDataToWriteSent = 0; barcodeConnector.mDataToWriteRemoved = true; + Logger.info("barcodeToWrite remove0 with length = {}", barcodeConnector.barcodeToWrite.size()); + Logger.pkData("PkData: new barcodeToWrite size = {}", barcodeConnector.barcodeToWrite.size()); } - appendToLog("decodeBarcodeUplinkData found = " + found); + Logger.info("decodeBarcodeUplinkData found = {}", found); return found; } } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/BluetoothConnector.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/BluetoothConnector.java index f6f2a07..b511816 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/BluetoothConnector.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/BluetoothConnector.java @@ -1,31 +1,26 @@ package com.csl.cslibrary4a; import android.content.Context; -import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; public class BluetoothConnector { - boolean DEBUG_PKDATA; - final boolean DEBUG = false; // public boolean userDebugEnableDefault = false; // public boolean userDebugEnable = userDebugEnableDefault; Context context; Utility utility; boolean userDebugEnable; public BluetoothConnector(Context context, Utility utility, boolean userDebugEnable) { this.context = context; - this.utility = utility; DEBUG_PKDATA = utility.DEBUG_PKDATA; + this.utility = utility; this.userDebugEnable = userDebugEnable; } private String byteArrayToString(byte[] packet) { return utility.byteArrayToString(packet); } private boolean compareArray(byte[] array1, byte[] array2, int length) { return utility.compareByteArray(array1, array2, length); } - private void appendToLog(String s) { utility.appendToLog(s); } - private void appendToLogView(String s) { utility.appendToLogView(s); } private int icsModel = -1; public int getCsModel() { - if (false) appendToLog("icsModel = " + icsModel); + Logger.trace("icsModel = {}", icsModel); return icsModel; } @@ -41,9 +36,8 @@ public class BluetoothIcData { private byte[] mBluetoothIcVersion = new byte[]{-1, -1, -1}; private boolean mBluetoothIcVersionUpdated = false; public String getBluetoothIcVersion() { - boolean DEBUG = false; if (mBluetoothIcVersionUpdated == false) { - if (DEBUG) appendToLog("mBluetoothIcVersionUpdated is false"); + Logger.debug("mBluetoothIcVersionUpdated is false"); boolean repeatRequest = false; if (bluetoothIcToWrite.size() != 0) { if (bluetoothIcToWrite.get(bluetoothIcToWrite.size() - 1).bluetoothIcPayloadEvent == BluetoothIcPayloadEvents.BLUETOOTH_GET_VERSION) { @@ -54,34 +48,33 @@ public String getBluetoothIcVersion() { BluetoothIcData cs108BluetoothIcData = new BluetoothIcData(); cs108BluetoothIcData.bluetoothIcPayloadEvent = BluetoothIcPayloadEvents.BLUETOOTH_GET_VERSION; bluetoothIcToWrite.add(cs108BluetoothIcData); - if (DEBUG_PKDATA) appendToLog("add " + cs108BluetoothIcData.bluetoothIcPayloadEvent.toString() + " to mBluetoothIcToWrite with length = " + bluetoothIcToWrite.size()); + Logger.pkData("add {} to mBluetoothIcToWrite with length = {}",cs108BluetoothIcData.bluetoothIcPayloadEvent, bluetoothIcToWrite.size()); } return ""; } else { String retValue = String.valueOf(mBluetoothIcVersion[0]) + "." + String.valueOf(mBluetoothIcVersion[1]) + "." + String.valueOf(mBluetoothIcVersion[2]); - if (DEBUG) appendToLog("mBluetoothIcVersionUpdated is true with data = " + byteArrayToString(mBluetoothIcVersion) + ", icsModel = " + icsModel); + Logger.debug("mBluetoothIcVersionUpdated is true with data = {}, icsModel = {}", byteArrayToString(mBluetoothIcVersion), icsModel); return retValue; } } public byte[] deviceName = null; public String getBluetoothIcName() { - boolean DEBBUG = false; - if (DEBBUG) appendToLog("3 deviceName = " + (deviceName == null ? "null" : byteArrayToString(deviceName))); + Logger.debug("3 deviceName = {}", (deviceName == null ? "null" : byteArrayToString(deviceName))); if (deviceName == null) { boolean repeatRequest = false; - if (DEBBUG) appendToLog("3A mBluetoothIcToWrite.size = " + bluetoothIcToWrite.size()); + Logger.debug("3A mBluetoothIcToWrite.size = {}", bluetoothIcToWrite.size()); if (bluetoothIcToWrite.size() != 0) { if (bluetoothIcToWrite.get(bluetoothIcToWrite.size() - 1).bluetoothIcPayloadEvent == BluetoothIcPayloadEvents.BLUETOOTH_GET_DEVICE_NAME) { repeatRequest = true; } } - if (DEBBUG) appendToLog("3b repeatRequest = " + repeatRequest); + Logger.debug("3b repeatRequest = {}", repeatRequest); if (repeatRequest == false) { BluetoothIcData cs108BluetoothIcData = new BluetoothIcData(); cs108BluetoothIcData.bluetoothIcPayloadEvent = BluetoothIcPayloadEvents.BLUETOOTH_GET_DEVICE_NAME; bluetoothIcToWrite.add(cs108BluetoothIcData); - if (DEBUG_PKDATA) appendToLog("add " + cs108BluetoothIcData.bluetoothIcPayloadEvent.toString() + " to mBluetoothIcToWrite with length = " + bluetoothIcToWrite.size()); + Logger.pkData("add {} to mBluetoothIcToWrite with length = {}", cs108BluetoothIcData.bluetoothIcPayloadEvent, bluetoothIcToWrite.size()); } return ""; } else { @@ -94,7 +87,7 @@ public boolean setBluetoothIcName(String name) { if (name.length() > 20) return false; BluetoothIcData cs108BluetoothIcData = new BluetoothIcData(); cs108BluetoothIcData.bluetoothIcPayloadEvent = BluetoothIcPayloadEvents.BLUETOOTH_SET_DEVICE_NAME; - if (DEBUG) appendToLog("deviceName.length = " + deviceName.length + ", name.getBytes = " + byteArrayToString(name.getBytes())); + Logger.debug("deviceName.length = {}, name.getBytes = {}", deviceName.length, byteArrayToString(name.getBytes())); cs108BluetoothIcData.dataValues = name.getBytes(); if (bluetoothIcToWrite.add(cs108BluetoothIcData) == false) return false; deviceName = name.getBytes(); @@ -135,7 +128,7 @@ private boolean arrayTypeSet(byte[] dataBuf, int pos, BluetoothIcPayloadEvents e private byte[] writeBluetoothIc(BluetoothIcData data) { int datalength = 0; - if (DEBUG) appendToLog("data.bluetoothIcPayloadEvent=" + data.bluetoothIcPayloadEvent.toString() + ", data.dataValues=" + byteArrayToString(data.dataValues)); + Logger.debug("data.bluetoothIcPayloadEvent={}, data.dataValues={}", data.bluetoothIcPayloadEvent, byteArrayToString(data.dataValues)); if (data.dataValues != null) datalength = data.dataValues.length; byte[] dataOutRef = new byte[]{(byte) 0xA7, (byte) 0xB3, 2, (byte) 0x5F, (byte) 0x82, (byte) 0x37, 0, 0, (byte) 0xC0, 0}; byte[] dataOut = new byte[10 + datalength]; @@ -144,7 +137,7 @@ private byte[] writeBluetoothIc(BluetoothIcData data) { dataOutRef[2] += datalength; } System.arraycopy(dataOutRef, 0, dataOut, 0, dataOutRef.length); - if (DEBUG) appendToLog("dataOut=" + byteArrayToString(dataOut)); + Logger.debug("dataOut={}", byteArrayToString(dataOut)); if (arrayTypeSet(dataOut, 9, data.bluetoothIcPayloadEvent)) { if (data.bluetoothIcPayloadEvent == BluetoothIcPayloadEvents.BLUETOOTH_SET_DEVICE_NAME && data.dataValues.length < 21) { byte[] dataOut1 = new byte[10+21]; @@ -152,7 +145,7 @@ private byte[] writeBluetoothIc(BluetoothIcData data) { dataOut1[2] = 23; dataOut = dataOut1; } - if (DEBUG) appendToLog(byteArrayToString(dataOut)); + Logger.debug(byteArrayToString(dataOut)); return dataOut; } return null; @@ -166,7 +159,7 @@ public boolean isMatchBluetoothIcToWrite(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 BluetoothIc.Reply with payload = " + byteArrayToString(connectorData.dataValues) + " for writeData BluetoothIc." + bluetoothIcToWrite.get(0).bluetoothIcPayloadEvent.toString()); + Logger.debug("PkData: matched BluetoothIc.Reply with payload = {} for writeData BluetoothIc.{}", byteArrayToString(connectorData.dataValues), bluetoothIcToWrite.get(0).bluetoothIcPayloadEvent); if (bluetoothIcToWrite.get(0).bluetoothIcPayloadEvent == BluetoothIcPayloadEvents.BLUETOOTH_GET_VERSION) { if (connectorData.dataValues.length > 2) { int length = mBluetoothIcVersion.length; @@ -175,10 +168,10 @@ public boolean isMatchBluetoothIcToWrite(ConnectorData connectorData) { if (mBluetoothIcVersion[0] == 3) icsModel = 463; else if (mBluetoothIcVersion[0] == 1) icsModel = 108; mBluetoothIcVersionUpdated = true; - if (DEBUG) appendToLog("mBluetoothIcVersionUpdated is true"); + Logger.debug("mBluetoothIcVersionUpdated is true"); bprocessed = true; } - if (DEBUG_PKDATA) appendToLog("PkData: matched BluetoothIc.Reply.GetVersion with version = " + byteArrayToString(mBluetoothIcVersion)); + Logger.pkData("PkData: matched BluetoothIc.Reply.GetVersion with version = {}", byteArrayToString(mBluetoothIcVersion)); } else if (bluetoothIcToWrite.get(0).bluetoothIcPayloadEvent == BluetoothIcPayloadEvents.BLUETOOTH_GET_DEVICE_NAME) { if (connectorData.dataValues.length > 2) { byte[] deviceName1 = new byte[connectorData.dataValues.length - 2]; @@ -186,15 +179,15 @@ public boolean isMatchBluetoothIcToWrite(ConnectorData connectorData) { deviceName = deviceName1; bprocessed = true; } - if (DEBUG_PKDATA) appendToLog("PkData: matched mBluetoothIc.GetDeviceName.Reply data is found with name=" + byteArrayToString(deviceName) + ", dataValues.length=" + connectorData.dataValues.length + ", deviceName.length=" + deviceName.length); + Logger.pkData("PkData: matched mBluetoothIc.GetDeviceName.Reply data is found with name={}, dataValues.length={}, deviceName.length={}", byteArrayToString(deviceName), connectorData.dataValues.length, deviceName.length); } else { bprocessed = true; - if (DEBUG) appendToLog("matched mBluetoothIc.Other.Reply data is found."); + Logger.debug("matched mBluetoothIc.Other.Reply data is found."); } String string = "Up3 " + (bprocessed ? "" : "Unprocessed, ") + bluetoothIcToWrite.get(0).bluetoothIcPayloadEvent.toString() + ", " + byteArrayToString(data1); utility.writeDebug2File(string); bluetoothIcToWrite.remove(0); sendDataToWriteSent = 0; - if (DEBUG_PKDATA) appendToLog("PkData: new mBluetoothIcToWrite size = " + bluetoothIcToWrite.size()); + Logger.pkData("PkData: new mBluetoothIcToWrite size = {}", bluetoothIcToWrite.size()); } } } @@ -209,14 +202,13 @@ public byte[] sendBluetoothIcToWrite() { } else if (sendDataToWriteSent >= 5) { int oldSize = bluetoothIcToWrite.size(); bluetoothIcToWrite.remove(0); sendDataToWriteSent = 0; - if (DEBUG) appendToLog("Removed after sending count-out with oldSize = " + oldSize + ", updated mBluetoothIcToWrite.size() = " + bluetoothIcToWrite.size()); - if (DEBUG) appendToLog("Removed after sending count-out."); + Logger.debug("Removed after sending count-out with oldSize = {}, updated mBluetoothIcToWrite.size() = {}", oldSize, bluetoothIcToWrite.size()); String string = "Problem in sending data to Bluetooth Module. Removed data sending after count-out"; if (userDebugEnable) Toast.makeText(context, string, Toast.LENGTH_SHORT).show(); - else appendToLogView(string); + else Logger.toLogView(string).info(); bluetoothFailure = true; } else { - if (DEBUG) appendToLog("size = " + bluetoothIcToWrite.size() + ", PayloadEvents = " + bluetoothIcToWrite.get(0).bluetoothIcPayloadEvent.toString()); + Logger.debug("size = {}, PayloadEvents = {}", bluetoothIcToWrite.size(), bluetoothIcToWrite.get(0).bluetoothIcPayloadEvent); sendDataToWriteSent++; return writeBluetoothIc(bluetoothIcToWrite.get(0)); } @@ -241,8 +233,8 @@ void addBluetoothToWrite(BluetoothIcData cs108BluetoothIcData) { } if (repeatRequest == false) { bluetoothIcToWrite.add(cs108BluetoothIcData); - appendToLog("2b GET_DEVICE_NAME"); - if (DEBUG_PKDATA) appendToLog("add " + cs108BluetoothIcData.bluetoothIcPayloadEvent.toString() + " to mBluetoothIcToWrite with length = " + bluetoothIcToWrite.size()); + Logger.info("2b GET_DEVICE_NAME"); + Logger.pkData("add {} to mBluetoothIcToWrite with length = {}",cs108BluetoothIcData.bluetoothIcPayloadEvent, bluetoothIcToWrite.size()); } } } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/BluetoothGatt.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/BluetoothGatt.java index 4e0b367..76f923f 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/BluetoothGatt.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/BluetoothGatt.java @@ -29,12 +29,6 @@ import static android.content.Context.LOCATION_SERVICE; 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 = true, DEBUG_BTOP = false; - static final String TAG = "Hello"; - private Handler mHandler = new Handler(); private ReaderDevice mBluetoothDevice; @@ -131,45 +125,45 @@ public boolean setConnectionHSpeedA(boolean connectionHSpeed) { public void onConnectionStateChange(android.bluetooth.BluetoothGatt gatt, int status, int newState) { boolean DEBUG = false; super.onConnectionStateChange(gatt, status, newState); - if (DEBUG_CONNECT) appendToLog("newState = " + newState); + Logger.connect("newState = {}", newState); if (gatt != bluetoothGatt) { - if (DEBUG) appendToLog("abcc mismatched mBluetoothGatt = " + (gatt != bluetoothGatt) + ", status = " + status); + Logger.debug("abcc mismatched mBluetoothGatt = {}, status = {}", gatt != bluetoothGatt, status); } else { bluetoothConnectionState = newState; switch (newState) { case BluetoothProfile.STATE_DISCONNECTED: - if (DEBUG_CONNECT) appendToLog("state=Disconnected with status = " + status); + Logger.connect("state=Disconnected with status = {}", status); if (disconnectRunning == false) { - if (DEBUG) appendToLog("disconnect b"); + Logger.debug("disconnect b"); disconnect(); } break; case BluetoothProfile.STATE_CONNECTED: - if (DEBUG_CONNECT) appendToLog("state=Connected with status = " + status); + Logger.connect("state=Connected with status = {}", status); if (disconnectRunning) { - if (DEBUG) appendToLog("abcc disconnectRunning !!!"); + Logger.debug("abcc disconnectRunning !!!"); break; } mStreamWriteCount = mStreamWriteCountOld = 0; _readCharacteristic_in_progress = _writeCharacteristic_in_progress = false; if (bDiscoverStarted) { - if (DEBUG) appendToLog("abc discovery has been started before"); + Logger.debug("abc discovery has been started before"); break; } - if (DEBUG_CONNECT) appendToLog("Start discoverServices"); + Logger.connect("Start discoverServices"); if (discoverServices()) { bDiscoverStarted = true; - if (DEBUG_CONNECT) appendToLog("state=Connected. discoverServices starts with status = " + status); + Logger.connect("state=Connected. discoverServices starts with status = {}", status); } else { - if (DEBUG) appendToLog("state=Connected. discoverServices FAIL"); + Logger.debug("state=Connected. discoverServices FAIL"); } utility.setReferenceTimeMs(); mHandler.removeCallbacks(mReadRssiRunnable); mHandler.post(mReadRssiRunnable); break; default: - if (DEBUG) appendToLog("state=" + newState); + Logger.debug("state={}",newState); break; } } @@ -179,36 +173,35 @@ public void onConnectionStateChange(android.bluetooth.BluetoothGatt gatt, int st @Override public void onServicesDiscovered(android.bluetooth.BluetoothGatt gatt, int status) { - boolean DEBUG = false; super.onServicesDiscovered(gatt, status); if (gatt != bluetoothGatt) { - if (DEBUG) appendToLog("INVALID mBluetoothGatt"); + Logger.debug("INVALID mBluetoothGatt"); } else if (status != android.bluetooth.BluetoothGatt.GATT_SUCCESS) { - if (DEBUG) appendToLog("status=" + status + ". restart discoverServices"); + Logger.debug("status={}. restart discoverServices", status); discoverServices(); } else { UUID UUID_READER_SERVICE = UUID.fromString("0000" + strReaderServiceUUID + "-0000-1000-8000-00805f9b34fb"); mReaderStreamOutCharacteristic = getCharacteristic(UUID_READER_SERVICE, UUID_READER_STREAM_OUT_CHARACTERISTIC); mReaderStreamInCharacteristic = getCharacteristic(UUID_READER_SERVICE, UUID_READER_STREAM_IN_CHARACTERISTIC); - if (DEBUG_BTOP) appendToLog("mReaderStreamOutCharacteristic flag = " + mReaderStreamOutCharacteristic.getProperties()); - if (DEBUG_BTOP) appendToLog("mReaderStreamInCharacteristic flag = " + mReaderStreamInCharacteristic.getProperties()); + Logger.btop("mReaderStreamOutCharacteristic flag = {}", mReaderStreamOutCharacteristic.getProperties()); + Logger.btop("mReaderStreamInCharacteristic flag = {}", mReaderStreamInCharacteristic.getProperties()); if (mReaderStreamInCharacteristic == null || mReaderStreamOutCharacteristic == null) { - if (DEBUG_BTOP) appendToLog("restart discoverServices"); + Logger.debug("restart discoverServices"); discoverServices(); return; } if (checkSelfPermissionBLUETOOTH() == false) return; if (!bluetoothGatt.setCharacteristicNotification(mReaderStreamInCharacteristic, true)) { - if (DEBUG) appendToLog("setCharacteristicNotification() FAIL"); + Logger.debug("setCharacteristicNotification() FAIL"); } else { int mtu_requested = 255; boolean bValue = gatt.requestMtu(mtu_requested); - if (DEBUG_BTOP) appendToLog("requestMtu[" + mtu_requested + "] with result=" + bValue); + Logger.btop("requestMtu[{}] with result={}",mtu_requested, bValue); - if (DEBUG_BTOP) appendToLog("characteristicListRead = " + characteristicListRead); + Logger.btop("characteristicListRead = {}", characteristicListRead); if (characteristicListRead == false) { - if (DEBUG) appendToLog("with services"); + Logger.debug("with services"); mBluetoothGattCharacteristicToRead.clear(); List ss = bluetoothGatt.getServices(); for (BluetoothGattService service : ss) { @@ -219,30 +212,26 @@ public void onServicesDiscovered(android.bluetooth.BluetoothGatt gatt, int statu int properties = characteristic.getProperties(); boolean do_something = false; if ((properties & BluetoothGattCharacteristic.PROPERTY_READ) > 0) { - if (DEBUG) - appendToLog("service=" + uuid + ", characteristic=" + characteristicUuid + ", property=read"); + Logger.debug("service={}, characteristic={}, property=read", uuid, characteristicUuid); mBluetoothGattCharacteristicToRead.add(characteristic); do_something = true; } if ((properties & BluetoothGattCharacteristic.PROPERTY_WRITE) > 0) { - if (DEBUG) - appendToLog("service=" + uuid + ", characteristic=" + characteristicUuid + ", property=write"); + Logger.debug("service={} characteristic={}, property=write", uuid, characteristicUuid); do_something = true; } if ((properties & BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) { - if (DEBUG) - appendToLog("service=" + uuid + ", characteristic=" + characteristicUuid + ", property=notify"); + Logger.debug("service={}, characteristic={}, property=notify", uuid, characteristicUuid); do_something = true; } if (!do_something) { - if (DEBUG) - appendToLog("service=" + uuid + ", characteristic=" + characteristicUuid + ", property=" + String.format("%X ", properties)); + Logger.debug("service={}, characteristic={}, property={}", uuid, characteristicUuid, String.format("%X ", properties)); } } } if (true) mBluetoothGattCharacteristicToRead.clear(); mHandler.removeCallbacks(mReadCharacteristicRunnable); - if (DEBUG) appendToLog("starts in onServicesDiscovered"); + Logger.debug("starts in onServicesDiscovered"); mHandler.postDelayed(mReadCharacteristicRunnable, 500); } } @@ -251,30 +240,28 @@ public void onServicesDiscovered(android.bluetooth.BluetoothGatt gatt, int statu @Override public void onReadRemoteRssi(android.bluetooth.BluetoothGatt gatt, int rssi, int status) { - boolean DEBUG = false; super.onReadRemoteRssi(gatt, rssi, status); if (gatt != bluetoothGatt) { - if (DEBUG) utility.appendToLogRunnable("onReadRemoteRssi: INVALID mBluetoothGatt"); + Logger.runDebug("onReadRemoteRssi: INVALID mBluetoothGatt"); } else if (status != android.bluetooth.BluetoothGatt.GATT_SUCCESS) { - if (DEBUG) utility.appendToLogRunnable("onReadRemoteRssi: NOT GATT_SUCCESS"); + Logger.runDebug("onReadRemoteRssi: NOT GATT_SUCCESS"); } else { - if (DEBUG_BTOP) utility.appendToLogRunnable("onReadRemoteRssi: rssi=" + rssi); + Logger.runDebug("onReadRemoteRssi: rssi={}", rssi); mRssi = rssi; } } private final Runnable mReadRssiRunnable = new Runnable() { - boolean DEBUG = false; @Override public void run() { if (checkSelfPermissionBLUETOOTH() == false) return; if (bluetoothGatt == null) { - if (DEBUG) appendToLog("mReadRssiRunnable: readRemoteRssi with null mBluetoothGatt"); + Logger.debug("mReadRssiRunnable: readRemoteRssi with null mBluetoothGatt"); return; } else if (bluetoothGatt.readRemoteRssi()) { - if (DEBUG_BTOP) appendToLog("mReadRssiRunnable: readRemoteRssi starts"); + Logger.btop("mReadRssiRunnable: readRemoteRssi starts"); } else { - if (DEBUG) appendToLog("mReadRssiRunnable: readRemoteRssi FAIL"); + Logger.debug("mReadRssiRunnable: readRemoteRssi FAIL"); } } }; @@ -283,11 +270,11 @@ public void run() { public void onDescriptorWrite(android.bluetooth.BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { super.onDescriptorWrite(gatt, descriptor, status); if (gatt != bluetoothGatt) { - if (DEBUG) appendToLog("INVALID mBluetoothGatt"); + Logger.debug("INVALID mBluetoothGatt"); } else if (status != android.bluetooth.BluetoothGatt.GATT_SUCCESS) { - if (DEBUG) appendToLog("status=" + status); + Logger.debug("status={}", status); } else { - if (DEBUG) appendToLog("descriptor=" + descriptor.getUuid().toString().substring(4, 8)); + Logger.debug("descriptor={}", descriptor.getUuid().toString().substring(4, 8)); } } @@ -303,11 +290,11 @@ private boolean writeDescriptor(BluetoothGattDescriptor descriptor, byte[] value public void onDescriptorRead(android.bluetooth.BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) { super.onDescriptorRead(gatt, descriptor, status); if (gatt != bluetoothGatt) { - if (DEBUG) utility.appendToLogRunnable("onDescriptorRead(): INVALID mBluetoothGatt"); + Logger.runDebug("onDescriptorRead(): INVALID mBluetoothGatt"); } else if (status != android.bluetooth.BluetoothGatt.GATT_SUCCESS) { - if (DEBUG) utility.appendToLogRunnable("onDescriptorRead(): status=" + status); + Logger.runDebug("onDescriptorRead(): status={}", status); } else { - if (DEBUG) utility.appendToLogRunnable("onDescriptorRead(): descriptor=" + descriptor.getUuid().toString().substring(4, 8)); + Logger.runDebug("onDescriptorRead(): descriptor={}", descriptor.getUuid().toString().substring(4, 8)); } } @@ -315,9 +302,9 @@ public void onDescriptorRead(android.bluetooth.BluetoothGatt gatt, BluetoothGatt public void onCharacteristicRead(android.bluetooth.BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { super.onCharacteristicRead(gatt, characteristic, status); if (gatt != bluetoothGatt) { - if (DEBUG) appendToLog("INVALID mBluetoothGatt"); + Logger.debug("INVALID mBluetoothGatt"); } else if (status != android.bluetooth.BluetoothGatt.GATT_SUCCESS) { - if (DEBUG) appendToLog("status=" + status); + Logger.debug("status={}", status); } else { _readCharacteristic_in_progress = false; @@ -332,8 +319,8 @@ public void onCharacteristicRead(android.bluetooth.BluetoothGatt gatt, Bluetooth for (byte b : v) stringBuilder.append(String.format("%02X ", b)); } - if (DEBUG) appendToLog(serviceUuidd + ", " + characteristicUuid + " = " + stringBuilder.toString() + " = " + new String(v)); - if (DEBUG) appendToLog("starts in onCharacteristicRead"); + Logger.debug("{}, {} = {} = {}", serviceUuidd, characteristicUuid, stringBuilder, new String(v)); + Logger.debug("starts in onCharacteristicRead"); mReadCharacteristicRunnable.run(); } } @@ -342,17 +329,17 @@ public void onCharacteristicRead(android.bluetooth.BluetoothGatt gatt, Bluetooth @Override public void run() { if (mBluetoothGattCharacteristicToRead.size() == 0) { - if (DEBUG) appendToLog("mReadCharacteristicRunnable(): read finish"); + Logger.debug("mReadCharacteristicRunnable(): read finish"); characteristicListRead = true; } else if (isBleBusy()) { - if (DEBUG) appendToLog("mReadCharacteristicRunnable(): PortBusy"); + Logger.debug("mReadCharacteristicRunnable(): PortBusy"); mHandler.postDelayed(mReadCharacteristicRunnable, 100); } else if (readCharacteristic(mBluetoothGattCharacteristicToRead.get(0)) == false) { - if (DEBUG) appendToLog("mReadCharacteristicRunnable(): Read FAIL"); + Logger.debug("mReadCharacteristicRunnable(): Read FAIL"); mHandler.postDelayed(mReadCharacteristicRunnable, 100); } else { mBluetoothGattCharacteristicToRead.remove(0); - if (DEBUG) appendToLog("mReadCharacteristicRunnable(): starts in mReadCharacteristicRunnable"); + Logger.debug("mReadCharacteristicRunnable(): starts in mReadCharacteristicRunnable"); mHandler.postDelayed(mReadCharacteristicRunnable, 10000); } } @@ -369,16 +356,15 @@ private boolean readCharacteristic(BluetoothGattCharacteristic characteristic) { @Override public void onCharacteristicWrite(android.bluetooth.BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { - boolean DEBUG = false; super.onCharacteristicWrite(gatt, characteristic, status); if (gatt != bluetoothGatt) { - if (DEBUG) appendToLog("INVALID mBluetoothGatt"); + Logger.debug("INVALID mBluetoothGatt"); } else if (status != android.bluetooth.BluetoothGatt.GATT_SUCCESS) { onCharacteristicWriteFailue++; - if (DEBUG) appendToLog("status=" + status); + Logger.debug("status={}", status); } else { onCharacteristicWriteFailue = 0; - if (DEBUG) appendToLog("characteristic=" + characteristic.getUuid().toString().substring(4, 8) + ", sent " + (mStreamWriteCount - mStreamWriteCountOld) + " bytes"); + Logger.debug("characteristic={}, sent {} bytes", characteristic.getUuid().toString().substring(4, 8), mStreamWriteCount - mStreamWriteCountOld); _writeCharacteristic_in_progress = false; } } @@ -387,11 +373,11 @@ public void onCharacteristicWrite(android.bluetooth.BluetoothGatt gatt, Bluetoot private int onCharacteristicWriteFailue = 0; public boolean writeBleStreamOut(byte[] value) { if (bluetoothGatt == null) { - if (DEBUG) appendToLog("ERROR with NULL mBluetoothGatt"); + Logger.debug("ERROR with NULL mBluetoothGatt"); } else if (mReaderStreamOutCharacteristic == null) { - if (DEBUG) appendToLog("ERROR with NULL mReaderStreamOutCharacteristic"); + Logger.debug("ERROR with NULL mReaderStreamOutCharacteristic"); } else if (isBleBusy() || characteristicListRead == false) { - if (true) appendToLog("isBleBusy() = " + isBleBusy() + ", characteristicListRead = " + characteristicListRead); + Logger.info("isBleBusy() = {}, characteristicListRead = ", isBleBusy(), characteristicListRead); } else { mReaderStreamOutCharacteristic.setValue(value); if (checkSelfPermissionBLUETOOTH() == false) return false; @@ -399,7 +385,7 @@ public boolean writeBleStreamOut(byte[] value) { if (bValue == false) writeBleFailure++; else { writeBleFailure = 0; - if (utility.DEBUG_BTDATA || true) appendToLogView("BtDataOut: " + byteArrayToString(value)); + Logger.btdData("BtDataOut: {}", byteArrayToString(value)); writeDebug2File("Down " + byteArrayToString(value)); _writeCharacteristic_in_progress = true; mStreamWriteCountOld = mStreamWriteCount; @@ -407,10 +393,10 @@ public boolean writeBleStreamOut(byte[] value) { return true; } if (false && (writeBleFailure != 0 || onCharacteristicWriteFailue != 0)) { - appendToLogView("failure in writeCharacteristic(" + byteArrayToString(value) + "), writeBleFailure = " + writeBleFailure + ", onCharacteristicWriteFailue = " + onCharacteristicWriteFailue); + Logger.trace("failure in writeCharacteristic({}), writeBleFailure = {}, onCharacteristicWriteFailue = {}", byteArrayToString(value), writeBleFailure, onCharacteristicWriteFailue); if (writeBleFailure > 5 || onCharacteristicWriteFailue > 5) { - appendToLogView("writeBleFailure is too much. start disconnect !!!"); - appendToLog("disconnect C"); + Logger.trace("writeBleFailure is too much. start disconnect !!!"); + Logger.trace("disconnect C"); disconnect(); //mReaderStreamOutCharacteristic = null; } } @@ -424,13 +410,10 @@ public void onCharacteristicChanged(android.bluetooth.BluetoothGatt gatt, Blueto super.onCharacteristicChanged(gatt, characteristic); if (gatt != bluetoothGatt) { utility.writeDebug2File("Up1 Error, mismatched gatt"); - if (DEBUG) { - byte[] v = characteristic.getValue(); - utility.appendToLogRunnable("onCharacteristicChanged(): INVALID mBluetoothGatt, with address = " + gatt.getDevice().getAddress() + ", values =" + byteArrayToString(v)); - } + Logger.runDebug("onCharacteristicChanged(): INVALID mBluetoothGatt, with address = {}, values ={}", gatt.getDevice().getAddress(), byteArrayToString(characteristic.getValue())); } else if (!characteristic.equals(mReaderStreamInCharacteristic)) { utility.writeDebug2File("Up1 Error, mismatched characteristic"); - if (DEBUG) utility.appendToLogRunnable("onCharacteristicChanged(): characteristic is not ReaderSteamIn"); + Logger.runDebug("onCharacteristicChanged(): characteristic is not ReaderSteamIn"); } else if (bluetoothConnectionState == BluetoothProfile.STATE_DISCONNECTED) { utility.writeDebug2File("Up1 Error, disconnected bluetoothConnectionState"); streamInBufferHead = 0; @@ -438,27 +421,27 @@ public void onCharacteristicChanged(android.bluetooth.BluetoothGatt gatt, Blueto streamInBufferSize = 0; } else { byte[] v = characteristic.getValue(); - if (false) utility.appendToLogRunnable("onCharacteristicChanged(): VALID mBluetoothGatt, values =" + byteArrayToString(v)); + if (false) Logger.runDebug("onCharacteristicChanged(): VALID mBluetoothGatt, values ={}", byteArrayToString(v)); synchronized (arrayListStreamIn) { if (v.length != 0) { streamInTotalCounter++; } if (streamInBufferReseting) { - if (DEBUG) utility.appendToLogRunnable("onCharacteristicChanged(): RESET."); + Logger.runDebug("onCharacteristicChanged(): RESET."); streamInBufferReseting = false; streamInBufferSize = 0; streamInBytesMissing = 0; } if (streamInBufferSize + v.length > streamInBuffer.length) { utility.writeDebug2File("Up1 Error, insufficient buffer. missed " + byteArrayToString(v)); - Log.i(TAG, ".Hello: missing data = " + byteArrayToString(v)); + Logger.info(".Hello: missing data = {}", byteArrayToString(v)); if (streamInBytesMissing == 0) { streamInOverflowTime = utility.getReferencedCurrentTimeMs(); } streamInBytesMissing += v.length; } else { if (true) utility.writeDebug2File("Up1 " + byteArrayToString(v)); - if (utility.DEBUG_BTDATA) Log.i(TAG, "BtDataIn= " + byteArrayToString(v)); + Logger.btdData("BtDataIn= {}", byteArrayToString(v)); if (isStreamInBufferRing) { streamInBufferPush(v, 0, v.length); } else { @@ -469,7 +452,6 @@ public void onCharacteristicChanged(android.bluetooth.BluetoothGatt gatt, Blueto streamInAddTime = utility.getReferencedCurrentTimeMs(); if (streamInRequest == false) { streamInRequest = true; - //appendToLog("post runnableProcessBleStreamInData after onCharacteristicChanged"); mHandler.removeCallbacks(runnableProcessBleStreamInData); mHandler.post(runnableProcessBleStreamInData); } } @@ -496,7 +478,6 @@ public interface BluetoothGattConnectorCallback { public void run() { streamInRequest = false; processBleStreamInData(); - //appendToLog("post runnableProcessBleStreamInData within runnableProcessBleStreamInData"); mHandler.postDelayed(runnableProcessBleStreamInData, intervalProcessBleStreamInData); } }; @@ -504,13 +485,13 @@ public void run() { @Override public void onMtuChanged(android.bluetooth.BluetoothGatt gatt, int mtu, int status) { super.onMtuChanged(gatt, mtu, status); - Log.i(TAG, "onMtuChanged starts"); + Logger.info("onMtuChanged starts"); if (gatt != bluetoothGatt) { - if (DEBUG) utility.appendToLogRunnable("onMtuChanged: INVALID mBluetoothGatt"); + Logger.runDebug("onMtuChanged: INVALID mBluetoothGatt"); } else if (status != android.bluetooth.BluetoothGatt.GATT_SUCCESS) { - if (DEBUG) utility.appendToLogRunnable("onMtuChanged: status=" + status); + Logger.runDebug("onMtuChanged: status={}", status); } else { - if (DEBUG_BTOP) utility.appendToLogRunnable("onMtuChanged: mtu=" + mtu); + Logger.runDebug("onMtuChanged: mtu={}", mtu); } } @@ -518,23 +499,21 @@ public void onMtuChanged(android.bluetooth.BluetoothGatt gatt, int mtu, int stat public void onReliableWriteCompleted(android.bluetooth.BluetoothGatt gatt, int status) { super.onReliableWriteCompleted(gatt, status); if (gatt != bluetoothGatt) { - if (true) utility.appendToLogRunnable("INVALID mBluetoothGatt"); + Logger.runDebug("INVALID mBluetoothGatt"); } else { - if (true) utility.appendToLogRunnable("onReliableWriteCompleted(): status=" + status); + Logger.runDebug("onReliableWriteCompleted(): status={}", status); //mBluetoothGatt.abortReliableWrite(); } } private Context mContext; Utility utility; String strReaderServiceUUID; //private Activity activity; public BluetoothGatt(Context context, Utility utility, String strReaderServiceUUID) { - boolean DEBUG = false; mContext = context; //activity = (Activity) mContext; this.strReaderServiceUUID = strReaderServiceUUID; - this.utility = utility; DEBUG_PKDATA = utility.DEBUG_PKDATA; DEBUG_APDATA = utility.DEBUG_APDATA; + this.utility = utility; // BluetoothConfigManager mConfigManager; // mConfigManager = BluetoothConfigManager.getInstance(); -// appendToLog("BluetoothConfigManager.getIoCapability = " + mConfigManager.getIoCapability()); PackageManager mPackageManager = mContext.getPackageManager(); if (mPackageManager.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { @@ -543,27 +522,27 @@ public BluetoothGatt(Context context, Utility utility, String strReaderServiceUU if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) { boolean isBle5 = bluetoothAdapter.isLeCodedPhySupported(); boolean isAdvertising5 = bluetoothAdapter.isLeExtendedAdvertisingSupported(); - if (DEBUG) appendToLog("isBle5 = " + isBle5 + ", isAdvertising5 = " + isAdvertising5); + Logger.debug("isBle5 = {}, isAdvertising5 = {}", isBle5, isAdvertising5); } } else { bluetoothAdapter = null; - if (DEBUG) appendToLog("NO BLUETOOTH_LE"); + Logger.debug("NO BLUETOOTH_LE"); } - if (DEBUG) { + if (Logger.LEVEL.ordinal() <= Logger.LogLevel.DEBUG.ordinal()) { LocationManager locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE); - if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) appendToLog("permitted ACCESS_FINE_LOCATION"); - if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) appendToLog("permitted ACCESS_COARSE_LOCATION"); + if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) Logger.debug("permitted ACCESS_FINE_LOCATION"); + if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) Logger.debug("permitted ACCESS_COARSE_LOCATION"); List stringProviderList = locationManager.getAllProviders(); for (String stringProvider : stringProviderList) - appendToLog("Provider = " + stringProvider); + Logger.debug("Provider = {}", stringProvider); if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) - appendToLog("ProviderEnabled GPS_PROVIDER"); + Logger.debug("ProviderEnabled GPS_PROVIDER"); if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) - appendToLog("ProviderEnabled NETWORK_PROVIDER"); + Logger.debug("ProviderEnabled NETWORK_PROVIDER"); if (locationManager.isProviderEnabled(LocationManager.PASSIVE_PROVIDER)) - appendToLog("ProviderEnabled PASSIVE_PROVIDER"); + Logger.debug("ProviderEnabled PASSIVE_PROVIDER"); } } @@ -572,8 +551,7 @@ public BluetoothGatt(Context context, Utility utility, String strReaderServiceUU private boolean isLocationAccepted = false; boolean bAlerting = false; //CustomAlertDialog appdialog; public boolean scanLeDevice(boolean enable, BluetoothAdapter.LeScanCallback mLeScanCallback, ScanCallback mScanCallBack) { - boolean DEBUG = false; - if (DEBUG) appendToLog("StreamOut: enable = " + enable); + Logger.debug("StreamOut: enable = {}", enable); boolean result = false; boolean locationReady = true; if (enable && isBleConnected()) return true; @@ -584,17 +562,15 @@ public boolean scanLeDevice(boolean enable, BluetoothAdapter.LeScanCallback mLeS if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) == false && locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) == false) isLocationAccepted = false; } - if (DEBUG_SCAN) appendToLog("isLocationAccepted = " + isLocationAccepted + ", bAlerting = " + bAlerting + ", bleEnableRequestShown = " + bleEnableRequestShown); + Logger.scan("isLocationAccepted = {}, bAlerting = {}, bleEnableRequestShown = {}",isLocationAccepted, bAlerting, bleEnableRequestShown); /*if (false && isLocationAccepted == false) { if (bAlerting == false && bleEnableRequestShown0 == false) { bAlerting = true; - if (DEBUG) appendToLog("StreamOut: new AlertDialog"); popupAlert(); } return false; }*/ /* - if (DEBUG) appendToLog("StreamOut: Passed AlertDialog"); if (enable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (DEBUG) appendToLog("Checking permission and grant !!!"); LocationManager locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE); @@ -642,9 +618,9 @@ public void onClick(View v) { if (isBLUETOOTH_CONNECTinvalid()) return false; if (locationReady == false) { - if (DEBUG) appendToLog("AccessCoarseLocatin is NOT granted"); + Logger.debug("AccessCoarseLocatin is NOT granted"); } else if (bluetoothAdapter == null) { - if (DEBUG) appendToLog("scanLeDevice(" + enable + ") with NULL mBluetoothAdapter"); + Logger.debug("scanLeDevice({}) with NULL mBluetoothAdapter"); /* } else if (!bluetoothAdapter.isEnabled()) { if (DEBUG) appendToLog("StreamOut: bleEnableRequestShown = " + bleEnableRequestShown); if (bleEnableRequestShown == false) { @@ -660,12 +636,12 @@ public void onClick(View v) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { bluetoothLeScanner = bluetoothAdapter.getBluetoothLeScanner(); if (bluetoothLeScanner == null) { - if (DEBUG) appendToLog("scanLeDevice(" + enable + ") with NULL BluetoothLeScanner"); + Logger.debug("scanLeDevice({}) with NULL BluetoothLeScanner", enable); return false; } } - if (enable == false) { - if (true) appendToLog("abcc scanLeDevice(" + enable + ") with mScanCallBack is " + (mScanCallBack != null ? "VALID" : "INVALID")); + if (!enable) { + Logger.info("abcc scanLeDevice({}) with mScanCallBack is {}", enable, mScanCallBack != null ? "VALID" : "INVALID"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (mScanCallBack != null) bluetoothLeScanner.stopScan(mScanCallBack); } else { @@ -674,11 +650,11 @@ public void onClick(View v) { mScanning = false; result = true; } else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - if (true) appendToLog("scanLeDevice(" + enable + "): START with mleScanner. ActivityCompat.checkSelfPermission(activity, Manifest.permission.BLUETOOTH_SCAN) = " + ActivityCompat.checkSelfPermission(mContext, Manifest.permission.BLUETOOTH_SCAN)); + Logger.info("scanLeDevice({}): START with mleScanner. ActivityCompat.checkSelfPermission(activity, Manifest.permission.BLUETOOTH_SCAN) = {}", enable, ActivityCompat.checkSelfPermission(mContext, Manifest.permission.BLUETOOTH_SCAN)); if (isBLUETOOTH_CONNECTinvalid()) return false; else bluetoothLeScanner.startScan(mScanCallBack); } else { - if (true) appendToLog("scanLeDevice(" + enable + "): START with mBluetoothAdapter"); + Logger.info("scanLeDevice({}): START with mBluetoothAdapter", enable); bluetoothAdapter.startLeScan(mLeScanCallback); } mScanning = true; result = true; @@ -752,20 +728,19 @@ public void onReceive(Context context, Intent intent) { }; */ public boolean connectBle(ReaderDevice readerDevice) { - boolean DEBUG = false; - if (DEBUG) appendToLog("abcc: start connecting " + readerDevice.getName()); + Logger.debug("abcc: start connecting {}", readerDevice.getName()); if (readerDevice == null) { - if (DEBUG) appendToLog("with NULL readerDevice"); + Logger.debug("with NULL readerDevice"); } else { String address = readerDevice.getAddress(); if (bluetoothAdapter == null) { - if (DEBUG) appendToLog("connectBle[" + address + "] with NULL mBluetoothAdapter"); + Logger.debug("connectBle[{}] with NULL mBluetoothAdapter", address); } else if (!bluetoothAdapter.isEnabled()) { - if (DEBUG) appendToLog("connectBle[" + address + "] with DISABLED mBluetoothAdapter"); + Logger.debug("connectBle[{}] with DISABLED mBluetoothAdapter", address); } else { utility.debugFileSetup(); utility.debugFileEnable(true); utility.setReferenceTimeMs(); - if (DEBUG_CONNECT) appendToLog("connectBle[" + address + "]: connectGatt starts"); + Logger.connect("connectBle[{}]: connectGatt starts", address); bluetoothConnectionState = -1; if (checkSelfPermissionBLUETOOTH() == false) return false; bluetoothGatt = bluetoothAdapter.getRemoteDevice(address).connectGatt(mContext, false, this); @@ -773,16 +748,16 @@ public boolean connectBle(ReaderDevice readerDevice) { if (false && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (true) { bluetoothGatt.requestConnectionPriority(android.bluetooth.BluetoothGatt.CONNECTION_PRIORITY_HIGH); - if (DEBUG) appendToLog("Stream Set to HIGH"); + Logger.debug("Stream Set to HIGH"); } else { bluetoothGatt.requestConnectionPriority(android.bluetooth.BluetoothGatt.CONNECTION_PRIORITY_BALANCED); - if (DEBUG) appendToLog("Stream Set to BALANCED"); + Logger.debug("Stream Set to BALANCED"); } } mBluetoothDevice = readerDevice; characteristicListRead = true; //skip in case there is problem in completing reading characteristic features, causing endless reading 0706 and 0C02 - appendToLog("post runnableProcessBleStreamInData after connectBle"); + Logger.info("post runnableProcessBleStreamInData after connectBle"); mHandler.removeCallbacks(runnableProcessBleStreamInData); mHandler.post(runnableProcessBleStreamInData); return true; } @@ -791,16 +766,16 @@ public boolean connectBle(ReaderDevice readerDevice) { } public void disconnect() { - appendToLog("abcc: start disconnect "); + Logger.info("abcc: start disconnect "); if (bluetoothGatt == null) { - if (DEBUG) appendToLog("NULL mBluetoothGatt"); + Logger.debug("NULL mBluetoothGatt"); } else { utility.debugFileClose(); mReaderStreamOutCharacteristic = null; mHandler.removeCallbacks(mDisconnectRunnable); mHandler.post(mDisconnectRunnable); disconnectRunning = true; - if (DEBUG) appendToLog("abcc done and start mDisconnectRunnable"); - appendToLog("post runnableProcessBleStreamInData after disconnect"); + Logger.debug("abcc done and start mDisconnectRunnable"); + Logger.info("post runnableProcessBleStreamInData after disconnect"); mHandler.removeCallbacks(runnableProcessBleStreamInData); } } @@ -810,12 +785,12 @@ boolean forcedDisconnect1() { mHandler.removeCallbacks(mReadCharacteristicRunnable); if (bluetoothGatt != null) { if (mBluetoothGattActive) { - appendToLog("abcc mDisconnectRunnable(): close mBluetoothGatt"); + Logger.info("abcc mDisconnectRunnable(): close mBluetoothGatt"); if (checkSelfPermissionBLUETOOTH() == false) return false; bluetoothGatt.close(); mBluetoothGattActive = false; } else { - appendToLog("abcc mDisconnectRunnable(): Null mBluetoothGatt"); + Logger.info("abcc mDisconnectRunnable(): Null mBluetoothGatt"); bluetoothGatt = null; return true; } @@ -833,19 +808,19 @@ public void run() { int bGattConnection = -1; if (checkSelfPermissionBLUETOOTH() == false) return; if (bluetoothDeviceConnectOld != null) bGattConnection = bluetoothManager.getConnectionState(bluetoothDeviceConnectOld, BluetoothProfile.GATT); - if (DEBUG) appendToLog("abcc DisconnectRunnable(): disconnect with mBluetoothConnectionState = " + bluetoothConnectionState + ", gattConnection = " + bGattConnection); + Logger.debug("abcc DisconnectRunnable(): disconnect with mBluetoothConnectionState = {}, getConnection = {}", bluetoothConnectionState, bGattConnection); if (bluetoothConnectionState < 0) { - appendToLog("abcc DisconnectRunnable(): start mBluetoothGatt.disconnect"); + Logger.info("abcc DisconnectRunnable(): start mBluetoothGatt.disconnect"); bluetoothGatt.disconnect(); bluetoothConnectionState = BluetoothProfile.STATE_DISCONNECTED; } else if (bluetoothConnectionState != BluetoothProfile.STATE_DISCONNECTED) { - appendToLog("abcc 2 DisconnectRunnable(): start mBluetoothGatt.disconnect"); + Logger.info("abcc 2 DisconnectRunnable(): start mBluetoothGatt.disconnect"); if (checkSelfPermissionBLUETOOTH()) { bluetoothGatt.disconnect(); //forcedDisconnect(true); bluetoothConnectionState = BluetoothProfile.STATE_DISCONNECTED; } } else if (forcedDisconnect1()) { - if (DEBUG) appendToLog("abcc mDisconnectRunnable(): END"); + Logger.debug("abcc mDisconnectRunnable(): END"); disconnectRunning = false; if (false) bluetoothAdapter.disable(); done = true; @@ -942,7 +917,6 @@ private void streamInBufferPush(byte[] inData, int inDataOffset, int length) { if (totalTemp > 17 && timeDifference > 1000) { totalReceived = totalTemp; totalTime = timeDifference; - //appendToLog("BtDataIn: totalReceived = " + totalReceived + ", totalTime = " + totalTime); firstTime = System.currentTimeMillis(); totalTemp = 0; } @@ -969,7 +943,6 @@ public boolean isBLUETOOTH_CONNECTinvalid() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && ( ActivityCompat.checkSelfPermission(mContext, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED || ActivityCompat.checkSelfPermission(mContext, Manifest.permission.BLUETOOTH_SCAN) != PackageManager.PERMISSION_GRANTED )) { - appendToLog("requestPermissions BLUETOOTH_CONNECT & BLUETOOTH_CONNECT 123"); requestPermissions(activity, new String[] { Manifest.permission.BLUETOOTH_SCAN, Manifest.permission.BLUETOOTH_CONNECT @@ -977,7 +950,6 @@ public boolean isBLUETOOTH_CONNECTinvalid() { if (false) Toast.makeText(mContext, R.string.toast_permission_not_granted, Toast.LENGTH_SHORT).show(); bValue = true; } - //appendToLog("isBLUETOOTH_CONNECTinvalid returns " + bValue); */ return bValue; } @@ -985,8 +957,6 @@ public boolean isBLUETOOTH_CONNECTinvalid() { String byteArray2DisplayString(byte[] byteData) { return utility.byteArray2DisplayString(byteData); } String byteArrayToString(byte[] packet) { return utility.byteArrayToString(packet); } int byteArrayToInt(byte[] bytes) { return utility.byteArrayToInt(bytes); } - void appendToLog(String s) { utility.appendToLog(s); } - void appendToLogView(String s) { utility.appendToLogView(s); } void writeDebug2File(String stringDebug) { utility.writeDebug2File(stringDebug); } boolean compareArray(byte[] array1, byte[] array2, int length) { return utility.compareByteArray(array1, array2, length); } void debugFileEnable(boolean enable) { utility.debugFileEnable(enable); } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/ControllerConnector.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/ControllerConnector.java index 29e5c39..80d9639 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/ControllerConnector.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/ControllerConnector.java @@ -1,13 +1,11 @@ package com.csl.cslibrary4a; import android.content.Context; -import android.widget.TextView; import android.widget.Toast; import java.util.ArrayList; public class ControllerConnector { - final boolean DEBUG = false; boolean userDebugEnableDefault = false, userDebugEnable = userDebugEnableDefault; Context context; Utility utility; @@ -17,12 +15,10 @@ public ControllerConnector(Context context, 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); } - private void appendToLog(String s) { utility.appendToLog(s); } - private void appendToLogView(String s) { utility.appendToLogView(s); } private int icsModel = -1; int getCsModel() { - if (false) appendToLog("icsModel = " + icsModel); + Logger.trace("icsModel = {}", icsModel); return icsModel; } @@ -38,7 +34,6 @@ class ControllerReadData { private byte[] controllerVersion = new byte[]{-1, -1, -1}; public String getVersion() { - boolean DEBUG = false; if (controllerVersion[0] == -1) { boolean repeatRequest = false; if (controllerToWrite.size() != 0) { @@ -48,13 +43,13 @@ public String getVersion() { } if (repeatRequest == false) { controllerToWrite.add(ControllerPayloadEvents.CONTROLLER_GET_VERSION); - if (utility.DEBUG_PKDATA || DEBUG) appendToLog("PkData: add GET_VERSION to controllerWrite with length = " + controllerToWrite.size()); + Logger.pkData("PkData: add GET_VERSION to controllerWrite with length = {}", controllerToWrite.size()); } return ""; } else { - if (DEBUG) appendToLog("controllerVersion = " + byteArrayToString(controllerVersion)); + Logger.debug("controllerVersion = {}", byteArrayToString(controllerVersion)); String string = String.valueOf(controllerVersion[0]) + "." + String.valueOf(controllerVersion[1]) + "." + String.valueOf(controllerVersion[2]); - if (DEBUG) appendToLog("controllerVersion string = " + string); + Logger.debug("controllerVersion string = {}", string); return string; } } @@ -70,7 +65,7 @@ public String getSerialNumber() { } if (repeatRequest == false) { controllerToWrite.add(ControllerPayloadEvents.CONTROLLER_GET_SERIALNUMBER); - if (utility.DEBUG_PKDATA) appendToLog("PkData: add GET_SERIALNUMBER to controllerToWrite with length = " + controllerToWrite.size()); + Logger.pkData("PkData: add GET_SERIALNUMBER to controllerToWrite with length = {}", controllerToWrite.size()); } return ""; } else { @@ -86,20 +81,20 @@ public String getSerialNumber() { if (bytes[i] == 0) bytes[i] = 0x30; } } - if (false) appendToLog("serialNumber = " + byteArrayToString(serialNumber) + ", revised = " + byteArrayToString(bytes)); + Logger.trace("serialNumber = {}, revised = {}", byteArrayToString(serialNumber), byteArrayToString(bytes)); String string = utility.byteArray2DisplayString(bytes); - if (string == null || string.length() == 0) { + if (string == null || string.isEmpty()) { string = byteArrayToString(bytes); if (string.length() > 16) string = string.substring(0, 16); } - if (false) appendToLog("string = " + string + " from serial " + byteArrayToString(serialNumber) + ", revised = " + byteArrayToString(bytes)); + Logger.trace("string = {} from serial {}, revised = {}", string, byteArrayToString(serialNumber), byteArrayToString(bytes)); return string; } } private byte[] modelName = null; public String getModelName() { - if (false) appendToLog("modelName = " + byteArrayToString(modelName)); + Logger.trace("modelName = {}", byteArrayToString(modelName)); String strValue = null; if (modelName == null) { boolean repeatRequest = false; @@ -110,23 +105,23 @@ public String getModelName() { } if (repeatRequest == false) { controllerToWrite.add(ControllerPayloadEvents.CONTROLLER_GET_MODELNAME); - if (false) appendToLog("PkData: add GET_MODELNAME to controllerWrite with length = " + controllerToWrite.size()); + Logger.trace("PkData: add GET_MODELNAME to controllerWrite with length = {}", controllerToWrite.size()); } } else { strValue = utility.byteArray2DisplayString(modelName); - if (false) appendToLog("strValue 0 = " + strValue); + Logger.trace("strValue 0 = {}", strValue); if (strValue == null || strValue.length() == 0) { strValue = byteArrayToString(modelName).substring(0, 5); } } - if (false) appendToLog("strValue = " + strValue); + Logger.trace("strValue = {}", strValue); return strValue; } boolean resetSiliconLab() { boolean bRetValue = false; bRetValue = controllerToWrite.add(ControllerConnector.ControllerPayloadEvents.CONTROLLER_RESET); - appendToLog("add RESET to mSiliconLabIcWrite with length = " + controllerToWrite.size()); + Logger.info("add RESET to mSiliconLabIcWrite with length = {}", controllerToWrite.size()); //mRfidDevice.setInventoring(false); return bRetValue; } @@ -166,7 +161,7 @@ private byte[] writeController(ControllerPayloadEvents event) { } else if (event == ControllerPayloadEvents.CONTROLLER_RESET) { dataOut = new byte[]{(byte) 0xA7, (byte) 0xB3, 2, (byte) 0xE8, (byte) 0x82, (byte) 0x37, 0, 0, (byte) 0xB0, 12}; } - if (DEBUG) appendToLog(byteArrayToString(dataOut) + " for " + event.toString()); + Logger.debug("{} for {}", byteArrayToString(dataOut), event.toString()); return dataOut; } @@ -176,31 +171,31 @@ 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 (utility.DEBUG_PKDATA) appendToLog("PkData: matched Controller.Reply with payload = " + byteArrayToString(connectorData.dataValues) + " for writeData.Controller." + controllerToWrite.get(0).toString()); + Logger.pkData("PkData: matched Controller.Reply with payload = {} for writeData.Controller.{}", byteArrayToString(connectorData.dataValues), controllerToWrite.get(0)); 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 (utility.DEBUG_PKDATA) appendToLog("PkData: matched Controller.Reply.GetVersion with version = " + byteArrayToString(controllerVersion)); + Logger.pkData("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 (utility.DEBUG_PKDATA) appendToLog("PkData: matched Controller.Reply.GetSerialNumber with serialNumber = " + byteArrayToString(serialNumber)); + Logger.pkData("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 (utility.DEBUG_PKDATA) appendToLog("PkData: matched controller.GetModelName.reply with modelName = " + byteArrayToString(modelName)); + Logger.pkData("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"); - } else appendToLog("matched Controller.reply data is found"); + Logger.info("Controller RESET is found with error"); + } else Logger.info("matched Controller.reply data is found"); } else { - appendToLog("matched controller.Other.reply data is found."); + Logger.info("matched controller.Other.reply data is found."); } controllerToWrite.remove(0); sendDataToWriteSent = 0; - if (utility.DEBUG_PKDATA) appendToLog("PkData: new controllerToWrite size = " + controllerToWrite.size()); + Logger.pkData("PkData: new controllerToWrite size = {}", controllerToWrite.size()); } } @@ -216,14 +211,14 @@ public byte[] sendControllerToWrite() { } else if (sendDataToWriteSent >= 5) { int oldSize = controllerToWrite.size(); controllerToWrite.remove(0); sendDataToWriteSent = 0; - if (DEBUG) appendToLog("Removed after sending count-out with oldSize = " + oldSize + ", updated controllerToWrite.size() = " + controllerToWrite.size()); - if (DEBUG) appendToLog("Removed after sending count-out."); + Logger.debug("Removed after sending count-out with oldSize = {}, updated controllerToWrite.size() = {}", oldSize, controllerToWrite.size()); + Logger.debug("Removed after sending count-out."); String string = "Problem in sending data to Controller Module. Removed data sending after count-out"; if (userDebugEnable) Toast.makeText(context, string, Toast.LENGTH_SHORT).show(); - else appendToLogView(string); + else Logger.toLogView(string).trace(); controllerFailure = true; // disconnect(false); } else { - if (DEBUG) appendToLog("size = " + controllerToWrite.size()); + Logger.debug("size = {}", controllerToWrite.size()); sendDataToWriteSent++; return writeController(controllerToWrite.get(0)); } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs108Library4A.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs108Library4A.java index b89d7a0..23d0778 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs108Library4A.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs108Library4A.java @@ -20,8 +20,9 @@ import java.util.ArrayList; import java.util.List; +import info.mqtt.android.service.BuildConfig; + public class Cs108Library4A { - final boolean DEBUG = false; final boolean DEBUG_FILE = false; private Handler mHandler = new Handler(); BluetoothAdapter.LeScanCallback mLeScanCallback = null; @@ -40,18 +41,18 @@ public Cs108Library4A(Context context, TextView mLogView) { this.context = context; utility = new Utility(context, mLogView); csReaderConnector = new CsReaderConnector(context, mLogView, utility, true); - bluetoothGatt = csReaderConnector.bluetoothGatt; DEBUG_CONNECT = bluetoothGatt.DEBUG_CONNECT; DEBUG_SCAN = bluetoothGatt.DEBUG_SCAN; + bluetoothGatt = csReaderConnector.bluetoothGatt; DEBUG_CONNECT = false; DEBUG_SCAN = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mScanCallback = new ScanCallback() { @Override public void onBatchScanResults(List results) { - if (DEBUG) appendToLog("onBatchScanResults()"); + Logger.debug("onBatchScanResults()"); } @Override public void onScanFailed(int errorCode) { - if (DEBUG) appendToLog("onScanFailed()"); + Logger.debug("onScanFailed()"); } @Override @@ -61,11 +62,11 @@ public void onScanResult(int callbackType, ScanResult result) { BluetoothGatt.CsScanData scanResultA = new BluetoothGatt.CsScanData(result.getDevice(), result.getRssi(), result.getScanRecord().getBytes()); boolean found98 = true; if (true) found98 = check9800(scanResultA); - if (DEBUG) appendToLog("found98 = " + found98 + ", mScanResultList 0 = " + (mScanResultList != null ? "VALID" : "NULL")); + Logger.debug("found98 = {}, mScanResultList 0 = {}", found98, mScanResultList != null ? "VALID" : "NULL"); if (mScanResultList != null && found98) { scanResultA.serviceUUID2p2 = check9800_serviceUUID2p1; mScanResultList.add(scanResultA); - if (DEBUG) appendToLog("mScanResultList 0 = " + mScanResultList.size()); + Logger.debug("mScanResultList 0 = {}", mScanResultList.size()); } } } @@ -74,15 +75,15 @@ public void onScanResult(int callbackType, ScanResult result) { mLeScanCallback = new BluetoothAdapter.LeScanCallback() { @Override public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) { - if (true) appendToLog("onLeScan()"); + Logger.info("onLeScan()"); BluetoothGatt.CsScanData scanResultA = new BluetoothGatt.CsScanData(device, rssi, scanRecord); boolean found98 = true; if (true) found98 = check9800(scanResultA); - appendToLog("found98 = " + found98 + ", mScanResultList 1 = " + (mScanResultList != null ? "VALID" : "NULL")); + Logger.info("found98 = {}, mScanResultList 1 = {}", found98, (mScanResultList != null ? "VALID" : "NULL")); if (mScanResultList != null && found98) { scanResultA.serviceUUID2p2 = check9800_serviceUUID2p1; mScanResultList.add(scanResultA); - appendToLog("mScanResultList 1 = " + mScanResultList.size()); + Logger.info("mScanResultList 1 = {}",+ mScanResultList.size()); } } }; @@ -91,15 +92,14 @@ public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] File path = context.getFilesDir(); File[] fileArray = path.listFiles(); boolean deleteFiles = false; - if (true || DEBUG) - appendToLog("Number of file in data storage sub-directory = " + fileArray.length); + Logger.debug("Number of file in data storage sub-directory = {}", fileArray.length); boolean bProfileInstalledFound = false; for (int i = 0; i < fileArray.length; i++) { String fileName = fileArray[i].toString(); - if (true) appendToLog("Stored file (" + i + ") = " + fileName); + Logger.info("Stored file ({}) = {}", i, fileName); if (fileName.contains("profileInstalled") || fileName.contains("profileinstaller")) { bProfileInstalledFound = true; - appendToLog("Found profileInstalled or profileinstaller file"); + Logger.info("Found profileInstalled or profileinstaller file"); } File file = new File(fileName); if (deleteFiles) file.delete(); @@ -109,7 +109,7 @@ public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] String fileName = fileArray[i].toString(); File file = new File(fileName); file.delete(); - appendToLog("Deleted " + fileName); + Logger.info("Deleted {}", fileName); } } } @@ -117,7 +117,7 @@ public String getlibraryVersion() { String version = BuildConfig.VERSION_NAME; //int iVersion = Integer.parseInt(version) + 10; version = "15.0"; //+ String.valueOf(iVersion); - appendToLog("version = " + version); + Logger.info("version = {}", version); return utility.getCombinedVersion(version); } public String checkVersion() { @@ -145,12 +145,6 @@ public String checkVersion() { public String byteArrayToString(byte[] packet) { return utility.byteArrayToString(packet); } - public void appendToLog(String s) { - utility.appendToLog(s); - } - public void appendToLogView(String s) { - utility.appendToLogView(s); - } public String strFloat16toFloat32(String strData) { return utility.strFloat16toFloat32(strData); } @@ -195,7 +189,7 @@ public boolean checkHostProcessorVersion(String version, int majorVersion, int m boolean check9800(BluetoothGatt.CsScanData scanResultA) { boolean found98 = false, DEBUG = false; - if (DEBUG) appendToLog("decoded data size = " + scanResultA.decoded_scanRecord.size()); + Logger.debug("decoded data size = {}", scanResultA.decoded_scanRecord.size()); int iNewADLength = 0; byte[] newAD = new byte[0]; int iNewADIndex = 0; @@ -204,15 +198,13 @@ boolean check9800(BluetoothGatt.CsScanData scanResultA) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) return true; String strTemp = scanResultA.getDevice().getName(); - if (strTemp != null && DEBUG) - appendToLog("Found name = " + strTemp + ", length = " + String.valueOf(strTemp.length())); + if (strTemp != null) Logger.debug("Found name = {}, length = {}", strTemp, strTemp.length()); for (byte bdata : scanResultA.getScanRecord()) { if (iNewADIndex >= iNewADLength && iNewADLength != 0) { scanResultA.decoded_scanRecord.add(newAD); iNewADIndex = 0; iNewADLength = 0; - if (DEBUG) - appendToLog("Size = " + scanResultA.decoded_scanRecord.size() + ", " + byteArrayToString(newAD)); + Logger.debug("Size = {}, {}", scanResultA.decoded_scanRecord.size(), byteArrayToString(newAD)); } if (iNewADLength == 0) { iNewADLength = bdata; @@ -220,31 +212,27 @@ boolean check9800(BluetoothGatt.CsScanData scanResultA) { iNewADIndex = 0; } else newAD[iNewADIndex++] = bdata; } - if (DEBUG) appendToLog("decoded data size = " + scanResultA.decoded_scanRecord.size()); + Logger.debug("decoded data size = {}", scanResultA.decoded_scanRecord.size()); for (int i = 0; /*scanResultA.device.getType() == BluetoothDevice.DEVICE_TYPE_LE &&*/ i < scanResultA.decoded_scanRecord.size(); i++) { byte[] currentAD = scanResultA.decoded_scanRecord.get(i); - if (DEBUG) appendToLog("Processing decoded data = " + byteArrayToString(currentAD)); + Logger.debug("Processing decoded data = {}", byteArrayToString(currentAD)); if (currentAD[0] == 2) { - if (DEBUG) appendToLog("Processing UUIDs"); + Logger.debug("Processing UUIDs"); if ((currentAD[1] == 0) && currentAD[2] == (byte) 0x98) { - if (DEBUG) appendToLog("Found 9800"); + Logger.debug("Found 9800"); found98 = true; check9800_serviceUUID2p1 = currentAD[1]; - if (DEBUG) appendToLog("serviceUD1D2p1 = " + check9800_serviceUUID2p1); + Logger.debug("serviceUD1D2p1 = {}", check9800_serviceUUID2p1); break; } } } - if (found98 == false && DEBUG) - appendToLog("No 9800: with scanData = " + byteArrayToString(scanResultA.getScanRecord())); - else if (DEBUG_SCAN) - appendToLog("Found 9800: with scanData = " + byteArrayToString(scanResultA.getScanRecord())); + if (!found98)Logger.debug("No 9800: with scanData = {}", byteArrayToString(scanResultA.getScanRecord())); + else Logger.scan("Found 9800: with scanData = {}", byteArrayToString(scanResultA.getScanRecord())); return found98; } boolean connect1(ReaderDevice readerDevice) { - boolean DEBUG = false; - if (DEBUG_CONNECT) - appendToLog("Connect with NULLreaderDevice = " + (readerDevice == null) + ", NULLreaderDeviceConnect = " + (readerDeviceConnect == null)); + Logger.connect("Connect with NULLreaderDevice = {}, NULLreaderDeviceConnect = {}", readerDevice == null, readerDeviceConnect == null); if (readerDevice == null && readerDeviceConnect != null) readerDevice = readerDeviceConnect; boolean result = false; if (readerDevice != null) { @@ -254,48 +242,43 @@ boolean connect1(ReaderDevice readerDevice) { bluetoothGatt.setServiceUUIDType(readerDevice.getServiceUUID2p1()); result = csReaderConnector.connectBle(readerDevice); } - if (DEBUG_CONNECT) appendToLog("Result = " + result); + Logger.connect("Result = {}", result); return result; } final Runnable connectRunnable = new Runnable() { - boolean DEBUG = false; @Override public void run() { - if (DEBUG_CONNECT) - appendToLog("0 connectRunnable: mBluetoothConnectionState = " + bluetoothGatt.bluetoothConnectionState + ", bNeedReconnect = " + bNeedReconnect); + Logger.connect("0 connectRunnable: mBluetoothConnectionState = {}, bNeedReconnect = {}", bluetoothGatt.bluetoothConnectionState, bNeedReconnect); if (isBleScanning()) { - if (DEBUG) appendToLog("connectRunnable: still scanning. Stop scanning first"); + Logger.debug("connectRunnable: still scanning. Stop scanning first"); scanLeDevice(false); } else if (bNeedReconnect) { if (bluetoothGatt.bluetoothGatt != null) { - if (DEBUG) - appendToLog("connectRunnable: mBluetoothGatt is null before connect. disconnect first"); + Logger.debug("connectRunnable: mBluetoothGatt is null before connect. disconnect first"); csReaderConnector.disconnect(); } else if (readerDeviceConnect == null) { - if (DEBUG) appendToLog("connectRunnable: exit with null readerDeviceConnect"); + Logger.debug("connectRunnable: exit with null readerDeviceConnect"); return; } else if (bluetoothGatt.bluetoothGatt == null) { - if (DEBUG_CONNECT) appendToLog("4 connectRunnable: connect1 starts"); + Logger.connect("4 connectRunnable: connect1 starts"); connect1(null); bNeedReconnect = false; } } else if (bluetoothGatt.bluetoothConnectionState == BluetoothProfile.STATE_DISCONNECTED) { //mReaderStreamOutCharacteristic valid around 1500ms iConnectStateTimer = 0; - if (DEBUG) - appendToLog("connectRunnable: disconnect as disconnected connectionState is received"); + Logger.debug("connectRunnable: disconnect as disconnected connectionState is received"); bNeedReconnect = true; if (bluetoothGatt.bluetoothGatt != null) { - if (DEBUG) appendToLog("disconnect F"); + Logger.debug("disconnect F"); csReaderConnector.disconnect(); } } else if (bluetoothGatt.mReaderStreamOutCharacteristic == null) { - if (DEBUG_CONNECT) - appendToLog("6 connectRunnable: wait as not yet discovery, with iConnectStateTimer = " + iConnectStateTimer); + Logger.connect("6 connectRunnable: wait as not yet discovery, with iConnectStateTimer = {}", iConnectStateTimer); if (++iConnectStateTimer > 10) { } } else { - if (DEBUG_CONNECT) appendToLog("7 connectRunnable: end of ConnectRunnable"); + Logger.connect("7 connectRunnable: end of ConnectRunnable"); return; } mHandler.postDelayed(connectRunnable, 500); @@ -305,11 +288,11 @@ public void run() { @Override public void run() { if (barcodeConnector == null) return; - appendToLog("abcc disconnectRunnable with barcodeToWrite.size = " + barcodeConnector.barcodeToWrite.size()); + Logger.info("abcc disconnectRunnable with barcodeToWrite.size = {}",barcodeConnector.barcodeToWrite.size()); if (barcodeConnector.barcodeToWrite.size() != 0) mHandler.postDelayed(disconnectRunnable, 100); else { - appendToLog("disconnect G"); + Logger.info("disconnect G"); csReaderConnector.disconnect(); } } @@ -318,20 +301,19 @@ public boolean isBleScanning() { return bluetoothGatt.isBleScanning(); } public boolean scanLeDevice(final boolean enable) { - boolean DEBUG = false; if (enable) mHandler.removeCallbacks(connectRunnable); - if (DEBUG_SCAN) appendToLog("scanLeDevice[" + enable + "]"); + Logger.scan("scanLeDevice[{}]", enable); if (bluetoothGatt.bluetoothDeviceConnectOld != null) { - if (DEBUG) appendToLog("bluetoothDeviceConnectOld connection state = " + bluetoothGatt.bluetoothManager.getConnectionState(bluetoothGatt.bluetoothDeviceConnectOld, BluetoothProfile.GATT)); + Logger.debug("bluetoothDeviceConnectOld connection state = {}", bluetoothGatt.bluetoothManager.getConnectionState(bluetoothGatt.bluetoothDeviceConnectOld, BluetoothProfile.GATT)); } boolean bValue = bluetoothGatt.scanLeDevice(enable, this.mLeScanCallback, this.mScanCallback); - if (DEBUG_SCAN) appendToLog("isScanning = " + isBleScanning()); + Logger.debug("isScanning = {}",isBleScanning()); return bValue; } public BluetoothGatt.CsScanData getNewDeviceScanned() { if (mScanResultList.size() != 0) { - if (DEBUG_SCAN) appendToLog("mScanResultList.size() = " + mScanResultList.size()); + Logger.scan("mScanResultList.size() = {}", mScanResultList.size()); BluetoothGatt.CsScanData csScanData = mScanResultList.get(0); mScanResultList.remove(0); return csScanData; } else return null; @@ -350,7 +332,7 @@ public boolean isBleConnected() { if (bleConnectionNew) { if (bleConnection == false) { bleConnection = bleConnectionNew; - if (DEBUG_CONNECT || DEBUG) appendToLog("Newly connected"); + Logger.connect("Newly connected"); csReaderConnector.csConnectorDataInit(); barcodeNewland = csReaderConnector.barcodeNewland; @@ -384,7 +366,7 @@ public boolean isBleConnected() { //getMacVer(); if (false) { //following two instructions seems not used int iValue = csReaderConnector.rfidReader.getDiagnosticConfiguration(); - if (DEBUG) appendToLog("diagnostic data = " + iValue); + Logger.debug("diagnostic data = {}", iValue); macWrite(0xC08, 0x100); } csReaderConnector.rfidReader.regionCode = null; @@ -398,7 +380,7 @@ public boolean isBleConnected() { csReaderConnector.rfidReader.getImpinjExtension(); csReaderConnector.rfidReader.getInvAlgoInChip(); csReaderConnector.rfidReader.getFreqChannelConfig(); - if (DEBUG_CONNECT || DEBUG) appendToLog("Start checkVersionRunnable"); + Logger.connect("Start checkVersionRunnable"); mHandler.postDelayed(checkVersionRunnable, 500); if (csReaderConnector.settingData.strForegroundReader.trim().length() != 0) { @@ -407,7 +389,7 @@ public boolean isBleConnected() { csReaderConnector.settingData.saveForegroundSetting2File(); } else if (csReaderConnector.rfidReader == null) { bleConnection = false; - appendToLog("csReaderConnector.rfidReader is NULL"); + Logger.info("csReaderConnector.rfidReader is NULL"); } else if (csReaderConnector.rfidReader.bFirmware_reset_before) { csReaderConnector.rfidReader.bFirmware_reset_before = false; mHandler.postDelayed(reinitaliseDataRunnable, 500); @@ -418,7 +400,7 @@ public boolean isBleConnected() { controllerConnector = null; bluetoothConnector = null; bleConnection = bleConnectionNew; - if (DEBUG) appendToLog("Newly disconnected"); + Logger.debug("Newly disconnected"); } return(bleConnection); } @@ -428,23 +410,24 @@ public void connect(ReaderDevice readerDevice) { if (readerDevice != null) readerDeviceConnect = readerDevice; mHandler.removeCallbacks(connectRunnable); bNeedReconnect = true; mHandler.post(connectRunnable); - if (DEBUG_CONNECT) appendToLog("Start ConnectRunnable"); + Logger.connect("Start ConnectRunnable"); } public void disconnect(boolean tempDisconnect) { - appendToLog("abcc tempDisconnect: getBarcodeOnStatus = " + (getBarcodeOnStatus() ? "on" : "off")); - if (DEBUG) appendToLog("tempDisconnect = " + tempDisconnect); + Logger.info("abcc tempDisconnect: getBarcodeOnStatus = {}", getBarcodeOnStatus() ? "on" : "off"); + Logger.debug("tempDisconnect = {}", tempDisconnect); mHandler.removeCallbacks(checkVersionRunnable); mHandler.removeCallbacks(runnableToggleConnection); if (getBarcodeOnStatus()) { - appendToLog("tempDisconnect: setBarcodeOn(false)"); + Logger.info("tempDisconnect: setBarcodeOn(false)"); if (barcodeConnector.barcodeToWrite.size() != 0) { - appendToLog("going to disconnectRunnable with remaining barcodeToWrite.size = " + barcodeConnector.barcodeToWrite.size() + ", data = " + byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); + Logger.info("going to disconnectRunnable with remaining barcodeToWrite.size = {}, data = {}", barcodeConnector.barcodeToWrite.size(), byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); } - barcodeConnector.barcodeToWrite.clear(); appendToLog("barcodeToWrite is clear"); + barcodeConnector.barcodeToWrite.clear(); + Logger.info("barcodeToWrite is clear"); setBarcodeOn(false); - } else appendToLog("tempDisconnect: getBarcodeOnStatus is false"); + } else Logger.info("tempDisconnect: getBarcodeOnStatus is false"); mHandler.postDelayed(disconnectRunnable, 100); - appendToLog("done with tempDisconnect = " + tempDisconnect); + Logger.info("done with tempDisconnect = {}", tempDisconnect); if (tempDisconnect == false) { mHandler.removeCallbacks(connectRunnable); bluetoothGatt.bluetoothDeviceConnectOld = null; @@ -518,13 +501,17 @@ RegionCodes[] getRegionList() { Runnable runnableToggleConnection = new Runnable() { @Override public void run() { - if (DEBUG) appendToLog("runnableToggleConnection(): toggledConnection = " + toggledConnection + ", isBleConnected() = " + isBleConnected()); + Logger.debug("runnableToggleConnection(): toggledConnection = {}, isBleConnected() = {}", toggledConnection, isBleConnected()); if (isBleConnected() == false) toggledConnection = true; if (toggledConnection) { if (isBleConnected() == false) { if (connect1(null) == false) return; } else return; - } else { appendToLog("disconnect H"); csReaderConnector.disconnect(); appendToLog("done"); } + } else { + Logger.info("disconnect H"); + csReaderConnector.disconnect(); + Logger.info("done"); + } mHandler.postDelayed(runnableToggleConnection, 500); } }; @@ -541,7 +528,6 @@ 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(); } @@ -664,7 +650,7 @@ public int getFastId() { return csReaderConnector.rfidReader.getFastId(); } public boolean setFastId(boolean fastIdNew) { - appendToLog("bFastId: setFastId[" + fastIdNew); + Logger.info("bFastId: setFastId[{}]", fastIdNew); return csReaderConnector.rfidReader.setFastId(fastIdNew); } public boolean getInvAlgo() { @@ -797,7 +783,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"); + Logger.scan("Debug_Select: Cs108Library4A.setSelectCriteriaDisable[{}] goes to setSelectCriteriaDisable", index); return csReaderConnector.rfidReader.setSelectCriteriaDisable(index); } int findFirstEmptySelect() { @@ -859,7 +845,7 @@ public int mrfidToWriteSize() { public void mrfidToWritePrint() { if (true) { csReaderConnector.rfidReader.mrfidToWriteSize(); return; } for (int i = 0; i < csReaderConnector.rfidReader.mRfidToWrite.size(); i++) { - appendToLog(byteArrayToString(csReaderConnector.rfidReader.mRfidToWrite.get(i).dataValues)); + Logger.info(byteArrayToString(csReaderConnector.rfidReader.mRfidToWrite.get(i).dataValues)); } } public long getTagRate() { @@ -873,7 +859,7 @@ public boolean abortOperation() { } public void restoreAfterTagSelect() { if (!isBleConnected()) return; - if (utility.DEBUG_SELECT) appendToLog("Debug_Select: Cs108Library4A.restoreAfterTagSelect goes to setSelectCriteriaDisable"); + Logger.select("Debug_Select: Cs108Library4A.restoreAfterTagSelect goes to setSelectCriteriaDisable"); setSelectCriteriaDisable(0); setSelectCriteriaDisable(1); setSelectCriteriaDisable(2); loadSetting1File(); setAccessCount(0); @@ -887,9 +873,10 @@ public void restoreAfterTagSelect() { if (csReaderConnector.rfidReader.postMatchDataChanged) { csReaderConnector.rfidReader.postMatchDataChanged = false; setPostMatchCriteria(csReaderConnector.rfidReader.postMatchDataOld.enable, csReaderConnector.rfidReader.postMatchDataOld.target, csReaderConnector.rfidReader.postMatchDataOld.offset, csReaderConnector.rfidReader.postMatchDataOld.mask); - appendToLog("PowerLevel"); + Logger.info("PowerLevel"); setPowerLevel(csReaderConnector.rfidReader.postMatchDataOld.pwrlevel); - appendToLog("writeBleStreamOut: invAlgo = " + csReaderConnector.rfidReader.postMatchDataOld.invAlgo); setInvAlgo1(csReaderConnector.rfidReader.postMatchDataOld.invAlgo); + Logger.info("writeBleStreamOut: invAlgo = {}", csReaderConnector.rfidReader.postMatchDataOld.invAlgo); + setInvAlgo1(csReaderConnector.rfidReader.postMatchDataOld.invAlgo); setQValue1(csReaderConnector.rfidReader.postMatchDataOld.qValue); } } @@ -903,7 +890,7 @@ public boolean setSelectedTag(boolean selectOne, String selectMask, int selectBa 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); + Logger.invCfg("Debug_InvCfg: Cs108Library4A.setMatchRep goes to setMatchRep with matchRep = {}", matchRep); return csReaderConnector.rfidReader.setMatchRep(matchRep); } public String[] getCountryList() { @@ -967,7 +954,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"); + Logger.compact("Debug_Compact 1: Cs108Library4A.setInvModeCompact goes to setInvModeCompact"); return csReaderConnector.rfidReader.setInvModeCompact(invModeCompact); } public boolean setAccessLockAction(int accessLockAction, int accessLockMask) { @@ -1075,29 +1062,30 @@ public boolean setBarcodeOn(boolean on) { if (on) csReaderBarcodeData.barcodePayloadEvent = BarcodeConnector.BarcodePayloadEvents.BARCODE_POWER_ON; else csReaderBarcodeData.barcodePayloadEvent = BarcodeConnector.BarcodePayloadEvents.BARCODE_POWER_OFF; csReaderBarcodeData.waitUplinkResponse = false; - retValue = barcodeConnector.barcodeToWrite.add(csReaderBarcodeData); appendToLog("barcodeToWrite added with size = " + barcodeConnector.barcodeToWrite.size()); - if (DEBUG_FILE) appendToLog("add " + csReaderBarcodeData.barcodePayloadEvent.toString() + " to barcodeToWrite with length = " + barcodeConnector.barcodeToWrite.size()); + retValue = barcodeConnector.barcodeToWrite.add(csReaderBarcodeData); + Logger.info("barcodeToWrite added with size = {}", barcodeConnector.barcodeToWrite.size()); + Logger.debug("add {} to barcodeToWrite with length {}", csReaderBarcodeData.barcodePayloadEvent, barcodeConnector.barcodeToWrite.size()); boolean continuousAfterOn = false; if (retValue && on && continuousAfterOn) { if (checkHostProcessorVersion(getBluetoothICFirmwareVersion(), 1, 0, 2)) { - if (DEBUG) appendToLog("to barcodeSendCommandConinuous()"); + Logger.debug("to barcodeSendCommandConinuous()"); retValue = barcodeNewland.barcodeSendCommandConinuous(); } else retValue = false; } - if (DEBUG) appendToLog("barcodeToWrite size = " + barcodeConnector.barcodeToWrite.size()); + Logger.debug("barcodeToWrite size = {}", barcodeConnector.barcodeToWrite.size()); return retValue; } int iModeSet = -1, iVibratieTimeSet = -1; public boolean setVibrateOn(int mode) { boolean retValue; - if (true) appendToLog("setVibrateOn with mode = " + mode + ", and isInventoring = " + csReaderConnector.rfidReader.isInventoring()); + Logger.info("setVibrateOn with mode = {}, and isInventoring = {}", mode, csReaderConnector.rfidReader.isInventoring()); if (csReaderConnector.rfidReader.isInventoring()) return false; BarcodeConnector.CsReaderBarcodeData csReaderBarcodeData = new BarcodeConnector.CsReaderBarcodeData(); if (mode > 0) csReaderBarcodeData.barcodePayloadEvent = BarcodeConnector.BarcodePayloadEvents.BARCODE_VIBRATE_ON; else csReaderBarcodeData.barcodePayloadEvent = BarcodeConnector.BarcodePayloadEvents.BARCODE_VIBRATE_OFF; csReaderBarcodeData.waitUplinkResponse = false; if (iModeSet == mode && iVibratieTimeSet == getVibrateTime()) { - appendToLog("writeBleStreamOut: A7B3: Skip saving vibration data"); + Logger.info("writeBleStreamOut: A7B3: Skip saving vibration data"); return true; } if (mode > 0) { @@ -1107,8 +1095,9 @@ public boolean setVibrateOn(int mode) { barcodeCommandData[2] = (byte) (getVibrateTime() % 256); csReaderBarcodeData.dataValues = barcodeCommandData; } - retValue = barcodeConnector.barcodeToWrite.add(csReaderBarcodeData); appendToLog("barcodeToWrite added with size = " + barcodeConnector.barcodeToWrite.size()); - if (DEBUG) appendToLog("barcodeToWrite size = " + barcodeConnector.barcodeToWrite.size()); + retValue = barcodeConnector.barcodeToWrite.add(csReaderBarcodeData); + Logger.info("barcodeToWrite added with size = {}", barcodeConnector.barcodeToWrite.size()); + Logger.debug("barcodeToWrite size = {}", barcodeConnector.barcodeToWrite.size()); if (retValue) { iModeSet = mode; iVibratieTimeSet = getVibrateTime(); } @@ -1118,10 +1107,9 @@ public boolean getInventoryVibrate() { return csReaderConnector.settingData.inventoryVibrate; } public boolean setInventoryVibrate(boolean inventoryVibrate) { - boolean DEBUG = false; - if (DEBUG) appendToLog("this.inventoryVibrate = " + csReaderConnector.settingData.inventoryVibrate + ", inventoryVibrate = " + inventoryVibrate); + Logger.debug("this.inventoryVibrate = {}, inventoryVibrate = {}", csReaderConnector.settingData.inventoryVibrate, inventoryVibrate); csReaderConnector.settingData.inventoryVibrate = inventoryVibrate; - if (DEBUG) appendToLog("this.inventoryVibrate = " + csReaderConnector.settingData.inventoryVibrate + ", inventoryVibrate = " + inventoryVibrate); + Logger.debug("this.inventoryVibrate = {}, inventoryVibrate = {}", csReaderConnector.settingData.inventoryVibrate, inventoryVibrate); return true; } public int getVibrateTime() { @@ -1159,24 +1147,44 @@ public String getBarcodeSerial() { boolean barcodeAutoStarted = false; public boolean barcodeInventory(boolean start) { boolean result = true; - appendToLog("TTestPoint 0: " + start); + Logger.trace("TTestPoint 0: {}", start); if (start) { barcodeConnector.mBarcodeToRead.clear(); barcodeDataStore = null; - if (getBarcodeOnStatus() == false) { result = setBarcodeOn(true); appendToLog("TTestPoint 1"); } + if (getBarcodeOnStatus() == false) { + result = setBarcodeOn(true); + Logger.trace("TTestPoint 1"); + } if (csReaderConnector.settingData.barcode2TriggerMode && result) { - if (getTriggerButtonStatus() && notificationConnector.getAutoBarStartSTop()) { appendToLog("TTestPoint 2"); barcodeAutoStarted = true; result = true; } - else { appendToLog("TTestPoint 3"); result = barcodeNewland.barcodeSendCommand(new byte[]{0x1b, 0x33}); } - } else appendToLog("TTestPoint 4"); - appendToLog("TTestPoint 5"); + if (getTriggerButtonStatus() && notificationConnector.getAutoBarStartSTop()) { + Logger.trace("TTestPoint 2"); + barcodeAutoStarted = true; + result = true; + } else { + Logger.trace("TTestPoint 3"); + result = barcodeNewland.barcodeSendCommand(new byte[]{0x1b, 0x33}); + } + } else Logger.trace("TTestPoint 4"); + Logger.trace("TTestPoint 5"); } else { - appendToLog("getBarcodeOnStatus = " + getBarcodeOnStatus() + ", result = " + result); - if (csReaderConnector.settingData.barcode2TriggerMode == false) { appendToLog("TTestPoint 6"); result = setBarcodeOn(false); } - else if (getBarcodeOnStatus() == false && result) { appendToLog("TTestPoint 7"); result = setBarcodeOn(true); } - appendToLog("barcode2TriggerMode = " + csReaderConnector.settingData.barcode2TriggerMode + ", result = " + result + ", barcodeAutoStarted = " + barcodeAutoStarted); + Logger.info("getBarcodeOnStatus = {}, result = {}", getBarcodeOnStatus(), result); + if (!csReaderConnector.settingData.barcode2TriggerMode) { + Logger.trace("TTestPoint 6"); + result = setBarcodeOn(false); + } else if (!getBarcodeOnStatus() && result) { + Logger.trace("TTestPoint 7"); + result = setBarcodeOn(true); + } + Logger.info("barcode2TriggerMode = {}, result = {}, barcodeAutoStarted = {}", csReaderConnector.settingData.barcode2TriggerMode, result, barcodeAutoStarted); if (csReaderConnector.settingData.barcode2TriggerMode && result) { - if (barcodeAutoStarted && result) { appendToLog("TTestPoint 8"); barcodeAutoStarted = false; result = true; } - else { appendToLog("TTestPoint 9"); result = barcodeNewland.barcodeSendCommand(new byte[] { 0x1b, 0x30 }); } - } else appendToLog("TTestPoint 10"); + if (barcodeAutoStarted && result) { + Logger.trace("TTestPoint 8"); + barcodeAutoStarted = false; + result = true; + } else { + Logger.trace("TTestPoint 9"); + result = barcodeNewland.barcodeSendCommand(new byte[] { 0x1b, 0x30 }); + } + } else Logger.trace("TTestPoint 10"); } return result; } @@ -1198,7 +1206,7 @@ public byte[] onBarcodeEvent() { byte[] barcodeCombined = null; if (false) barcodeCombined = barcodeData; else if (barcodeData != null) { - appendToLog("BarStream: barcodeData = " + byteArrayToString(barcodeData) + ", barcodeDataStore = " + byteArrayToString(barcodeDataStore)); + Logger.info("BarStream: barcodeData = {}, barcodeDataStore = {}", byteArrayToString(barcodeData), byteArrayToString(barcodeDataStore)); int barcodeDataStoreIndex = 0; int length = barcodeData.length; if (barcodeDataStore != null) { @@ -1226,7 +1234,7 @@ else if (barcodeData != null) { byte[] prefixExpected = barcodeNewland.getPrefix(); boolean prefixFound = false; byte[] suffixExpected = barcodeNewland.getSuffix(); boolean suffixFound = false; int codeTypeLength = 4; - appendToLog("BarStream: barcodeCombined = " + byteArrayToString(barcodeCombined) + ", Expected Prefix = " + byteArrayToString(prefixExpected) + ", Expected Suffix = " + byteArrayToString(suffixExpected)); + Logger.info("BarStream: barcodeCombined = {}, Expected Prefix = {}, Expected Suffix = {}", byteArrayToString(barcodeCombined), byteArrayToString(prefixExpected), byteArrayToString(suffixExpected)); if (barcodeCombined.length > prefixExpected.length + suffixExpected.length + codeTypeLength) { int i = 0; for (; i <= barcodeCombined.length - prefixExpected.length - suffixExpected.length; i++) { @@ -1244,19 +1252,19 @@ else if (barcodeData != null) { } if (j == suffixExpected.length) { suffixFound = true; break; } } - appendToLog("BarStream: iPrefix = " + i + ", iSuffix = " + k + ", with prefixFound = " + prefixFound + ", suffixFound = " + suffixFound); + Logger.info("BarStream: iPrefix = {}, iSuffix ={}, with prefixFound = {}, suffixFound = {}", i, k, prefixFound, suffixFound); if (prefixFound && suffixFound) { byte[] barcodeCombinedNew = new byte[k - i - prefixExpected.length - codeTypeLength]; System.arraycopy(barcodeCombined, i + prefixExpected.length + codeTypeLength, barcodeCombinedNew, 0, barcodeCombinedNew.length); barcodeCombined = barcodeCombinedNew; - appendToLog("BarStream: barcodeCombinedNew = " + byteArrayToString(barcodeCombinedNew)); + Logger.info("BarStream: barcodeCombinedNew = " + byteArrayToString(barcodeCombinedNew)); if (true) { byte[] prefixExpected1 = {0x5B, 0x29, 0x3E, 0x1E}; prefixFound = false; byte[] suffixExpected1 = {0x1E, 0x04}; suffixFound = false; - appendToLog("BarStream: barcodeCombined = " + byteArrayToString(barcodeCombined) + ", Expected Prefix = " + byteArrayToString(prefixExpected1) + ", Expected Suffix = " + byteArrayToString(suffixExpected1)); + Logger.info("BarStream: barcodeCombined = {}, Expected Prefix = {}, Expected Suffix = {}", byteArrayToString(barcodeCombined), byteArrayToString(prefixExpected1), byteArrayToString(suffixExpected1)); if (barcodeCombined.length > prefixExpected1.length + suffixExpected1.length) { i = 0; for (; i <= barcodeCombined.length - prefixExpected1.length - suffixExpected1.length; i++) { @@ -1280,12 +1288,12 @@ else if (barcodeData != null) { break; } } - appendToLog("BarStream: iPrefix = " + i + ", iSuffix = " + k + ", with prefixFound = " + prefixFound + ", suffixFound = " + suffixFound); + Logger.info("BarStream: iPrefix = {}, iSuffix = {}, with prefixFound = {}, suffixFound = {}", i, k, prefixFound, suffixFound); if (prefixFound && suffixFound) { barcodeCombinedNew = new byte[k - i - prefixExpected1.length]; System.arraycopy(barcodeCombined, i + prefixExpected1.length, barcodeCombinedNew, 0, barcodeCombinedNew.length); barcodeCombined = barcodeCombinedNew; - appendToLog("BarStream: barcodeCombinedNew = " + byteArrayToString(barcodeCombinedNew)); + Logger.info("BarStream: barcodeCombinedNew = {}", byteArrayToString(barcodeCombinedNew)); } } } @@ -1299,7 +1307,7 @@ else if (barcodeData != null) { //============ Android General ============ public void setSameCheck(boolean sameCheck1) { if (csReaderConnector.sameCheck == sameCheck1) return; - if (false) appendToLog("new sameCheck = " + sameCheck1 + ", with old sameCheck = " + csReaderConnector.sameCheck); + Logger.trace("new sameCheck = {}, with old sameCheck = {}", sameCheck1, csReaderConnector.sameCheck); csReaderConnector.sameCheck = sameCheck1; //sameCheck = false; } @@ -1322,9 +1330,9 @@ public boolean getSaveFileEnable() { return csReaderConnector.settingData.saveFileEnable; } public boolean setSaveFileEnable(boolean saveFileEnable) { - appendToLog("this.saveFileEnable = " + csReaderConnector.settingData.saveFileEnable + ", saveFileEnable = " + saveFileEnable); + Logger.trace("this.saveFileEnable = {}, saveFileEnable = {}", csReaderConnector.settingData.saveFileEnable, saveFileEnable); csReaderConnector.settingData.saveFileEnable = saveFileEnable; - appendToLog("this.saveFileEnable = " + csReaderConnector.settingData.saveFileEnable + ", saveFileEnable = " + saveFileEnable); + Logger.trace("this.saveFileEnable = {}, saveFileEnable = {}", csReaderConnector.settingData.saveFileEnable, saveFileEnable); return true; } public boolean getSaveCloudEnable() { @@ -1349,10 +1357,12 @@ public boolean setSaveAllCloudEnable(boolean saveAllCloudEnable) { return true; } public boolean getUserDebugEnable() { - boolean bValue = csReaderConnector.settingData.userDebugEnable; appendToLog("bValue = " + bValue); return bValue; + boolean bValue = csReaderConnector.settingData.userDebugEnable; + Logger.trace("bValue = {}", bValue); + return bValue; } public boolean setUserDebugEnable(boolean userDebugEnable) { - appendToLog("new userDebug = " + userDebugEnable); + Logger.trace("new userDebug = {}", userDebugEnable); csReaderConnector.settingData.userDebugEnable = userDebugEnable; return true; } @@ -1405,11 +1415,11 @@ public boolean setForegroundDupElim(int iForegroundDupElim) { } public int getInventoryCloudSave() { int i = csReaderConnector.settingData.inventoryCloudSave; - if (false) appendToLog("getInventoryCloudSave108 = " + i); + Logger.trace("getInventoryCloudSave108 = {}", i); return i; } public boolean setInventoryCloudSave(int inventoryCloudSave) { - appendToLog("setInventoryCloudSave108 = " + inventoryCloudSave); + Logger.trace("setInventoryCloudSave108 = {}", inventoryCloudSave); csReaderConnector.settingData.inventoryCloudSave = inventoryCloudSave; return true; } @@ -1421,12 +1431,12 @@ public boolean setServerImpinjLocation(String serverImpinjLocation) { return true; } public String getServerImpinjName() { - appendToLog("serverImpinjName = " + csReaderConnector.settingData.serverImpinjName); + Logger.trace("serverImpinjName = {}", csReaderConnector.settingData.serverImpinjName); return csReaderConnector.settingData.serverImpinjName; } public boolean setServerImpinjName(String serverImpinjName) { csReaderConnector.settingData.serverImpinjName = serverImpinjName; - appendToLog("serverImpinjName = " + serverImpinjName); + Logger.trace("serverImpinjName = {}", serverImpinjName); return true; } public String getServerImpinjPassword() { @@ -1467,7 +1477,7 @@ public int getSavingFormatSetting() { return csReaderConnector.settingData.savingFormatSelect; } public boolean setSavingFormatSetting(int savingFormatSelect) { - if (false) appendToLog("savingFormatSelect = " + savingFormatSelect); + Logger.trace("savingFormatSelect = {}", savingFormatSelect); if (savingFormatSelect < 0 || savingFormatSelect > 1) return false; csReaderConnector.settingData.savingFormatSelect = savingFormatSelect; return true; @@ -1559,14 +1569,14 @@ public String getHostProcessorICBoardVersion() { String str; if (bluetoothConnector.getCsModel() != 463) str = controllerConnector.getSerialNumber(); else str = csReaderConnector.rfidReader.getProductSerialNumber(); - if (false) appendToLog("getBoardVersion = " + str); + Logger.trace("getBoardVersion = {}", str); if (str != null) { if (str.length() == 16) { String strOut = ""; if (str.substring(13, 14).matches("0") == false) strOut = str.substring(13, 14); strOut += (strOut.length() != 0 ? "." : "") + str.substring(14, 15); if (str.substring(15, 16).matches("0") == false || strOut.length() < 3) strOut += (strOut.length() < 3 ? "." : "") + str.substring(15, 16); - if (false) appendToLog("getBoardVersion 1 = " + str); + Logger.trace("getBoardVersion 1 = {}", str); return strOut; } } @@ -1577,7 +1587,7 @@ public String getHostProcessorICBoardVersion() { int iBatteryCount; int getBatteryValue2Percent(float floatValue) { boolean DEBUG = false; - if (DEBUG) appendToLog("getHostProcessorICBoardVersion = " + getHostProcessorICBoardVersion() + ", strVersionMBoard = " + strVersionMBoard); + Logger.debug("getHostProcessorICBoardVersion = {}, strVersionMBoard = {}", getHostProcessorICBoardVersion(), strVersionMBoard); if (false || checkHostProcessorVersion(getHostProcessorICBoardVersion(), Integer.parseInt(strMBoardVersions[0].trim()), Integer.parseInt(strMBoardVersions[1].trim()), 0)) { final float[] fValueStbyRef = { (float) 4.212, (float) 4.175, (float) 4.154, (float) 4.133, (float) 4.112, @@ -1641,14 +1651,14 @@ else if (csReaderConnector.rfidReader.isInventoring()) { fValueRef = fValueRunRef; fPercentRef = fPercentRunRef; } - if (DEBUG) appendToLog("NEW Percentage cureve is USED with bUsingInventoryBatteryCurve = " + bUsingInventoryBatteryCurve + ", iBatteryNewCurveDelay = " + iBatteryNewCurveDelay); + Logger.debug("NEW Percentage cureve is USED with bUsingInventoryBatteryCurve = {}, iBatteryNewCurveDelay = {}", bUsingInventoryBatteryCurve, iBatteryNewCurveDelay); int index = 0; while (index < fValueRef.length) { if (floatValue > fValueRef[index]) break; index++; } - if (DEBUG) appendToLog("Index = " + index); + Logger.debug("Index = {}", index); if (index == 0) return 100; if (index == fValueRef.length) return 0; float value = ((fValueRef[index - 1] - floatValue) / (fValueRef[index - 1] - fValueRef[index])); @@ -1668,7 +1678,7 @@ else if (csReaderConnector.rfidReader.isInventoring()) { fBatteryValueOld = floatValue; iBatteryPercentOld = iValue; return iValue; } else { - if (DEBUG) appendToLog("OLD Percentage cureve is USED"); + Logger.debug("OLD Percentage cureve is USED"); if (floatValue >= 4) return 100; else if (floatValue < 3.4) return 0; else { @@ -1691,7 +1701,7 @@ public boolean batteryLevelRequest() { if (csReaderConnector.rfidReader == null) return false; if (notificationConnector == null) return false; if (csReaderConnector.rfidReader.isInventoring()) { - appendToLog("Skip batteryLevelREquest as inventoring !!!"); + Logger.info("Skip batteryLevelREquest as inventoring !!!"); return true; } if (mrfidToWriteSize() != 0) return false; @@ -1767,7 +1777,7 @@ public void setNotificationListener(NotificationConnector.NotificationListener l public byte[] onNotificationEvent() { byte[] notificationData = null; if (notificationConnector == null) { - appendToLog("notificationConnector is null"); + Logger.trace("notificationConnector is null"); return null; } if (notificationConnector.notificationToRead.size() != 0) { @@ -1791,12 +1801,12 @@ public boolean setRfidOn(boolean onStatus) { private final Runnable reinitaliseDataRunnable = new Runnable() { @Override public void run() { - appendToLog("reset before: reinitaliseDataRunnable starts with inventoring=" + csReaderConnector.rfidReader.isInventoring() + ", mrfidToWriteSize=" + mrfidToWriteSize()); + Logger.trace("reset before: reinitaliseDataRunnable starts with inventoring={}, mrfidToWriteSize={}", csReaderConnector.rfidReader.isInventoring(), mrfidToWriteSize()); if (csReaderConnector.rfidReader.isInventoring() || mrfidToWriteSize() != 0) { mHandler.removeCallbacks(reinitaliseDataRunnable); mHandler.postDelayed(reinitaliseDataRunnable, 500); } else { - if (DEBUG_CONNECT) appendToLog("reinitaliseDataRunnable: Start checkVersionRunnable"); + Logger.connect("reinitaliseDataRunnable: Start checkVersionRunnable"); mHandler.postDelayed(checkVersionRunnable, 500); } } @@ -1805,50 +1815,50 @@ public void run() { boolean DEBUG = false; @Override public void run() { - if (DEBUG_CONNECT || true) appendToLog("0 checkVersionRunnable with mrfidToWriteSize = " + mrfidToWriteSize()); + Logger.connect("0 checkVersionRunnable with mrfidToWriteSize = {}", mrfidToWriteSize()); if (mrfidToWriteSize() > 0) { mHandler.removeCallbacks(checkVersionRunnable); mHandler.postDelayed(checkVersionRunnable, 500); } else { //setSameCheck(false); - setAccessCount(0); //appendToLog("btDataOut: setAccessCount as 0"); + setAccessCount(0); notificationConnector.setVersion(hostProcessorICGetFirmwareVersion()); - if (DEBUG) appendToLog("checkVersionRunnable: Checkpoint 1 with BarcodeFailure = " + isBarcodeFailure()); + Logger.debug("checkVersionRunnable: Checkpoint 1 with BarcodeFailure = {}", isBarcodeFailure()); if (false && isBarcodeFailure() == false) { - if (DEBUG) appendToLog("checkVersionRunnable: Checkpoint 2"); + Logger.debug("checkVersionRunnable: Checkpoint 2"); if (barcodeNewland.checkPreSuffix(barcodeNewland.prefixRef, barcodeNewland.suffixRef) == false) barcodeNewland.barcodeSendCommandSetPreSuffix(); if (barcodeNewland.bBarcodeTriggerMode != 0x30) barcodeNewland.barcodeSendCommandTrigger(); notificationConnector.getAutoRFIDAbort(); notificationConnector.getAutoBarStartSTop(); //setAutoRFIDAbort(false); setAutoBarStartSTop(true); } - if (DEBUG) appendToLog("checkVersionRunnable: Checkpoint 3"); + Logger.debug("checkVersionRunnable: Checkpoint 3"); setAntennaCycle(0xffff); if (true) { if (bluetoothConnector.getCsModel() == 463) { - if (DEBUG) appendToLog("checkVersionRunnable: Checkpoint 4"); + Logger.debug("checkVersionRunnable: Checkpoint 4"); setAntennaDwell(2000); setAntennaInvCount(0); } else { //if (bluetoothConnector.getCsModel() != 463) { - if (DEBUG) appendToLog("checkVersionRunnable: Checkpoint 5"); + Logger.debug("checkVersionRunnable: Checkpoint 5"); setAntennaDwell(0); setAntennaInvCount(0xfffffffeL); } } - if (DEBUG) appendToLog("checkVersionRunnable: Checkpoint 6"); + Logger.debug("checkVersionRunnable: Checkpoint 6"); csReaderConnector.settingData.loadWedgeSettingFile(); if (loadSetting1File()) loadSetting1File(); - if (DEBUG) appendToLog("checkVersionRunnable: macVersion = " + getMacVer()); + Logger.debug("checkVersionRunnable: macVersion = {}", getMacVer()); if (checkHostProcessorVersion(getMacVer(), 2, 6, 8)) { - if (DEBUG) appendToLog("checkVersionRunnable: macVersion >= 2.6.8"); + Logger.debug("checkVersionRunnable: macVersion >= 2.6.8"); setTagDelay(csReaderConnector.rfidReader.tagDelaySetting); setCycleDelay(csReaderConnector.rfidReader.cycleDelaySetting); setInvModeCompact(true); } else { - if (DEBUG) appendToLog("checkVersionRunnable: macVersion < 2.6.8"); + Logger.debug("checkVersionRunnable: macVersion < 2.6.8"); setTagDelay(csReaderConnector.rfidReader.tagDelayDefaultNormalSetting); setCycleDelay(csReaderConnector.rfidReader.cycleDelaySetting); } csReaderConnector.rfidReader.setDiagnosticConfiguration(true); - if (DEBUG) appendToLog("checkVersionRunnable: Checkpoint 10"); + Logger.debug("checkVersionRunnable: Checkpoint 10"); //setSameCheck(true); } } @@ -1890,4 +1900,12 @@ public int getValidata() { 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); } + + public void appendToLogView(String s) { + Logger.toLogView(s).trace(); + } + + public void appendToLog(String s) { + Logger.trace(s); + } } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs710Library4A.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs710Library4A.java index 4ffb7e5..55e6bb4 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs710Library4A.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Cs710Library4A.java @@ -22,8 +22,6 @@ import java.util.List; public class Cs710Library4A { - final boolean DEBUG = false; - final boolean DEBUG_FILE = false; private Handler mHandler = new Handler(); BluetoothAdapter.LeScanCallback mLeScanCallback = null; ScanCallback mScanCallback = null; @@ -31,7 +29,6 @@ public class Cs710Library4A { Context context; CsReaderConnector csReaderConnector; Utility utility; - boolean DEBUG_CONNECT, DEBUG_SCAN; BluetoothGatt bluetoothGatt; RfidReaderChipE710 rfidReaderChip; //RfidConnector rfidConnector; BarcodeNewland barcodeNewland; BarcodeConnector barcodeConnector; @@ -42,32 +39,31 @@ public Cs710Library4A(Context context, TextView mLogView) { this.context = context; utility = new Utility(context, mLogView); csReaderConnector = new CsReaderConnector(context, mLogView, utility, false); - bluetoothGatt = csReaderConnector.bluetoothGatt; DEBUG_CONNECT = bluetoothGatt.DEBUG_CONNECT; DEBUG_SCAN = bluetoothGatt.DEBUG_SCAN; + bluetoothGatt = csReaderConnector.bluetoothGatt; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mScanCallback = new ScanCallback() { @Override public void onBatchScanResults(List results) { - if (DEBUG) appendToLog("onBatchScanResults()"); + Logger.debug("onBatchScanResults()"); } @Override public void onScanFailed(int errorCode) { - if (DEBUG) appendToLog("onScanFailed()"); + Logger.debug("onScanFailed()"); } @Override public void onScanResult(int callbackType, ScanResult result) { - boolean DEBUG = false; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { BluetoothGatt.CsScanData scanResultA = new BluetoothGatt.CsScanData(result.getDevice(), result.getRssi(), result.getScanRecord().getBytes()); boolean found98 = true; if (true) found98 = check9800(scanResultA); - if (DEBUG) appendToLog("found98 = " + found98 + ", mScanResultList 0 = " + (mScanResultList != null ? "VALID" : "NULL")); + Logger.debug("found98 = {}, mScanResultList 0 = {}", found98, (mScanResultList != null ? "VALID" : "NULL")); if (mScanResultList != null && found98) { scanResultA.serviceUUID2p2 = check9800_serviceUUID2p1; mScanResultList.add(scanResultA); - if (DEBUG) appendToLog("mScanResultList 0 = " + mScanResultList.size()); + Logger.debug("mScanResultList 0 = {}", mScanResultList.size()); } } } @@ -76,15 +72,15 @@ public void onScanResult(int callbackType, ScanResult result) { mLeScanCallback = new BluetoothAdapter.LeScanCallback() { @Override public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] scanRecord) { - if (true) appendToLog("onLeScan()"); + Logger.trace("onLeScan()"); BluetoothGatt.CsScanData scanResultA = new BluetoothGatt.CsScanData(device, rssi, scanRecord); boolean found98 = true; if (true) found98 = check9800(scanResultA); - appendToLog("found98 = " + found98 + ", mScanResultList 1 = " + (mScanResultList != null ? "VALID" : "NULL")); + Logger.trace("found98 = {}, mScanResultList 1 = {}", found98, (mScanResultList != null ? "VALID" : "NULL")); if (mScanResultList != null && found98) { scanResultA.serviceUUID2p2 = check9800_serviceUUID2p1; mScanResultList.add(scanResultA); - appendToLog("mScanResultList 1 = " + mScanResultList.size()); + Logger.trace("mScanResultList 1 = {}", mScanResultList.size()); } } }; @@ -93,15 +89,14 @@ public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] File path = context.getFilesDir(); File[] fileArray = path.listFiles(); boolean deleteFiles = false; - if (true || DEBUG) - appendToLog("Number of file in data storage sub-directory = " + fileArray.length); + Logger.debug("Number of file in data storage sub-directory = {}", fileArray.length); boolean bProfileInstalledFound = false; for (int i = 0; i < fileArray.length; i++) { String fileName = fileArray[i].toString(); - if (true) appendToLog("Stored file (" + i + ") = " + fileName); + Logger.trace("Stored file ({}) = {}", i, fileName); if (fileName.contains("profileInstalled") || fileName.contains("profileinstaller")) { bProfileInstalledFound = true; - appendToLog("Found profileInstalled or profileinstaller file"); + Logger.trace("Found profileInstalled or profileinstaller file"); } File file = new File(fileName); if (deleteFiles) file.delete(); @@ -111,7 +106,7 @@ public void onLeScan(final BluetoothDevice device, final int rssi, final byte[] String fileName = fileArray[i].toString(); File file = new File(fileName); file.delete(); - appendToLog("Deleted " + fileName); + Logger.trace("Deleted {}", fileName); } } } @@ -119,7 +114,7 @@ public String getlibraryVersion() { String version = BuildConfig.VERSION_NAME; //int iVersion = Integer.parseInt(version) + 10; version = "14.17"; //+ String.valueOf(iVersion); - appendToLog("version = " + version); + Logger.info("version = {}", version); return utility.getCombinedVersion(version); } public String checkVersion() { @@ -147,12 +142,6 @@ public String checkVersion() { public String byteArrayToString(byte[] packet) { return utility.byteArrayToString(packet); } - public void appendToLog(String s) { - utility.appendToLog(s); - } - public void appendToLogView(String s) { - utility.appendToLogView(s); - } public String strFloat16toFloat32(String strData) { return utility.strFloat16toFloat32(strData); } @@ -196,8 +185,8 @@ public boolean checkHostProcessorVersion(String version, int majorVersion, int m int iConnectStateTimer = 0; boolean check9800(BluetoothGatt.CsScanData scanResultA) { - boolean found98 = false, DEBUG = false; - if (DEBUG) appendToLog("decoded data size = " + scanResultA.decoded_scanRecord.size()); + boolean found98 = false; + Logger.debug("decoded data size = {}", scanResultA.decoded_scanRecord.size()); int iNewADLength = 0; byte[] newAD = new byte[0]; int iNewADIndex = 0; @@ -206,15 +195,13 @@ boolean check9800(BluetoothGatt.CsScanData scanResultA) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S && ActivityCompat.checkSelfPermission(context, Manifest.permission.BLUETOOTH_CONNECT) != PackageManager.PERMISSION_GRANTED) return true; String strTemp = scanResultA.getDevice().getName(); - if (strTemp != null && DEBUG) - appendToLog("Found name = " + strTemp + ", length = " + String.valueOf(strTemp.length())); + if (strTemp != null) Logger.debug("Found name = {}, length = {}", strTemp, strTemp.length()); for (byte bdata : scanResultA.getScanRecord()) { if (iNewADIndex >= iNewADLength && iNewADLength != 0) { scanResultA.decoded_scanRecord.add(newAD); iNewADIndex = 0; iNewADLength = 0; - if (DEBUG) - appendToLog("Size = " + scanResultA.decoded_scanRecord.size() + ", " + byteArrayToString(newAD)); + Logger.debug("Size = {}, {}", scanResultA.decoded_scanRecord.size(), byteArrayToString(newAD)); } if (iNewADLength == 0) { iNewADLength = bdata; @@ -222,31 +209,27 @@ boolean check9800(BluetoothGatt.CsScanData scanResultA) { iNewADIndex = 0; } else newAD[iNewADIndex++] = bdata; } - if (DEBUG) appendToLog("decoded data size = " + scanResultA.decoded_scanRecord.size()); + Logger.debug("decoded data size = {}", scanResultA.decoded_scanRecord.size()); for (int i = 0; /*scanResultA.device.getType() == BluetoothDevice.DEVICE_TYPE_LE &&*/ i < scanResultA.decoded_scanRecord.size(); i++) { byte[] currentAD = scanResultA.decoded_scanRecord.get(i); - if (DEBUG) appendToLog("Processing decoded data = " + byteArrayToString(currentAD)); + Logger.debug("Processing decoded data = {}", byteArrayToString(currentAD)); if (currentAD[0] == 2) { - if (DEBUG) appendToLog("Processing UUIDs 02"); + Logger.debug("Processing UUIDs 02"); if ((currentAD[1] == 2) && currentAD[2] == (byte) 0x98) { - if (DEBUG) appendToLog("Found 9802"); + Logger.debug("Found 9802"); found98 = true; check9800_serviceUUID2p1 = currentAD[1]; - if (DEBUG) appendToLog("serviceUD1D2p1 = " + check9800_serviceUUID2p1); + Logger.debug("serviceUD1D2p1 = {}", check9800_serviceUUID2p1); break; } } } - if (found98 == false && DEBUG) - appendToLog("No 9800: with scanData = " + byteArrayToString(scanResultA.getScanRecord())); - else if (DEBUG_SCAN) - appendToLog("Found 9800: with scanData = " + byteArrayToString(scanResultA.getScanRecord())); + if (!found98) Logger.debug("No 9800: with scanData = {}", byteArrayToString(scanResultA.getScanRecord())); + else Logger.scan("Found 9800: with scanData = {}", byteArrayToString(scanResultA.getScanRecord())); return found98; } boolean connect1(ReaderDevice readerDevice) { - boolean DEBUG = false; - if (DEBUG_CONNECT) - appendToLog("Connect with NULLreaderDevice = " + (readerDevice == null) + ", NULLreaderDeviceConnect = " + (readerDeviceConnect == null)); + Logger.connect("Connect with NULLreaderDevice = {}, NULLreaderDeviceConnect = {}", readerDevice == null, readerDeviceConnect == null); if (readerDevice == null && readerDeviceConnect != null) readerDevice = readerDeviceConnect; boolean result = false; if (readerDevice != null) { @@ -256,48 +239,43 @@ boolean connect1(ReaderDevice readerDevice) { bluetoothGatt.setServiceUUIDType(readerDevice.getServiceUUID2p1()); result = csReaderConnector.connectBle(readerDevice); } - if (DEBUG_CONNECT) appendToLog("Result = " + result); + Logger.connect("Result = {}", result); return result; } final Runnable connectRunnable = new Runnable() { - boolean DEBUG = false; @Override public void run() { - if (DEBUG_CONNECT) - appendToLog("0 connectRunnable: mBluetoothConnectionState = " + bluetoothGatt.bluetoothConnectionState + ", bNeedReconnect = " + bNeedReconnect); + Logger.connect("0 connectRunnable: mBluetoothConnectionState = {}, bNeedReconnect = {}", bluetoothGatt.bluetoothConnectionState, bNeedReconnect); if (isBleScanning()) { - if (DEBUG) appendToLog("connectRunnable: still scanning. Stop scanning first"); + Logger.debug("connectRunnable: still scanning. Stop scanning first"); scanLeDevice(false); } else if (bNeedReconnect) { if (bluetoothGatt.bluetoothGatt != null) { - if (DEBUG) - appendToLog("connectRunnable: mBluetoothGatt is null before connect. disconnect first"); + Logger.debug("connectRunnable: mBluetoothGatt is null before connect. disconnect first"); csReaderConnector.disconnect(); } else if (readerDeviceConnect == null) { - if (DEBUG) appendToLog("connectRunnable: exit with null readerDeviceConnect"); + Logger.debug("connectRunnable: exit with null readerDeviceConnect"); return; } else if (bluetoothGatt.bluetoothGatt == null) { - if (DEBUG_CONNECT) appendToLog("4 connectRunnable: connect1 starts"); + Logger.connect("4 connectRunnable: connect1 starts"); connect1(null); bNeedReconnect = false; } } else if (bluetoothGatt.bluetoothConnectionState == BluetoothProfile.STATE_DISCONNECTED) { //mReaderStreamOutCharacteristic valid around 1500ms iConnectStateTimer = 0; - if (DEBUG) - appendToLog("connectRunnable: disconnect as disconnected connectionState is received"); + Logger.debug("connectRunnable: disconnect as disconnected connectionState is received"); bNeedReconnect = true; if (bluetoothGatt.bluetoothGatt != null) { - if (DEBUG) appendToLog("disconnect F"); + Logger.debug("disconnect F"); csReaderConnector.disconnect(); } } else if (bluetoothGatt.mReaderStreamOutCharacteristic == null) { - if (DEBUG_CONNECT) - appendToLog("6 connectRunnable: wait as not yet discovery, with iConnectStateTimer = " + iConnectStateTimer); + Logger.connect("6 connectRunnable: wait as not yet discovery, with iConnectStateTimer = {}", iConnectStateTimer); if (++iConnectStateTimer > 10) { } } else { - if (DEBUG_CONNECT) appendToLog("7 connectRunnable: end of ConnectRunnable"); + Logger.connect("7 connectRunnable: end of ConnectRunnable"); return; } mHandler.postDelayed(connectRunnable, 500); @@ -307,11 +285,11 @@ public void run() { @Override public void run() { if (barcodeConnector == null) return; - appendToLog("abcc disconnectRunnable with barcodeToWrite.size = " + barcodeConnector.barcodeToWrite.size()); + Logger.trace("abcc disconnectRunnable with barcodeToWrite.size = {}", barcodeConnector.barcodeToWrite.size()); if (barcodeConnector.barcodeToWrite.size() != 0) mHandler.postDelayed(disconnectRunnable, 100); else { - appendToLog("disconnect G"); + Logger.trace("disconnect G"); csReaderConnector.disconnect(); } } @@ -320,20 +298,19 @@ public boolean isBleScanning() { return bluetoothGatt.isBleScanning(); } public boolean scanLeDevice(final boolean enable) { - boolean DEBUG = false; if (enable) mHandler.removeCallbacks(connectRunnable); - if (DEBUG_SCAN) appendToLog("scanLeDevice[" + enable + "]"); + Logger.scan("scanLeDevice[{}]", enable); if (bluetoothGatt.bluetoothDeviceConnectOld != null) { - if (DEBUG) appendToLog("bluetoothDeviceConnectOld connection state = " + bluetoothGatt.bluetoothManager.getConnectionState(bluetoothGatt.bluetoothDeviceConnectOld, BluetoothProfile.GATT)); + Logger.debug("bluetoothDeviceConnectOld connection state = {}", bluetoothGatt.bluetoothManager.getConnectionState(bluetoothGatt.bluetoothDeviceConnectOld, BluetoothProfile.GATT)); } boolean bValue = bluetoothGatt.scanLeDevice(enable, this.mLeScanCallback, this.mScanCallback); - if (DEBUG_SCAN) appendToLog("isScanning = " + isBleScanning()); + Logger.scan("isScanning = {}", isBleScanning()); return bValue; } public BluetoothGatt.CsScanData getNewDeviceScanned() { if (mScanResultList.size() != 0) { - if (DEBUG_SCAN) appendToLog("mScanResultList.size() = " + mScanResultList.size()); + Logger.scan("mScanResultList.size() = {}", mScanResultList.size()); BluetoothGatt.CsScanData csScanData = mScanResultList.get(0); mScanResultList.remove(0); return csScanData; } else return null; @@ -347,12 +324,11 @@ public String getBluetoothDeviceName() { return bluetoothGatt.getmBluetoothDevice().getName(); } public boolean isBleConnected() { - boolean DEBUG = true; boolean bleConnectionNew = csReaderConnector.isBleConnected(); if (bleConnectionNew) { if (bleConnection == false) { bleConnection = bleConnectionNew; - if (DEBUG_CONNECT || DEBUG) appendToLog("Newly connected"); + Logger.connect("Newly connected"); csReaderConnector.csConnectorDataInit(); rfidReaderChip = csReaderConnector.rfidReader.rfidReaderChipE710; @@ -409,7 +385,7 @@ public boolean isBleConnected() { getQueryTarget(); csReaderConnector.rfidReader.getImpinjExtension(); csReaderConnector.rfidReader.getInvAlgoInChip(); - if (DEBUG_CONNECT || DEBUG) appendToLog("Start checkVersionRunnable"); + Logger.connect("Start checkVersionRunnable"); mHandler.postDelayed(checkVersionRunnable, 500); if (csReaderConnector.settingData.strForegroundReader.trim().length() != 0) { @@ -418,7 +394,7 @@ public boolean isBleConnected() { csReaderConnector.settingData.saveForegroundSetting2File(); } else if (rfidReaderChip == null) { bleConnection = false; - appendToLog("rfidReaderChip is NULL"); + Logger.trace("rfidReaderChip is NULL"); } else if (csReaderConnector.rfidReader.bFirmware_reset_before) { csReaderConnector.rfidReader.bFirmware_reset_before = false; mHandler.postDelayed(reinitaliseDataRunnable, 500); @@ -430,7 +406,7 @@ public boolean isBleConnected() { controllerConnector = null; bluetoothConnector = null; bleConnection = bleConnectionNew; - if (DEBUG) appendToLog("Newly disconnected"); + Logger.debug("Newly disconnected"); } return(bleConnection); } @@ -440,23 +416,26 @@ public void connect(ReaderDevice readerDevice) { if (readerDevice != null) readerDeviceConnect = readerDevice; mHandler.removeCallbacks(connectRunnable); bNeedReconnect = true; mHandler.post(connectRunnable); - if (DEBUG_CONNECT) appendToLog("Start ConnectRunnable"); + Logger.connect("Start ConnectRunnable"); } public void disconnect(boolean tempDisconnect) { - appendToLog("abcc tempDisconnect: getBarcodeOnStatus = " + (getBarcodeOnStatus() ? "on" : "off")); - if (DEBUG) appendToLog("tempDisconnect = " + tempDisconnect); + Logger.trace("abcc tempDisconnect: getBarcodeOnStatus = {}", getBarcodeOnStatus() ? "on" : "off"); + Logger.debug("tempDisconnect = {}", tempDisconnect); mHandler.removeCallbacks(checkVersionRunnable); mHandler.removeCallbacks(runnableToggleConnection); if (getBarcodeOnStatus()) { - appendToLog("tempDisconnect: setBarcodeOn(false)"); + Logger.trace("tempDisconnect: setBarcodeOn(false)"); if (barcodeConnector.barcodeToWrite.size() != 0) { - appendToLog("going to disconnectRunnable with remaining barcodeToWrite.size = " + barcodeConnector.barcodeToWrite.size() + ", data = " + byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); + Logger.trace("going to disconnectRunnable with remaining barcodeToWrite.size = {}, barcodeToWrite = {}", barcodeConnector.barcodeToWrite.size(), byteArrayToString(barcodeConnector.barcodeToWrite.get(0).dataValues)); } - barcodeConnector.barcodeToWrite.clear(); appendToLog("barcodeToWrite is clear"); + barcodeConnector.barcodeToWrite.clear(); + Logger.trace("barcodeToWrite is clear"); setBarcodeOn(false); - } else appendToLog("tempDisconnect: getBarcodeOnStatus is false"); + } else { + Logger.trace("tempDisconnect: getBarcodeOnStatus is false"); + } mHandler.postDelayed(disconnectRunnable, 100); - appendToLog("done with tempDisconnect = " + tempDisconnect); + Logger.trace("done with tempDisconnect = {}", tempDisconnect); if (tempDisconnect == false) { mHandler.removeCallbacks(connectRunnable); bluetoothGatt.bluetoothDeviceConnectOld = null; @@ -530,13 +509,17 @@ RegionCodes[] getRegionList() { Runnable runnableToggleConnection = new Runnable() { @Override public void run() { - if (DEBUG) appendToLog("runnableToggleConnection(): toggledConnection = " + toggledConnection + ", isBleConnected() = " + isBleConnected()); - if (isBleConnected() == false) toggledConnection = true; + Logger.debug("runnableToggleConnection(): toggledConnection = {}, isBleConnected() = {}", toggledConnection, isBleConnected()); + if (!isBleConnected()) toggledConnection = true; if (toggledConnection) { - if (isBleConnected() == false) { - if (connect1(null) == false) return; + if (!isBleConnected()) { + if (!connect1(null)) return; } else return; - } else { appendToLog("disconnect H"); csReaderConnector.disconnect(); appendToLog("done"); } + } else { + Logger.trace("disconnect H"); + csReaderConnector.disconnect(); + Logger.trace("done"); + } mHandler.postDelayed(runnableToggleConnection, 500); } }; @@ -553,7 +536,6 @@ 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(); } @@ -642,17 +624,17 @@ public boolean setAntennaEnable(boolean enable) { return csReaderConnector.rfidReader.setAntennaEnable(enable); } public long getAntennaDwell() { - long lValue = 0; boolean DEBUG = false; - if (DEBUG) appendToLog("1 getAntennaDwell"); + long lValue = 0; + Logger.debug("1 getAntennaDwell"); lValue = rfidReaderChip.rx000Setting.getAntennaDwell(); - if (DEBUG) appendToLog("1A getAntennaDwell: lValue = " + lValue); + Logger.debug("1A getAntennaDwell: lValue = {}", lValue); return lValue; } public boolean setAntennaDwell(long antennaDwell) { - boolean bValue = false, DEBUG = false; - if (DEBUG) appendToLog("1 AntennaDwell = " + antennaDwell + " returning " + bValue); + boolean bValue = false; + Logger.debug("1 AntennaDwell = {} returning {}", antennaDwell, bValue); bValue = rfidReaderChip.rx000Setting.setAntennaDwell(antennaDwell); - if (DEBUG) appendToLog("1A AntennaDwell = " + antennaDwell + " returning " + bValue); + Logger.debug("1A AntennaDwell = {} returning {}", antennaDwell, bValue); return bValue; } public long getPwrlevel() { @@ -677,9 +659,8 @@ public int getQuerySelect() { return rfidReaderChip.rx000Setting.getQuerySelect(); } public boolean setTagGroup(int sL, int session, int target1) { - //appendToLog("1d"); int iAlgoAbFlip = rfidReaderChip.rx000Setting.getAlgoAbFlip(); - appendToLog("sL = " + sL + ", session = " + session + ", target = " + target1 + ", getAlgoAbFlip = " + iAlgoAbFlip); + Logger.trace("sL = {}, session = {}, target = {}, getAlgoAbFlip = {}", sL, session, target1, iAlgoAbFlip); boolean bValue = false; bValue = rfidReaderChip.rx000Setting.setQueryTarget(target1, session, sL); if (bValue) { @@ -698,7 +679,7 @@ public int getFastId() { return csReaderConnector.rfidReader.getFastId(); } public boolean setFastId(boolean fastIdNew) { - appendToLog("bFastId: setFastId[" + fastIdNew); + Logger.trace("bFastId: setFastId[{}]", fastIdNew); return csReaderConnector.rfidReader.setFastId(fastIdNew); } public boolean getInvAlgo() { @@ -799,16 +780,16 @@ public boolean setUntraceable(int range, boolean user, int tid, int epcLength, b } public boolean setAuthenticateConfiguration() { if (true) return csReaderConnector.rfidReader.setAuthenticateConfiguration(); - appendToLog("setAuthenticateConfiguration Started"); + Logger.trace("setAuthenticateConfiguration Started"); boolean bValue = rfidReaderChip.rx000Setting.setAuthenticateConfig((48 << 10) | (1 << 2) | 0x03); - appendToLog("setAuthenticateConfiguration 1: bValue = " + (bValue ? "true" : "false")); + Logger.trace("setAuthenticateConfiguration 1: bValue = {}", bValue ? "true" : "false"); if (bValue) { bValue = rfidReaderChip.rx000Setting.setAuthenticateMessage(new byte[] { 0x04, (byte)0x9C, (byte)0xA5, 0x3E, 0x55, (byte)0xEA } ); - appendToLog("setAuthenticateConfiguration 2: bValue = " + (bValue ? "true" : "false")); + Logger.trace("setAuthenticateConfiguration 2: bValue = {}", bValue ? "true" : "false"); } if (bValue) { bValue = rfidReaderChip.rx000Setting.setAuthenticateResponseLen(16 * 8); - appendToLog("setAuthenticateConfiguration 3: bValue = " + (bValue ? "true" : "false")); + Logger.trace("setAuthenticateConfiguration 3: bValue = {}", bValue ? "true" : "false"); } return bValue; } @@ -847,7 +828,7 @@ public boolean setInvSelectIndex(int invSelect) { return csReaderConnector.rfidReader.setInvSelectIndex(invSelect); } public boolean setSelectCriteriaDisable(int index) { - if (utility.DEBUG_SELECT) appendToLog("Debug_Select: Cs710Library4A.setSelectCriteriaDisable[" + index + "] goes to setSelectCriteriaDisable"); + Logger.select("Debug_Select: Cs710Library4A.setSelectCriteriaDisable[{}] goes to setSelectCriteriaDisable", index); return csReaderConnector.rfidReader.setSelectCriteriaDisable(index); } int findFirstEmptySelect() { @@ -909,7 +890,7 @@ public int mrfidToWriteSize() { public void mrfidToWritePrint() { if (true) { csReaderConnector.rfidReader.mrfidToWriteSize(); return; } for (int i = 0; i < csReaderConnector.rfidReader.mRfidToWrite.size(); i++) { - appendToLog(byteArrayToString(csReaderConnector.rfidReader.mRfidToWrite.get(i).dataValues)); + Logger.trace(byteArrayToString(csReaderConnector.rfidReader.mRfidToWrite.get(i).dataValues)); } } public long getTagRate() { @@ -923,7 +904,7 @@ public boolean abortOperation() { } public void restoreAfterTagSelect() { if (!isBleConnected()) return; - if (utility.DEBUG_SELECT) appendToLog("Debug_Select: Cs710Library4A.restoreAfterTagSelect goes to setSelectCriteriaDisable"); + Logger.select("Debug_Select: Cs710Library4A.restoreAfterTagSelect goes to setSelectCriteriaDisable"); setSelectCriteriaDisable(0); setSelectCriteriaDisable(1); setSelectCriteriaDisable(2); loadSetting1File(); setAccessCount(0); @@ -937,9 +918,10 @@ public void restoreAfterTagSelect() { if (csReaderConnector.rfidReader.postMatchDataChanged) { csReaderConnector.rfidReader.postMatchDataChanged = false; setPostMatchCriteria(csReaderConnector.rfidReader.postMatchDataOld.enable, csReaderConnector.rfidReader.postMatchDataOld.target, csReaderConnector.rfidReader.postMatchDataOld.offset, csReaderConnector.rfidReader.postMatchDataOld.mask); - appendToLog("PowerLevel"); + Logger.trace("PowerLevel"); setPowerLevel(csReaderConnector.rfidReader.postMatchDataOld.pwrlevel); - appendToLog("writeBleStreamOut: invAlgo = " + csReaderConnector.rfidReader.postMatchDataOld.invAlgo); setInvAlgo1(csReaderConnector.rfidReader.postMatchDataOld.invAlgo); + Logger.trace("writeBleStreamOut: invAlgo = {}", csReaderConnector.rfidReader.postMatchDataOld.invAlgo); + setInvAlgo1(csReaderConnector.rfidReader.postMatchDataOld.invAlgo); setQValue1(csReaderConnector.rfidReader.postMatchDataOld.qValue); } } @@ -953,7 +935,7 @@ public boolean setSelectedTag(String selectMask, int selectBank, int selectOffse return csReaderConnector.rfidReader.setSelectedTag4Access(false, selectMask, selectBank, selectOffset, pwrlevel, qValue, matchRep); } public boolean setMatchRep(int matchRep) { - if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: Cs710Library4A.setMatchRep goes to setMatchRep with matchRep = " + matchRep); + Logger.invCfg("Debug_InvCfg: Cs710Library4A.setMatchRep goes to setMatchRep with matchRep = {}", matchRep); return csReaderConnector.rfidReader.setMatchRep(matchRep); } public String[] getCountryList() { @@ -967,18 +949,18 @@ public boolean setCountryInList(int countryInList) { } public boolean getChannelHoppingStatus() { if (true) csReaderConnector.rfidReader.getChannelHoppingStatus(); - boolean bValue = false, DEBUG = false; + boolean bValue = false; int iValue = rfidReaderChip.rx000Setting.getCountryEnum(); //iValue--; - if (DEBUG) appendToLog("getChannelHoppingStatus: countryEnum = " + iValue); + Logger.debug("getChannelHoppingStatus: countryEnum = {}", iValue); if (iValue > 0) { String strFixedHop = csReaderConnector.rfidReader.countryChannelData.strCountryEnumInfo[(iValue - 1) * csReaderConnector.rfidReader.countryChannelData.iCountryEnumInfoColumn + 4]; - if (DEBUG) appendToLog("getChannelHoppingStatus: FixedHop = " + strFixedHop); + Logger.debug("getChannelHoppingStatus: FixedHop = {}", strFixedHop); if (strFixedHop.matches("Hop")) { - if (DEBUG) appendToLog("getChannelHoppingStatus: matched"); + Logger.debug("getChannelHoppingStatus: matched"); bValue = true; } } - if (DEBUG) appendToLog("getChannelHoppingStatus: bValue = " + bValue); + Logger.debug("getChannelHoppingStatus: bValue = {}", bValue); return bValue; //1 for hopping, 0 for fixed } public boolean setChannelHoppingStatus(boolean channelOrderHopping) { @@ -988,12 +970,14 @@ public boolean setChannelHoppingStatus(boolean channelOrderHopping) { if (getChannelHoppingDefault() == false) { result = rfidReaderChip.rx000Setting.setAntennaFreqAgile(channelOrderHopping ? 1 : 0); } - int freqcnt = FreqChnCnt(); appendToLog("FrequencyA Count = " + freqcnt); - int channel = getChannel(); appendToLog(" FrequencyA Channel = " + channel); - appendToLog(" FrequencyA: end of setting"); + int freqcnt = FreqChnCnt(); + Logger.debug("FrequencyA Count = {}", freqcnt); + int channel = getChannel(); + Logger.debug(" FrequencyA Channel = {}", channel); + Logger.debug(" FrequencyA: end of setting"); csReaderConnector.rfidReader.channelOrderType = (channelOrderHopping ? 0 : 1); - appendToLog("setChannelHoppingStatus: channelOrderType = " + csReaderConnector.rfidReader.channelOrderType); + Logger.debug("setChannelHoppingStatus: channelOrderType = {}", csReaderConnector.rfidReader.channelOrderType); } return true; } @@ -1028,7 +1012,6 @@ boolean setQValue1(int iValue) { return csReaderConnector.rfidReader.setQValue1(iValue); } public RfidReaderChipData.Rx000pkgData onRFIDEvent() { - boolean DEBUG = false; RfidReaderChipData.Rx000pkgData rx000pkgData = null; //if (mrfidToWriteSize() != 0) mRfidDevice.mRfidReaderChip.mRfidReaderChip.mRx000ToRead.clear(); if (rfidReaderChip.bRx000ToReading == false && rfidReaderChip.mRx000ToRead.size() != 0) { @@ -1037,9 +1020,9 @@ public RfidReaderChipData.Rx000pkgData onRFIDEvent() { try { rx000pkgData = rfidReaderChip.mRx000ToRead.get(index); if (false && rx000pkgData.responseType == RfidReaderChipData.HostCmdResponseTypes.TYPE_COMMAND_END) - if (DEBUG) appendToLog("get mRx000ToRead with COMMAND_END"); + Logger.debug("get mRx000ToRead with COMMAND_END"); rfidReaderChip.mRx000ToRead.remove(index); - if (DEBUG) appendToLog("got one mRx000ToRead with responseType = " + rx000pkgData.responseType.toString() + ", and remained size = " + rfidReaderChip.mRx000ToRead.size()); + Logger.debug("got one mRx000ToRead with responseType = {}, and remained size = {}", rx000pkgData.responseType, rfidReaderChip.mRx000ToRead.size()); } catch (Exception ex) { rx000pkgData = null; } @@ -1047,21 +1030,21 @@ public RfidReaderChipData.Rx000pkgData onRFIDEvent() { } if (rx000pkgData != null && rx000pkgData.responseType != null) { if (rx000pkgData.responseType == RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_INVENTORY || rx000pkgData.responseType == RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_INVENTORY_COMPACT) { - if (DEBUG) appendToLog("Before adjustment, decodedRssi = " + rx000pkgData.decodedRssi); + Logger.debug("Before adjustment, decodedRssi = {}", rx000pkgData.decodedRssi); rx000pkgData.decodedRssi += dBuV_dBm_constant; - if (DEBUG) appendToLog("After adjustment, decodedRssi = " + rx000pkgData.decodedRssi); + Logger.debug("After adjustment, decodedRssi = {}", rx000pkgData.decodedRssi); if (rfidReaderChip.rx000Setting.getInvMatchEnable() > 0) { byte[] bytesCompared = new byte[rx000pkgData.decodedEpc.length]; System.arraycopy(rx000pkgData.decodedEpc, 0, bytesCompared, 0, rx000pkgData.decodedEpc.length); //bytesCompared = new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x2F }; //bytesCompared = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) 0xFF, (byte) 0xFF, (byte) 0x2F }; - appendToLog("decodedEpc = " + byteArrayToString(rx000pkgData.decodedEpc)); + Logger.debug("decodedEpc = {}", byteArrayToString(rx000pkgData.decodedEpc)); if (rfidReaderChip.rx000Setting.getInvMatchOffset() > 0) { - appendToLog("getInvMatchOffset = " + rfidReaderChip.rx000Setting.getInvMatchOffset()); + Logger.trace("getInvMatchOffset = {}", rfidReaderChip.rx000Setting.getInvMatchOffset()); BigInteger bigInt = new BigInteger(bytesCompared); BigInteger shiftInt = bigInt.shiftLeft(rfidReaderChip.rx000Setting.getInvMatchOffset()); byte [] shifted = shiftInt.toByteArray(); - appendToLog("shifted = " + byteArrayToString(shifted)); + Logger.trace("shifted = {}", byteArrayToString(shifted)); if (shifted.length > bytesCompared.length) System.arraycopy(shifted, shifted.length - bytesCompared.length, bytesCompared, 0, bytesCompared.length); else if (shifted.length < bytesCompared.length) { System.arraycopy(shifted, 0, bytesCompared, bytesCompared.length - shifted.length, shifted.length); @@ -1070,25 +1053,25 @@ else if (shifted.length < bytesCompared.length) { else bytesCompared[i] = (byte)0xFF; } } - appendToLog("new bytesCompared 1 = " + byteArrayToString(bytesCompared)); + Logger.trace("new bytesCompared 1 = {}", byteArrayToString(bytesCompared)); } if (rfidReaderChip.rx000Setting.getInvMatchType() > 0) { - appendToLog("getInvMatchType = " + rfidReaderChip.rx000Setting.getInvMatchType()); + Logger.trace("getInvMatchType = {}", rfidReaderChip.rx000Setting.getInvMatchType()); for (int i = 0; i < bytesCompared.length; i++) { bytesCompared[i] ^= (byte) 0xFF; } } - appendToLog("new bytesCompared 2 = " + byteArrayToString(bytesCompared)); - appendToLog("getInvMatchData = " + rfidReaderChip.rx000Setting.getInvMatchData()); + Logger.trace("new bytesCompared 2 = {}", byteArrayToString(bytesCompared)); + Logger.trace("getInvMatchData = {}", rfidReaderChip.rx000Setting.getInvMatchData()); if (byteArrayToString(bytesCompared).indexOf(rfidReaderChip.rx000Setting.getInvMatchData()) != 0) { - appendToLog("Post Mis-Matched !!!"); + Logger.trace("Post Mis-Matched !!!"); rx000pkgData = null; } } } } - if (rx000pkgData != null && DEBUG) appendToLog("response = " + rx000pkgData.responseType.toString() + ", " + byteArrayToString(rx000pkgData.dataValues)); + if (rx000pkgData != null) Logger.debug("response = {}, {}", rx000pkgData.responseType, byteArrayToString(rx000pkgData.dataValues)); return rx000pkgData; } public String getModelNumber() { @@ -1104,7 +1087,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"); + Logger.compact("Debug_Compact 2: Cs710Library4A.setInvModeCompact goes to setInvModeCompact"); return csReaderConnector.rfidReader.setInvModeCompact(invModeCompact); } public boolean setAccessLockAction(int accessLockAction, int accessLockMask) { @@ -1212,29 +1195,30 @@ public boolean setBarcodeOn(boolean on) { if (on) csReaderBarcodeData.barcodePayloadEvent = BarcodeConnector.BarcodePayloadEvents.BARCODE_POWER_ON; else csReaderBarcodeData.barcodePayloadEvent = BarcodeConnector.BarcodePayloadEvents.BARCODE_POWER_OFF; csReaderBarcodeData.waitUplinkResponse = false; - retValue = barcodeConnector.barcodeToWrite.add(csReaderBarcodeData); appendToLog("barcodeToWrite added with size = " + barcodeConnector.barcodeToWrite.size()); - if (DEBUG_FILE) appendToLog("add " + csReaderBarcodeData.barcodePayloadEvent.toString() + " to barcodeToWrite with length = " + barcodeConnector.barcodeToWrite.size()); + retValue = barcodeConnector.barcodeToWrite.add(csReaderBarcodeData); + Logger.trace("barcodeToWrite added with size = {}", barcodeConnector.barcodeToWrite.size()); + Logger.debug("add {} to barcodeToWrite with length = {}", csReaderBarcodeData.barcodePayloadEvent, barcodeConnector.barcodeToWrite.size()); boolean continuousAfterOn = false; if (retValue && on && continuousAfterOn) { if (checkHostProcessorVersion(getBluetoothICFirmwareVersion(), 1, 0, 2)) { - if (DEBUG) appendToLog("to barcodeSendCommandConinuous()"); + Logger.debug("to barcodeSendCommandConinuous()"); retValue = barcodeNewland.barcodeSendCommandConinuous(); } else retValue = false; } - if (DEBUG) appendToLog("barcodeToWrite size = " + barcodeConnector.barcodeToWrite.size()); + Logger.debug("barcodeToWrite size = {}", barcodeConnector.barcodeToWrite.size()); return retValue; } int iModeSet = -1, iVibratieTimeSet = -1; public boolean setVibrateOn(int mode) { boolean retValue; - if (true) appendToLog("setVibrateOn with mode = " + mode + ", and isInventoring = " + csReaderConnector.rfidReader.isInventoring()); + Logger.trace("setVibrateOn with mode = {}, and isInventoring = {}", mode, csReaderConnector.rfidReader.isInventoring()); if (csReaderConnector.rfidReader.isInventoring()) return false; BarcodeConnector.CsReaderBarcodeData csReaderBarcodeData = new BarcodeConnector.CsReaderBarcodeData(); if (mode > 0) csReaderBarcodeData.barcodePayloadEvent = BarcodeConnector.BarcodePayloadEvents.BARCODE_VIBRATE_ON; else csReaderBarcodeData.barcodePayloadEvent = BarcodeConnector.BarcodePayloadEvents.BARCODE_VIBRATE_OFF; csReaderBarcodeData.waitUplinkResponse = false; if (iModeSet == mode && iVibratieTimeSet == getVibrateTime()) { - appendToLog("writeBleStreamOut: A7B3: Skip saving vibration data"); + Logger.trace("writeBleStreamOut: A7B3: Skip saving vibration data"); return true; } if (mode > 0) { @@ -1244,8 +1228,9 @@ public boolean setVibrateOn(int mode) { barcodeCommandData[2] = (byte) (getVibrateTime() % 256); csReaderBarcodeData.dataValues = barcodeCommandData; } - retValue = barcodeConnector.barcodeToWrite.add(csReaderBarcodeData); appendToLog("barcodeToWrite added with size = " + barcodeConnector.barcodeToWrite.size()); - if (DEBUG) appendToLog("barcodeToWrite size = " + barcodeConnector.barcodeToWrite.size()); + retValue = barcodeConnector.barcodeToWrite.add(csReaderBarcodeData); + Logger.trace("barcodeToWrite added with size = {}", barcodeConnector.barcodeToWrite.size()); + Logger.debug("barcodeToWrite size = {}", barcodeConnector.barcodeToWrite.size()); if (retValue) { iModeSet = mode; iVibratieTimeSet = getVibrateTime(); } @@ -1255,10 +1240,9 @@ public boolean getInventoryVibrate() { return csReaderConnector.settingData.inventoryVibrate; } public boolean setInventoryVibrate(boolean inventoryVibrate) { - boolean DEBUG = false; - if (DEBUG) appendToLog("this.inventoryVibrate = " + csReaderConnector.settingData.inventoryVibrate + ", inventoryVibrate = " + inventoryVibrate); + Logger.debug("this.inventoryVibrate = {}, inventoryVibrate = {}", csReaderConnector.settingData.inventoryVibrate, inventoryVibrate); csReaderConnector.settingData.inventoryVibrate = inventoryVibrate; - if (DEBUG) appendToLog("this.inventoryVibrate = " + csReaderConnector.settingData.inventoryVibrate + ", inventoryVibrate = " + inventoryVibrate); + Logger.debug("this.inventoryVibrate = {}, inventoryVibrate = {}", csReaderConnector.settingData.inventoryVibrate, inventoryVibrate); return true; } public int getVibrateTime() { @@ -1296,24 +1280,48 @@ public String getBarcodeSerial() { boolean barcodeAutoStarted = false; public boolean barcodeInventory(boolean start) { boolean result = true; - appendToLog("TTestPoint 0: " + start); + Logger.trace("TTestPoint 0: {}", start); if (start) { barcodeConnector.mBarcodeToRead.clear(); barcodeDataStore = null; - if (getBarcodeOnStatus() == false) { result = setBarcodeOn(true); appendToLog("TTestPoint 1"); } + if (!getBarcodeOnStatus()) { + result = setBarcodeOn(true); + Logger.trace("TTestPoint 1"); + } if (csReaderConnector.settingData.barcode2TriggerMode && result) { - if (getTriggerButtonStatus() && notificationConnector.getAutoBarStartSTop()) { appendToLog("TTestPoint 2"); barcodeAutoStarted = true; result = true; } - else { appendToLog("TTestPoint 3"); result = barcodeNewland.barcodeSendCommand(new byte[]{0x1b, 0x33}); } - } else appendToLog("TTestPoint 4"); - appendToLog("TTestPoint 5"); + if (getTriggerButtonStatus() && notificationConnector.getAutoBarStartSTop()) { + Logger.trace("TTestPoint 2"); + barcodeAutoStarted = true; + result = true; + } else { + Logger.trace("TTestPoint 3"); + result = barcodeNewland.barcodeSendCommand(new byte[]{0x1b, 0x33}); + } + } else { + Logger.trace("TTestPoint 4"); + } + Logger.trace("TTestPoint 5"); } else { - appendToLog("getBarcodeOnStatus = " + getBarcodeOnStatus() + ", result = " + result); - if (csReaderConnector.settingData.barcode2TriggerMode == false) { appendToLog("TTestPoint 6"); result = setBarcodeOn(false); } - else if (getBarcodeOnStatus() == false && result) { appendToLog("TTestPoint 7"); result = setBarcodeOn(true); } - appendToLog("barcode2TriggerMode = " + csReaderConnector.settingData.barcode2TriggerMode + ", result = " + result + ", barcodeAutoStarted = " + barcodeAutoStarted); + Logger.trace("getBarcodeOnStatus = {}, result = {}", getBarcodeOnStatus(), result); + if (!csReaderConnector.settingData.barcode2TriggerMode) { + Logger.trace("TTestPoint 6"); + result = setBarcodeOn(false); + } else if (!getBarcodeOnStatus() && result) { + Logger.trace("TTestPoint 7"); + result = setBarcodeOn(true); + } + Logger.trace("barcode2TriggerMode = {}, result = {}, barcodeAutoStarted = {}", csReaderConnector.settingData.barcode2TriggerMode, result, barcodeAutoStarted); if (csReaderConnector.settingData.barcode2TriggerMode && result) { - if (barcodeAutoStarted && result) { appendToLog("TTestPoint 8"); barcodeAutoStarted = false; result = true; } - else { appendToLog("TTestPoint 9"); result = barcodeNewland.barcodeSendCommand(new byte[] { 0x1b, 0x30 }); } - } else appendToLog("TTestPoint 10"); + if (barcodeAutoStarted && result) { + Logger.trace("TTestPoint 8"); + barcodeAutoStarted = false; + result = true; + } else { + Logger.trace("TTestPoint 9"); + result = barcodeNewland.barcodeSendCommand(new byte[] { 0x1b, 0x30 }); + } + } else{ + Logger.trace("TTestPoint 10"); + } } return result; } @@ -1335,7 +1343,7 @@ public byte[] onBarcodeEvent() { byte[] barcodeCombined = null; if (false) barcodeCombined = barcodeData; else if (barcodeData != null) { - appendToLog("BarStream: barcodeData = " + byteArrayToString(barcodeData) + ", barcodeDataStore = " + byteArrayToString(barcodeDataStore)); + Logger.trace("BarStream: barcodeData = {}, barcodeDataStore = {}", byteArrayToString(barcodeData), byteArrayToString(barcodeDataStore)); int barcodeDataStoreIndex = 0; int length = barcodeData.length; if (barcodeDataStore != null) { @@ -1363,7 +1371,7 @@ else if (barcodeData != null) { byte[] prefixExpected = barcodeNewland.getPrefix(); boolean prefixFound = false; byte[] suffixExpected = barcodeNewland.getSuffix(); boolean suffixFound = false; int codeTypeLength = 4; - appendToLog("BarStream: barcodeCombined = " + byteArrayToString(barcodeCombined) + ", Expected Prefix = " + byteArrayToString(prefixExpected) + ", Expected Suffix = " + byteArrayToString(suffixExpected)); + Logger.trace("BarStream: barcodeCombined = {}, Expected Prefix = {], Expected Suffix = {}", byteArrayToString(barcodeCombined), byteArrayToString(prefixExpected), byteArrayToString(suffixExpected)); if (barcodeCombined.length > prefixExpected.length + suffixExpected.length + codeTypeLength) { int i = 0; for (; i <= barcodeCombined.length - prefixExpected.length - suffixExpected.length; i++) { @@ -1381,19 +1389,19 @@ else if (barcodeData != null) { } if (j == suffixExpected.length) { suffixFound = true; break; } } - appendToLog("BarStream: iPrefix = " + i + ", iSuffix = " + k + ", with prefixFound = " + prefixFound + ", suffixFound = " + suffixFound); + Logger.trace("BarStream: iPrefix = {}, iSuffix = {}, with prefixFound = {}, suffixFound = {}", i, k, prefixFound, suffixFound); if (prefixFound && suffixFound) { byte[] barcodeCombinedNew = new byte[k - i - prefixExpected.length - codeTypeLength]; System.arraycopy(barcodeCombined, i + prefixExpected.length + codeTypeLength, barcodeCombinedNew, 0, barcodeCombinedNew.length); barcodeCombined = barcodeCombinedNew; - appendToLog("BarStream: barcodeCombinedNew = " + byteArrayToString(barcodeCombinedNew)); + Logger.trace("BarStream: barcodeCombinedNew = {}", byteArrayToString(barcodeCombinedNew)); if (true) { byte[] prefixExpected1 = {0x5B, 0x29, 0x3E, 0x1E}; prefixFound = false; byte[] suffixExpected1 = {0x1E, 0x04}; suffixFound = false; - appendToLog("BarStream: barcodeCombined = " + byteArrayToString(barcodeCombined) + ", Expected Prefix = " + byteArrayToString(prefixExpected1) + ", Expected Suffix = " + byteArrayToString(suffixExpected1)); + Logger.trace("BarStream: barcodeCombined = {}, Expected Prefix = {}, Expected Suffix = {}", byteArrayToString(barcodeCombined), byteArrayToString(prefixExpected1), byteArrayToString(suffixExpected1)); if (barcodeCombined.length > prefixExpected1.length + suffixExpected1.length) { i = 0; for (; i <= barcodeCombined.length - prefixExpected1.length - suffixExpected1.length; i++) { @@ -1417,12 +1425,12 @@ else if (barcodeData != null) { break; } } - appendToLog("BarStream: iPrefix = " + i + ", iSuffix = " + k + ", with prefixFound = " + prefixFound + ", suffixFound = " + suffixFound); + Logger.trace("BarStream: iPrefix = {}, iSuffix = {}, with prefixFound = {}, suffixFound = {}", i, k, prefixFound, suffixFound); if (prefixFound && suffixFound) { barcodeCombinedNew = new byte[k - i - prefixExpected1.length]; System.arraycopy(barcodeCombined, i + prefixExpected1.length, barcodeCombinedNew, 0, barcodeCombinedNew.length); barcodeCombined = barcodeCombinedNew; - appendToLog("BarStream: barcodeCombinedNew = " + byteArrayToString(barcodeCombinedNew)); + Logger.trace("BarStream: barcodeCombinedNew = {}", byteArrayToString(barcodeCombinedNew)); } } } @@ -1436,7 +1444,7 @@ else if (barcodeData != null) { //============ Android General ============ public void setSameCheck(boolean sameCheck1) { if (csReaderConnector.sameCheck == sameCheck1) return; - if (false) appendToLog("new sameCheck = " + sameCheck1 + ", with old sameCheck = " + csReaderConnector.sameCheck); + Logger.trace("new sameCheck = {}, with old sameCheck = {}", sameCheck1, csReaderConnector.sameCheck); csReaderConnector.sameCheck = sameCheck1; //sameCheck = false; } @@ -1460,9 +1468,9 @@ public boolean getSaveFileEnable() { return csReaderConnector.settingData.saveFileEnable; } public boolean setSaveFileEnable(boolean saveFileEnable) { - appendToLog("this.saveFileEnable = " + csReaderConnector.settingData.saveFileEnable + ", saveFileEnable = " + saveFileEnable); + Logger.trace("this.saveFileEnable = {}, saveFileEnable = {}", csReaderConnector.settingData.saveFileEnable, saveFileEnable); csReaderConnector.settingData.saveFileEnable = saveFileEnable; - appendToLog("this.saveFileEnable = " + csReaderConnector.settingData.saveFileEnable + ", saveFileEnable = " + saveFileEnable); + Logger.trace("this.saveFileEnable = {}, saveFileEnable = {}", csReaderConnector.settingData.saveFileEnable, saveFileEnable); return true; } public boolean getSaveCloudEnable() { @@ -1487,10 +1495,12 @@ public boolean setSaveAllCloudEnable(boolean saveAllCloudEnable) { return true; } public boolean getUserDebugEnable() { - boolean bValue = csReaderConnector.settingData.userDebugEnable; appendToLog("bValue = " + bValue); return bValue; + boolean bValue = csReaderConnector.settingData.userDebugEnable; + Logger.trace("bValue = {}", bValue); + return bValue; } public boolean setUserDebugEnable(boolean userDebugEnable) { - appendToLog("new userDebug = " + userDebugEnable); + Logger.trace("new userDebug = {}", userDebugEnable); csReaderConnector.settingData.userDebugEnable = userDebugEnable; return true; } @@ -1543,11 +1553,11 @@ public boolean setForegroundDupElim(int iForegroundDupElim) { } public int getInventoryCloudSave() { int i = csReaderConnector.settingData.inventoryCloudSave; - if (false) appendToLog("getInventoryCloudSave710 = " + i); + Logger.trace("getInventoryCloudSave710 = {}", i); return i; } public boolean setInventoryCloudSave(int inventoryCloudSave) { - appendToLog("setInventoryCloudSave710 = " + inventoryCloudSave); + Logger.trace("setInventoryCloudSave710 = {}", inventoryCloudSave); csReaderConnector.settingData.inventoryCloudSave = inventoryCloudSave; return true; } @@ -1559,12 +1569,12 @@ public boolean setServerImpinjLocation(String serverImpinjLocation) { return true; } public String getServerImpinjName() { - appendToLog("serverImpinjName = " + csReaderConnector.settingData.serverImpinjName); + Logger.trace("serverImpinjName = {}", csReaderConnector.settingData.serverImpinjName); return csReaderConnector.settingData.serverImpinjName; } public boolean setServerImpinjName(String serverImpinjName) { csReaderConnector.settingData.serverImpinjName = serverImpinjName; - appendToLog("serverImpinjName = " + serverImpinjName); + Logger.trace("serverImpinjName = {}", serverImpinjName); return true; } public String getServerImpinjPassword() { @@ -1605,7 +1615,7 @@ public int getSavingFormatSetting() { return csReaderConnector.settingData.savingFormatSelect; } public boolean setSavingFormatSetting(int savingFormatSelect) { - if (false) appendToLog("savingFormatSelect = " + savingFormatSelect); + Logger.trace("savingFormatSelect = {}", savingFormatSelect); if (savingFormatSelect < 0 || savingFormatSelect > 1) return false; csReaderConnector.settingData.savingFormatSelect = savingFormatSelect; return true; @@ -1686,7 +1696,7 @@ public String hostProcessorICGetFirmwareVersion() { } public String getHostProcessorICSerialNumber() { String str = controllerConnector.getSerialNumber(); - appendToLog("str = " + str); + Logger.trace("str = {}", str); if (str != null) { if (str.length() >= 16) return str.substring(0, 16); } @@ -1694,7 +1704,7 @@ public String getHostProcessorICSerialNumber() { } public String getHostProcessorICBoardVersion() { String str = controllerConnector.getSerialNumber(); - if (false) appendToLog("str = " + str); + Logger.trace("str = {}", str); if (str == null) return null; if (str.length() < 16+4) return null; str = str.substring(16); @@ -1717,8 +1727,7 @@ public String getHostProcessorICBoardVersion() { //============ Controller notification ============ int iBatteryCount; int getBatteryValue2Percent(float floatValue) { - boolean DEBUG = false; - if (DEBUG) appendToLog("getHostProcessorICBoardVersion = " + getHostProcessorICBoardVersion() + ", strVersionMBoard = " + strVersionMBoard); + Logger.debug("getHostProcessorICBoardVersion = {}, strVersionMBoard = {}", getHostProcessorICBoardVersion(), strVersionMBoard); if (false || checkHostProcessorVersion(getHostProcessorICBoardVersion(), Integer.parseInt(strMBoardVersions[0].trim()), Integer.parseInt(strMBoardVersions[1].trim()), 0)) { final float[] fValueStbyRef = { (float) 4.212, (float) 4.175, (float) 4.154, (float) 4.133, (float) 4.112, @@ -1782,14 +1791,14 @@ else if (csReaderConnector.rfidReader.isInventoring()) { fValueRef = fValueRunRef; fPercentRef = fPercentRunRef; } - if (DEBUG) appendToLog("NEW Percentage cureve is USED with bUsingInventoryBatteryCurve = " + bUsingInventoryBatteryCurve + ", iBatteryNewCurveDelay = " + iBatteryNewCurveDelay); + Logger.debug("NEW Percentage cureve is USED with bUsingInventoryBatteryCurve = {}, iBatteryNewCurveDelay = {}", bUsingInventoryBatteryCurve, iBatteryNewCurveDelay); int index = 0; while (index < fValueRef.length) { if (floatValue > fValueRef[index]) break; index++; } - if (DEBUG) appendToLog("Index = " + index); + Logger.debug("Index = {}", index); if (index == 0) return 100; if (index == fValueRef.length) return 0; float value = ((fValueRef[index - 1] - floatValue) / (fValueRef[index - 1] - fValueRef[index])); @@ -1809,7 +1818,7 @@ else if (csReaderConnector.rfidReader.isInventoring()) { fBatteryValueOld = floatValue; iBatteryPercentOld = iValue; return iValue; } else { - if (DEBUG) appendToLog("OLD Percentage cureve is USED"); + Logger.debug("OLD Percentage cureve is USED"); if (floatValue >= 4) return 100; else if (floatValue < 3.4) return 0; else { @@ -1824,7 +1833,7 @@ public int getBatteryLevel() { String strVersionHost = "2.1.5"; String[] strHostVersions = strVersionHost.split("\\."); boolean bResult = checkHostProcessorVersion(hostVersion, Integer.parseInt(strHostVersions[0].trim()), Integer.parseInt(strHostVersions[1].trim()), Integer.parseInt(strHostVersions[2].trim())); - appendToLog("getBatteryLevel: hostVersion = " + hostVersion + ", bResult = " + bResult + ", level = " + iValue); + Logger.trace("getBatteryLevel: hostVersion = {}, bResult = {}, level = {}", hostVersion, bResult, iValue); if (!bResult) { if (iValue >= 4450) iValue -= 430; else if (iValue > 350) iValue -= 350; @@ -1842,7 +1851,7 @@ public boolean batteryLevelRequest() { if (csReaderConnector.rfidReader == null) return false; if (notificationConnector == null) return false; if (csReaderConnector.rfidReader.isInventoring()) { - appendToLog("Skip batteryLevelREquest as inventoring !!!"); + Logger.trace("Skip batteryLevelREquest as inventoring !!!"); return true; } if (mrfidToWriteSize() != 0) return false; @@ -1925,7 +1934,7 @@ public void setNotificationListener(NotificationConnector.NotificationListener l public byte[] onNotificationEvent() { byte[] notificationData = null; if (notificationConnector == null) { - appendToLog("notificationConnector is null"); + Logger.trace("notificationConnector is null"); return null; } if (notificationConnector.notificationToRead.size() != 0) { @@ -1938,14 +1947,13 @@ public byte[] onNotificationEvent() { //============ to be modified ============ String getModelName() { - boolean DEBUG = false; String strModelName = controllerConnector.getModelName(); - if (DEBUG) appendToLog("getModelName 0xb006 = " + strModelName); + Logger.debug("getModelName 0xb006 = {}", strModelName); if (true) { String strModelName1 = rfidReaderChip.rx000Setting.getModelCode(); - if (DEBUG) appendToLog("getModelCode 0x5000 = " + strModelName1); + Logger.debug("getModelCode 0x5000 = {}", strModelName1); if (strModelName == null || strModelName.length() == 0) { - if (DEBUG) appendToLog("strModeName is updated as modeCode"); + Logger.debug("strModeName is updated as modeCode"); strModelName = strModelName1; } } @@ -1961,18 +1969,17 @@ public boolean setRfidOn(boolean onStatus) { private final Runnable reinitaliseDataRunnable = new Runnable() { @Override public void run() { - appendToLog("reset before: reinitaliseDataRunnable starts with inventoring=" + csReaderConnector.rfidReader.isInventoring() + ", mrfidToWriteSize=" + mrfidToWriteSize()); + Logger.trace("reset before: reinitaliseDataRunnable starts with inventoring= {}, mrfidToWriteSize=", csReaderConnector.rfidReader.isInventoring(), mrfidToWriteSize()); if (csReaderConnector.rfidReader.isInventoring() || mrfidToWriteSize() != 0) { mHandler.removeCallbacks(reinitaliseDataRunnable); mHandler.postDelayed(reinitaliseDataRunnable, 500); } else { - if (DEBUG_CONNECT) appendToLog("reinitaliseDataRunnable: Start checkVersionRunnable"); + Logger.connect("reinitaliseDataRunnable: Start checkVersionRunnable"); mHandler.postDelayed(checkVersionRunnable, 500); } } }; private final Runnable checkVersionRunnable = new Runnable() { - boolean DEBUG = false; @Override public void run() { if (csReaderConnector.rfidReader == null || barcodeNewland == null || csReaderConnector.rfidReader.mRfidToWrite.size() != 0 || (isBarcodeFailure() == false && barcodeNewland.bBarcodeTriggerMode == (byte)0xFF)) { @@ -1980,9 +1987,9 @@ public void run() { mHandler.postDelayed(checkVersionRunnable, 500); } else { setSameCheck(false); - if (DEBUG_CONNECT) appendToLog("2 checkVersionRunnable: BarcodeFailure = " + isBarcodeFailure()); /// + Logger.connect("2 checkVersionRunnable: BarcodeFailure = {}", isBarcodeFailure()); if (isBarcodeFailure() == false) { - if (DEBUG_CONNECT) appendToLog("3 checkVersionRunnable"); ///5 + Logger.connect("3 checkVersionRunnable"); if (barcodeNewland.checkPreSuffix(barcodeNewland.prefixRef, barcodeNewland.suffixRef) == false) barcodeNewland.barcodeSendCommandSetPreSuffix(); if (barcodeNewland.bBarcodeTriggerMode != 0x30) barcodeNewland.barcodeSendCommandTrigger(); notificationConnector.getAutoRFIDAbort(); notificationConnector.getAutoBarStartSTop(); //setAutoRFIDAbort(false); setAutoBarStartSTop(true); @@ -1990,11 +1997,11 @@ public void run() { setAntennaCycle(0xffff); if (false) { if (bluetoothConnector.getCsModel() == 463) { - appendToLog("4 checkVersionRunnable"); + Logger.trace("4 checkVersionRunnable"); setAntennaDwell(2000); setAntennaInvCount(0); } else { - if (DEBUG_CONNECT) appendToLog("5 checkVersionRunnable"); ///8 + Logger.connect("5 checkVersionRunnable"); setAntennaDwell(0); setAntennaInvCount(0xfffffffeL); } @@ -2002,18 +2009,18 @@ public void run() { csReaderConnector.settingData.loadWedgeSettingFile(); if (loadSetting1File()) loadSetting1File(); if (checkHostProcessorVersion(getMacVer(), 2, 6, 8)) { - if (DEBUG_CONNECT) appendToLog("7 checkVersionRunnable: macVersion [" + getMacVer() + "] >= 2.6.8"); - appendToLog("0a setTagDelay[" + csReaderConnector.rfidReader.tagDelaySetting + "]"); + Logger.connect("7 checkVersionRunnable: macVersion [{}] >= 2.6.8", getMacVer()); + Logger.trace("0a setTagDelay[{}]", csReaderConnector.rfidReader.tagDelaySetting); rfidReaderChip.rx000Setting.setTagDelay(csReaderConnector.rfidReader.tagDelaySetting); rfidReaderChip.rx000Setting.setCycleDelay(csReaderConnector.rfidReader.cycleDelaySetting); - appendToLog("2EF setInvAlgo"); + Logger.trace("2EF setInvAlgo"); rfidReaderChip.rx000Setting.setInvModeCompact(true); } else { - if (DEBUG_CONNECT) appendToLog("8 checkVersionRunnable: macVersion [" + getMacVer() + "] < 2.6.8"); + Logger.connect("8 checkVersionRunnable: macVersion [{}] < 2.6.8", getMacVer()); rfidReaderChip.rx000Setting.setTagDelay(csReaderConnector.rfidReader.tagDelayDefaultNormalSetting); rfidReaderChip.rx000Setting.setCycleDelay(csReaderConnector.rfidReader.cycleDelaySetting); } - if (DEBUG_CONNECT) appendToLog("9 checkVersionRunnable: end of CheckVersionRunnable with mRfidToWrite.size = " + csReaderConnector.rfidReader.mRfidToWrite.size()); + Logger.connect("9 checkVersionRunnable: end of CheckVersionRunnable with mRfidToWrite.size = {}", csReaderConnector.rfidReader.mRfidToWrite.size()); setSameCheck(true); } } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsLibrary4A.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsLibrary4A.java index 8732188..74f3575 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsLibrary4A.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsLibrary4A.java @@ -7,7 +7,6 @@ import java.util.List; public class CsLibrary4A { - boolean DEBUG = false, DEBUG2 = false; String stringVersion = "14.10"; Utility utility; Cs710Library4A cs710Library4A; @@ -22,20 +21,22 @@ public CsLibrary4A(Context context, TextView mLogView) { iNO_SUCH_SETTING = cs108Library4A.iNO_SUCH_SETTING; } public String getlibraryVersion() { - if (DEBUG) Log.i("Hello2", "getlibraryVersion"); - String string710 = cs710Library4A.getlibraryVersion(); appendToLog("string710 = " + string710); + Logger.debug("getlibraryVersion"); + String string710 = cs710Library4A.getlibraryVersion(); + Logger.trace("string710 = {}", string710); int iPos0 = string710.indexOf("."); int iPos1 = string710.substring(iPos0 + 1).indexOf("."); - String string108 = cs108Library4A.getlibraryVersion(); appendToLog("string108 = " + string108); + String string108 = cs108Library4A.getlibraryVersion(); + Logger.trace("string108 = {}", string108); int iPos2 = string108.indexOf("."); int iPos3 = string108.substring(iPos2 + 1).indexOf("."); return stringVersion + "-" + string710.substring(iPos0 + iPos1 + 2) + "-" + string108.substring(iPos2 + iPos3 + 2); } public String checkVersion() { - if (DEBUG) Log.i("Hello2", "checkVersion"); + Logger.debug("checkVersion"); if (isCs108Connected()) return cs108Library4A.checkVersion(); else if (isCs710Connected()) return cs710Library4A.checkVersion(); - else Log.i("Hello2", "checkVersion" + stringNOTCONNECT); + else Logger.trace("Hello2", "checkVersion" + stringNOTCONNECT); return null; } @@ -43,12 +44,6 @@ public String checkVersion() { public String byteArrayToString(byte[] packet) { return utility.byteArrayToString(packet); } - public void appendToLog(String s) { - utility.appendToLog(s); - } - public void appendToLogView(String s) { - utility.appendToLogView(s); - } public String strFloat16toFloat32(String strData) { return utility.strFloat16toFloat32(strData); } @@ -85,27 +80,27 @@ public boolean checkHostProcessorVersion(String version, int majorVersion, int m //============ android bluetooth ============ public boolean isBleScanning() { - if (DEBUG) Log.i("Hello2", "isBleScanning"); + Logger.trace("isBleScanning"); boolean bValue = false, bValue1 = false, bValue7 = false; bValue1 = cs108Library4A.isBleScanning(); bValue7 = cs710Library4A.isBleScanning(); if (bValue1 && bValue7) bValue = true; else if (bValue1 == false && bValue7 == false) { } - else Log.i("Hello2", "isBleScanning: bVAlue1 = " + bValue1 + ", bValue7 = " + bValue7); + else Logger.trace("isBleScanning: bVAlue1 = {}, bValu7 = {}", bValue1, bValue7); return bValue; } public boolean scanLeDevice(final boolean enable) { boolean bValue = false, bValue1 = false, bValue7 = false; - if (DEBUG) Log.i("Hello2", "scanLeDevice"); + Logger.trace("scanLeDevice"); bValue1 = cs108Library4A.scanLeDevice(enable); bValue7 = cs710Library4A.scanLeDevice(enable); if (bValue1 && bValue7) bValue = true; else if (bValue1 == false && bValue7 == false) { } - else Log.i("Hello2", "scanLeDevice: bValue1 = " + bValue1 + ", bValue7 = " + bValue7); + else Logger.trace("scanLeDevice: bValue1 = {}, bValue7 = {}", bValue1, bValue7); return bValue; } public BluetoothGatt.CsScanData getNewDeviceScanned() { - if (DEBUG2) Log.i("Hello2", "getNewDeviceScanned"); + Logger.trace("getNewDeviceScanned"); BluetoothGatt.CsScanData csScanData1; BluetoothGatt.CsScanData csScanData7 = cs710Library4A.getNewDeviceScanned(); BluetoothGatt.CsScanData csScanData = null; @@ -122,22 +117,22 @@ public BluetoothGatt.CsScanData getNewDeviceScanned() { return csScanData; } public String getBluetoothDeviceAddress() { - if (DEBUG) Log.i("Hello2", "getBluetoothDeviceAddress"); + Logger.trace("getBluetoothDeviceAddress"); if (isCs108Connected()) return cs108Library4A.getBluetoothDeviceAddress(); else if (isCs710Connected()) return cs710Library4A.getBluetoothDeviceAddress(); - else Log.i("Hello2", "getBluetoothDeviceAddress" + stringNOTCONNECT); + else Logger.trace("getBluetoothDeviceAddress {}", stringNOTCONNECT); return null; } public String getBluetoothDeviceName() { - if (DEBUG) Log.i("Hello2", "getBluetoothDeviceName"); + Logger.trace("getBluetoothDeviceName"); if (isCs108Connected()) return cs108Library4A.getBluetoothDeviceName(); else if (isCs710Connected()) return cs710Library4A.getBluetoothDeviceName(); - else Log.i("Hello2", "getBluetoothDeviceName" + stringNOTCONNECT); + else Logger.trace("getBluetoothDeviceName {}", stringNOTCONNECT); return null; } public boolean isBleConnected() { boolean bValue = false; - if (DEBUG2) Log.i("Hello2", "isBleConnected"); + Logger.trace("isBleConnected"); if (isCs108Connected()) { bValue = cs108Library4A.isBleConnected(); if (bValue == false) bConnectStatus = 0; @@ -156,7 +151,7 @@ public boolean isBleConnected() { return bValue; } public void connect(ReaderDevice readerDevice) { - if (DEBUG || true) Log.i("Hello2", "connect with readerDevice as " + (readerDevice != null ? "valid" : "null") + ", and iServiceUuidConnectedBefore = " + iServiceUuidConnectedBefore); + Logger.trace("connect with readerDevice as {}, and iServiceUuidConnectedBefore = {}", readerDevice != null ? "valid" : "null", iServiceUuidConnectedBefore); int iServiceUuid = -1; if (readerDevice == null) iServiceUuid = iServiceUuidConnectedBefore; else iServiceUuid = readerDevice.getServiceUUID2p1(); @@ -169,709 +164,711 @@ public void connect(ReaderDevice readerDevice) { cs108Library4A.connect(readerDevice1); iServiceUuidConnectedBefore = 0; } else if (iServiceUuid == 2) { cs710Library4A.connect(readerDevice); iServiceUuidConnectedBefore = 2; - } else appendToLog("invalid serviceUUID = " + (readerDevice == null ? "null" : readerDevice.getServiceUUID2p1())); + } else { + Logger.trace("invalid serviceUUID = {}", readerDevice == null ? "null" : readerDevice.getServiceUUID2p1()); + } } public void disconnect(boolean tempDisconnect) { - if (DEBUG) Log.i("Hello2", "disconnect"); + Logger.trace("disconnect"); if (isCs108Connected()) cs108Library4A.disconnect(tempDisconnect); else if (isCs710Connected()) cs710Library4A.disconnect(tempDisconnect); } public boolean forceBTdisconnect() { - if (DEBUG) Log.i("Hello2", "forceBTdisconnect"); + Logger.trace("forceBTdisconnect"); if (isCs108Connected()) return cs108Library4A.forceBTdisconnect(); else if (isCs710Connected()) return cs710Library4A.forceBTdisconnect(); - else Log.i("Hello2", "forceBTdisconnect" + stringNOTCONNECT); + else Logger.trace("forceBTdisconnect {}", stringNOTCONNECT); return false; } public int getRssi() { - if (DEBUG) Log.i("Hello2", "getRssi"); + Logger.trace("getRssi"); if (isCs108Connected()) return cs108Library4A.getRssi(); else if (isCs710Connected()) return cs710Library4A.getRssi(); - else Log.i("Hello2", "getRssi" + stringNOTCONNECT); + else Logger.trace("getRssi {}", stringNOTCONNECT); return -1; } //411 public long getStreamInRate() { - if (DEBUG) Log.i("Hello2", "getStreamInRate"); + Logger.trace("getStreamInRate"); if (isCs108Connected()) return cs108Library4A.getStreamInRate(); else if (isCs710Connected()) return cs710Library4A.getStreamInRate(); - else Log.i("Hello2", "getStreamInRate" + stringNOTCONNECT); + else Logger.trace("getStreamInRate {}", stringNOTCONNECT); return -1; } public int get98XX() { - if (DEBUG) Log.i("Hello2", "get98XX"); + Logger.trace("get98XX"); if (isCs108Connected()) return cs108Library4A.get98XX(); else if (isCs710Connected()) return cs710Library4A.get98XX(); - else Log.i("Hello2", "get98XX" + stringNOTCONNECT); + else Logger.trace("get98XX {}", stringNOTCONNECT); return -1; } //============ Rfid ============ public String getAuthMatchData() { - if (DEBUG) Log.i("Hello2", "getAuthMatchData"); + Logger.trace("getAuthMatchData"); if (isCs108Connected()) return cs108Library4A.getAuthMatchData(); else if (isCs710Connected()) return cs710Library4A.getAuthMatchData(); - else Log.i("Hello2", "getAuthMatchData" + stringNOTCONNECT); + else Logger.trace("getAuthMatchData {}", stringNOTCONNECT); return null; } public boolean setAuthMatchData(String mask) { - if (DEBUG) Log.i("Hello2", "setAuthMatchData"); + Logger.trace("setAuthMatchData"); if (isCs108Connected()) return cs108Library4A.setAuthMatchData(mask); else if (isCs710Connected()) return cs710Library4A.setAuthMatchData(mask); - else Log.i("Hello2", "setAuthMatchData" + stringNOTCONNECT); + else Logger.trace("setAuthMatchData {}", stringNOTCONNECT); return false; } public int getStartQValue() { - if (DEBUG) Log.i("Hello2", "getStartQValue"); + Logger.trace("getStartQValue"); if (isCs108Connected()) return cs108Library4A.getStartQValue(); else if (isCs710Connected()) return cs710Library4A.getStartQValue(); - else Log.i("Hello2", "getStartQValue" + stringNOTCONNECT); + else Logger.trace("getStartQValue {}", stringNOTCONNECT); return -1; } public int getMaxQValue() { - if (DEBUG) Log.i("Hello2", "getMaxQValue"); + Logger.trace("getMaxQValue"); if (isCs108Connected()) return cs108Library4A.getMaxQValue(); else if (isCs710Connected()) return cs710Library4A.getMaxQValue(); - else Log.i("Hello2", "getMaxQValue" + stringNOTCONNECT); + else Logger.trace("getMaxQValue {}", stringNOTCONNECT); return -1; } public int getMinQValue() { - if (DEBUG) Log.i("Hello2", "getMinQValue"); + Logger.trace("getMinQValue"); if (isCs108Connected()) return cs108Library4A.getMinQValue(); else if (isCs710Connected()) return cs710Library4A.getMinQValue(); - else Log.i("Hello2", "getMinQValue" + stringNOTCONNECT); + else Logger.trace("getMinQValue {}", stringNOTCONNECT); return -1; } public boolean setDynamicQParms(int startQValue, int minQValue, int maxQValue, int retryCount) { - if (DEBUG) Log.i("Hello2", "setDynamicQParms"); + Logger.trace("setDynamicQParms"); if (isCs108Connected()) return cs108Library4A.setDynamicQParms(startQValue, minQValue, maxQValue, retryCount); else if (isCs710Connected()) return cs710Library4A.setDynamicQParms(startQValue, minQValue, maxQValue, retryCount); - else Log.i("Hello2", "setDynamicQParms" + stringNOTCONNECT); + else Logger.trace("setDynamicQParms {}", stringNOTCONNECT); return false; } public int getFixedQValue() { - if (DEBUG) Log.i("Hello2", "getFixedQValue"); + Logger.trace("getFixedQValue"); if (isCs108Connected()) return cs108Library4A.getFixedQValue(); else if (isCs710Connected()) return cs710Library4A.getFixedQValue(); - else Log.i("Hello2", "getFixedQValue" + stringNOTCONNECT); + else Logger.trace("getFixedQValue {}", stringNOTCONNECT); return -1; } public int getFixedRetryCount() { - if (DEBUG) Log.i("Hello2", "getFixedRetryCount"); + Logger.trace("getFixedRetryCount"); if (isCs108Connected()) return cs108Library4A.getFixedRetryCount(); else if (isCs710Connected()) return cs710Library4A.getFixedRetryCount(); - else Log.i("Hello2", "getFixedRetryCount" + stringNOTCONNECT); + else Logger.trace("getFixedRetryCount {}", stringNOTCONNECT); return -1; } public boolean getRepeatUnitNoTags() { - if (DEBUG) Log.i("Hello2", "getRepeatUnitNoTags"); + Logger.trace("getRepeatUnitNoTags"); if (isCs108Connected()) return cs108Library4A.getRepeatUnitNoTags(); else if (isCs710Connected()) return cs710Library4A.getRepeatUnitNoTags(); - else Log.i("Hello2", "getRepeatUnitNoTags" + stringNOTCONNECT); + else Logger.trace("getRepeatUnitNoTags {}", stringNOTCONNECT); return false; } public boolean setFixedQParms(int qValue, int retryCount, boolean repeatUnitNoTags) { - if (DEBUG) Log.i("Hello2", "setFixedQParms"); + Logger.trace("setFixedQParms"); if (isCs108Connected()) return cs108Library4A.setFixedQParms(qValue, retryCount, repeatUnitNoTags); else if (isCs710Connected()) return cs710Library4A.setFixedQParms(qValue, retryCount, repeatUnitNoTags); - else Log.i("Hello2", "setFixedQParms" + stringNOTCONNECT); + else Logger.trace("setFixedQParms {}", stringNOTCONNECT); return false; } public boolean getChannelHoppingDefault() { - if (DEBUG) Log.i("Hello2", "getChannelHoppingDefault"); + Logger.trace("getChannelHoppingDefault"); if (isCs108Connected()) return cs108Library4A.getChannelHoppingDefault(); else if (isCs710Connected()) return cs710Library4A.getChannelHoppingDefault(); - else Log.i("Hello2", "getChannelHoppingDefault" + stringNOTCONNECT); + else Logger.trace("getChannelHoppingDefault {}", stringNOTCONNECT); return false; } public boolean getRfidOnStatus() { - if (DEBUG) Log.i("Hello2", "getRfidOnStatus"); + Logger.trace("getRfidOnStatus"); if (isCs108Connected()) return cs108Library4A.getRfidOnStatus(); else if (isCs710Connected()) return cs710Library4A.getRfidOnStatus(); - else Log.i("Hello2", "getRfidOnStatus" + stringNOTCONNECT); + else Logger.trace("getRfidOnStatus {}", stringNOTCONNECT); return false; } public boolean isRfidFailure() { - if (DEBUG2) Log.i("Hello2", "isRfidFailure"); + Logger.trace("isRfidFailure"); if (isCs108Connected()) return cs108Library4A.isRfidFailure(); else if (isCs710Connected()) return cs710Library4A.isRfidFailure(); return false; } public void setReaderDefault() { - if (DEBUG) Log.i("Hello2", "setReaderDefault"); + Logger.trace("setReaderDefault"); if (isCs108Connected()) cs108Library4A.setReaderDefault(); else if (isCs710Connected()) cs710Library4A.setReaderDefault(); - else Log.i("Hello2", "setReaderDefault" + stringNOTCONNECT); + else Logger.trace("setReaderDefault {}", stringNOTCONNECT); } public String getMacVer() { - if (DEBUG) Log.i("Hello2", "getMacVer"); + Logger.trace("getMacVer"); if (isCs108Connected()) return cs108Library4A.getMacVer(); else if (isCs710Connected()) return cs710Library4A.getMacVer(); - else Log.i("Hello2", "getMacVer" + stringNOTCONNECT); + else Logger.trace("getMacVer {}", stringNOTCONNECT); return null; } public String getRadioSerial() { - if (DEBUG) Log.i("Hello2", "getRadioSerial"); + Logger.trace("getRadioSerial"); if (isCs108Connected()) return cs108Library4A.getRadioSerial(); else if (isCs710Connected()) return cs710Library4A.getRadioSerial(); - else Log.i("Hello2", "getRadioSerial" + stringNOTCONNECT); + else Logger.trace("getRadioSerial {}", stringNOTCONNECT); return null; } public String getRadioBoardVersion() { - if (DEBUG) Log.i("Hello2", "getRadioBoardVersion"); + Logger.trace("getRadioBoardVersion"); if (isCs108Connected()) return cs108Library4A.getRadioBoardVersion(); else if (isCs710Connected()) return cs710Library4A.getRadioBoardVersion(); - else Log.i("Hello2", "getRadioBoardVersion" + stringNOTCONNECT); + else Logger.trace("getRadioBoardVersion {}", stringNOTCONNECT); return null; } public int getPortNumber() { - if (DEBUG) Log.i("Hello2", "getPortNumber"); + Logger.trace("getPortNumber"); if (isCs108Connected()) return cs108Library4A.getPortNumber(); else if (isCs710Connected()) return cs710Library4A.getPortNumber(); - else Log.i("Hello2", "getPortNumber" + stringNOTCONNECT); + else Logger.trace("getPortNumber {}", stringNOTCONNECT); return -1; } public int getAntennaSelect() { - if (DEBUG) Log.i("Hello2", "getAntennaSelect"); + Logger.trace("getAntennaSelect"); if (isCs108Connected()) return cs108Library4A.getAntennaSelect(); else if (isCs710Connected()) return cs710Library4A.getAntennaSelect(); - else Log.i("Hello2", "getAntennaSelect" + stringNOTCONNECT); + else Logger.trace("getAntennaSelect {}", stringNOTCONNECT); return -1; } public boolean setAntennaSelect(int number) { - if (DEBUG) Log.i("Hello2", "setAntennaSelect"); + Logger.trace("setAntennaSelect"); if (isCs108Connected()) return cs108Library4A.setAntennaSelect(number); else if (isCs710Connected()) return cs710Library4A.setAntennaSelect(number); - else Log.i("Hello2", "setAntennaSelect" + stringNOTCONNECT); + else Logger.trace("setAntennaSelect {}", stringNOTCONNECT); return false; } public boolean getAntennaEnable() { - if (DEBUG) Log.i("Hello2", "getAntennaEnable"); + Logger.trace("getAntennaEnable"); if (isCs108Connected()) return cs108Library4A.getAntennaEnable(); else if (isCs710Connected()) return cs710Library4A.getAntennaEnable(); - else Log.i("Hello2", "getAntennaEnable" + stringNOTCONNECT); + else Logger.trace("getAntennaEnable {}", stringNOTCONNECT); return false; } public boolean setAntennaEnable(boolean enable) { - if (DEBUG) Log.i("Hello2", "setAntennaEnable"); + Logger.trace("setAntennaEnable"); if (isCs108Connected()) return cs108Library4A.setAntennaEnable(enable); else if (isCs710Connected()) return cs710Library4A.setAntennaEnable(enable); - else Log.i("Hello2", "setAntennaEnable" + stringNOTCONNECT); + else Logger.trace("setAntennaEnable {}", stringNOTCONNECT); return false; } public long getAntennaDwell() { - if (DEBUG) Log.i("Hello2", "getAntennaDwell"); + Logger.trace("getAntennaDwell"); if (isCs108Connected()) return cs108Library4A.getAntennaDwell(); else if (isCs710Connected()) return cs710Library4A.getAntennaDwell(); - else Log.i("Hello2", "getAntennaDwell" + stringNOTCONNECT); + else Logger.trace("getAntennaDwell {}", stringNOTCONNECT); return -1; } public boolean setAntennaDwell(long antennaDwell) { - if (DEBUG) Log.i("Hello2", "setAntennaDwell"); + Logger.trace("setAntennaDwell"); if (isCs108Connected()) return cs108Library4A.setAntennaDwell(antennaDwell); else if (isCs710Connected()) return cs710Library4A.setAntennaDwell(antennaDwell); - else Log.i("Hello2", "setAntennaDwell" + stringNOTCONNECT); + else Logger.trace("setAntennaDwell {}", stringNOTCONNECT); return false; } public long getPwrlevel() { - if (DEBUG) Log.i("Hello2", "getPwrlevel"); + Logger.trace("getPwrlevel"); if (isCs108Connected()) return cs108Library4A.getPwrlevel(); else if (isCs710Connected()) return cs710Library4A.getPwrlevel(); - else Log.i("Hello2", "getPwrlevel" + stringNOTCONNECT); + else Logger.trace("getPwrlevel {}", stringNOTCONNECT); return -1; } public boolean setPowerLevel(long pwrlevel) { - if (DEBUG) Log.i("Hello2", "setPowerLevel"); + Logger.trace("setPowerLevel"); if (isCs108Connected()) return cs108Library4A.setPowerLevel(pwrlevel); else if (isCs710Connected()) return cs710Library4A.setPowerLevel(pwrlevel); - else Log.i("Hello2", "setPowerLevel" + stringNOTCONNECT); + else Logger.trace("setPowerLevel {}", stringNOTCONNECT); return false; } public int getQueryTarget() { - if (DEBUG) Log.i("Hello2", "getQueryTarget"); + Logger.trace("getQueryTarget"); if (isCs108Connected()) return cs108Library4A.getQueryTarget(); else if (isCs710Connected()) return cs710Library4A.getQueryTarget(); - else Log.i("Hello2", "getQueryTarget" + stringNOTCONNECT); + else Logger.trace("getQueryTarget {}", stringNOTCONNECT); return -1; } public int getQuerySession() { - if (DEBUG) Log.i("Hello2", "getQuerySession"); + Logger.trace("getQuerySession"); if (isCs108Connected()) return cs108Library4A.getQuerySession(); else if (isCs710Connected()) return cs710Library4A.getQuerySession(); - else Log.i("Hello2", "getQuerySession" + stringNOTCONNECT); + else Logger.trace("getQuerySession {}", stringNOTCONNECT); return -1; } public int getQuerySelect() { - if (DEBUG) Log.i("Hello2", "getQuerySelect"); + Logger.trace("getQuerySelect"); if (isCs108Connected()) return cs108Library4A.getQuerySelect(); else if (isCs710Connected()) return cs710Library4A.getQuerySelect(); - else Log.i("Hello2", "getQuerySelect" + stringNOTCONNECT); + else Logger.trace("getQuerySelect {}", stringNOTCONNECT); return -1; } public boolean setTagGroup(int sL, int session, int target1) { - if (DEBUG) Log.i("Hello2", "setTagGroup"); + Logger.trace("setTagGroup"); if (isCs108Connected()) return cs108Library4A.setTagGroup(sL, session, target1); else if (isCs710Connected()) return cs710Library4A.setTagGroup(sL, session, target1); - else Log.i("Hello2", "setTagGroup" + stringNOTCONNECT); + else Logger.trace("setTagGroup {}", stringNOTCONNECT); return false; } public int getTagFocus() { - if (DEBUG) Log.i("Hello2", "getTagFocus"); + Logger.trace("getTagFocus"); if (isCs108Connected()) return cs108Library4A.getTagFocus(); else if (isCs710Connected()) return cs710Library4A.getTagFocus(); - else Log.i("Hello2", "getTagFocus" + stringNOTCONNECT); + else Logger.trace("getTagFocus {}", stringNOTCONNECT); return -1; } public boolean setTagFocus(boolean tagFocusNew) { - if (DEBUG) Log.i("Hello2", "setTagFocus"); + Logger.trace("setTagFocus"); if (isCs108Connected()) return cs108Library4A.setTagFocus(tagFocusNew); else if (isCs710Connected()) return cs710Library4A.setTagFocus(tagFocusNew); - else Log.i("Hello2", "setTagFocus" + stringNOTCONNECT); + else Logger.trace("setTagFocus {}", stringNOTCONNECT); return false; } public int getFastId() { - if (DEBUG) Log.i("Hello2", "getFastId"); + Logger.trace("getFastId"); if (isCs108Connected()) return cs108Library4A.getFastId(); else if (isCs710Connected()) return cs710Library4A.getFastId(); - else Log.i("Hello2", "getFastId" + stringNOTCONNECT); + else Logger.trace("getFastId {}", stringNOTCONNECT); return -1; } public boolean setFastId(boolean fastIdNew) { - if (DEBUG) Log.i("Hello2", "setFastId"); + Logger.trace("setFastId"); if (isCs108Connected()) return cs108Library4A.setFastId(fastIdNew); else if (isCs710Connected()) return cs710Library4A.setFastId(fastIdNew); - else Log.i("Hello2", "setFastId" + stringNOTCONNECT); + else Logger.trace("setFastId {}", stringNOTCONNECT); return false; } public boolean getInvAlgo() { - if (DEBUG) Log.i("Hello2", "getInvAlgo"); + Logger.trace("getInvAlgo"); if (isCs108Connected()) return cs108Library4A.getInvAlgo(); else if (isCs710Connected()) return cs710Library4A.getInvAlgo(); - else Log.i("Hello2", "getInvAlgo" + stringNOTCONNECT); + else Logger.trace("getInvAlgo {}", stringNOTCONNECT); return false; } public boolean setInvAlgo(boolean dynamicAlgo) { - if (DEBUG) Log.i("Hello2", "setInvAlgo"); + Logger.trace("setInvAlgo"); if (isCs108Connected()) return cs108Library4A.setInvAlgo(dynamicAlgo); else if (isCs710Connected()) return cs710Library4A.setInvAlgo(dynamicAlgo); - else Log.i("Hello2", "setInvAlgo" + stringNOTCONNECT); + else Logger.trace("setInvAlgo {}", stringNOTCONNECT); return false; } public List getProfileList() { - if (DEBUG) Log.i("Hello2", "getProfileList"); + Logger.trace("getProfileList"); if (isCs108Connected()) return cs108Library4A.getProfileList(); else if (isCs710Connected()) return cs710Library4A.getProfileList(); - else Log.i("Hello2", "getProfileList" + stringNOTCONNECT); + else Logger.trace("getProfileList {}", stringNOTCONNECT); return null; } public int getCurrentProfile() { - if (DEBUG) Log.i("Hello2", "getCurrentProfile"); + Logger.trace("getCurrentProfile"); if (isCs108Connected()) return cs108Library4A.getCurrentProfile(); else if (isCs710Connected()) return cs710Library4A.getCurrentProfile(); - else Log.i("Hello2", "getCurrentProfile" + stringNOTCONNECT); + else Logger.trace("getCurrentProfile {}", stringNOTCONNECT); return -1; } public boolean setBasicCurrentLinkProfile() { - if (DEBUG) Log.i("Hello2", "setBasicCurrentLinkProfile"); + Logger.trace("setBasicCurrentLinkProfile"); if (isCs108Connected()) return true; else if (isCs710Connected()) return cs710Library4A.setBasicCurrentLinkProfile(); - else Log.i("Hello2", "setBasicCurrentLinkProfile" + stringNOTCONNECT); + else Logger.trace("setBasicCurrentLinkProfile {}", stringNOTCONNECT); return false; } public boolean setCurrentLinkProfile(int profile) { - if (DEBUG) Log.i("Hello2", "setCurrentLinkProfile to " + profile); + Logger.trace("setCurrentLinkProfile to " + profile); if (isCs108Connected()) return cs108Library4A.setCurrentLinkProfile(profile); else if (isCs710Connected()) return cs710Library4A.setCurrentLinkProfile(profile); - else Log.i("Hello2", "setCurrentLinkProfile" + stringNOTCONNECT); + else Logger.trace("setCurrentLinkProfile {}", stringNOTCONNECT); return false; } public void resetEnvironmentalRSSI() { - if (DEBUG) Log.i("Hello2", "resetEnvironmentalRSSI"); + Logger.trace("resetEnvironmentalRSSI"); if (isCs108Connected()) cs108Library4A.resetEnvironmentalRSSI(); else if (isCs710Connected()) cs710Library4A.resetEnvironmentalRSSI(); - else Log.i("Hello2", "resetEnvironmentalRSSI" + stringNOTCONNECT); + else Logger.trace("resetEnvironmentalRSSI {}", stringNOTCONNECT); } public String getEnvironmentalRSSI() { - if (DEBUG) Log.i("Hello2", "getEnvironmentalRSSI"); + Logger.trace("getEnvironmentalRSSI"); if (isCs108Connected()) return cs108Library4A.getEnvironmentalRSSI(); else if (isCs710Connected()) return cs710Library4A.getEnvironmentalRSSI(); - else Log.i("Hello2", "getEnvironmentalRSSI" + stringNOTCONNECT); + else Logger.trace("getEnvironmentalRSSI {}", stringNOTCONNECT); return null; } public int getHighCompression() { - if (DEBUG) Log.i("Hello2", "getHighCompression"); + Logger.trace("getHighCompression"); if (isCs108Connected()) return cs108Library4A.getHighCompression(); else if (isCs710Connected()) return cs710Library4A.getHighCompression(); - else Log.i("Hello2", "getHighCompression" + stringNOTCONNECT); + else Logger.trace("getHighCompression {}", stringNOTCONNECT); return -1; } public int getRflnaGain() { - if (DEBUG) Log.i("Hello2", "getRflnaGain"); + Logger.trace("getRflnaGain"); if (isCs108Connected()) return cs108Library4A.getRflnaGain(); else if (isCs710Connected()) return cs710Library4A.getRflnaGain(); - else Log.i("Hello2", "getRflnaGain" + stringNOTCONNECT); + else Logger.trace("getRflnaGain {}", stringNOTCONNECT); return -1; } public int getIflnaGain() { - if (DEBUG) Log.i("Hello2", "getIflnaGain"); + Logger.trace("getIflnaGain"); if (isCs108Connected()) return cs108Library4A.getIflnaGain(); else if (isCs710Connected()) return cs710Library4A.getIflnaGain(); - else Log.i("Hello2", "getIflnaGain" + stringNOTCONNECT); + else Logger.trace("getIflnaGain {}", stringNOTCONNECT); return -1; } public int getAgcGain() { - if (DEBUG) Log.i("Hello2", "getAgcGain"); + Logger.trace("getAgcGain"); if (isCs108Connected()) return cs108Library4A.getAgcGain(); else if (isCs710Connected()) return cs710Library4A.getAgcGain(); - else Log.i("Hello2", "getAgcGain" + stringNOTCONNECT); + else Logger.trace("getAgcGain {}", stringNOTCONNECT); return -1; } public int getRxGain() { - if (DEBUG) Log.i("Hello2", "getRxGain"); + Logger.trace("getRxGain"); if (isCs108Connected()) return cs108Library4A.getRxGain(); else if (isCs710Connected()) return cs710Library4A.getRxGain(); - else Log.i("Hello2", "getRxGain" + stringNOTCONNECT); + else Logger.trace("getRxGain {}", stringNOTCONNECT); return -1; } public boolean setRxGain(int highCompression, int rflnagain, int iflnagain, int agcgain) { - if (DEBUG) Log.i("Hello2", "setRxGain"); + Logger.trace("setRxGain"); if (isCs108Connected()) return cs108Library4A.setRxGain(highCompression, rflnagain, iflnagain, agcgain); else if (isCs710Connected()) return cs710Library4A.setRxGain(highCompression, rflnagain, iflnagain, agcgain); - else Log.i("Hello2", "setRxGain" + stringNOTCONNECT); + else Logger.trace("setRxGain {}", stringNOTCONNECT); return false; } public boolean setRxGain(int rxGain) { - if (DEBUG) Log.i("Hello2", "setRxGain"); + Logger.trace("setRxGain"); if (isCs108Connected()) return cs108Library4A.setRxGain(rxGain); else if (isCs710Connected()) return cs710Library4A.setRxGain(rxGain); - else Log.i("Hello2", "setRxGain" + stringNOTCONNECT); + else Logger.trace("setRxGain {}", stringNOTCONNECT); return false; } public int FreqChnCnt() { - if (DEBUG) Log.i("Hello2", "FreqChnCnt"); + Logger.trace("FreqChnCnt"); if (isCs108Connected()) return cs108Library4A.FreqChnCnt(); else if (isCs710Connected()) return cs710Library4A.FreqChnCnt(); - else Log.i("Hello2", "FreqChnCnt" + stringNOTCONNECT); + else Logger.trace("FreqChnCnt {}", stringNOTCONNECT); return -1; } public double getLogicalChannel2PhysicalFreq(int channel) { - if (DEBUG) Log.i("Hello2", "getLogicalChannel2PhysicalFreq"); + Logger.trace("getLogicalChannel2PhysicalFreq"); if (isCs108Connected()) return cs108Library4A.getLogicalChannel2PhysicalFreq(channel); else if (isCs710Connected()) return cs710Library4A.getLogicalChannel2PhysicalFreq(channel); - else Log.i("Hello2", "getLogicalChannel2PhysicalFreq" + stringNOTCONNECT); + else Logger.trace("getLogicalChannel2PhysicalFreq {}", stringNOTCONNECT); return -1; } public byte getTagDelay() { - if (DEBUG) Log.i("Hello2", "getTagDelay"); + Logger.trace("getTagDelay"); if (isCs108Connected()) return cs108Library4A.getTagDelay(); else if (isCs710Connected()) return cs710Library4A.getTagDelay(); - else Log.i("Hello2", "getTagDelay" + stringNOTCONNECT); + else Logger.trace("getTagDelay {}", stringNOTCONNECT); return -1; } public boolean setTagDelay(byte tagDelay) { - if (DEBUG) Log.i("Hello2", "setTagDelay"); + Logger.trace("setTagDelay"); if (isCs108Connected()) return cs108Library4A.setTagDelay(tagDelay); else if (isCs710Connected()) return cs710Library4A.setTagDelay(tagDelay); - else Log.i("Hello2", "setTagDelay" + stringNOTCONNECT); + else Logger.trace("setTagDelay {}", stringNOTCONNECT); return false; } public byte getIntraPkDelay() { - if (DEBUG) Log.i("Hello2", "getIntraPkDelay"); + Logger.trace("getIntraPkDelay"); if (isCs108Connected()) return cs108Library4A.getIntraPkDelay(); else if (isCs710Connected()) return cs710Library4A.getIntraPkDelay(); - else Log.i("Hello2", "getIntraPkDelay" + stringNOTCONNECT); + else Logger.trace("getIntraPkDelay {}", stringNOTCONNECT); return -1; } public boolean setIntraPkDelay(byte intraPkDelay) { - if (DEBUG) Log.i("Hello2", "setIntraPkDelay"); + Logger.trace("setIntraPkDelay"); if (isCs108Connected()) return cs108Library4A.setIntraPkDelay(intraPkDelay); else if (isCs710Connected()) return cs710Library4A.setIntraPkDelay(intraPkDelay); - else Log.i("Hello2", "setIntraPkDelay" + stringNOTCONNECT); + else Logger.trace("setIntraPkDelay {}", stringNOTCONNECT); return false; } public byte getDupDelay() { - if (DEBUG) Log.i("Hello2", "getDupDelay"); + Logger.trace("getDupDelay"); if (isCs108Connected()) return cs108Library4A.getDupDelay(); else if (isCs710Connected()) return cs710Library4A.getDupDelay(); - else Log.i("Hello2", "getDupDelay" + stringNOTCONNECT); + else Logger.trace("getDupDelay {}", stringNOTCONNECT); return -1; } public boolean setDupDelay(byte dupElim) { - if (DEBUG) Log.i("Hello2", "setDupDelay"); + Logger.trace("setDupDelay"); if (isCs108Connected()) return cs108Library4A.setDupDelay(dupElim); else if (isCs710Connected()) return cs710Library4A.setDupDelay(dupElim); - else Log.i("Hello2", "setDupDelay" + stringNOTCONNECT); + else Logger.trace("setDupDelay {}", stringNOTCONNECT); return false; } public long getCycleDelay() { - if (DEBUG) Log.i("Hello2", "getCycleDelay"); + Logger.trace("getCycleDelay"); if (isCs108Connected()) return cs108Library4A.getCycleDelay(); else if (isCs710Connected()) return cs710Library4A.getCycleDelay(); - else Log.i("Hello2", "getCycleDelay" + stringNOTCONNECT); + else Logger.trace("getCycleDelay {}", stringNOTCONNECT); return -1; } public boolean setCycleDelay(long cycleDelay) { - if (DEBUG) Log.i("Hello2", "setCycleDelay"); + Logger.trace("setCycleDelay"); if (isCs108Connected()) return cs108Library4A.setCycleDelay(cycleDelay); else if (isCs710Connected()) return cs710Library4A.setCycleDelay(cycleDelay); return false; } public void getAuthenticateReplyLength() { - if (DEBUG) Log.i("Hello2", "getAuthenticateReplyLength"); + Logger.trace("getAuthenticateReplyLength"); if (isCs108Connected()) cs108Library4A.getAuthenticateReplyLength(); else if (isCs710Connected()) cs710Library4A.getAuthenticateReplyLength(); - else Log.i("Hello2", "getAuthenticateReplyLength" + stringNOTCONNECT); + else Logger.trace("getAuthenticateReplyLength {}", stringNOTCONNECT); } public boolean setTamConfiguration(boolean header, String matchData) { - if (DEBUG | true) Log.i("Hello2", "setTamConfiguration with header = " + header + ", matchData = " + matchData); + Logger.trace("setTamConfiguration with header = {}, matchData = {}", header, matchData); if (isCs108Connected()) return cs108Library4A.setTamConfiguration(header, matchData); else if (isCs710Connected()) return cs710Library4A.setTamConfiguration(header, matchData); - else Log.i("Hello2", "setTam1Configuration"); + else Logger.trace("setTam1Configuration"); return false; } public boolean setTam1Configuration(int keyId, String matchData) { - if (DEBUG | true) Log.i("Hello2", "setTam1Configuration with KeyId = " + keyId + ", matchData = " + matchData); + Logger.trace("setTam1Configuration with KeyId = {}, matchData = {}", keyId, matchData); if (isCs108Connected()) return cs108Library4A.setTam1Configuration(keyId, matchData); else if (isCs710Connected()) return cs710Library4A.setTam1Configuration(keyId, matchData); - else Log.i("Hello2", "setTam1Configuration"); + else Logger.trace("setTam1Configuration"); return false; } public boolean setTam2Configuration(int keyId, String matchData, int profile, int offset, int blockId, int protMode) { - if (DEBUG) Log.i("Hello2", "setTam2Configuration"); + Logger.trace("setTam2Configuration"); if (isCs108Connected()) return cs108Library4A.setTam2Configuration(keyId, matchData, profile, offset, blockId, protMode); else if (isCs710Connected()) return cs710Library4A.setTam2Configuration(keyId, matchData, profile, offset, blockId, protMode); - else Log.i("Hello2", "setTam2Configuration"); + else Logger.trace("setTam2Configuration"); return false; } public int getUntraceableEpcLength() { - if (DEBUG) Log.i("Hello2", "getUntraceableEpcLength"); + Logger.trace("getUntraceableEpcLength"); if (isCs108Connected()) return cs108Library4A.getUntraceableEpcLength(); else if (isCs710Connected()) return cs710Library4A.getUntraceableEpcLength(); - else Log.i("Hello2", "getUntraceableEpcLength" + stringNOTCONNECT); + else Logger.trace("getUntraceableEpcLength {}", stringNOTCONNECT); return -1; } public boolean setUntraceable(boolean bHideEpc, int ishowEpcSize, int iHideTid, boolean bHideUser, boolean bHideRange) { - Log.i("Hello2", "setUntraceable 1"); + Logger.trace("setUntraceable 1"); return false; } public boolean setUntraceable(int range, boolean user, int tid, int epcLength, boolean epc, boolean uxpc) { - if (DEBUG) Log.i("Hello2", "setUntraceable"); + Logger.trace("setUntraceable"); if (isCs108Connected()) return cs108Library4A.setUntraceable(range, user, tid, epcLength, epc, uxpc); else if (isCs710Connected()) return false; - else Log.i("Hello2", "setUntraceable" + stringNOTCONNECT); + else Logger.trace("setUntraceable {}", stringNOTCONNECT); return false; } public boolean setAuthenticateConfiguration() { - if (DEBUG) Log.i("Hello2", "setAuthenticateConfiguration"); + Logger.trace("setAuthenticateConfiguration"); if (isCs108Connected()) return cs108Library4A.setAuthenticateConfiguration(); else if (isCs710Connected()) return cs710Library4A.setAuthenticateConfiguration(); - else Log.i("Hello2", "setAuthenticateConfiguration" + stringNOTCONNECT); + else Logger.trace("setAuthenticateConfiguration {}", stringNOTCONNECT); return false; } public int getRetryCount() { - if (DEBUG) Log.i("Hello2", "getRetryCount"); + Logger.trace("getRetryCount"); if (isCs108Connected()) return cs108Library4A.getRetryCount(); else if (isCs710Connected()) return cs710Library4A.getRetryCount(); - else Log.i("Hello2", "getRetryCount" + stringNOTCONNECT); + else Logger.trace("getRetryCount {}", stringNOTCONNECT); return -1; } public boolean setRetryCount(int retryCount) { - if (DEBUG) Log.i("Hello2", "setRetryCount"); + Logger.trace("setRetryCount"); if (isCs108Connected()) return cs108Library4A.setRetryCount(retryCount); else if (isCs710Connected()) return cs710Library4A.setRetryCount(retryCount); - else Log.i("Hello2", "setRetryCount" + stringNOTCONNECT); + else Logger.trace("setRetryCount {}", stringNOTCONNECT); return false; } public int getInvSelectIndex() { - if (DEBUG) Log.i("Hello2", "getInvSelectIndex"); + Logger.trace("getInvSelectIndex"); if (isCs108Connected()) return cs108Library4A.getInvSelectIndex(); else if (isCs710Connected()) return cs710Library4A.getInvSelectIndex(); - else Log.i("Hello2", "getInvSelectIndex" + stringNOTCONNECT); + else Logger.trace("getInvSelectIndex {}", stringNOTCONNECT); return -1; } //2286 public boolean getSelectEnable() { - if (DEBUG) Log.i("Hello2", "getSelectEnable"); + Logger.trace("getSelectEnable"); if (isCs108Connected()) return cs108Library4A.getSelectEnable(); else if (isCs710Connected()) return cs710Library4A.getSelectEnable(); - else Log.i("Hello2", "getSelectEnable" + stringNOTCONNECT); + else Logger.trace("getSelectEnable {}", stringNOTCONNECT); return false; } public int getSelectTarget() { - if (DEBUG) Log.i("Hello2", "getSelectTarget"); + Logger.trace("getSelectTarget"); if (isCs108Connected()) return cs108Library4A.getSelectTarget(); else if (isCs710Connected()) return cs710Library4A.getSelectTarget(); - else Log.i("Hello2", "getSelectTarget" + stringNOTCONNECT); + else Logger.trace("getSelectTarget {}", stringNOTCONNECT); return -1; } public int getSelectAction() { - if (DEBUG) Log.i("Hello2", "getSelectAction"); + Logger.trace("getSelectAction"); if (isCs108Connected()) return cs108Library4A.getSelectAction(); else if (isCs710Connected()) return cs710Library4A.getSelectAction(); - else Log.i("Hello2", "getSelectAction" + stringNOTCONNECT); + else Logger.trace("getSelectAction {}", stringNOTCONNECT); return -1; } public int getSelectMaskBank() { - if (DEBUG) Log.i("Hello2", "getSelectMaskBank"); + Logger.trace("getSelectMaskBank"); if (isCs108Connected()) return cs108Library4A.getSelectMaskBank(); else if (isCs710Connected()) return cs710Library4A.getSelectMaskBank(); - else Log.i("Hello2", "getSelectMaskBank" + stringNOTCONNECT); + else Logger.trace("getSelectMaskBank {}", stringNOTCONNECT); return -1; } public int getSelectMaskOffset() { - if (DEBUG) Log.i("Hello2", "getSelectMaskOffset"); + Logger.trace("getSelectMaskOffset"); if (isCs108Connected()) return cs108Library4A.getSelectMaskOffset(); else if (isCs710Connected()) return cs710Library4A.getSelectMaskOffset(); - else Log.i("Hello2", "getSelectMaskOffset" + stringNOTCONNECT); + else Logger.trace("getSelectMaskOffset {}", stringNOTCONNECT); return -1; } public String getSelectMaskData() { - if (DEBUG) Log.i("Hello2", "getSelectMaskData"); + Logger.trace("getSelectMaskData"); if (isCs108Connected()) return cs108Library4A.getSelectMaskData(); else if (isCs710Connected()) return cs710Library4A.getSelectMaskData(); - else Log.i("Hello2", "getSelectMaskData" + stringNOTCONNECT); + else Logger.trace("getSelectMaskData {}", stringNOTCONNECT); return null; } public boolean setInvSelectIndex(int invSelect) { - if (DEBUG) Log.i("Hello2", "setInvSelectIndex"); + Logger.trace("setInvSelectIndex"); if (isCs108Connected()) return cs108Library4A.setInvSelectIndex(invSelect); else if (isCs710Connected()) return cs710Library4A.setInvSelectIndex(invSelect); - else Log.i("Hello2", "setInvSelectIndex" + stringNOTCONNECT); + else Logger.trace("setInvSelectIndex {}", stringNOTCONNECT); return false; } public boolean setSelectCriteriaDisable(int index) { - if (DEBUG || true) appendToLog("csLibrary4A: setSelectCriteria Disable with index = " + index); + Logger.trace("csLibrary4A: setSelectCriteria Disable with index = {}", index); if (isCs108Connected()) return cs108Library4A.setSelectCriteriaDisable(index); else if (isCs710Connected()) return cs710Library4A.setSelectCriteriaDisable(index); - else Log.i("Hello2", "setSelectCriteriaDisable" + stringNOTCONNECT); + else Logger.trace("setSelectCriteriaDisable {}", stringNOTCONNECT); return false; } public boolean setSelectCriteria(int index, boolean enable, int target, int action, int bank, int offset, String mask, boolean maskbit) { - appendToLog("csLibrary4A: setSelectCriteria 1 with index = " + index + ", enable = " + enable + ", target = " + target + ", action = " + action + ", bank = " + bank + ", offset = " + offset + ", mask = " + mask + ", maskbit = " + maskbit); + Logger.trace("csLibrary4A: setSelectCriteria 1 with index = {}, enable = {}, target = {}, action = {}, bank = {}, offset = {}, mask = {}, maskbit = {}", index, enable, target, action, bank, offset, mask, maskbit); if (isCs108Connected()) return cs108Library4A.setSelectCriteria(index, enable, target, action, bank, offset, mask, maskbit); else if (isCs710Connected()) return cs710Library4A.setSelectCriteria(index, enable, target, action, bank, offset, mask, maskbit); - else Log.i("Hello2", "setSelectCriteria 1" + stringNOTCONNECT); + else Logger.trace("setSelectCriteria 1 {}", stringNOTCONNECT); return false; } public boolean setSelectCriteria(int index, boolean enable, int target, int action, int delay, int bank, int offset, String mask) { - appendToLog("csLibrary4A: setSelectCriteria 2 with index = " + index + ", enable = " + enable + ", target = " + target + ", action = " + action + ", delay = " + delay + ", bank = " + bank + ", offset = " + offset + ", mask = " + mask); + Logger.trace("csLibrary4A: setSelectCriteria 2 with index = {}, enable = {}, target = {}, action = {}, delay = {}, bank = {}, offset = {}, mask = {}", index, enable, target, action, delay, bank, offset, mask); if (isCs108Connected()) return cs108Library4A.setSelectCriteria(index, enable, target, action, delay, bank, offset, mask); else if (isCs710Connected()) return cs710Library4A.setSelectCriteria(index, enable, target, action, delay, bank, offset, mask); - else Log.i("Hello2", "setSelectCriteria" + stringNOTCONNECT); + else Logger.trace("setSelectCriteria {}", stringNOTCONNECT); return false; } public boolean getRssiFilterEnable() { - if (DEBUG) Log.i("Hello2", "getRssiFilterEnable"); + Logger.trace("getRssiFilterEnable"); if (isCs108Connected()) return cs108Library4A.getRssiFilterEnable(); else if (isCs710Connected()) return cs710Library4A.getRssiFilterEnable(); - else Log.i("Hello2", "getRssiFilterEnable" + stringNOTCONNECT); + else Logger.trace("getRssiFilterEnable {}", stringNOTCONNECT); return false; } public int getRssiFilterType() { - if (DEBUG) Log.i("Hello2", "getRssiFilterType"); + Logger.trace("getRssiFilterType"); if (isCs108Connected()) return cs108Library4A.getRssiFilterType(); else if (isCs710Connected()) return cs710Library4A.getRssiFilterType(); - else Log.i("Hello2", "getRssiFilterType" + stringNOTCONNECT); + else Logger.trace("getRssiFilterType {}", stringNOTCONNECT); return -1; } public int getRssiFilterOption() { - if (DEBUG) Log.i("Hello2", "getRssiFilterOption"); + Logger.trace("getRssiFilterOption"); if (isCs108Connected()) return cs108Library4A.getRssiFilterOption(); else if (isCs710Connected()) return cs710Library4A.getRssiFilterOption(); return -1; } public boolean setRssiFilterConfig(boolean enable, int rssiFilterType, int rssiFilterOption) { - if (DEBUG) Log.i("Hello2", "setRssiFilterConfig"); + Logger.trace("setRssiFilterConfig"); if (isCs108Connected()) return cs108Library4A.setRssiFilterConfig(enable, rssiFilterType, rssiFilterOption); else if (isCs710Connected()) return cs710Library4A.setRssiFilterConfig(enable, rssiFilterType, rssiFilterOption); - else Log.i("Hello2", "setRssiFilterConfig" + stringNOTCONNECT); + else Logger.trace("setRssiFilterConfig {}", stringNOTCONNECT); return false; } public double getRssiFilterThreshold1() { - if (DEBUG) Log.i("Hello2", "getRssiFilterThreshold1"); + Logger.trace("getRssiFilterThreshold1"); if (isCs108Connected()) return cs108Library4A.getRssiFilterThreshold1(); else if (isCs710Connected()) return cs710Library4A.getRssiFilterThreshold1(); - else Log.i("Hello2", "getRssiFilterThreshold1" + stringNOTCONNECT); + else Logger.trace("getRssiFilterThreshold1 {}", stringNOTCONNECT); return -1; } public double getRssiFilterThreshold2() { - if (DEBUG) Log.i("Hello2", "getRssiFilterThreshold2"); + Logger.trace("getRssiFilterThreshold2"); if (isCs108Connected()) return cs108Library4A.getRssiFilterThreshold2(); else if (isCs710Connected()) return cs710Library4A.getRssiFilterThreshold2(); - else Log.i("Hello2", "getRssiFilterThreshold2" + stringNOTCONNECT); + else Logger.trace("getRssiFilterThreshold2 {}", stringNOTCONNECT); return -1; } public boolean setRssiFilterThreshold(double rssiFilterThreshold1, double rssiFilterThreshold2) { - if (DEBUG) Log.i("Hello2", "setRssiFilterThreshold"); + Logger.trace("setRssiFilterThreshold"); if (isCs108Connected()) return cs108Library4A.setRssiFilterThreshold(rssiFilterThreshold1, rssiFilterThreshold2); else if (isCs710Connected()) return cs710Library4A.setRssiFilterThreshold(rssiFilterThreshold1, rssiFilterThreshold2); - else Log.i("Hello2", "setRssiFilterThreshold" + stringNOTCONNECT); + else Logger.trace("setRssiFilterThreshold {}", stringNOTCONNECT); return false; } public long getRssiFilterCount() { - if (DEBUG) Log.i("Hello2", "getRssiFilterCount"); + Logger.trace("getRssiFilterCount"); if (isCs108Connected()) return cs108Library4A.getRssiFilterCount(); else if (isCs710Connected()) return cs710Library4A.getRssiFilterCount(); - else Log.i("Hello2", "getRssiFilterCount" + stringNOTCONNECT); + else Logger.trace("getRssiFilterCount {}", stringNOTCONNECT); return -1; } public boolean setRssiFilterCount(long rssiFilterCount) { - Log.i("Hello2", "setRssiFilterCount"); + Logger.trace("setRssiFilterCount"); return false; } public boolean getInvMatchEnable() { - if (DEBUG) Log.i("Hello2", "getInvMatchEnable"); + Logger.trace("getInvMatchEnable"); if (isCs108Connected()) return cs108Library4A.getInvMatchEnable(); else if (isCs710Connected()) return cs710Library4A.getInvMatchEnable(); - else Log.i("Hello2", "getInvMatchEnable" + stringNOTCONNECT); + else Logger.trace("getInvMatchEnable {}", stringNOTCONNECT); return false; } public boolean getInvMatchType() { - if (DEBUG) Log.i("Hello2", "getInvMatchType"); + Logger.trace("getInvMatchType"); if (isCs108Connected()) return cs108Library4A.getInvMatchType(); else if (isCs710Connected()) return cs710Library4A.getInvMatchType(); - else Log.i("Hello2", "getInvMatchType" + stringNOTCONNECT); + else Logger.trace("getInvMatchType {}", stringNOTCONNECT); return false; } public int getInvMatchOffset() { - if (DEBUG) Log.i("Hello2", "getInvMatchOffset"); + Logger.trace("getInvMatchOffset"); if (isCs108Connected()) return cs108Library4A.getInvMatchOffset(); else if (isCs710Connected()) return cs710Library4A.getInvMatchOffset(); - else Log.i("Hello2", "getInvMatchOffset" + stringNOTCONNECT); + else Logger.trace("getInvMatchOffset {}", stringNOTCONNECT); return -1; } public String getInvMatchData() { - if (DEBUG) Log.i("Hello2", "getInvMatchData"); + Logger.trace("getInvMatchData"); if (isCs108Connected()) return cs108Library4A.getInvMatchData(); else if (isCs710Connected()) return cs710Library4A.getInvMatchData(); - else Log.i("Hello2", "getInvMatchData" + stringNOTCONNECT); + else Logger.trace("getInvMatchData {}", stringNOTCONNECT); return null; } public boolean setPostMatchCriteria(boolean enable, boolean target, int offset, String mask) { - if (DEBUG) Log.i("Hello2", "setPostMatchCriteria"); + Logger.trace("setPostMatchCriteria"); if (isCs108Connected()) return cs108Library4A.setPostMatchCriteria(enable, target, offset, mask); else if (isCs710Connected()) return cs710Library4A.setPostMatchCriteria(enable, target, offset, mask); - else Log.i("Hello2", "setPostMatchCriteria" + stringNOTCONNECT); + else Logger.trace("setPostMatchCriteria {}", stringNOTCONNECT); return false; } public int mrfidToWriteSize() { - if (DEBUG2) Log.i("Hello2", "mrfidToWriteSize"); + Logger.trace("mrfidToWriteSize"); if (isCs108Connected()) return cs108Library4A.mrfidToWriteSize(); else if (isCs710Connected()) return cs710Library4A.mrfidToWriteSize(); - else Log.i("Hello2", "mrfidToWriteSize" + stringNOTCONNECT); + else Logger.trace("mrfidToWriteSize {}", stringNOTCONNECT); return -1; } public void mrfidToWritePrint() { - Log.i("Hello2", "mrfidToWritePrint"); + Logger.trace("mrfidToWritePrint"); } public long getTagRate() { - if (DEBUG) Log.i("Hello2", "getTagRate"); + Logger.trace("getTagRate"); if (isCs108Connected()) return cs108Library4A.getTagRate(); else if (isCs710Connected()) return cs710Library4A.getTagRate(); - else Log.i("Hello2", "getTagRate" + stringNOTCONNECT); + else Logger.trace("getTagRate {}", stringNOTCONNECT); return -1; } public boolean startOperation(RfidReaderChipData.OperationTypes operationTypes) { - if (DEBUG) Log.i("Hello2", "startOperation"); + Logger.trace("startOperation"); if (isCs108Connected()) { /*RfidReaderChipData.OperationTypes operationTypes1 = null; switch (operationTypes) { @@ -907,139 +904,139 @@ public boolean startOperation(RfidReaderChipData.OperationTypes operationTypes) }*/ return cs710Library4A.startOperation(operationTypes); } - else Log.i("Hello2", "startOperation" + stringNOTCONNECT); + else Logger.trace("startOperation {}", stringNOTCONNECT); return false; } public boolean abortOperation() { - if (DEBUG) Log.i("Hello2", "abortOperation"); + Logger.trace("abortOperation"); if (isCs108Connected()) return cs108Library4A.abortOperation(); else if (isCs710Connected()) return cs710Library4A.abortOperation(); - else Log.i("Hello2", "abortOperation" + stringNOTCONNECT); + else Logger.trace("abortOperation {}", stringNOTCONNECT); return false; } public void restoreAfterTagSelect() { - if (DEBUG | true) Log.i("Hello2", "restoreAfterTagSelect"); + Logger.trace("restoreAfterTagSelect"); if (isCs108Connected()) cs108Library4A.restoreAfterTagSelect(); else if (isCs710Connected()) cs710Library4A.restoreAfterTagSelect(); - else Log.i("Hello2", "restoreAfterTagSelect" + stringNOTCONNECT); + else Logger.trace("restoreAfterTagSelect {}", stringNOTCONNECT); } public boolean setSelectedTagByTID(String strTagId, long pwrlevel) { - appendToLog("csLibrary4A: setSelectCriteria setSelectedByTID strTagId = " + strTagId + ", pwrlevel = " + pwrlevel); + Logger.trace("csLibrary4A: setSelectCriteria setSelectedByTID strTagId = {}, pwrlevel = {}", strTagId, pwrlevel); if (isCs108Connected()) return cs108Library4A.setSelectedTagByTID(strTagId, pwrlevel); else if (isCs710Connected()) return cs710Library4A.setSelectedTagByTID(strTagId, pwrlevel); - else Log.i("Hello2", "setSelectedTagByTID" + stringNOTCONNECT); + else Logger.trace("setSelectedTagByTID {}", stringNOTCONNECT); return false; } public boolean setSelectedTag(String strTagId, int selectBank, long pwrlevel) { - if (DEBUG) Log.i("Hello2", "setSelectedTag 1"); + Logger.trace("setSelectedTag 1"); if (isCs108Connected()) return cs108Library4A.setSelectedTag(strTagId, selectBank, pwrlevel); else if (isCs710Connected()) return cs710Library4A.setSelectedTag(strTagId, selectBank, pwrlevel); - else Log.i("Hello2", "setSelectedTag 1" + stringNOTCONNECT); + else Logger.trace("setSelectedTag 1 {}", stringNOTCONNECT); return false; } 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); + Logger.trace("csLibraryA: setSelectCriteria strTagId = {}, selectBank = {}, selectOffset = {}, pwrlevel = {}, qValue = {}, matchRep = {}", selectOne, 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); + else Logger.trace("setSelectedTag 2 {}", stringNOTCONNECT); return false; } public boolean setMatchRep(int matchRep) { - if (DEBUG) Log.i("Hello2", "setMatchRep"); + Logger.trace("setMatchRep"); if (isCs108Connected()) return cs108Library4A.setMatchRep(matchRep); else if (isCs710Connected()) return cs710Library4A.setMatchRep(matchRep); - else Log.i("Hello2", "setMatchRep" + stringNOTCONNECT); + else Logger.trace("setMatchRep {}", stringNOTCONNECT); return false; } public String[] getCountryList() { - if (DEBUG) Log.i("Hello2", "getCountryList"); + Logger.trace("getCountryList"); if (isCs108Connected()) return cs108Library4A.getCountryList(); else if (isCs710Connected()) return cs710Library4A.getCountryList(); - else Log.i("Hello2", "getCountryList" + stringNOTCONNECT); + else Logger.trace("getCountryList {}", stringNOTCONNECT); return null; } public int getCountryNumberInList() { - if (DEBUG) Log.i("Hello2", "getCountryNumberInList"); + Logger.trace("getCountryNumberInList"); if (isCs108Connected()) return cs108Library4A.getCountryNumberInList(); else if (isCs710Connected()) return cs710Library4A.getCountryNumberInList(); - else Log.i("Hello2", "getCountryNumberInList" + stringNOTCONNECT); + else Logger.trace("getCountryNumberInList {}", stringNOTCONNECT); return -1; } public boolean setCountryInList(int countryInList) { - if (DEBUG || true) Log.i("Hello2", "setCountryInList"); + Logger.trace("setCountryInList"); if (isCs108Connected()) return cs108Library4A.setCountryInList(countryInList); else if (isCs710Connected()) return cs710Library4A.setCountryInList(countryInList); - else Log.i("Hello2", "setCountryInList" + stringNOTCONNECT); + else Logger.trace("setCountryInList {}", stringNOTCONNECT); return false; } public boolean getChannelHoppingStatus() { - if (DEBUG) Log.i("Hello2", "getChannelHoppingStatus"); + Logger.trace("getChannelHoppingStatus"); if (isCs108Connected()) return cs108Library4A.getChannelHoppingStatus(); else if (isCs710Connected()) return cs710Library4A.getChannelHoppingStatus(); - else Log.i("Hello2", "getChannelHoppingStatus" + stringNOTCONNECT); + else Logger.trace("getChannelHoppingStatus {}", stringNOTCONNECT); return false; } public boolean setChannelHoppingStatus(boolean channelOrderHopping) { - Log.i("Hello2", "setChannelHoppingStatus"); + Logger.trace("setChannelHoppingStatus"); return false; } public String[] getChannelFrequencyList() { if (isCs108Connected()) return cs108Library4A.getChannelFrequencyList(); else if (isCs710Connected()) return cs710Library4A.getChannelFrequencyList(); - else Log.i("Hello2", "getChannelFrequencyList" + stringNOTCONNECT); + else Logger.trace("getChannelFrequencyList {}", stringNOTCONNECT); return null; } public int getChannel() { - if (DEBUG) Log.i("Hello2", "getChannel"); + Logger.trace("getChannel"); if (isCs108Connected()) return cs108Library4A.getChannel(); else if (isCs710Connected()) return cs710Library4A.getChannel(); - else Log.i("Hello2", "getChannel" + stringNOTCONNECT); + else Logger.trace("getChannel {}", stringNOTCONNECT); return -1; } public boolean setChannel(int channelSelect) { - if (DEBUG) Log.i("Hello2", "setChannel"); + Logger.trace("setChannel"); if (isCs108Connected()) return cs108Library4A.setChannel(channelSelect); else if (isCs710Connected()) return cs710Library4A.setChannel(channelSelect); - else Log.i("Hello2", "setChannel" + stringNOTCONNECT); + else Logger.trace("setChannel {}", stringNOTCONNECT); return false; } public byte getPopulation2Q(int population) { - if (DEBUG) Log.i("Hello2", "getPopulation2Q"); + Logger.trace("getPopulation2Q"); if (isCs108Connected()) return cs108Library4A.getPopulation2Q(population); else if (isCs710Connected()) return cs710Library4A.getPopulation2Q(population); - else Log.i("Hello2", "getPopulation2Q" + stringNOTCONNECT); + else Logger.trace("getPopulation2Q {}", stringNOTCONNECT); return -1; } public int getPopulation() { - if (DEBUG) Log.i("Hello2", "getPopulation"); + Logger.trace("getPopulation"); if (isCs108Connected()) return cs108Library4A.getPopulation(); else if (isCs710Connected()) return cs710Library4A.getPopulation(); - else Log.i("Hello2", "getPopulation" + stringNOTCONNECT); + else Logger.trace("getPopulation {}", stringNOTCONNECT); return -1; } //3348 public boolean setPopulation(int population) { - if (DEBUG || true) Log.i("Hello2", "setPopulation " + population); + Logger.trace("setPopulation {}", population); if (isCs108Connected()) return cs108Library4A.setPopulation(population); else if (isCs710Connected()) return cs710Library4A.setPopulation(population); - else Log.i("Hello2", "setPopulation" + stringNOTCONNECT); + else Logger.trace("setPopulation {}", stringNOTCONNECT); return false; } public byte getQValue() { - if (DEBUG) Log.i("Hello2", "getQValue"); + Logger.trace("getQValue"); if (isCs108Connected()) return cs108Library4A.getQValue(); else if (isCs710Connected()) return cs710Library4A.getQValue(); - else Log.i("Hello2", "getQValue" + stringNOTCONNECT); + else Logger.trace("getQValue {}", stringNOTCONNECT); return -1; } public boolean setQValue(byte byteValue) { - if (DEBUG) Log.i("Hello2", "setQValue"); + Logger.trace("setQValue"); if (isCs108Connected()) return cs108Library4A.setQValue(byteValue); else if (isCs710Connected()) return cs710Library4A.setQValue(byteValue); - else Log.i("Hello2", "setQValue" + stringNOTCONNECT); + else Logger.trace("setQValue {}", stringNOTCONNECT); return false; } public RfidReaderChipData.Rx000pkgData onRFIDEvent() { - if (DEBUG2) Log.i("Hello2", "onRFIDEvent"); + Logger.trace("onRFIDEvent"); if (isCs108Connected()) { RfidReaderChipData.Rx000pkgData rx000pkgData = null; RfidReaderChipData.Rx000pkgData rx000pkgData1 = cs108Library4A.onRFIDEvent(); @@ -1062,7 +1059,7 @@ public RfidReaderChipData.Rx000pkgData onRFIDEvent() { rx000pkgData.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_TAG_ACCESS; break; default: - Log.i("Hello2", "onRFIDEvent: responseType = " + rx000pkgData1.responseType.toString()); + Logger.trace("onRFIDEvent: responseType = {}", rx000pkgData1.responseType); } rx000pkgData.flags = rx000pkgData1.flags; rx000pkgData.dataValues = rx000pkgData1.dataValues; @@ -1102,7 +1099,7 @@ public RfidReaderChipData.Rx000pkgData onRFIDEvent() { rx000pkgData.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_TAG_ACCESS; break; default: - Log.i("Hello2", "onRFIDEvent: responseType = " + rx000pkgData1.responseType.toString()); + Logger.trace("onRFIDEvent: responseType = {}", rx000pkgData1.responseType); } rx000pkgData.flags = rx000pkgData1.flags; rx000pkgData.dataValues = rx000pkgData1.dataValues; @@ -1119,126 +1116,125 @@ public RfidReaderChipData.Rx000pkgData onRFIDEvent() { rx000pkgData.decodedResult = rx000pkgData1.decodedResult; rx000pkgData.decodedError = rx000pkgData1.decodedError; } - if (rx000pkgData != null) appendToLog("response0 = " + rx000pkgData.responseType.toString() + ", " + byteArrayToString(rx000pkgData.dataValues)); + if (rx000pkgData != null) Logger.trace("response0 = {}, {}", rx000pkgData.responseType, byteArrayToString(rx000pkgData.dataValues)); return rx000pkgData; - } - else Log.i("Hello2", "onRFIDEvent" + stringNOTCONNECT); + } else Logger.trace("onRFIDEvent {}", stringNOTCONNECT); return null; } public String getModelNumber() { - if (DEBUG) Log.i("Hello2", "getModelNumber"); + Logger.trace("getModelNumber"); if (isCs108Connected()) return cs108Library4A.getModelNumber(); else if (isCs710Connected()) return cs710Library4A.getModelNumber(); - else Log.i("Hello2", "getModelNumber" + stringNOTCONNECT); + else Logger.trace("getModelNumber {}", stringNOTCONNECT); return null; } public boolean setRx000KillPassword(String password) { - if (DEBUG) Log.i("Hello2", "setRx000KillPassword"); + Logger.trace("setRx000KillPassword"); if (isCs108Connected()) return cs108Library4A.setRx000KillPassword(password); else if (isCs710Connected()) return cs710Library4A.setRx000KillPassword(password); - else Log.i("Hello2", "setRx000KillPassword" + stringNOTCONNECT); + else Logger.trace("setRx000KillPassword {}", stringNOTCONNECT); return false; } public boolean setRx000AccessPassword(String password) { - if (DEBUG) Log.i("Hello2", "setRx000AccessPassword"); + Logger.trace("setRx000AccessPassword"); if (isCs108Connected()) return cs108Library4A.setRx000AccessPassword(password); else if (isCs710Connected()) return cs710Library4A.setRx000AccessPassword(password); - else Log.i("Hello2", "setRx000AccessPassword" + stringNOTCONNECT); + else Logger.trace("setRx000AccessPassword {}", stringNOTCONNECT); return false; } public boolean setAccessRetry(boolean accessVerfiy, int accessRetry) { - if (DEBUG) Log.i("Hello2", "setAccessRetry"); + Logger.trace("setAccessRetry"); if (isCs108Connected()) return cs108Library4A.setAccessRetry(accessVerfiy, accessRetry); else if (isCs710Connected()) return cs710Library4A.setAccessRetry(accessVerfiy, accessRetry); - else Log.i("Hello2", "setAccessRetry" + stringNOTCONNECT); + else Logger.trace("setAccessRetry {}", stringNOTCONNECT); return false; } public boolean setInvModeCompact(boolean invModeCompact) { - if (DEBUG) Log.i("Hello2", "setInvModeCompact"); + Logger.trace("setInvModeCompact"); if (isCs108Connected()) return cs108Library4A.setInvModeCompact(invModeCompact); else if (isCs710Connected()) return cs710Library4A.setInvModeCompact(invModeCompact); - else Log.i("Hello2", "setInvModeCompact" + stringNOTCONNECT); + else Logger.trace("setInvModeCompact {}", stringNOTCONNECT); return false; } public boolean setAccessLockAction(int accessLockAction, int accessLockMask) { - if (DEBUG) Log.i("Hello2", "setAccessLockAction"); + Logger.trace("setAccessLockAction"); if (isCs108Connected()) return cs108Library4A.setAccessLockAction(accessLockAction, accessLockMask); else if (isCs710Connected()) return cs710Library4A.setAccessLockAction(accessLockAction, accessLockMask); - else Log.i("Hello2", "setAccessLockAction" + stringNOTCONNECT); + else Logger.trace("setAccessLockAction {}", stringNOTCONNECT); return false; } public boolean setAccessBank(int accessBank) { - if (DEBUG) Log.i("Hello2", "setAccessBank 1"); + Logger.trace("setAccessBank 1"); if (isCs108Connected()) return cs108Library4A.setAccessBank(accessBank); else if (isCs710Connected()) return cs710Library4A.setAccessBank(accessBank); - else Log.i("Hello2", "setAccessBank 1" + stringNOTCONNECT); + else Logger.trace("setAccessBank 1 {}", stringNOTCONNECT); return false; } public boolean setAccessBank(int accessBank, int accessBank2) { - if (DEBUG) Log.i("Hello2", "setAccessBank 2"); + Logger.trace("setAccessBank 2"); if (isCs108Connected()) return cs108Library4A.setAccessBank(accessBank, accessBank2); else if (isCs710Connected()) return cs710Library4A.setAccessBank(accessBank, accessBank2); - else Log.i("Hello2", "setAccessBank 2" + stringNOTCONNECT); + else Logger.trace("setAccessBank 2 {}", stringNOTCONNECT); return false; } public boolean setAccessOffset(int accessOffset) { - if (DEBUG) Log.i("Hello2", "setAccessOffset 1"); + Logger.trace("setAccessOffset 1"); if (isCs108Connected()) return cs108Library4A.setAccessOffset(accessOffset); else if (isCs710Connected()) return cs710Library4A.setAccessOffset(accessOffset); - else Log.i("Hello2", "setAccessOffset 1" + stringNOTCONNECT); + else Logger.trace("setAccessOffset 1 {}", stringNOTCONNECT); return false; } public boolean setAccessOffset(int accessOffset, int accessOffset2) { - if (DEBUG) Log.i("Hello2", "setAccessOffset 2"); + Logger.trace("setAccessOffset 2"); if (isCs108Connected()) return cs108Library4A.setAccessOffset(accessOffset, accessOffset2); else if (isCs710Connected()) return cs710Library4A.setAccessOffset(accessOffset, accessOffset2); - else Log.i("Hello2", "setAccessOffset 2" + stringNOTCONNECT); + else Logger.trace("setAccessOffset 2 {}", stringNOTCONNECT); return false; } public boolean setAccessCount(int accessCount) { - if (DEBUG) Log.i("Hello2", "setAccessCount 1"); + Logger.trace("setAccessCount 1"); if (isCs108Connected()) return cs108Library4A.setAccessCount(accessCount); else if (isCs710Connected()) return cs710Library4A.setAccessCount(accessCount); - else Log.i("Hello2", "setAccessCount 1" + stringNOTCONNECT); + else Logger.trace("setAccessCount 1 {}", stringNOTCONNECT); return false; } public boolean setAccessCount(int accessCount, int accessCount2) { - if (DEBUG) Log.i("Hello2", "setAccessCount 2"); + Logger.trace("setAccessCount 2"); if (isCs108Connected()) return cs108Library4A.setAccessCount(accessCount, accessCount2); else if (isCs710Connected()) return cs710Library4A.setAccessCount(accessCount, accessCount2); - else Log.i("Hello2", "setAccessCount 2" + stringNOTCONNECT); + else Logger.trace("setAccessCount 2 {}", stringNOTCONNECT); return false; } public boolean setAccessWriteData(String dataInput) { - if (DEBUG) Log.i("Hello2", "setAccessWriteData"); + Logger.trace("setAccessWriteData"); if (isCs108Connected()) return cs108Library4A.setAccessWriteData(dataInput); else if (isCs710Connected()) return cs710Library4A.setAccessWriteData(dataInput); - else Log.i("Hello2", "setAccessWriteData" + stringNOTCONNECT); + else Logger.trace("setAccessWriteData {}", stringNOTCONNECT); return false; } public boolean setResReadNoReply(boolean resReadNoReply) { - if (DEBUG) Log.i("Hello2", "setResReadNoReply"); + Logger.trace("setResReadNoReply"); if (isCs108Connected()) return false; else if (isCs710Connected()) return cs710Library4A.setResReadNoReply(resReadNoReply); - else Log.i("Hello2", "setResReadNoReply" + stringNOTCONNECT); + else Logger.trace("setResReadNoReply {}", stringNOTCONNECT); return false; } public boolean setTagRead(int tagRead) { - if (DEBUG) Log.i("Hello2", "setTagRead"); + Logger.trace("setTagRead"); if (isCs108Connected()) return cs108Library4A.setTagRead(tagRead); else if (isCs710Connected()) return cs710Library4A.setTagRead(tagRead); - else Log.i("Hello2", "setTagRead" + stringNOTCONNECT); + else Logger.trace("setTagRead {}", stringNOTCONNECT); return false; } public boolean setInvBrandId(boolean invBrandId) { - if (DEBUG) Log.i("Hello2", "setInvBrandId"); + Logger.trace("setInvBrandId"); if (isCs108Connected()) return cs108Library4A.setInvBrandId(invBrandId); else if (isCs710Connected()) return cs710Library4A.setInvBrandId(invBrandId); - else Log.i("Hello2", "setInvBrandId" + stringNOTCONNECT); + else Logger.trace("setInvBrandId {}", stringNOTCONNECT); return false; } public boolean sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands hostCommand) { - if (DEBUG | true) Log.i("Hello2", "sendHostRegRequestHST_CMD with hostCommand = " + hostCommand.toString()); + Logger.trace("sendHostRegRequestHST_CMD with hostCommand = {}", hostCommand); if (isCs108Connected()) { RfidReaderChipData.HostCommands hostCommands1 = null; switch (hostCommand) { @@ -1300,7 +1296,7 @@ public boolean sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands hostCom hostCommands1 = RfidReaderChipData.HostCommands.CMD_FDM_LED_CTRL; break; default: - Log.i("Hello2", "Skip sendHostRegRequestHST_CMD: hostCommand = " + hostCommand.toString()); + Logger.trace("Skip sendHostRegRequestHST_CMD: hostCommand = {}", hostCommand); break; } if (hostCommands1 == null) return false; @@ -1329,536 +1325,536 @@ public boolean sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands hostCom case CMD_GETSENSORDATA: hostCommands1 = RfidReaderChipData.HostCommands.CMD_GETSENSORDATA; default: - Log.i("Hello2", "sendHostRegRequestHST_CMD: hostCommand = " + hostCommand.toString()); + Logger.trace("sendHostRegRequestHST_CMD: hostCommand = {}", hostCommand); break; } if (hostCommands1 == null) return false; return cs710Library4A.sendHostRegRequestHST_CMD(hostCommands1); } - else Log.i("Hello2", "sendHostRegRequestHST_CMD" + stringNOTCONNECT); + else Logger.trace("sendHostRegRequestHST_CMD {}", stringNOTCONNECT); return false; } public boolean setPwrManagementMode(boolean bLowPowerStandby) { - if (DEBUG) Log.i("Hello2", "setPwrManagementMode"); + Logger.trace("setPwrManagementMode"); if (isCs108Connected()) return cs108Library4A.setPwrManagementMode(bLowPowerStandby); else if (isCs710Connected()) return cs710Library4A.setPwrManagementMode(bLowPowerStandby); return false; } public void macWrite(int address, long value) { - if (DEBUG) Log.i("Hello2", "macWrite"); + Logger.trace("macWrite"); if (isCs108Connected()) cs108Library4A.macWrite(address, value); else if (isCs710Connected()) { } } public void set_fdCmdCfg(int value) { - if (DEBUG) Log.i("Hello2", "set_fdCmdCfg"); + Logger.trace("set_fdCmdCfg"); if (isCs108Connected()) cs108Library4A.set_fdCmdCfg(value); else if (isCs710Connected()) { } } public void set_fdRegAddr(int addr) { - if (DEBUG) Log.i("Hello2", "set_fdRegAddr"); + Logger.trace("set_fdRegAddr"); if (isCs108Connected()) cs108Library4A.set_fdRegAddr(addr); else if (isCs710Connected()) { } } public void set_fdWrite(int addr, long value) { - if (DEBUG) Log.i("Hello2", "set_fdWrite"); + Logger.trace("set_fdWrite"); if (isCs108Connected()) cs108Library4A.set_fdWrite(addr, value); else if (isCs710Connected()) { } } public void set_fdPwd(int value) { - if (DEBUG) Log.i("Hello2", "set_fdPwd"); + Logger.trace("set_fdPwd"); if (isCs108Connected()) cs108Library4A.set_fdPwd(value); else if (isCs710Connected()) { } } public void set_fdBlockAddr4GetTemperature(int addr) { - if (DEBUG) Log.i("Hello2", "set_fdBlockAddr4GetTemperature"); + Logger.trace("set_fdBlockAddr4GetTemperature"); if (isCs108Connected()) cs108Library4A.set_fdBlockAddr4GetTemperature(addr); else if (isCs710Connected()) { } } public void set_fdReadMem(int addr, long len) { - if (DEBUG) Log.i("Hello2", "set_fdReadMem"); + Logger.trace("set_fdReadMem"); if (isCs108Connected()) cs108Library4A.set_fdReadMem(addr, len); else if (isCs710Connected()) { } } public void set_fdWriteMem(int addr, int len, long value) { - if (DEBUG) Log.i("Hello2", "set_fdWriteMem"); + Logger.trace("set_fdWriteMem"); if (isCs108Connected()) cs108Library4A.set_fdWriteMem(addr, len, value); else if (isCs710Connected()) { } } public void setImpinJExtension(boolean tagFocus, boolean fastId) { - if (DEBUG) Log.i("Hello2", "setImpinJExtension with tagFocus = " + tagFocus + ", fastId = " + fastId); + Logger.trace("setImpinJExtension with tagFocus = {}, fastId = {}", tagFocus, fastId); if (isCs108Connected()) cs108Library4A.setImpinJExtension(tagFocus, fastId); else if (isCs710Connected()) cs710Library4A.setImpinJExtension(tagFocus, fastId); - else Log.i("Hello2", "setImpinJExtension" + stringNOTCONNECT); + else Logger.trace("setImpinJExtension {}", stringNOTCONNECT); } //============ Barcode ============ public void getBarcodePreSuffix() { - if (DEBUG) Log.i("Hello2", "getBarcodePreSuffix"); + Logger.trace("getBarcodePreSuffix"); if (isCs108Connected()) cs108Library4A.getBarcodePreSuffix(); else if (isCs710Connected()) cs710Library4A.getBarcodePreSuffix(); - else Log.i("Hello2", "getBarcodePreSuffix" + stringNOTCONNECT); + else Logger.trace("getBarcodePreSuffix {}", stringNOTCONNECT); } public void getBarcodeReadingMode() { - if (DEBUG) Log.i("Hello2", "getBarcodeReadingMode"); + Logger.trace("getBarcodeReadingMode"); if (isCs108Connected()) cs108Library4A.getBarcodeReadingMode(); else if (isCs710Connected()) cs710Library4A.getBarcodeReadingMode(); - else Log.i("Hello2", "getBarcodeReadingMode" + stringNOTCONNECT); + else Logger.trace("getBarcodeReadingMode {}", stringNOTCONNECT); } public boolean isBarcodeFailure() { - if (DEBUG) Log.i("Hello2", "isBarcodeFailure"); + Logger.trace("isBarcodeFailure"); if (isCs108Connected()) return cs108Library4A.isBarcodeFailure(); else if (isCs710Connected()) return cs710Library4A.isBarcodeFailure(); - else Log.i("Hello2", "isBarcodeFailure" + stringNOTCONNECT); + else Logger.trace("isBarcodeFailure {}", stringNOTCONNECT); return false; } public String getBarcodeDate() { - if (DEBUG) Log.i("Hello2", "getBarcodeDate"); + Logger.trace("getBarcodeDate"); if (isCs108Connected()) return cs108Library4A.getBarcodeDate(); else if (isCs710Connected()) return cs710Library4A.getBarcodeDate(); - else Log.i("Hello2", "getBarcodeDate" + stringNOTCONNECT); + else Logger.trace("getBarcodeDate {}", stringNOTCONNECT); return null; } public boolean getBarcodeOnStatus() { - if (DEBUG) Log.i("Hello2", "getBarcodeOnStatus"); + Logger.trace("getBarcodeOnStatus"); if (isCs108Connected()) return cs108Library4A.getBarcodeOnStatus(); else if (isCs710Connected()) return cs710Library4A.getBarcodeOnStatus(); - else Log.i("Hello2", "getBarcodeOnStatus" + stringNOTCONNECT); + else Logger.trace("getBarcodeOnStatus {}", stringNOTCONNECT); return false; } public boolean setBarcodeOn(boolean on) { - if (DEBUG) Log.i("Hello2", "setBarcodeOn"); + Logger.trace("setBarcodeOn"); if (isCs108Connected()) return cs108Library4A.setBarcodeOn(on); else if (isCs710Connected()) return cs710Library4A.setBarcodeOn(on); - else Log.i("Hello2", "setBarcodeOn" + stringNOTCONNECT); + else Logger.trace("setBarcodeOn {}", stringNOTCONNECT); return false; } public boolean setVibrateOn(int mode) { - if (DEBUG || true) Log.i("Hello2", "setVibrateOn with mode = " + mode); + Logger.trace("setVibrateOn with mode = {}", mode); if (isCs108Connected()) return cs108Library4A.setVibrateOn(mode); else if (isCs710Connected()) return cs710Library4A.setVibrateOn(mode); - else Log.i("Hello2", "setVibrateOn" + stringNOTCONNECT); + else Logger.trace("setVibrateOn {}", stringNOTCONNECT); return false; } public boolean getInventoryVibrate() { - if (DEBUG) Log.i("Hello2", "getInventoryVibrate"); + Logger.trace("getInventoryVibrate"); if (isCs108Connected()) return cs108Library4A.getInventoryVibrate(); else if (isCs710Connected()) return cs710Library4A.getInventoryVibrate(); - else Log.i("Hello2", "getInventoryVibrate" + stringNOTCONNECT); + else Logger.trace("getInventoryVibrate {}", stringNOTCONNECT); return false; } public boolean setInventoryVibrate(boolean inventoryVibrate) { - if (DEBUG) Log.i("Hello2", "setInventoryVibrate"); + Logger.trace("setInventoryVibrate"); if (isCs108Connected()) return cs108Library4A.setInventoryVibrate(inventoryVibrate); else if (isCs710Connected()) return cs710Library4A.setInventoryVibrate(inventoryVibrate); - else Log.i("Hello2", "setInventoryVibrate" + stringNOTCONNECT); + else Logger.trace("setInventoryVibrate {}", stringNOTCONNECT); return false; } public int getVibrateTime() { - if (DEBUG) Log.i("Hello2", "getVibrateTime"); + Logger.trace("getVibrateTime"); if (isCs108Connected()) return cs108Library4A.getVibrateTime(); else if (isCs710Connected()) return cs710Library4A.getVibrateTime(); - else Log.i("Hello2", "getVibrateTime" + stringNOTCONNECT); + else Logger.trace("getVibrateTime {}", stringNOTCONNECT); return -1; } public boolean setVibrateTime(int vibrateTime) { - if (DEBUG) Log.i("Hello2", "setVibrateTime"); + Logger.trace("setVibrateTime"); if (isCs108Connected()) return cs108Library4A.setVibrateTime(vibrateTime); else if (isCs710Connected()) return cs710Library4A.setVibrateTime(vibrateTime); - else Log.i("Hello2", "setVibrateTime" + stringNOTCONNECT); + else Logger.trace("setVibrateTime {}", stringNOTCONNECT); return false; } public int getVibrateWindow() { - if (DEBUG) Log.i("Hello2", "getVibrateWindow"); + Logger.trace("getVibrateWindow"); if (isCs108Connected()) return cs108Library4A.getVibrateWindow(); else if (isCs710Connected()) return cs710Library4A.getVibrateWindow(); - else Log.i("Hello2", "getVibrateWindow" + stringNOTCONNECT); + else Logger.trace("getVibrateWindow {}", stringNOTCONNECT); return -1; } public boolean setVibrateWindow(int vibrateWindow) { - if (DEBUG) Log.i("Hello2", "setVibrateWindow"); + Logger.trace("setVibrateWindow"); if (isCs108Connected()) return cs108Library4A.setVibrateWindow(vibrateWindow); else if (isCs710Connected()) return cs710Library4A.setVibrateWindow(vibrateWindow); - else Log.i("Hello2", "setVibrateWindow" + stringNOTCONNECT); + else Logger.trace("setVibrateWindow {}", stringNOTCONNECT); return false; } public boolean barcodeSendCommandTrigger() { - if (DEBUG) Log.i("Hello2", "barcodeSendCommandTrigger"); + Logger.trace("barcodeSendCommandTrigger"); if (isCs108Connected()) return cs108Library4A.barcodeSendCommandTrigger(); else if (isCs710Connected()) return cs710Library4A.barcodeSendCommandTrigger(); - else Log.i("Hello2", "barcodeSendCommandTrigger" + stringNOTCONNECT); + else Logger.trace("barcodeSendCommandTrigger {}", stringNOTCONNECT); return false; } public boolean barcodeSendCommandSetPreSuffix() { - if (DEBUG) Log.i("Hello2", "barcodeSendCommandSetPreSuffix"); + Logger.trace("barcodeSendCommandSetPreSuffix"); if (isCs108Connected()) return cs108Library4A.barcodeSendCommandSetPreSuffix(); else if (isCs710Connected()) return cs710Library4A.barcodeSendCommandSetPreSuffix(); - else Log.i("Hello2", "barcodeSendCommandSetPreSuffix" + stringNOTCONNECT); + else Logger.trace("barcodeSendCommandSetPreSuffix {}", stringNOTCONNECT); return false; } public boolean barcodeSendCommandResetPreSuffix() { - if (DEBUG) Log.i("Hello2", "barcodeSendCommandResetPreSuffix"); + Logger.trace("barcodeSendCommandResetPreSuffix"); if (isCs108Connected()) return cs108Library4A.barcodeSendCommandResetPreSuffix(); else if (isCs710Connected()) return cs710Library4A.barcodeSendCommandResetPreSuffix(); - else Log.i("Hello2", "barcodeSendCommandResetPreSuffix" + stringNOTCONNECT); + else Logger.trace("barcodeSendCommandResetPreSuffix {}", stringNOTCONNECT); return false; } public boolean barcodeSendCommandConinuous() { - if (DEBUG) Log.i("Hello2", "barcodeSendCommandConinuous"); + Logger.trace("barcodeSendCommandConinuous"); if (isCs108Connected()) return cs108Library4A.barcodeSendCommandConinuous(); else if (isCs710Connected()) return cs710Library4A.barcodeSendCommandConinuous(); - else Log.i("Hello2", "barcodeSendCommandConinuous" + stringNOTCONNECT); + else Logger.trace("barcodeSendCommandConinuous {}", stringNOTCONNECT); return false; } public String getBarcodeVersion() { - if (DEBUG) Log.i("Hello2", "getBarcodeVersion"); + Logger.trace("getBarcodeVersion"); if (isCs108Connected()) return cs108Library4A.getBarcodeVersion(); else if (isCs710Connected()) return cs710Library4A.getBarcodeVersion(); - else Log.i("Hello2", "getBarcodeVersion" + stringNOTCONNECT); + else Logger.trace("getBarcodeVersion {}", stringNOTCONNECT); return null; } public String getBarcodeSerial() { - if (DEBUG) Log.i("Hello2", "getBarcodeSerial"); + Logger.trace("getBarcodeSerial"); if (isCs108Connected()) return cs108Library4A.getBarcodeSerial(); else if (isCs710Connected()) return cs710Library4A.getBarcodeSerial(); - else Log.i("Hello2", "getBarcodeSerial" + stringNOTCONNECT); + else Logger.trace("getBarcodeSerial {}", stringNOTCONNECT); return null; } public boolean barcodeInventory(boolean start) { - if (DEBUG) Log.i("Hello2", "barcodeInventory"); + Logger.trace("barcodeInventory"); if (isCs108Connected()) return cs108Library4A.barcodeInventory(start); else if (isCs710Connected()) return cs710Library4A.barcodeInventory(start); - else Log.i("Hello2", "barcodeInventory" + stringNOTCONNECT); + else Logger.trace("barcodeInventory {}", stringNOTCONNECT); return false; } public byte[] onBarcodeEvent() { - if (DEBUG) Log.i("Hello2", "onBarcodeEvent"); + Logger.trace("onBarcodeEvent"); if (isCs108Connected()) return cs108Library4A.onBarcodeEvent(); else if (isCs710Connected()) return cs710Library4A.onBarcodeEvent(); - else Log.i("Hello2", "onBarcodeEvent" + stringNOTCONNECT); + else Logger.trace("onBarcodeEvent {}", stringNOTCONNECT); return null; } //============ Android General ============ public void setSameCheck(boolean sameCheck1) { - if (DEBUG) Log.i("Hello2", "setSameCheck"); + Logger.trace("setSameCheck"); if (isCs108Connected()) cs108Library4A.setSameCheck(sameCheck1); else if (isCs710Connected()) cs710Library4A.setSameCheck(sameCheck1); - else Log.i("Hello2", "setSameCheck" + stringNOTCONNECT); + else Logger.trace("setSameCheck {}", stringNOTCONNECT); } public void saveSetting2File() { - if (DEBUG) Log.i("Hello2", "saveSetting2File"); + Logger.trace("saveSetting2File"); if (isCs108Connected()) cs108Library4A.saveSetting2File(); else if (isCs710Connected()) cs710Library4A.saveSetting2File(); - else Log.i("Hello2", "saveSetting2File" + stringNOTCONNECT); + else Logger.trace("saveSetting2File {}", stringNOTCONNECT); } public int getBeepCount() { - if (DEBUG) Log.i("Hello2", "getBeepCount"); + Logger.trace("getBeepCount"); if (isCs108Connected()) return cs108Library4A.getBeepCount(); else if (isCs710Connected()) return cs710Library4A.getBeepCount(); - else Log.i("Hello2", "getBeepCount" + stringNOTCONNECT); + else Logger.trace("getBeepCount {}", stringNOTCONNECT); return -1; } public boolean setBeepCount(int beepCount) { - if (DEBUG) Log.i("Hello2", "setBeepCount"); + Logger.trace("setBeepCount"); if (isCs108Connected()) return cs108Library4A.setBeepCount(beepCount); else if (isCs710Connected()) return cs710Library4A.setBeepCount(beepCount); - else Log.i("Hello2", "setBeepCount" + stringNOTCONNECT); + else Logger.trace("setBeepCount {}", stringNOTCONNECT); return false; } public boolean getInventoryBeep() { - if (DEBUG) Log.i("Hello2", "getInventoryBeep"); + Logger.trace("getInventoryBeep"); if (isCs108Connected()) return cs108Library4A.getInventoryBeep(); else if (isCs710Connected()) return cs710Library4A.getInventoryBeep(); - else Log.i("Hello2", "getInventoryBeep" + stringNOTCONNECT); + else Logger.trace("getInventoryBeep {}", stringNOTCONNECT); return false; } public boolean setInventoryBeep(boolean inventoryBeep) { - if (DEBUG) Log.i("Hello2", "setInventoryBeep"); + Logger.trace("setInventoryBeep"); if (isCs108Connected()) return cs108Library4A.setInventoryBeep(inventoryBeep); else if (isCs710Connected()) return cs710Library4A.setInventoryBeep(inventoryBeep); - else Log.i("Hello2", "setInventoryBeep" + stringNOTCONNECT); + else Logger.trace("setInventoryBeep {}", stringNOTCONNECT); return false; } public boolean getSaveFileEnable() { - if (DEBUG) Log.i("Hello2", "getSaveFileEnable"); + Logger.trace("getSaveFileEnable"); if (isCs108Connected()) return cs108Library4A.getSaveFileEnable(); else if (isCs710Connected()) return cs710Library4A.getSaveFileEnable(); - else Log.i("Hello2", "getSaveFileEnable" + stringNOTCONNECT); + else Logger.trace("getSaveFileEnable {}", stringNOTCONNECT); return false; } public boolean setSaveFileEnable(boolean saveFileEnable) { - if (DEBUG) Log.i("Hello2", "setSaveFileEnable"); + Logger.trace("setSaveFileEnable"); if (isCs108Connected()) return cs108Library4A.setSaveFileEnable(saveFileEnable); else if (isCs710Connected()) return cs710Library4A.setSaveFileEnable(saveFileEnable); - else Log.i("Hello2", "setSaveFileEnable" + stringNOTCONNECT); + else Logger.trace("setSaveFileEnable {}", stringNOTCONNECT); return false; } public boolean getSaveCloudEnable() { - if (DEBUG) Log.i("Hello2", "getSaveCloudEnable"); + Logger.trace("getSaveCloudEnable"); if (isCs108Connected()) return cs108Library4A.getSaveCloudEnable(); else if (isCs710Connected()) return cs710Library4A.getSaveCloudEnable(); - else Log.i("Hello2", "getSaveCloudEnable" + stringNOTCONNECT); + else Logger.trace("getSaveCloudEnable {}", stringNOTCONNECT); return false; } public boolean setSaveCloudEnable(boolean saveCloudEnable) { - if (DEBUG) Log.i("Hello2", "setSaveCloudEnable"); + Logger.trace("setSaveCloudEnable"); if (isCs108Connected()) return cs108Library4A.setSaveCloudEnable(saveCloudEnable); else if (isCs710Connected()) return cs710Library4A.setSaveCloudEnable(saveCloudEnable); - else Log.i("Hello2", "setSaveCloudEnable" + stringNOTCONNECT); + else Logger.trace("setSaveCloudEnable {}", stringNOTCONNECT); return false; } public boolean getSaveNewCloudEnable() { - if (DEBUG) Log.i("Hello2", "getSaveNewCloudEnable"); + Logger.trace("getSaveNewCloudEnable"); if (isCs108Connected()) return cs108Library4A.getSaveNewCloudEnable(); else if (isCs710Connected()) return cs710Library4A.getSaveNewCloudEnable(); - else Log.i("Hello2", "getSaveNewCloudEnable" + stringNOTCONNECT); + else Logger.trace("getSaveNewCloudEnable {}", stringNOTCONNECT); return false; } public boolean setSaveNewCloudEnable(boolean saveNewCloudEnable) { - Log.i("Hello2", "setSaveNewCloudEnable"); + Logger.trace("setSaveNewCloudEnable"); return false; } public boolean getSaveAllCloudEnable() { - if (DEBUG) Log.i("Hello2", "getSaveAllCloudEnable"); + Logger.trace("getSaveAllCloudEnable"); if (isCs108Connected()) return cs108Library4A.getSaveAllCloudEnable(); else if (isCs710Connected()) return cs710Library4A.getSaveAllCloudEnable(); - else Log.i("Hello2", "getSaveAllCloudEnable" + stringNOTCONNECT); + else Logger.trace("getSaveAllCloudEnable {}", stringNOTCONNECT); return false; } public boolean setSaveAllCloudEnable(boolean saveAllCloudEnable) { - Log.i("Hello2", "setSaveAllCloudEnable"); + Logger.trace("setSaveAllCloudEnable"); return false; } public boolean getUserDebugEnable() { - if (DEBUG) Log.i("Hello2", "getUserDebugEnable"); + Logger.trace("getUserDebugEnable"); if (isCs108Connected()) return cs108Library4A.getUserDebugEnable(); else if (isCs710Connected()) return cs710Library4A.getUserDebugEnable(); - else Log.i("Hello2", "getUserDebugEnable" + stringNOTCONNECT); + else Logger.trace("getUserDebugEnable {}", stringNOTCONNECT); return false; } public boolean setUserDebugEnable(boolean userDebugEnable) { - if (DEBUG) Log.i("Hello2", "setUserDebugEnable"); + Logger.trace("setUserDebugEnable"); if (isCs108Connected()) return cs108Library4A.setUserDebugEnable(userDebugEnable); else if (isCs710Connected()) return cs710Library4A.setUserDebugEnable(userDebugEnable); - else Log.i("Hello2", "getUserDebugEnable" + stringNOTCONNECT); + else Logger.trace("getUserDebugEnable {}", stringNOTCONNECT); return false; } public String getForegroundReader() { String string108 = cs108Library4A.getForegroundReader().trim(); String string710 = cs710Library4A.getForegroundReader().trim(); - appendToLog("foregroundReader108 = " + string108 + ", foregroundReader710 = " + string710); + Logger.trace("foregroundReader108 = {}, foregroundReader710 = {}", string108, string710); if (isCs108Connected()) return string108; return string710; } public boolean getForegroundServiceEnable() { - if (DEBUG) Log.i("Hello2", "getForegroundEnable"); + Logger.trace("getForegroundEnable"); if (isCs108Connected()) return cs108Library4A.getForegroundServiceEnable(); else if (isCs710Connected()) return cs710Library4A.getForegroundServiceEnable(); - else Log.i("Hello2", "getForegroundEnable" + stringNOTCONNECT); + else Logger.trace("getForegroundEnable {}", stringNOTCONNECT); return false; } public boolean setForegroundServiceEnable(boolean forgroundServiceEnable) { - if (DEBUG) Log.i("Hello2", "setForegroundServiceEnable"); + Logger.trace("setForegroundServiceEnable"); if (isCs108Connected()) return cs108Library4A.setForegroundServiceEnable(forgroundServiceEnable); else if (isCs710Connected()) return cs710Library4A.setForegroundServiceEnable(forgroundServiceEnable); - else Log.i("Hello2", "setForegroundServiceEnable" + stringNOTCONNECT); + else Logger.trace("setForegroundServiceEnable {}", stringNOTCONNECT); return false; } public String getServerLocation() { - if (DEBUG) Log.i("Hello2", "getServerLocation"); + Logger.trace("getServerLocation"); if (isCs108Connected()) return cs108Library4A.getServerLocation(); else if (isCs710Connected()) return cs710Library4A.getServerLocation(); - else Log.i("Hello2", "getServerLocation" + stringNOTCONNECT); + else Logger.trace("getServerLocation {}", stringNOTCONNECT); return null; } public boolean setServerLocation(String serverLocation) { - if (DEBUG) Log.i("Hello2", "setServerLocation"); + Logger.trace("setServerLocation"); if (isCs108Connected()) return cs108Library4A.setServerLocation(serverLocation); else if (isCs710Connected()) return cs710Library4A.setServerLocation(serverLocation); - else Log.i("Hello2", "setServerLocation" + stringNOTCONNECT); + else Logger.trace("setServerLocation {}", stringNOTCONNECT); return false; } public int getServerTimeout() { - if (DEBUG) Log.i("Hello2", "getServerTimeout"); + Logger.trace("getServerTimeout"); if (isCs108Connected()) return cs108Library4A.getServerTimeout(); else if (isCs710Connected()) return cs710Library4A.getServerTimeout(); - else Log.i("Hello2", "getServerTimeout" + stringNOTCONNECT); + else Logger.trace("getServerTimeout {}", stringNOTCONNECT); return -1; } public boolean setServerTimeout(int serverTimeout) { - if (DEBUG) Log.i("Hello2", "setServerTimeout"); + Logger.trace("setServerTimeout"); if (isCs108Connected()) return cs108Library4A.setServerTimeout(serverTimeout); else if (isCs710Connected()) return cs710Library4A.setServerTimeout(serverTimeout); - else Log.i("Hello2", "setServerTimeout" + stringNOTCONNECT); + else Logger.trace("setServerTimeout {}", stringNOTCONNECT); return false; } public String getServerMqttLocation() { - if (DEBUG) Log.i("Hello2", "getServerMqttLocation"); + Logger.trace("getServerMqttLocation"); if (isCs108Connected()) return cs108Library4A.getServerMqttLocation(); else if (isCs710Connected()) return cs710Library4A.getServerMqttLocation(); - else Log.i("Hello2", "getServerMqttLocation" + stringNOTCONNECT); + else Logger.trace("getServerMqttLocation {}", stringNOTCONNECT); return null; } public boolean setServerMqttLocation(String serverLocation) { - if (DEBUG) Log.i("Hello2", "setServerMqttLocation"); + Logger.trace("setServerMqttLocation"); if (isCs108Connected()) return cs108Library4A.setServerMqttLocation(serverLocation); else if (isCs710Connected()) return cs710Library4A.setServerMqttLocation(serverLocation); - else Log.i("Hello2", "setServerMqttLocation" + stringNOTCONNECT); + else Logger.trace("setServerMqttLocation {}", stringNOTCONNECT); return false; } public String getTopicMqtt() { - if (DEBUG) Log.i("Hello2", "getServerTopicMqtt"); + Logger.trace("getServerTopicMqtt"); if (isCs108Connected()) return cs108Library4A.getTopicMqtt(); else if (isCs710Connected()) return cs710Library4A.getTopicMqtt(); - else Log.i("Hello2", "getServerTopicMqtt" + stringNOTCONNECT); + else Logger.trace("getServerTopicMqtt {}", stringNOTCONNECT); return null; } public boolean setTopicMqtt(String topic) { - if (DEBUG) Log.i("Hello2", "setServerTopicMqtt"); + Logger.trace("setServerTopicMqtt"); if (isCs108Connected()) return cs108Library4A.setTopicMqtt(topic); else if (isCs710Connected()) return cs710Library4A.setTopicMqtt(topic); - else Log.i("Hello2", "setServerTopicMqtt" + stringNOTCONNECT); + else Logger.trace("setServerTopicMqtt {}", stringNOTCONNECT); return false; } public int getForegroundDupElim() { - if (DEBUG) Log.i("Hello2", "getForegroundDupElim"); + Logger.trace("getForegroundDupElim"); if (isCs108Connected()) return cs108Library4A.getForegroundDupElim(); else if (isCs710Connected()) return cs710Library4A.getForegroundDupElim(); - else Log.i("Hello2", "getForegroundDupElim" + stringNOTCONNECT); + else Logger.trace("getForegroundDupElim {}", stringNOTCONNECT); return -1; } public boolean setForegroundDupElim(int iForegroundDupElim) { - if (DEBUG) Log.i("Hello2", "setForegroundDupElim"); + Logger.trace("setForegroundDupElim"); if (isCs108Connected()) return cs108Library4A.setForegroundDupElim(iForegroundDupElim); else if (isCs710Connected()) return cs710Library4A.setForegroundDupElim(iForegroundDupElim); - else Log.i("Hello2", "setForegroundDupElim" + stringNOTCONNECT); + else Logger.trace("setForegroundDupElim {}", stringNOTCONNECT); return false; } public int getInventoryCloudSave() { - if (DEBUG) Log.i("Hello2", "getInventoryCloudSave"); + Logger.trace("getInventoryCloudSave"); if (isCs108Connected()) return cs108Library4A.getInventoryCloudSave(); else if (isCs710Connected()) return cs710Library4A.getInventoryCloudSave(); - else Log.i("Hello2", "getInventoryCloudSave" + stringNOTCONNECT); + else Logger.trace("getInventoryCloudSave {}", stringNOTCONNECT); return -1; } public boolean setInventoryCloudSave(int inventoryCloudSave) { - if (DEBUG) Log.i("Hello2", "setInventoryCloudSave"); + Logger.trace("setInventoryCloudSave"); if (isCs108Connected()) return cs108Library4A.setInventoryCloudSave(inventoryCloudSave); else if (isCs710Connected()) return cs710Library4A.setInventoryCloudSave(inventoryCloudSave); - else Log.i("Hello2", "setInventoryCloudSave" + stringNOTCONNECT); + else Logger.trace("setInventoryCloudSave {}", stringNOTCONNECT); return false; } public String getServerImpinjLocation() { - if (DEBUG) Log.i("Hello2", "getServerImpinjLocation"); + Logger.trace("getServerImpinjLocation"); if (isCs108Connected()) return cs108Library4A.getServerImpinjLocation(); else if (isCs710Connected()) return cs710Library4A.getServerImpinjLocation(); - else Log.i("Hello2", "getServerImpinjLocation" + stringNOTCONNECT); + else Logger.trace("getServerImpinjLocation {}", stringNOTCONNECT); return null; } public boolean setServerImpinjLocation(String serverImpinjLocation) { - if (DEBUG) Log.i("Hello2", "setServerImpinjLocation"); + Logger.trace("setServerImpinjLocation"); if (isCs108Connected()) return cs108Library4A.setServerImpinjLocation(serverImpinjLocation); else if (isCs710Connected()) return cs710Library4A.setServerImpinjLocation(serverImpinjLocation); - else Log.i("Hello2", "setServerImpinjLocation" + stringNOTCONNECT); + else Logger.trace("setServerImpinjLocation {}", stringNOTCONNECT); return false; } public String getServerImpinjName() { - if (DEBUG) Log.i("Hello2", "getServerImpinjName"); + Logger.trace("getServerImpinjName"); if (isCs108Connected()) return cs108Library4A.getServerImpinjName(); else if (isCs710Connected()) return cs710Library4A.getServerImpinjName(); - else Log.i("Hello2", "getServerImpinjName" + stringNOTCONNECT); + else Logger.trace("getServerImpinjName {}", stringNOTCONNECT); return null; } public boolean setServerImpinjName(String serverImpinjName) { - if (DEBUG) Log.i("Hello2", "setServerImpinjName"); + Logger.trace("setServerImpinjName"); if (isCs108Connected()) return cs108Library4A.setServerImpinjName(serverImpinjName); else if (isCs710Connected()) return cs710Library4A.setServerImpinjName(serverImpinjName); - else Log.i("Hello2", "setServerImpinjName" + stringNOTCONNECT); + else Logger.trace("setServerImpinjName {}", stringNOTCONNECT); return false; } public String getServerImpinjPassword() { - if (DEBUG) Log.i("Hello2", "getServerImpinjPassword"); + Logger.trace("getServerImpinjPassword"); if (isCs108Connected()) return cs108Library4A.getServerImpinjPassword(); else if (isCs710Connected()) return cs710Library4A.getServerImpinjPassword(); - else Log.i("Hello2", "getServerImpinjPassword" + stringNOTCONNECT); + else Logger.trace("getServerImpinjPassword {}", stringNOTCONNECT); return null; } public boolean setServerImpinjPassword(String serverImpinjPassword) { - if (DEBUG) Log.i("Hello2", "setServerImpinjPassword"); + Logger.trace("setServerImpinjPassword"); if (isCs108Connected()) return cs108Library4A.setServerImpinjPassword(serverImpinjPassword); else if (isCs710Connected()) return cs710Library4A.setServerImpinjPassword(serverImpinjPassword); - else Log.i("Hello2", "setServerImpinjPassword" + stringNOTCONNECT); + else Logger.trace("setServerImpinjPassword {}", stringNOTCONNECT); return false; } public int getBatteryDisplaySetting() { - if (DEBUG) Log.i("Hello2", "getBatteryDisplaySetting"); + Logger.trace("getBatteryDisplaySetting"); if (isCs108Connected()) return cs108Library4A.getBatteryDisplaySetting(); else if (isCs710Connected()) return cs710Library4A.getBatteryDisplaySetting(); - else Log.i("Hello2", "getBatteryDisplaySetting" + stringNOTCONNECT); + else Logger.trace("getBatteryDisplaySetting {}", stringNOTCONNECT); return -1; } public boolean setBatteryDisplaySetting(int batteryDisplaySelect) { - if (DEBUG) Log.i("Hello2", "setBatteryDisplaySetting"); + Logger.trace("setBatteryDisplaySetting"); if (isCs108Connected()) return cs108Library4A.setBatteryDisplaySetting(batteryDisplaySelect); else if (isCs710Connected()) return cs710Library4A.setBatteryDisplaySetting(batteryDisplaySelect); - else Log.i("Hello2", "setBatteryDisplaySetting" + stringNOTCONNECT); + else Logger.trace("setBatteryDisplaySetting {}", stringNOTCONNECT); return false; } public double dBuV_dBm_constant = RfidReader.dBuV_dBm_constant; //106.98; public int getRssiDisplaySetting() { - if (DEBUG) Log.i("Hello2", "getRssiDisplaySetting"); + Logger.trace("getRssiDisplaySetting"); if (isCs108Connected()) return cs108Library4A.getRssiDisplaySetting(); else if (isCs710Connected()) return cs710Library4A.getRssiDisplaySetting(); return 0; } public boolean setRssiDisplaySetting(int rssiDisplaySelect) { - if (DEBUG) Log.i("Hello2", "setRssiDisplaySetting"); + Logger.trace("setRssiDisplaySetting"); if (isCs108Connected()) return cs108Library4A.setRssiDisplaySetting(rssiDisplaySelect); else if (isCs710Connected()) return cs710Library4A.setRssiDisplaySetting(rssiDisplaySelect); - else Log.i("Hello2", "setRssiDisplaySetting" + stringNOTCONNECT); + else Logger.trace("setRssiDisplaySetting {}", stringNOTCONNECT); return false; } public int getVibrateModeSetting() { - if (DEBUG) Log.i("Hello2", "getVibrateModeSetting"); + Logger.trace("getVibrateModeSetting"); if (isCs108Connected()) return cs108Library4A.getVibrateModeSetting(); else if (isCs710Connected()) return cs710Library4A.getVibrateModeSetting(); - else Log.i("Hello2", "getVibrateModeSetting" + stringNOTCONNECT); + else Logger.trace("getVibrateModeSetting {}", stringNOTCONNECT); return -1; } public boolean setVibrateModeSetting(int vibrateModeSelect) { - if (DEBUG) Log.i("Hello2", "setVibrateModeSetting"); + Logger.trace("setVibrateModeSetting"); if (isCs108Connected()) return cs108Library4A.setVibrateModeSetting(vibrateModeSelect); else if (isCs710Connected()) return cs710Library4A.setVibrateModeSetting(vibrateModeSelect); - else Log.i("Hello2", "setVibrateModeSetting" + stringNOTCONNECT); + else Logger.trace("setVibrateModeSetting {}", stringNOTCONNECT); return false; } public int getSavingFormatSetting() { - if (DEBUG) Log.i("Hello2", "getSavingFormatSetting"); + Logger.trace("getSavingFormatSetting"); if (isCs108Connected()) return cs108Library4A.getSavingFormatSetting(); else if (isCs710Connected()) return cs710Library4A.getSavingFormatSetting(); - else Log.i("Hello2", "getSavingFormatSetting" + stringNOTCONNECT); + else Logger.trace("getSavingFormatSetting {}", stringNOTCONNECT); return -1; } public boolean setSavingFormatSetting(int savingFormatSelect) { - if (DEBUG) Log.i("Hello2", "setSavingFormatSetting"); + Logger.trace("setSavingFormatSetting"); if (isCs108Connected()) return cs108Library4A.setSavingFormatSetting(savingFormatSelect); else if (isCs710Connected()) return cs710Library4A.setSavingFormatSetting(savingFormatSelect); - else Log.i("Hello2", "setSavingFormatSetting" + stringNOTCONNECT); + else Logger.trace("setSavingFormatSetting {}", stringNOTCONNECT); return false; } public int getCsvColumnSelectSetting() { - if (DEBUG) Log.i("Hello2", "getCsvColumnSelectSetting"); + Logger.trace("getCsvColumnSelectSetting"); if (isCs108Connected()) return cs108Library4A.getCsvColumnSelectSetting(); else if (isCs710Connected()) return cs710Library4A.getCsvColumnSelectSetting(); - else Log.i("Hello2", "getCsvColumnSelectSetting" + stringNOTCONNECT); + else Logger.trace("getCsvColumnSelectSetting {}", stringNOTCONNECT); return -1; } public boolean setCsvColumnSelectSetting(int csvColumnSelect) { - if (DEBUG) Log.i("Hello2", "setCsvColumnSelectSetting"); + Logger.trace("setCsvColumnSelectSetting"); if (isCs108Connected()) return cs108Library4A.setCsvColumnSelectSetting(csvColumnSelect); else if (isCs710Connected()) return cs710Library4A.setCsvColumnSelectSetting(csvColumnSelect); - else Log.i("Hello2", "setCsvColumnSelectSetting" + stringNOTCONNECT); + else Logger.trace("setCsvColumnSelectSetting {}", stringNOTCONNECT); return false; } public String getWedgeDeviceName() { @@ -1932,154 +1928,154 @@ public void saveWedgeSetting2File() { //============ Bluetooth ============ public String getBluetoothICFirmwareVersion() { - if (DEBUG) Log.i("Hello2", "getBluetoothICFirmwareVersion"); + Logger.trace("getBluetoothICFirmwareVersion"); if (isCs108Connected()) return cs108Library4A.getBluetoothICFirmwareVersion(); else if (isCs710Connected()) return cs710Library4A.getBluetoothICFirmwareVersion(); - else Log.i("Hello2", "getBluetoothICFirmwareVersion" + stringNOTCONNECT); + else Logger.trace("getBluetoothICFirmwareVersion {}", stringNOTCONNECT); return null; } public String getBluetoothICFirmwareName() { - if (DEBUG) Log.i("Hello2", "getBluetoothICFirmwareName"); + Logger.trace("getBluetoothICFirmwareName"); if (isCs108Connected()) return cs108Library4A.getBluetoothICFirmwareName(); else if (isCs710Connected()) return cs710Library4A.getBluetoothICFirmwareName(); - else Log.i("Hello2", "getBluetoothICFirmwareName" + stringNOTCONNECT); + else Logger.trace("getBluetoothICFirmwareName {}", stringNOTCONNECT); return null; } public boolean setBluetoothICFirmwareName(String name) { - if (DEBUG) Log.i("Hello2", "setBluetoothICFirmwareName"); + Logger.trace("setBluetoothICFirmwareName"); if (isCs108Connected()) return cs108Library4A.setBluetoothICFirmwareName(name); else if (isCs710Connected()) return cs710Library4A.setBluetoothICFirmwareName(name); - else Log.i("Hello2", "setBluetoothICFirmwareName" + stringNOTCONNECT); + else Logger.trace("setBluetoothICFirmwareName {}", stringNOTCONNECT); return false; } //============ Controller ============ public String hostProcessorICGetFirmwareVersion() { - if (DEBUG) Log.i("Hello2", "hostProcessorICGetFirmwareVersion"); + Logger.trace("hostProcessorICGetFirmwareVersion"); if (isCs108Connected()) return cs108Library4A.hostProcessorICGetFirmwareVersion(); else if (isCs710Connected()) return cs710Library4A.hostProcessorICGetFirmwareVersion(); - else Log.i("Hello2", "hostProcessorICGetFirmwareVersion" + stringNOTCONNECT); + else Logger.trace("hostProcessorICGetFirmwareVersion {}", stringNOTCONNECT); return null; } public String getHostProcessorICSerialNumber() { - if (DEBUG) Log.i("Hello2", "getHostProcessorICSerialNumber"); + Logger.trace("getHostProcessorICSerialNumber"); if (isCs108Connected()) return cs108Library4A.getHostProcessorICSerialNumber(); else if (isCs710Connected()) return cs710Library4A.getHostProcessorICSerialNumber(); - else Log.i("Hello2", "getHostProcessorICSerialNumber" + stringNOTCONNECT); + else Logger.trace("getHostProcessorICSerialNumber {}", stringNOTCONNECT); return null; } public String getHostProcessorICBoardVersion() { - if (DEBUG) Log.i("Hello2", "getHostProcessorICBoardVersion"); + Logger.trace("getHostProcessorICBoardVersion"); if (isCs108Connected()) return cs108Library4A.getHostProcessorICBoardVersion(); else if (isCs710Connected()) return cs710Library4A.getHostProcessorICBoardVersion(); - else Log.i("Hello2", "getHostProcessorICBoardVersion" + stringNOTCONNECT); + else Logger.trace("getHostProcessorICBoardVersion {}", stringNOTCONNECT); return null; } //============ Controller notification ============ public int getBatteryLevel() { - if (DEBUG) Log.i("Hello2", "getBatteryLevel"); + Logger.trace("getBatteryLevel"); if (isCs108Connected()) return cs108Library4A.getBatteryLevel(); else if (isCs710Connected()) return cs710Library4A.getBatteryLevel(); - else Log.i("Hello2", "getBatteryLevel" + stringNOTCONNECT); + else Logger.trace("getBatteryLevel {}", stringNOTCONNECT); return -1; } public boolean setAutoTriggerReporting(byte timeSecond) { - if (DEBUG) Log.i("Hello2", "setAutoTriggerReporting"); + Logger.trace("setAutoTriggerReporting"); if (isCs108Connected()) return cs108Library4A.setAutoTriggerReporting(timeSecond); else if (isCs710Connected()) return cs710Library4A.setAutoTriggerReporting(timeSecond); - else Log.i("Hello2", "setAutoTriggerReporting" + stringNOTCONNECT); + else Logger.trace("setAutoTriggerReporting {}", stringNOTCONNECT); return false; } public boolean getAutoBarStartSTop() { - if (DEBUG) Log.i("Hello2", "getAutoBarStartSTop"); + Logger.trace("getAutoBarStartSTop"); if (isCs108Connected()) return cs108Library4A.getAutoBarStartSTop(); else if (isCs710Connected()) return cs710Library4A.getAutoBarStartSTop(); - else Log.i("Hello2", "getAutoBarStartSTop" + stringNOTCONNECT); + else Logger.trace("getAutoBarStartSTop {}", stringNOTCONNECT); return false; } public boolean batteryLevelRequest() { - if (DEBUG) Log.i("Hello2", "batteryLevelRequest"); + Logger.trace("batteryLevelRequest"); if (isCs108Connected()) return cs108Library4A.batteryLevelRequest(); else if (isCs710Connected()) return cs710Library4A.batteryLevelRequest(); - else Log.i("Hello2", "batteryLevelRequest" + stringNOTCONNECT); + else Logger.trace("batteryLevelRequest {}", stringNOTCONNECT); return false; } public boolean setAutoBarStartSTop(boolean enable) { - if (DEBUG) Log.i("Hello2", "setAutoBarStartSTop"); + Logger.trace("setAutoBarStartSTop"); if (isCs108Connected()) return cs108Library4A.setAutoBarStartSTop(enable); else if (isCs710Connected()) return cs710Library4A.setAutoBarStartSTop(enable); - else Log.i("Hello2", "setAutoBarStartSTop" + stringNOTCONNECT); + else Logger.trace("setAutoBarStartSTop {}", stringNOTCONNECT); return false; } public boolean getTriggerReporting() { - if (DEBUG) Log.i("Hello2", "getTriggerReporting"); + Logger.trace("getTriggerReporting"); if (isCs108Connected()) cs108Library4A.getTriggerReporting(); else if (isCs710Connected()) cs710Library4A.getTriggerReporting(); - else Log.i("Hello2", "getTriggerReporting" + stringNOTCONNECT); + else Logger.trace("getTriggerReporting {}", stringNOTCONNECT); return false; } public boolean setTriggerReporting(boolean triggerReporting) { - if (DEBUG) Log.i("Hello2", "setTriggerReporting"); + Logger.trace("setTriggerReporting"); if (isCs108Connected()) return cs108Library4A.setTriggerReporting(triggerReporting); else if (isCs710Connected()) return cs710Library4A.setTriggerReporting(triggerReporting); - else Log.i("Hello2", "setTriggerReporting" + stringNOTCONNECT); + else Logger.trace("setTriggerReporting {}", stringNOTCONNECT); return false; } public int iNO_SUCH_SETTING = -1; public short getTriggerReportingCount() { - if (DEBUG) Log.i("Hello2", "getTriggerReportingCount"); + Logger.trace("getTriggerReportingCount"); if (isCs108Connected()) return cs108Library4A.getTriggerReportingCount(); else if (isCs710Connected()) return cs710Library4A.getTriggerReportingCount(); - else Log.i("Hello2", "getTriggerReportingCount" + stringNOTCONNECT); + else Logger.trace("getTriggerReportingCount {}", stringNOTCONNECT); return 5; } public boolean setTriggerReportingCount(short triggerReportingCount) { - if (DEBUG) Log.i("Hello2", "setTriggerReportingCount"); + Logger.trace("setTriggerReportingCount"); if (isCs108Connected()) return cs108Library4A.setTriggerReportingCount(triggerReportingCount); else if (isCs710Connected()) return cs710Library4A.setTriggerReportingCount(triggerReportingCount); - else Log.i("Hello2", "setTriggerReportingCount" + stringNOTCONNECT); + else Logger.trace("setTriggerReportingCount {}", stringNOTCONNECT); return false; } public String getBatteryDisplay(boolean voltageDisplay) { - if (DEBUG) Log.i("Hello2", "getBatteryDisplay"); + Logger.trace("getBatteryDisplay"); if (isCs108Connected()) return cs108Library4A.getBatteryDisplay(voltageDisplay); else if (isCs710Connected()) return cs710Library4A.getBatteryDisplay(voltageDisplay); - else Log.i("Hello2", "getBatteryDisplay is called befoe connection !!!"); + else Logger.trace("getBatteryDisplay is called befoe connection !!!"); return null; } String stringNOTCONNECT; public String isBatteryLow() { - if (DEBUG) Log.i("Hello2", "isBatteryLow"); + Logger.trace("isBatteryLow"); if (isCs108Connected()) return cs108Library4A.isBatteryLow(); else if (isCs710Connected()) return cs710Library4A.isBatteryLow(); - else Log.i("Hello2", "isBatteryLow" + stringNOTCONNECT); + else Logger.trace("isBatteryLow {}", stringNOTCONNECT); return null; } public int getBatteryCount() { - if (DEBUG2) Log.i("Hello2", "getBatteryCount"); + Logger.trace("getBatteryCount"); if (isCs108Connected()) return cs108Library4A.getBatteryCount(); else if (isCs710Connected()) return cs710Library4A.getBatteryCount(); - else Log.i("Hello2", "getBatteryCount" + stringNOTCONNECT); + else Logger.trace("getBatteryCount {}", stringNOTCONNECT); return -1; } public boolean getTriggerButtonStatus() { - if (DEBUG2) Log.i("Hello2", "getTriggerButtonStatus"); + Logger.trace("getTriggerButtonStatus"); if (isCs108Connected()) return cs108Library4A.getTriggerButtonStatus(); else if (isCs710Connected()) return cs710Library4A.getTriggerButtonStatus(); - else Log.i("Hello2", "getTriggerButtonStatus" + stringNOTCONNECT); + else Logger.trace("getTriggerButtonStatus {}", stringNOTCONNECT); return false; } public int getTriggerCount() { - if (DEBUG2) Log.i("Hello2", "getTriggerCount"); + Logger.trace("getTriggerCount"); if (isCs108Connected()) return cs108Library4A.getTriggerCount(); else if (isCs710Connected()) return cs710Library4A.getTriggerCount(); - else Log.i("Hello2", "getTriggerCount" + stringNOTCONNECT); + else Logger.trace("getTriggerCount {}", stringNOTCONNECT); return -1; } //public interface NotificationListener { void onChange(); } public void setNotificationListener(NotificationConnector.NotificationListener listener) { - if (DEBUG) Log.i("Hello2", "setNotificationListener"); + Logger.trace("setNotificationListener"); if (isCs108Connected()) { cs108Library4A.setNotificationListener(new NotificationConnector.NotificationListener() { @Override @@ -2095,84 +2091,84 @@ public void onChange() { } }); } - else Log.i("Hello2", "setNotificationListener" + stringNOTCONNECT); + else Logger.trace("setNotificationListener {}", stringNOTCONNECT); } public byte[] onNotificationEvent() { - if (DEBUG2) Log.i("Hello2", "onNotificationEvent"); + Logger.trace("onNotificationEvent"); if (isCs108Connected()) return cs108Library4A.onNotificationEvent(); else if (isCs710Connected()) return cs710Library4A.onNotificationEvent(); - else Log.i("Hello2", "onNotificationEvent" + stringNOTCONNECT); + else Logger.trace("onNotificationEvent {}", stringNOTCONNECT); return null; } //============ to be modified ============ public String getSerialNumber() { - if (DEBUG2) Log.i("Hello2", "getSerialNumber"); + Logger.trace("getSerialNumber"); if (isCs108Connected()) return cs108Library4A.getSerialNumber(); else if (isCs710Connected()) return cs710Library4A.getSerialNumber(); - else Log.i("Hello2", "getSerialNumber" + stringNOTCONNECT); + else Logger.trace("getSerialNumber {}", stringNOTCONNECT); return null; } public boolean setRfidOn(boolean onStatus) { - if (DEBUG2) Log.i("Hello2", "setRfidOn"); + Logger.trace("setRfidOn"); if (isCs108Connected()) return cs108Library4A.setRfidOn(onStatus); else if (isCs710Connected()) return cs710Library4A.setRfidOn(onStatus); - else Log.i("Hello2", "setRfidOn" + stringNOTCONNECT); + else Logger.trace("setRfidOn {}", stringNOTCONNECT); return false; } public int getcsModel() { - if (DEBUG2) Log.i("Hello2", "getcsModel"); + Logger.trace("getcsModel"); if (isCs108Connected()) return cs108Library4A.getcsModel(); else if (isCs710Connected()) return cs710Library4A.getcsModel(); - else Log.i("Hello2", "getcsModel" + stringNOTCONNECT); + else Logger.trace("getcsModel {}", stringNOTCONNECT); return -1; } public int getAntennaCycle() { - if (DEBUG2) Log.i("Hello2", "getAntennaCycle"); + Logger.trace("getAntennaCycle"); if (isCs108Connected()) return cs108Library4A.getAntennaCycle(); else if (isCs710Connected()) return cs710Library4A.getAntennaCycle(); - else Log.i("Hello2", "getAntennaCycle" + stringNOTCONNECT); + else Logger.trace("getAntennaCycle {}", stringNOTCONNECT); return -1; } public boolean setAntennaCycle(int antennaCycle) { - if (DEBUG2) Log.i("Hello2", "setAntennaCycle"); + Logger.trace("setAntennaCycle"); if (isCs108Connected()) return cs108Library4A.setAntennaCycle(antennaCycle); else if (isCs710Connected()) return cs710Library4A.setAntennaCycle(antennaCycle); - else Log.i("Hello2", "setAntennaCycle" + stringNOTCONNECT); + else Logger.trace("setAntennaCycle {}", stringNOTCONNECT); return false; } public boolean setAntennaInvCount(long antennaInvCount) { - if (DEBUG2) Log.i("Hello2", "setAntennaInvCount"); + Logger.trace("setAntennaInvCount"); if (isCs108Connected()) return cs108Library4A.setAntennaInvCount(antennaInvCount); else if (isCs710Connected()) return cs710Library4A.setAntennaInvCount(antennaInvCount); - else Log.i("Hello2", "setAntennaInvCount" + stringNOTCONNECT); + else Logger.trace("setAntennaInvCount {}", stringNOTCONNECT); return false; } public void clearInvalidata() { - if (DEBUG2) Log.i("Hello2", "clearInvalidata"); + Logger.trace("clearInvalidata"); if (isCs108Connected()) cs108Library4A.clearInvalidata(); else if (isCs710Connected()) cs710Library4A.clearInvalidata(); - else Log.i("Hello2", "clearInvalidata" + stringNOTCONNECT); + else Logger.trace("clearInvalidata {}", stringNOTCONNECT); } public int getInvalidata() { - if (DEBUG2) Log.i("Hello2", "getInvalidata"); + Logger.trace("getInvalidata"); if (isCs108Connected()) return cs108Library4A.getInvalidata(); else if (isCs710Connected()) return cs710Library4A.getInvalidata(); - else Log.i("Hello2", "getInvalidata" + stringNOTCONNECT); + else Logger.trace("getInvalidata {}", stringNOTCONNECT); return -1; } public int getInvalidUpdata() { - if (DEBUG2) Log.i("Hello2", "getInvalidUpdata"); + Logger.trace("getInvalidUpdata"); if (isCs108Connected()) return cs108Library4A.getInvalidUpdata(); else if (isCs710Connected()) return cs710Library4A.getInvalidUpdata(); - else Log.i("Hello2", "getInvalidUpdata" + stringNOTCONNECT); + else Logger.trace("getInvalidUpdata {}", stringNOTCONNECT); return -1; } public int getValidata() { - if (DEBUG2) Log.i("Hello2", "getValidata"); + Logger.trace("getValidata"); if (isCs108Connected()) return cs108Library4A.getValidata(); else if (isCs710Connected()) return cs710Library4A.getValidata(); - else Log.i("Hello2", "getValidata" + stringNOTCONNECT); + else Logger.trace("getValidata {}", stringNOTCONNECT); return -1; } @@ -2183,10 +2179,10 @@ public int getValidata() { 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"); + Logger.trace("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); + else Logger.trace("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 1a01db2..c50cb39 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsReaderConnector.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/CsReaderConnector.java @@ -9,17 +9,12 @@ import java.util.Date; public class CsReaderConnector { - final boolean appendToLogViewDisable = false; - final boolean DEBUG = false; final boolean DEBUGTHREAD = false; - boolean DEBUG_CONNECT, DEBUG_SCAN; - boolean DEBUG_APDATA; public boolean sameCheck = true; String byteArrayToString(byte[] packet) { return utility.byteArrayToString(packet); } - void appendToLog(String s) { utility.appendToLog(s); } public boolean connectBle(ReaderDevice readerDevice) { boolean result = false; - if (DEBUG_CONNECT) appendToLog("ConnectBle(" + readerDevice.getCompass() + ")"); + Logger.connect("ConnectBle({})", readerDevice.getCompass()); result = bluetoothGatt.connectBle(readerDevice); if (result) writeDataCount = 0; return result; @@ -29,7 +24,7 @@ public boolean connectBle(ReaderDevice readerDevice) { public void disconnect() { bluetoothGatt.disconnect(); - appendToLog("abcc done"); + Logger.trace("abcc done"); if (rfidConnector != null) rfidConnector.mRfidToWrite.clear(); if (rfidReader != null) rfidReader.mRx000ToWrite.clear(); } @@ -39,10 +34,10 @@ public void disconnect() { 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)); + Logger.toLogView("BtData: isInventoring is true when writeData {}", byteArrayToString(buffer)).trace(); } boolean result = bluetoothGatt.writeBleStreamOut(buffer); - if (result == false) appendToLog("!!! failure to writeData with previous btSendTimeout = " + btSendTimeOut + ", btSendTime = " + btSendTime); + if (result == false) Logger.trace("!!! failure to writeData with previous btSendTimeout = {}, btSendTime = {}", btSendTimeOut, btSendTime); if (true) { btSendTime = System.currentTimeMillis(); btSendTimeOut = timeout + BTSENDDELAY; @@ -97,7 +92,6 @@ public void clearInvalidata() { //boolean dataInBufferResetting; void processBleStreamInData() { - final boolean DEBUG = false; int cs108DataReadStartOld = 0; int cs108DataReadStart = 0; boolean validHeader = false; @@ -114,43 +108,45 @@ void processBleStreamInData() { 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); + if (bLooping == false) Logger.fmdData("FmData: Enter loop with cs108DataLeftOffset={}, streamInBufferSize={}", cs108DataLeftOffset, iStreamInBufferSize); bLooping = true; if (System.currentTimeMillis() - lTime > (bluetoothGatt.getIntervalProcessBleStreamInData()/2)) { utility.writeDebug2File("Up2 " + bluetoothGatt.getIntervalProcessBleStreamInData()/2 + "ms Timeout"); - utility.appendToLogView("FmData: Timeout !!!"); + Logger.toLogView("FmData: Timeout !!!").trace(); break; } long streamInOverflowTime = bluetoothGatt.getStreamInOverflowTime(); int streamInMissing = bluetoothGatt.getStreamInBytesMissing(); - if (streamInMissing != 0) utility.appendToLogView("FmData: processCs108DataIn(" + bluetoothGatt.getStreamInTotalCounter() + ", " + bluetoothGatt.getStreamInAddCounter() + "): len=0, getStreamInOverflowTime()=" + streamInOverflowTime + ", MissBytes=" + streamInMissing + ", Offset=" + cs108DataLeftOffset); + if (streamInMissing != 0) { + Logger.toLogView("FmData: processCs108DataIn({}, {}): len=0, getStreamInOverflowTime()={}, MissBytes={}, Offset={}", bluetoothGatt.getStreamInTotalCounter(), bluetoothGatt.getStreamInAddCounter(), streamInOverflowTime, streamInMissing, cs108DataLeftOffset); + } int len = readData(cs108DataLeft, cs108DataLeftOffset, cs108DataLeft.length); - if (utility.DEBUG_FMDATA && len != 0) { + if (len != 0) { byte[] debugData = new byte[len]; System.arraycopy(cs108DataLeft, cs108DataLeftOffset, debugData, 0, len); - appendToLog("FmData: dataIn " + len + " = " + byteArrayToString(debugData)); + Logger.fmdData("FmData: dataIn {} = {}", len, byteArrayToString(debugData)); } //if (len != 0 && bFirst) { bFirst = false; } //writeDebug2File("B" + String.valueOf(getIntervalProcessBleStreamInData()) + ", " + System.currentTimeMillis()); } cs108DataLeftOffset += len; if (len == 0) { - appendToLog("FmData: len is zero !!!"); + Logger.fmdData("FmData: len is zero !!!"); if (zeroLenDisplayed == false) { zeroLenDisplayed = true; if (bluetoothGatt.getStreamInTotalCounter() != bluetoothGatt.getStreamInAddCounter() || bluetoothGatt.getStreamInAddTime() != 0 || cs108DataLeftOffset != 0) { - if (DEBUG) appendToLog("FmData: processCs108DataIn(" + bluetoothGatt.getStreamInTotalCounter() + "," + bluetoothGatt.getStreamInAddCounter() + "): len=0, getStreamInAddTime()=" + bluetoothGatt.getStreamInAddTime() + ", Offset=" + cs108DataLeftOffset); + Logger.debug("FmData: processCs108DataIn({}, {}): len=0, getStreamInAddTime()={}, Offset={}", bluetoothGatt.getStreamInTotalCounter(), bluetoothGatt.getStreamInAddCounter(), bluetoothGatt.getStreamInAddTime(), cs108DataLeftOffset); } } if (cs108DataLeftOffset == cs108DataLeft.length) { - if (DEBUG) appendToLog("FmData: cs108DataLeftOffset=" + cs108DataLeftOffset + ", cs108DataLeft=" + byteArrayToString(cs108DataLeft)); + Logger.debug("FmData: cs108DataLeftOffset={}, cs108DataLeft={}", cs108DataLeftOffset, byteArrayToString(cs108DataLeft)); } break; } else { dataRead = true; zeroLenDisplayed = false; - if (utility.DEBUG_FMDATA) appendToLog("FmData: cs108DataReadStart = " + cs108DataReadStart + ", cs108DataLeftOffset = " + cs108DataLeftOffset); + Logger.fmdData("FmData: cs108DataReadStart = {}, cs108DataLeftOffset = {}", cs108DataReadStart, cs108DataLeftOffset); while (cs108DataLeftOffset >= cs108DataReadStart + 8) { validHeader = false; byte[] dataIn = cs108DataLeft; @@ -178,27 +174,28 @@ void processBleStreamInData() { checksum2 = (checksum2 >> 8) ^ table_value; } } - if (false) appendToLog("FmData: checksum = " + String.format("%04X", checksum) + ", checksum2 = " + String.format("%04X", checksum2)); + Logger.trace("FmData: checksum = {}, checksum2 = {}", String.format("%04X", checksum), String.format("%04X", checksum2)); } if (bcheckChecksum && checksum != checksum2) { - if (utility.DEBUG_FMDATA) { + if (Logger.LOG_FMDATA) { if (iPayloadLength < 0) { - appendToLog("FmData: CheckSum ERROR, iPayloadLength=" + iPayloadLength + ", cs108DataLeftOffset=" + cs108DataLeftOffset + ", dataIn=" + byteArrayToString(dataIn)); + Logger.fmdData("FmData: CheckSum ERROR, iPayloadLength={}, cs108DataLeftOffset={}, dataIn={}", iPayloadLength, cs108DataLeftOffset, byteArrayToString(dataIn)); } byte[] invalidPart = new byte[8 + iPayloadLength]; System.arraycopy(dataIn, cs108DataReadStart, invalidPart, 0, invalidPart.length); - appendToLog("FmData: processCs108DataIn_ERROR, INCORRECT RevChecksum=" + Integer.toString(checksum, 16) + ", CalChecksum2=" + Integer.toString(checksum2, 16) + ",data=" + byteArrayToString(invalidPart)); + Logger.fmdData("FmData: processCs108DataIn_ERROR, INCORRECT RevChecksum={}, CalChecksum2={}, data={}", Integer.toString(checksum, 16), Integer.toString(checksum2, 16), byteArrayToString(invalidPart)); } } else { validHeader = true; if (cs108DataReadStart > cs108DataReadStartOld) { - if (utility.DEBUG_FMDATA) { + if (Logger.LOG_FMDATA) { byte[] invalidPart = new byte[cs108DataReadStart - cs108DataReadStartOld]; System.arraycopy(dataIn, cs108DataReadStartOld, invalidPart, 0, invalidPart.length); - appendToLog("FmData: processCs108DataIn_ERROR, before valid data, invalid unused data: " + invalidPart.length + ", " + byteArrayToString(invalidPart)); + Logger.trace("FmData: processCs108DataIn_ERROR, before valid data, invalid unused data: " + invalidPart.length + ", " + byteArrayToString(invalidPart)); } - } else if (cs108DataReadStart < cs108DataReadStartOld) - if (utility.DEBUG_FMDATA) appendToLog("FmData: processCs108DataIn_ERROR, invalid cs108DataReadStartdata=" + cs108DataReadStart + " < cs108DataReadStartOld=" + cs108DataReadStartOld); + } else if (cs108DataReadStart < cs108DataReadStartOld) { + Logger.fmdData("FmData: processCs108DataIn_ERROR, invalid cs108DataReadStartdata={} < cs108DataReadStartOld={}", cs108DataReadStart, cs108DataReadStartOld); + } cs108DataReadStartOld = cs108DataReadStart; ConnectorData connectorData = new ConnectorData(); @@ -206,10 +203,10 @@ void processBleStreamInData() { System.arraycopy(dataIn, cs108DataReadStart + 8, dataValues, 0, dataValues.length); connectorData.dataValues = dataValues; connectorData.milliseconds = System.currentTimeMillis(); - if (utility.DEBUG_FMDATA) { + if (Logger.LOG_FMDATA) { byte[] headerbytes = new byte[8]; System.arraycopy(dataIn, cs108DataReadStart, headerbytes, 0, headerbytes.length); - appendToLog("FmData: Got formatted dataIn = " + byteArrayToString(headerbytes) + " " + byteArrayToString(dataValues)); + Logger.fmdData("FmData: Got formatted dataIn = {} {}", byteArrayToString(headerbytes), byteArrayToString(dataValues)); } switch (dataIn[cs108DataReadStart + 3]) { case (byte) 0xC2: @@ -223,9 +220,9 @@ void processBleStreamInData() { itemp += 256; } itemp -= (this.iSequenceNumber + 1); - if (DEBUG) appendToLog("iSequenceNumber = " + iSequenceNumber + ", old iSequenceNumber = " + this.iSequenceNumber + ", difference = " + itemp); + Logger.debug("iSequenceNumber = {}, old iSequenceNumber = {}, difference = {}", iSequenceNumber, this.iSequenceNumber, itemp); if (itemp != 0) { - if (DEBUG) appendToLog("Non-zero iSequenceNumber difference = " + itemp); + Logger.debug("Non-zero iSequenceNumber difference = {}", itemp); connectorData.invalidSequence = true; if (bFirstSequence == false) { invalidata += itemp; @@ -235,17 +232,17 @@ void processBleStreamInData() { if (iMissedNumber < 0) iMissedNumber += 256; stringSequenceList += (i != 0 ? ", " : "") + String.format("%X", iMissedNumber); } - if (DEBUG) utility.appendToLogView(String.format("ERROR !!!: invalidata = %d, %X - %X, miss %d: ", invalidata, iSequenceNumber, this.iSequenceNumber, itemp) + stringSequenceList); + Logger.toLogView(String.format("ERROR !!!: invalidata = %d, %X - %X, miss %d: %s", invalidata, iSequenceNumber, this.iSequenceNumber, itemp, stringSequenceList)).info(); } } bFirstSequence = false; this.iSequenceNumber = iSequenceNumber; } - if (DEBUG) utility.appendToLogView("Rin: " + (connectorData.invalidSequence ? "invalid sequence" : "ok") + "," + byteArrayToString(connectorData.dataValues)); + Logger.toLogView("Rin: {}, {}", connectorData.invalidSequence ? "invalid sequence" : "ok", byteArrayToString(connectorData.dataValues)).debug(); validata++; break; case (byte) 0xD9: - if (DEBUG) appendToLog("BARTRIGGER NotificationData = " + byteArrayToString(connectorData.dataValues)); + Logger.debug("BARTRIGGER NotificationData = {}", byteArrayToString(connectorData.dataValues)); connectorData.connectorTypes = ConnectorData.ConnectorTypes.NOTIFICATION; break; case (byte) 0xE8: @@ -256,13 +253,13 @@ void processBleStreamInData() { break; } this.connectorDataList.add(connectorData); - if (utility.DEBUG_FMDATA) appendToLog("FmData: Got PackageIn " + connectorData.connectorTypes.toString() + ", " + byteArrayToString(connectorData.dataValues)); + Logger.fmdData("FmData: Got PackageIn {}, {}", connectorData.connectorTypes, 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) { - if (utility.DEBUG_FMDATA) appendToLog("FmData: cs108DataLeftOffset = " + cs108DataLeftOffset + ", cs108DataReadStart = " + cs108DataReadStart + ", buffer = " + byteArrayToString(cs108DataLeft)); + Logger.fmdData("FmData: cs108DataLeftOffset = {}, cs108DataReadStart = {}, buffer = {}", cs108DataLeftOffset, cs108DataReadStart, byteArrayToString(cs108DataLeft)); break; } System.arraycopy(cs108DataLeft, cs108DataReadStart, cs108DataLeftNew, 0, cs108DataLeftOffset - cs108DataReadStart); @@ -272,11 +269,10 @@ void processBleStreamInData() { cs108DataReadStart = -1; if (true || mCs108DataReadRequest == false) { mCs108DataReadRequest = true; - if (DEBUGTHREAD && DEBUG) appendToLog("ready2Write: start immediate mReadWriteRunnable"); - //appendToLog("post mReadWriteRunnable within processBleStreamInData"); + Logger.debug("ready2Write: start immediate mReadWriteRunnable"); 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"); + Logger.btdData("BtData: CsReaderConnector.processBleStreamOut starts mReadWriteRunnable as mCs108DataReadRequest"); + } } } if (validHeader && cs108DataReadStart < 0) { @@ -287,12 +283,12 @@ void processBleStreamInData() { } } if (cs108DataReadStart != 0 && cs108DataLeftOffset >= 8) { - if (utility.DEBUG_FMDATA) { + if (Logger.LOG_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); - appendToLog("FmData: processCs108DataIn_ERROR, ENDLOOP invalid unused data: " + invalidPart.length + ", " + byteArrayToString(invalidPart) + ", with valid data length=" + validPart.length + ", " + byteArrayToString(validPart)); + Logger.trace("FmData: processCs108DataIn_ERROR, ENDLOOP invalid unused data: {}, {}, with valid data length={}, {}", invalidPart.length, byteArrayToString(invalidPart), validPart.length, byteArrayToString(validPart)); utility.writeDebug2File("Up2 Invalid " + invalidPart.length + ", " + byteArrayToString(invalidPart)); } @@ -303,7 +299,7 @@ void processBleStreamInData() { } } } - if (utility.DEBUG_FMDATA && bLooping) appendToLog("FmData: Exit loop with cs108DataLeftOffset=" + cs108DataLeftOffset + ", streamInBufferSize=" + bluetoothGatt.getStreamInBufferSize()); + if (bLooping) Logger.fmdData("FmData: Exit loop with cs108DataLeftOffset={}, streamInBufferSize={}", cs108DataLeftOffset, bluetoothGatt.getStreamInBufferSize()); } private int readData(byte[] buffer, int byteOffset, int byteCount) { return bluetoothGatt.readBleSteamIn(buffer, byteOffset, byteCount); } @@ -362,7 +358,7 @@ public boolean callbackMethod(byte[] dataValues, BarcodeConnector.CsReaderBarcod }; settingData.setConnectedConnectors(notificationConnector, rfidReader); mHandler.removeCallbacks(mReadWriteRunnable); mHandler.post(mReadWriteRunnable); - appendToLog("!!! all major classes are initialised"); + Logger.trace("!!! all major classes are initialised"); } final int CS108DATALEFT_SIZE = 300; //4000; //100; @@ -379,43 +375,35 @@ public CsReaderConnector(Context context, TextView mLogView, Utility utility, bo this.utility = utility; this.bis108 = bis108; - DEBUG_APDATA = utility.DEBUG_APDATA; bluetoothGatt = new BluetoothGatt(context, utility, (bis108 ? "9800" : "9802")); bluetoothGatt.bluetoothGattConnectorCallback = new BluetoothGatt.BluetoothGattConnectorCallback(){ @Override public void callbackMethod() { - //appendToLog("going to processBleStreamInData with bis108 " + bis108 + " and connected " + isBleConnected()); processBleStreamInData(); } }; - DEBUG_CONNECT = bluetoothGatt.DEBUG_CONNECT; DEBUG_SCAN = bluetoothGatt.DEBUG_SCAN; - - //cs108ConnectorDataInit(); - //mHandler.removeCallbacks(bluetoothGatt.runnableProcessBleStreamInData); mHandler.post(bluetoothGatt.runnableProcessBleStreamInData); - //if (DEBUGTHREAD) appendToLog("start immediate mReadWriteRunnable"); - //mHandler.removeCallbacks(mReadWriteRunnable); mHandler.post(mReadWriteRunnable); - //mHandler.removeCallbacks(runnableRx000UplinkHandler); mHandler.post(runnableRx000UplinkHandler); - appendToLog("foregroundReader: new SettingData for bis108 as " + bis108); + + Logger.trace("foregroundReader: new SettingData for bis108 as {}", bis108); settingData = new SettingData(context, utility, bluetoothGatt, this); } long timeReady; boolean aborting = false, sendFailure = false; private final Runnable mReadWriteRunnable = new Runnable() { - boolean ready2Write = false, DEBUG = false; + boolean ready2Write = false; int timer2Write = 0; boolean validBuffer; @Override public void run() { - if (DEBUGTHREAD || utility.DEBUG_BTDATA) appendToLog("BtData: CsReaderConnector.mReadWriteRunnable starts"); + Logger.btdData("BtData: CsReaderConnector.mReadWriteRunnable starts"); if (rfidConnector == null) { mHandler.postDelayed(mReadWriteRunnable, 500); - if (utility.DEBUG_BTDATA) appendToLog("BtData: CsReaderConnector.mReadWriteRunnable restart after 500ms"); + Logger.btdData("BtData: CsReaderConnector.mReadWriteRunnable restart after 500ms"); return; } if (timer2Write != 0 || bluetoothGatt.getStreamInBufferSize() != 0 || rfidConnector.mRfidToRead.size() != 0) { validBuffer = true; - if (DEBUG) appendToLog("mReadWriteRunnable(): START, timer2Write=" + timer2Write + ", streamInBufferSize = " + bluetoothGatt.getStreamInBufferSize() + ", mRfidToRead.size=" + rfidConnector.mRfidToRead.size() + ", mRx000ToRead.size=" + rfidReader.mRx000ToRead.size()); + Logger.debug("mReadWriteRunnable(): START, timer2Write={}, streamInBufferSize = {}, mRfidToRead.size={}, mRx000ToRead.size={}", timer2Write, bluetoothGatt.getStreamInBufferSize(), rfidConnector.mRfidToRead.size(), rfidReader.mRx000ToRead.size()); } else validBuffer = false; int intervalReadWrite = 250; //50; //50; //500; //500, 100; if (rfidConnector.rfidPowerOnTimeOut >= intervalReadWrite) { @@ -431,27 +419,26 @@ public void run() { } } if (barcodeConnector.barcodePowerOnTimeOut != 0) - if (DEBUG) appendToLog("mReadWriteRunnable(): barcodePowerOnTimeOut = " + barcodeConnector.barcodePowerOnTimeOut); + Logger.debug("mReadWriteRunnable(): barcodePowerOnTimeOut = {}", barcodeConnector.barcodePowerOnTimeOut); long lTime = System.currentTimeMillis(); - if (DEBUGTHREAD) appendToLog("start new mReadWriteRunnable after " + intervalReadWrite + " ms"); - //appendToLog("postDelayed mReadWriteRunnable within mReadWriteRunnable"); + Logger.debug("start new mReadWriteRunnable after {} ms", intervalReadWrite); mHandler.removeCallbacks(mReadWriteRunnable); mHandler.postDelayed(mReadWriteRunnable, intervalReadWrite); - if (utility.DEBUG_BTDATA) appendToLog("BtData: CsReaderConnector.mReadWriteRunnable restart after 250ms"); + Logger.btdData("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()); + if (bLooping == false) Logger.btdData("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("PkData: mReadWriteRunnable: TIMEOUT !!! mCs108DataRead.size() = " + connectorDataList.size()); + Logger.toLogView("PkData: mReadWriteRunnable: TIMEOUT !!! mCs108DataRead.size() = {}", connectorDataList.size()).trace(); break; } else { if (bFirst) { bFirst = false; } //writeDebug2File("C" + String.valueOf(intervalReadWrite) + ", " + System.currentTimeMillis()); } @@ -459,25 +446,36 @@ public void run() { ConnectorData connectorData = connectorDataList.get(0); connectorDataList.remove(0); boolean bValid = true; - if (utility.DEBUG_PKDATA) appendToLog("PkData: connectorData.type = " + connectorData.connectorTypes.toString() + ", connectorData.dataValues = " + byteArrayToString(connectorData.dataValues)); + Logger.pkData("PkData: connectorData.type = {}/, connectorData.dataValues = {}", connectorData.connectorTypes, byteArrayToString(connectorData.dataValues)); if (rfidConnector.isMatchRfidToWrite(connectorData)) { if (false) { for (int i = 0; i < rfidReader.mRx000ToRead.size(); i++) { if (rfidReader.mRx000ToRead.get(i).responseType == RfidReaderChipData.HostCmdResponseTypes.TYPE_COMMAND_END) - if (DEBUG) appendToLog("mRx0000ToRead with COMMAND_END is removed"); + Logger.debug("mRx0000ToRead with COMMAND_END is removed"); } - if (DEBUG) appendToLog("mRx000ToRead.clear !!!"); + Logger.debug("mRx000ToRead.clear !!!"); } - rfidReader.mRx000ToRead.clear(); if (DEBUG) appendToLog("mRx000ToRead.clear !!!"); + rfidReader.mRx000ToRead.clear(); + Logger.debug("mRx000ToRead.clear !!!"); if (writeDataCount > 0) writeDataCount--; if (bis108) ready2Write = true; //btSendTime = 0; aborting = false; } 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; 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."); + if (writeDataCount > 0) writeDataCount--; ready2Write = true; + Logger.trace("ready2Write is set true after true isMatchNotificationToWrite "); + btSendTime = 0; + Logger.pkData("PkData: mReadWriteRunnable: matched notification. btSendTime is set to 0 to allow new sending."); } else if (controllerConnector.isMatchControllerToWrite(connectorData)) { - 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."); + if (writeDataCount > 0) writeDataCount--; ready2Write = true; + Logger.trace("ready2Write is set true after true isMatchSiliconLabIcToWrite "); + btSendTime = 0; + Logger.pkData("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 (utility.DEBUG_PKDATA) appendToLog("PKData: mReadWriteRunnable: matched bluetoothIc. btSendTime is set to 0 to allow new sending."); + if (writeDataCount > 0) writeDataCount--; + ready2Write = true; + Logger.trace("ready2Write is set true after true isMatchBluetoothIcToWrite "); + btSendTime = 0; + Logger.pkData("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)) { @@ -493,54 +491,55 @@ public void run() { if (bValid) { //writeDebug2File("Up33 " + cs108ReadData.cs108ConnectedDevices.toString() + ", " + byteArrayToString(cs108ReadData.dataValues)); } else { - appendToLog("mReadWriteRunnable: !!! CANNOT process " + byteArrayToString(connectorData.dataValues) + " with mDataToWriteRemoved = " + barcodeConnector.mDataToWriteRemoved); + Logger.info("mReadWriteRunnable: !!! CANNOT process {} with mDataToWriteRemoved = {}", byteArrayToString(connectorData.dataValues), barcodeConnector.mDataToWriteRemoved); utility.writeDebug2File("Up3 Invalid " + connectorData.dataValues.length + ", " + byteArrayToString(connectorData.dataValues)); } if (barcodeConnector.mDataToWriteRemoved) { barcodeConnector.mDataToWriteRemoved = false; ready2Write = true; btSendTime = 0; - appendToLog("ready2Write is set true after true mBarcodeDevice.mDataToWriteRemoved "); - if (utility.DEBUG_PKDATA) appendToLog("PkData: mReadWriteRunnable: processed barcode. btSendTime is set to 0 to allow new sending."); + Logger.trace("ready2Write is set true after true mBarcodeDevice.mDataToWriteRemoved "); + Logger.pkData("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()); + if (bLooping) Logger.pkData("PkData: Exiting loop with connectorDataList.size = {}", connectorDataList.size()); lTime = System.currentTimeMillis(); if (rfidConnector.mRfidToWriteRemoved) { - rfidConnector.mRfidToWriteRemoved = false; ready2Write = true; btSendTime = 0; if (false) appendToLog("ready2Write is set true after true mRfidDevice.mRfidToWriteRemoved "); + rfidConnector.mRfidToWriteRemoved = false; + ready2Write = true; + btSendTime = 0; + Logger.trace("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"); + Logger.trace("ready2Write: start new mReadWriteRunnable after {} ms", BTSENDDELAY); 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); + Logger.pkData("BtData: CsReaderConnector.mReadWriteRunnable restart after {} ms", BTSENDDELAY + 2); + Logger.pkData("PkData: mReadWriteRunnable: processed Rfidcode. btSendTime is set to 0 to allow new sending with systime = {}", lTime); } if (bis108) { int timeout2Ready = 2000; if (aborting || sendFailure) timeout2Ready = 200; if (System.currentTimeMillis() > timeReady + timeout2Ready) ready2Write = true; } else { - if (ready2Write == false && lTime - btSendTime > btSendTimeOut) { - appendToLog("ready2Write is set to true from false with difference = " + (lTime - btSendTime) + ", systime = " + lTime + ", btSendTime = " + btSendTime + ", btSendTimeOut = " + btSendTime); + if (!ready2Write && lTime - btSendTime > btSendTimeOut) { + Logger.trace("ready2Write is set to true from false with difference = {}, systime = {}, btSendTime = {}, btSendTimeOut = {}", lTime - btSendTime, lTime, btSendTime, btSendTimeOut); ready2Write = true; } } - if (DEBUG) appendToLog("BtData: ready2Write = " + ready2Write); + Logger.debug("BtData: ready2Write = {}", ready2Write); if (ready2Write) { timeReady = System.currentTimeMillis(); timer2Write = 0; if (rfidConnector.rfidFailure) rfidConnector.mRfidToWrite.clear(); - //if (barcodeConnector.barcodeFailure) { barcodeConnector.barcodeToWrite.clear(); appendToLog("barcodeToWrite is clear"); } if (rfidReader.mRx000ToWrite.size() != 0 && rfidConnector.mRfidToWrite.size() == 0) { - if (DEBUG) - appendToLog("mReadWriteRunnable(): mRx000ToWrite.size=" + rfidReader.mRx000ToWrite.size() + ", mRfidToWrite.size=" + rfidConnector.mRfidToWrite.size()); + Logger.debug("mReadWriteRunnable(): mRx000ToWrite.size={}, mRfidToWrite.size={}", rfidReader.mRx000ToWrite.size(), rfidConnector.mRfidToWrite.size()); rfidReader.addRfidToWrite(rfidReader.mRx000ToWrite.get(0)); } boolean bisRfidCommandStop = false, bisRfidCommandExecute = false; - if (rfidConnector.mRfidToWrite.size() != 0 && DEBUG) - appendToLog("mRfidToWrite = " + rfidConnector.mRfidToWrite.get(0).rfidPayloadEvent.toString() + "." + byteArrayToString(rfidConnector.mRfidToWrite.get(0).dataValues) + ", ready2write = " + ready2Write); + if (!rfidConnector.mRfidToWrite.isEmpty()) { + Logger.trace("mRfidToWrite = {}.{}, ready2write = {}", rfidConnector.mRfidToWrite.get(0).rfidPayloadEvent, byteArrayToString(rfidConnector.mRfidToWrite.get(0).dataValues), ready2Write); + } if (rfidConnector.mRfidToWrite.size() != 0) { RfidConnector.CsReaderRfidData csReaderRfidData = rfidConnector.mRfidToWrite.get(0); if (csReaderRfidData.rfidPayloadEvent == RfidConnector.RfidPayloadEvents.RFID_COMMAND) { @@ -558,88 +557,88 @@ public void run() { if (byCommandStop[ii] != csReaderRfidData.dataValues[ii]) break; } if (ii == 4) bisRfidCommandStop = true; - if (DEBUG) - appendToLog("mRfidToWrite(0).dataValues = " + byteArrayToString(rfidConnector.mRfidToWrite.get(0).dataValues) + ", bisRfidCommandExecute = " + bisRfidCommandExecute + ", bisRfidCommandStop = " + bisRfidCommandStop); + Logger.debug("mRfidToWrite(0).dataValues = {}, bisRfidCommandExecute = {}, bisRfidCommandStop = {}", byteArrayToString(rfidConnector.mRfidToWrite.get(0).dataValues), bisRfidCommandExecute, bisRfidCommandStop); } } - 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 (!barcodeConnector.barcodeToWrite.isEmpty()) { + Logger.trace("AAA 1 barcodeToWrite.size = {}, bisRfidCommandStop = {}, barcodePowerOnTimeOut = ", barcodeConnector.barcodeToWrite.size(), bisRfidCommandStop, barcodeConnector.barcodePowerOnTimeOut); + } + Logger.debug("BtData: bisRfidCommandStop is {}", bisRfidCommandStop); if (bisRfidCommandStop) { 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) { + Logger.debug("rfidPowerOnTimeOut = {}, mRfidToWrite.size() = {}", rfidConnector.rfidPowerOnTimeOut, rfidConnector.mRfidToWrite.size()); + } else if (!rfidConnector.rfidFailure && !rfidConnector.mRfidToWrite.isEmpty()) { + if (!isBleConnected()) { rfidConnector.mRfidToWrite.clear(); } else { - if (utility.DEBUG_BTDATA) appendToLog("BtData: CsReaderConnector.mReadWriteRunnable 1: currentTime = " + System.currentTimeMillis() + ", btSendTime = " + btSendTime + ", difference = " + (System.currentTimeMillis() - btSendTime) + ", btSendTimeOut = " + btSendTimeOut); + Logger.btdData("BtData: CsReaderConnector.mReadWriteRunnable 1: currentTime = {}, btSendTime = {}, difference = {}, btSendTimeOut = {}", System.currentTimeMillis(), btSendTime, System.currentTimeMillis() - btSendTime, 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)); - if (false) appendToLog("BtData: done writeData with waitUplinkResponse = " + rfidConnector.mRfidToWrite.get(0).waitUplinkResponse); + Logger.trace("BtData: done writeData with waitUplinkResponse = {}", rfidConnector.mRfidToWrite.get(0).waitUplinkResponse); } - appendToLog("BtData: done writeRfid with size = " + rfidConnector.mRfidToWrite.size() + ", PayloadEvents = " + rfidConnector.mRfidToWrite.get(0).rfidPayloadEvent.toString() + ", data=" + byteArrayToString(rfidConnector.mRfidToWrite.get(0).dataValues)); + Logger.trace("BtData: done writeRfid with size = {}, PayloadEvents = {}, data={}", rfidConnector.mRfidToWrite.size(), rfidConnector.mRfidToWrite.get(0).rfidPayloadEvent, byteArrayToString(rfidConnector.mRfidToWrite.get(0).dataValues)); rfidConnector.sendRfidToWriteSent++; if (retValue) { rfidConnector.mRfidToWriteRemoved = false; - if (DEBUG) appendToLog("writeRfid() with sendRfidToWriteSent = " + rfidConnector.sendRfidToWriteSent); + Logger.debug("writeRfid() with sendRfidToWriteSent = {}", rfidConnector.sendRfidToWriteSent); sendFailure = false; //bValue = true; } else sendFailure = true; ready2Write = false; // - appendToLog("ready2Write is set false after sendRfidToWrite"); + Logger.trace("ready2Write is set false after sendRfidToWrite"); } } } } else if (!bis108 && rfidReader.isInventoring()) { 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) { + Logger.debug("rfidPowerOnTimeOut = {}, mRfidToWrite.size() = {}", rfidConnector.rfidPowerOnTimeOut, rfidConnector.mRfidToWrite.size()); + } else if (!rfidConnector.rfidFailure && !rfidConnector.mRfidToWrite.isEmpty()) { + if (!isBleConnected()) { rfidConnector.mRfidToWrite.clear(); } else { - if (DEBUG) - appendToLog("BtDataOut 2: currentTime = " + System.currentTimeMillis() + ", btSendTime = " + btSendTime + ", difference = " + (System.currentTimeMillis() - btSendTime) + ", btSendTimeOut = " + btSendTimeOut); + Logger.debug("BtDataOut 2: currentTime = {}, btSendTime = {}, difference = {}, btSendTimeOut = {}", System.currentTimeMillis(), btSendTime, System.currentTimeMillis() - btSendTime, 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)); - if (false) appendToLog("done writeData with waitUplinkResponse = " + rfidConnector.mRfidToWrite.get(0).waitUplinkResponse); + Logger.trace("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)); + Logger.debug("BtDataOut: done writeRfid with size = {}, PayloadEvents = {}, data={}", rfidConnector.mRfidToWrite.size(), rfidConnector.mRfidToWrite.get(0).rfidPayloadEvent, byteArrayToString(rfidConnector.mRfidToWrite.get(0).dataValues)); rfidConnector.sendRfidToWriteSent++; if (retValue) { rfidConnector.mRfidToWriteRemoved = false; - if (DEBUG) appendToLog("writeRfid() with sendRfidToWriteSent = " + rfidConnector.sendRfidToWriteSent); + Logger.debug("writeRfid() with sendRfidToWriteSent = {}", rfidConnector.sendRfidToWriteSent); sendFailure = false; //bValue = true; } else sendFailure = true; if (retValue) { ready2Write = false; - if (false) appendToLog("ready2Write is set false after true sendRfidToWrite"); + Logger.trace("ready2Write is set false after true sendRfidToWrite"); } } } } } else if (notificationConnector.notificationToWrite.size() != 0) { if (isBleConnected() == false) { - notificationConnector.notificationToWrite.clear(); appendToLog("notificationToWrite is clear"); } - else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { + notificationConnector.notificationToWrite.clear(); + Logger.trace("notificationToWrite is clear"); + } else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { byte[] dataOut = notificationConnector.sendNotificationToWrite(); boolean retValue = false; - 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) { + Logger.pkData("!!! notificationToWrite.sendDataToWriteSent = {}", controllerConnector.sendDataToWriteSent); + } + Logger.pkData("PkData: write notificationToWrite.{} with notificationConnector.sendDataToWriteSent = {}", + notificationConnector.notificationToWrite.get(0).notificationPayloadEvent, + notificationConnector.sendDataToWriteSent); if (false && notificationConnector.sendDataToWriteSent != 0) - appendToLog("!!! mSiliconLabIcDevice.sendDataToWriteSent = " + notificationConnector.sendDataToWriteSent); + Logger.trace("!!! mSiliconLabIcDevice.sendDataToWriteSent = {}", notificationConnector.sendDataToWriteSent); if (dataOut != null) retValue = writeData(dataOut, 0); if (retValue) { @@ -650,22 +649,21 @@ else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { } } ready2Write = false; // - if (false) appendToLog("ready2Write is set false after true sendSiliconLabIcToWrite"); + Logger.trace("ready2Write is set false after true sendSiliconLabIcToWrite"); } else if (controllerConnector.controllerToWrite.size() != 0) { - appendToLog("AAA 5"); + Logger.trace("AAA 5"); if (isBleConnected() == false) controllerConnector.controllerToWrite.clear(); else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { byte[] dataOut = controllerConnector.sendControllerToWrite(); boolean retValue = false; - if (utility.DEBUG_PKDATA && controllerConnector.sendDataToWriteSent != 0) - appendToLog("!!! siliconLabIcDevice.sendDataToWriteSent = " + controllerConnector.sendDataToWriteSent); - 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) + Logger.pkData("!!! siliconLabIcDevice.sendDataToWriteSent = {}", controllerConnector.sendDataToWriteSent); + Logger.pkData("PkData: write mSiliconLabIcDevice.{} with mSiliconLabIcDevice.sendDataToWriteSent = {}", + controllerConnector.controllerToWrite.get(0), + controllerConnector.sendDataToWriteSent); if (false && controllerConnector.sendDataToWriteSent != 0) - appendToLog("!!! mSiliconLabIcDevice.sendDataToWriteSent = " + controllerConnector.sendDataToWriteSent); + Logger.trace("!!! mSiliconLabIcDevice.sendDataToWriteSent = {}", controllerConnector.sendDataToWriteSent); if (dataOut != null) retValue = writeData(dataOut, 0); if (retValue) { @@ -676,24 +674,24 @@ else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { } } ready2Write = false; // - if (false) appendToLog("ready2Write is set false after true sendSiliconLabIcToWrite"); + Logger.trace("ready2Write is set false after true sendSiliconLabIcToWrite"); } else if (bluetoothConnector.bluetoothIcToWrite.size() != 0) { //Bluetooth version affects Barcode operation - appendToLog("AAA 6"); + Logger.trace("AAA 6"); if (isBleConnected() == false) bluetoothConnector.bluetoothIcToWrite.clear(); else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { byte[] dataOut = bluetoothConnector.sendBluetoothIcToWrite(); boolean retValue = false; - if (utility.DEBUG_PKDATA && bluetoothConnector.sendDataToWriteSent != 0) - appendToLog("!!! mBluetoothIcDevice.sendDataToWriteSent = " + bluetoothConnector.sendDataToWriteSent); - 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), - bluetoothConnector.sendDataToWriteSent)); - if (bluetoothConnector.sendDataToWriteSent != 0) - appendToLog("!!! mBluetoothIcDevice.sendDataToWriteSent = " + bluetoothConnector.sendDataToWriteSent); - + if (bluetoothConnector.sendDataToWriteSent != 0) { + Logger.pkData("!!! mBluetoothIcDevice.sendDataToWriteSent = {}", bluetoothConnector.sendDataToWriteSent); + } + Logger.pkData("PkData: write mBluetoothIcDevice.{}.{} with mBluetoothIcDevice.sendDataToWriteSent = {}", + bluetoothConnector.bluetoothIcToWrite.get(0).bluetoothIcPayloadEvent, + byteArrayToString(bluetoothConnector.bluetoothIcToWrite.get(0).dataValues), + bluetoothConnector.sendDataToWriteSent); + if (bluetoothConnector.sendDataToWriteSent != 0) { + Logger.trace("!!! mBluetoothIcDevice.sendDataToWriteSent = {}", bluetoothConnector.sendDataToWriteSent); + } if (dataOut != null) retValue = writeData(dataOut, 0); if (retValue) { //bluetoothConnector.sendDataToWriteSent++; @@ -703,54 +701,54 @@ else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { } } ready2Write = false; - appendToLog("ready2Write is set false after non-zero mBluetoothIcToWrite.size()"); + Logger.trace("ready2Write is set false after non-zero mBluetoothIcToWrite.size()"); } else if (barcodeConnector.barcodeToWrite.size() != 0 && barcodeConnector.barcodePowerOnTimeOut == 0) { - appendToLog("AAA 7 barcodeToWrite.size = " + barcodeConnector.barcodeToWrite.size()); - if (isBleConnected() == false) { barcodeConnector.barcodeToWrite.clear(); appendToLog("barcodeToWrite is clear"); } + Logger.trace("AAA 7 barcodeToWrite.size = {}", barcodeConnector.barcodeToWrite.size()); + if (isBleConnected() == false) { + barcodeConnector.barcodeToWrite.clear(); + Logger.trace("barcodeToWrite is clear"); + } else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { byte[] dataOut = barcodeConnector.sendBarcodeToWrite(); if (dataOut != null) writeData(dataOut, (barcodeConnector.barcodeToWrite.get(0).waitUplinkResponse ? 500 : 0)); } ready2Write = false; - appendToLog("ready2Write is set false after true sendBarcodeToWrite"); + Logger.trace("ready2Write is set false after true sendBarcodeToWrite"); } else if (rfidConnector.rfidPowerOnTimeOut != 0) { - if (DEBUG || true) appendToLog("rfidPowerOnTimeOut = " + rfidConnector.rfidPowerOnTimeOut + ", mRfidToWrite.size() = " + rfidConnector.mRfidToWrite.size()); + Logger.debug("rfidPowerOnTimeOut = {}, mRfidToWrite.size() = {}", rfidConnector.rfidPowerOnTimeOut, 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()); + Logger.btdData("BtData: CsReaderConnector.mReadWriteRunnable rfidFailure is false and mRfidToWrite.size is {}", rfidConnector.mRfidToWrite.size()); if (isBleConnected() == false) { rfidConnector.mRfidToWrite.clear(); } else { - if (utility.DEBUG_BTDATA) - appendToLog("BtData: CsReaderConnector.mReadWriteRunnable 3 currentTime = " + System.currentTimeMillis() + ", btSendTime = " + btSendTime + ", difference = " + (System.currentTimeMillis() - btSendTime) + ", btSendTimeOut = " + btSendTimeOut); + Logger.btdData("BtData: CsReaderConnector.mReadWriteRunnable 3 currentTime = {}, btSendTime = {}, difference = {}, btSendTimeOut = {}", System.currentTimeMillis(), btSendTime, System.currentTimeMillis() - btSendTime, 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)); - if (false) appendToLog("done writeData with waitUplinkResponse = " + rfidConnector.mRfidToWrite.get(0).waitUplinkResponse); + Logger.trace("done writeData with waitUplinkResponse = {}", rfidConnector.mRfidToWrite.get(0).waitUplinkResponse); - if (false) appendToLog("AAA sending rifd data = " + byteArrayToString(dataOut)); + Logger.trace("AAA sending rifd data = {}", byteArrayToString(dataOut)); String string = byteArrayToString(dataOut).substring(16); String stringCompare = "800280B310A"; if (bis108) stringCompare = "8002700100F00F000000"; - if (false) appendToLog("AAA sending rifd data portion = " + string + ", " + string.indexOf(stringCompare)); + Logger.trace("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)); + Logger.debug("BtDataOut: done writeRfid with size = {}, PayloadEvents = {}, data={}", rfidConnector.mRfidToWrite.size(), rfidConnector.mRfidToWrite.get(0).rfidPayloadEvent, byteArrayToString(rfidConnector.mRfidToWrite.get(0).dataValues)); rfidConnector.sendRfidToWriteSent++; if (retValue) { rfidConnector.mRfidToWriteRemoved = false; - if (DEBUG) - appendToLog("writeRfid() with sendRfidToWriteSent = " + rfidConnector.sendRfidToWriteSent); + Logger.debug("writeRfid() with sendRfidToWriteSent = {}", rfidConnector.sendRfidToWriteSent); sendFailure = false; //bValue = true; } else sendFailure = true; if (retValue) { - if (false) appendToLog("ready2Write is set false after true sendRfidToWrite"); + Logger.trace("ready2Write is set false after true sendRfidToWrite"); ready2Write = false; } } @@ -764,7 +762,7 @@ else if (System.currentTimeMillis() - btSendTime > btSendTimeOut) { //appendToLog("mRfidDevice.mRfidReaderChip is " + (mRfidDevice.mRfidReaderChip == null ? "null" : "valid")); //appendToLog("mRfidDevice.mRfidReaderChip.mRfidReaderChip is " + (mRfidDevice.mRfidReaderChip.mRfidReaderChip == null ? "null" : "valid")); if (rfidReader != null) rfidReader.uplinkHandler(); - if (DEBUGTHREAD) appendToLog("mReadWriteRunnable: mReadWriteRunnable ends"); + Logger.debug("mReadWriteRunnable: mReadWriteRunnable ends"); } }; diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/Logger.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Logger.java new file mode 100644 index 0000000..bde5814 --- /dev/null +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Logger.java @@ -0,0 +1,188 @@ +package com.csl.cslibrary4a; + +import static com.csl.cslibrary4a.Utility.getReferencedCurrentTimeMs; + +import android.os.Handler; +import android.os.Looper; +import android.util.Log; +import android.widget.TextView; + +import java.util.Locale; + +/** + * Lazy and configurable logger for the library + */ +public class Logger { + private static Handler mHandler = new Handler(); + + public static boolean LOG_VIEW_ENABLED = false; + public static boolean LOG_APDATA = false; + public static boolean LOG_PKDATA = false; + public static boolean LOG_BTDATA = false; + public static boolean LOG_FMDATA = false; + public static boolean LOG_BTOP = false; + public static boolean LOG_INVCFG = false; + public static boolean LOG_CONNECT = false; + public static boolean LOG_SCAN = false; + public static boolean LOG_SELECT = false; + public static boolean LOG_COMPACT = false; + + static TextView mLogView; + + public final static LogLevel LEVEL = LogLevel.WARN; + + public static void trace(String pattern, Object... args) { + if (LEVEL.ordinal() <= LogLevel.TRACE.ordinal()) { + Log.v(getTag(), fillPattern(pattern, args)); + } + } + + public static void debug(String pattern, Object... args) { + if (LEVEL.ordinal() <= LogLevel.DEBUG.ordinal()) { + Log.d(getTag(), fillPattern(pattern, args)); + } + } + + public static void info(String pattern, Object... args) { + if (LEVEL.ordinal() <= LogLevel.INFO.ordinal()) { + Log.i(getTag(), fillPattern(pattern, args)); + } + } + + public static void warn(String pattern, Object... args) { + if (LEVEL.ordinal() <= LogLevel.WARN.ordinal()) { + Log.w(getTag(), fillPattern(pattern, args)); + } + } + + public static void error(String pattern, Object... args) { + if (LEVEL.ordinal() <= LogLevel.WARN.ordinal()) { + Log.e(getTag(), fillPattern(pattern, args)); + } + } + + public static void apData(String pattern, Object... args) { + if (LOG_APDATA) { + Log.d(getTag(), fillPattern(pattern, args)); + } + } + + public static void pkData(String pattern, Object... args) { + if (LOG_PKDATA) { + Log.d(getTag(), fillPattern(pattern, args)); + } + } + + public static void btdData(String pattern, Object... args) { + if (LOG_BTDATA) { + Log.d(getTag(), fillPattern(pattern, args)); + } + } + + public static void fmdData(String pattern, Object... args) { + if (LOG_FMDATA) { + Log.d(getTag(), fillPattern(pattern, args)); + } + } + + public static void connect(String pattern, Object... args) { + if (LOG_CONNECT) { + Log.d(getTag(), fillPattern(pattern, args)); + } + } + + public static void scan(String pattern, Object... args) { + if (LOG_SCAN) { + Log.d(getTag(), fillPattern(pattern, args)); + } + } + + public static void select(String pattern, Object... args) { + if (LOG_SELECT) { + Log.d(getTag(), fillPattern(pattern, args)); + } + } + + public static void compact(String pattern, Object... args) { + if (LOG_COMPACT) { + Log.d(getTag(), fillPattern(pattern, args)); + } + } + + public static void btop(String pattern, Object... args) { + if (LOG_BTOP) { + Log.d(getTag(), fillPattern(pattern, args)); + } + } + + public static void invCfg(String pattern, Object... args) { + if (LOG_INVCFG) { + Log.d(getTag(), fillPattern(pattern, args)); + } + } + + public static void runDebug(String pattern, Object... args) { + mHandler.post(() -> debug(pattern, args)); + } + + /** + * Tries to extract the caller method name from the stack trace to + * determine customized log tag. + * @return the log tag from the stacktrace or the default tag + */ + private static String getTag() { + StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace(); + boolean foundMe = false; + for (StackTraceElement e : stacktrace) { + String methodName = e.getMethodName(); + if (methodName.contains("appendToLog")) { + foundMe = true; + } else if (foundMe && !methodName.startsWith("access$")) { + return String.format(Locale.US, "%s", methodName); + } + } + return "CSLibrary4a"; + } + + /** + * Replaces all {} from the pattern with string representation of + * the parameters. + * @param pattern the string to replace {} by args in + * @param args the objects to replace placeholders with + * @return the filled pattern + */ + private static String fillPattern(String pattern, Object... args) { + int i = 0; + int pos = pattern.indexOf("{}"); + while (pos != -1 && i < args.length) { + pattern = pattern.substring(0, pos) + args[i] + pattern.substring(pos + 2); + i++; + pos = pattern.indexOf("{}"); + } + return pattern; + } + + public static LoggerMessage toLogView(String pattern, Object... args) { + if (LOG_VIEW_ENABLED && Looper.myLooper() == Looper.getMainLooper() && mLogView != null) { + String message = fillPattern(pattern, args); + mLogView.append("\n" + getReferencedCurrentTimeMs() + "." + message); + return new LoggerMessage(message); + } + return LoggerMessage.EMPTY; + } + + static class LoggerMessage { + static final LoggerMessage EMPTY = new LoggerMessage(null); + private final String value; + LoggerMessage(String value) { this.value = value; } + + public void trace() { if (value != null) Logger.trace(value); } + public void debug() { if (value != null) Logger.debug(value); } + public void info() { if (value != null) Logger.info(value); } + public void warn() { if (value != null) Logger.warn(value); } + public void error() { if (value != null) Logger.error(value); } + } + + /** Different level of logs to filter messages */ + public enum LogLevel { TRACE, DEBUG, INFO, WARN, ERROR } +} diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/NotificationConnector.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/NotificationConnector.java index b7bb9b7..b9b80e5 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/NotificationConnector.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/NotificationConnector.java @@ -6,7 +6,6 @@ import java.util.ArrayList; public class NotificationConnector { - boolean DEBUG_PKDATA; boolean userDebugEnableDefault = false, userDebugEnable = userDebugEnableDefault; public int mVoltageValue; public int mVoltageCount; @@ -47,8 +46,9 @@ boolean getAutoRfidAbortStatus() { if (!autoRfidAbortStatusUpdate) { CsReaderNotificationData csReaderNotificationData = new CsReaderNotificationData(); csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_GET_AUTO_RFIDINV_ABORT; - 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()); + notificationToWrite.add(csReaderNotificationData); + Logger.trace("notificationToWrite is added with length = {}", notificationToWrite.size()); + Logger.pkData("PkData: add NOTIFICATION_GET_AUTO_RFIDINV_ABORT to mNotificationToWrite with length = {}", notificationToWrite.size()); } return autoRfidAbortStatus; } @@ -59,8 +59,9 @@ public boolean getAutoBarStartStopStatus() { if (mAutoBarStartStopStatusUpdated == false) { CsReaderNotificationData csReaderNotificationData = new CsReaderNotificationData(); csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_GET_AUTO_BARINV_STARTSTOP; - 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()); + notificationToWrite.add(csReaderNotificationData); + Logger.trace("notificationToWrite is added with length = {}", notificationToWrite.size()); + Logger.pkData("PkData: add NOTIFICATION_GET_AUTO_BARINV_STARTSTOP to mNotificationToWrite with length = {}", notificationToWrite.size()); } return mAutoBarStartStopStatus; } @@ -148,19 +149,19 @@ private boolean arrayTypeSet(byte[] dataBuf, int pos, NotificationPayloadEvents } private byte[] writeNotification(CsReaderNotificationData data) { - int datalength = 0; boolean DEBUG = false; + int datalength = 0; if (data.dataValues != null) datalength = data.dataValues.length; byte[] dataOutRef = new byte[]{(byte) 0xA7, (byte) 0xB3, 2, (byte) 0xD9, (byte) 0x82, (byte) 0x37, 0, 0, (byte) 0xA0, 0}; byte[] dataOut = new byte[10 + datalength]; - if (DEBUG) appendToLog("event = " + data.notificationPayloadEvent.toString() + ", with datalength = " + datalength); + Logger.debug("event = {}, with datalength = {}", data.notificationPayloadEvent, datalength); if (datalength != 0) { System.arraycopy(data.dataValues, 0, dataOut, 10, datalength); dataOutRef[2] += datalength; } System.arraycopy(dataOutRef, 0, dataOut, 0, dataOutRef.length); if (arrayTypeSet(dataOut, 9, data.notificationPayloadEvent)) { - if (DEBUG_PKDATA) appendToLog(String.format("PkData: write mNotificationDevice.%s.%s with mNotificationDevice.sendDataToWriteSent = %d", data.notificationPayloadEvent.toString(), byteArrayToString(data.dataValues), sendDataToWriteSent)); - if (DEBUG) appendToLogView("NOut: " + byteArrayToString(dataOut)); + Logger.pkData("PkData: write mNotificationDevice.{}.{} with mNotificationDevice.sendDataToWriteSent = {}", data.notificationPayloadEvent, byteArrayToString(data.dataValues), sendDataToWriteSent); + Logger.toLogView("NOut: {}", byteArrayToString(dataOut)).debug(); return dataOut; } return null; @@ -173,14 +174,14 @@ public boolean isMatchNotificationToWrite(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 Notification.Reply with payload = " + byteArrayToString(connectorData.dataValues) + " for writeData Notification." + notificationToWrite.get(0).notificationPayloadEvent.toString()); + Logger.pkData("PkData: matched Notification.Reply with payload = {} for writeData Notification. {}", byteArrayToString(connectorData.dataValues), notificationToWrite.get(0).notificationPayloadEvent); if (notificationToWrite.get(0).notificationPayloadEvent == NotificationPayloadEvents.NOTIFICATION_GET_BATTERY_VOLTAGE) { if (connectorData.dataValues.length >= dataInCompare.length + 2) { mVoltageValue = (connectorData.dataValues[2] & 0xFF) * 256 + (connectorData.dataValues[3] & 0xFF); mVoltageCount++; bprocessed = true; } - if (DEBUG_PKDATA) appendToLog("PkData: matched Notification.Reply.GetBatteryVoltage with result = " + String.format("%X", mVoltageValue)); + Logger.pkData("PkData: matched Notification.Reply.GetBatteryVoltage with result = {}", String.format("%X", mVoltageValue)); } else if (notificationToWrite.get(0).notificationPayloadEvent == NotificationPayloadEvents.NOTIFICATION_GET_TRIGGER_STATUS) { if (connectorData.dataValues[2] != 0) { setTriggerStatus(true); //mTriggerStatus = true; @@ -190,26 +191,27 @@ public boolean isMatchNotificationToWrite(ConnectorData connectorData) { triggerButtonStatus = false; } iTriggerCount++; - if (DEBUG_PKDATA) appendToLog("PkData: BARTRIGGER: isMatchNotificationToWrite finds trigger = " + getTriggerStatus()); + Logger.pkData("PkData: BARTRIGGER: isMatchNotificationToWrite finds trigger = {}", getTriggerStatus()); bprocessed = true; } else if (notificationToWrite.get(0).notificationPayloadEvent == NotificationPayloadEvents.NOTIFICATION_GET_AUTO_RFIDINV_ABORT) { if (connectorData.dataValues[2] != 0) setAutoRfidAbortStatus(true); else setAutoRfidAbortStatus(false); - if (DEBUG_PKDATA) appendToLog("PkData: matched Notification.Reply.GetAutoRfidinvAbort with result = " + connectorData.dataValues[2] + " and autoRfidAbortStatus = " + getAutoRfidAbortStatus()); + Logger.pkData("PkData: matched Notification.Reply.GetAutoRfidinvAbort with result = {} and autoRfidAbortStatus = {}", connectorData.dataValues[2], getAutoRfidAbortStatus()); bprocessed = true; } else if (notificationToWrite.get(0).notificationPayloadEvent == NotificationPayloadEvents.NOTIFICATION_GET_AUTO_BARINV_STARTSTOP) { if (connectorData.dataValues[2] != 0) setAutoBarStartStopStatus(true); else setAutoBarStartStopStatus(false); - if (DEBUG_PKDATA) appendToLog("PkData: matched Notification.Reply.GetAutoBarinvStartstop with result = " + connectorData.dataValues[2] + " and " + getAutoBarStartStopStatus()); + Logger.pkData("PkData: matched Notification.Reply.GetAutoBarinvStartstop with result = {} and {}", connectorData.dataValues[2], getAutoBarStartStopStatus()); bprocessed = true; } else { bprocessed = true; - if (DEBUG_PKDATA) appendToLog("PkData: matched Notification.Reply." + notificationToWrite.get(0).notificationPayloadEvent.toString() + " with result = " + connectorData.dataValues[2]); + Logger.pkData("PkData: matched Notification.Reply.{} with result = {}", notificationToWrite.get(0).notificationPayloadEvent, connectorData.dataValues[2]); } String string = "Up31 " + (bprocessed ? "" : "Unprocessed, ") + notificationToWrite.get(0).notificationPayloadEvent.toString() + ", " + byteArrayToString(data1); utility.writeDebug2File(string); - notificationToWrite.remove(0); sendDataToWriteSent = 0; if (false) appendToLog("notificationToWrite remove0 with length = " + notificationToWrite.size()); - if (DEBUG_PKDATA) appendToLog("PkData: new mNotificationToWrite size = " + notificationToWrite.size()); + notificationToWrite.remove(0); sendDataToWriteSent = 0; + Logger.trace("notificationToWrite remove0 with length = {}", notificationToWrite.size()); + Logger.pkData("PkData: new mNotificationToWrite size = {}", notificationToWrite.size()); } } } @@ -219,18 +221,20 @@ public boolean isMatchNotificationToWrite(ConnectorData connectorData) { public int sendDataToWriteSent = 0; boolean notificationFailure = false; public byte[] sendNotificationToWrite() { - boolean DEBUG = false; if (notificationFailure) { - notificationToWrite.remove(0); sendDataToWriteSent = 0; if (false) appendToLog("notificationToWrite remove0 with length = " + notificationToWrite.size()); + notificationToWrite.remove(0); sendDataToWriteSent = 0; + Logger.trace("notificationToWrite remove0 with length = {}", notificationToWrite.size()); } else if (sendDataToWriteSent >= 5) { int oldSize = notificationToWrite.size(); CsReaderNotificationData csReaderNotificationData = notificationToWrite.get(0); - 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."); + notificationToWrite.remove(0); + sendDataToWriteSent = 0; + Logger.trace("notificationToWrite remove0 with length = {}", notificationToWrite.size()); + Logger.debug("Removed after sending count-out with oldSize = {}, updated mNotificationToWrite.size() = {}", oldSize , notificationToWrite.size()); + Logger.debug("Removed after sending count-out."); String string = "Problem in sending data to Notification Module. Removed data sending after count-out"; if (userDebugEnable) Toast.makeText(context, string, Toast.LENGTH_SHORT).show(); - else appendToLogView(string); + else Logger.trace(string); if (true) Toast.makeText(context, csReaderNotificationData.notificationPayloadEvent.toString(), Toast.LENGTH_LONG).show(); notificationFailure = true; // disconnect(false); } else { @@ -242,7 +246,7 @@ public byte[] sendNotificationToWrite() { long timeTriggerRelease; public boolean isNotificationToRead(ConnectorData connectorData) { - boolean found = false, DEBUG = false; + boolean found = false; CsReaderNotificationData csReaderNotificationData = new CsReaderNotificationData(); byte[] data1 = new byte[connectorData.dataValues.length - 2]; System.arraycopy(connectorData.dataValues, 2, data1, 0, data1.length); if (connectorData.dataValues[0] == (byte) 0xA0 && connectorData.dataValues[1] == (byte) 0x00 && connectorData.dataValues.length >= 4) { @@ -251,8 +255,8 @@ public boolean isNotificationToRead(ConnectorData connectorData) { csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_GET_BATTERY_VOLTAGE; csReaderNotificationData.dataValues = data1; if (false) notificationToRead.add(csReaderNotificationData); - if (DEBUG_PKDATA) appendToLog("PkData: found Notification.Uplink with payload = " + byteArrayToString(connectorData.dataValues)); - if (DEBUG_PKDATA) appendToLog("PkData: Notification.Uplink.GetCurrentBattteryVoltage is processed as mVoltageValue = " + mVoltageValue + " and mVoltageCount = " + mVoltageCount); + Logger.pkData("PkData: found Notification.Uplink with payload = {}", byteArrayToString(connectorData.dataValues)); + Logger.pkData("PkData: Notification.Uplink.GetCurrentBattteryVoltage is processed as mVoltageValue = {} and mVoltageCount = {}", mVoltageValue, mVoltageCount); found = true; } else if (connectorData.dataValues[0] == (byte) 0xA0 && connectorData.dataValues[1] == (byte) 0x01 && connectorData.dataValues.length >= 3) { if (connectorData.dataValues[2] == 0) triggerButtonStatus = false; @@ -260,91 +264,92 @@ public boolean isNotificationToRead(ConnectorData connectorData) { iTriggerCount++; csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_GET_TRIGGER_STATUS; csReaderNotificationData.dataValues = data1; - if (DEBUG_PKDATA) appendToLog("PkData: found Notification.Uplink with payload = " + byteArrayToString(connectorData.dataValues)); - if (DEBUG_PKDATA) appendToLog("PkData: Notification.Uplink.GetCurrentTriggerState is processed as triggerButtonStatus = " + triggerButtonStatus + " and iTriggerCount = " + iTriggerCount); + Logger.pkData("PkData: found Notification.Uplink with payload = {}", byteArrayToString(connectorData.dataValues)); + Logger.pkData("PkData: Notification.Uplink.GetCurrentTriggerState is processed as triggerButtonStatus = {} and iTriggerCount = {}", triggerButtonStatus, iTriggerCount); found = true; } else if (connectorData.dataValues[0] == (byte) 0xA1) { - if (DEBUG_PKDATA) appendToLog("PkData: found Notification.Uplink with payload = " + byteArrayToString(connectorData.dataValues)); + Logger.pkData("PkData: found Notification.Uplink with payload = {}", byteArrayToString(connectorData.dataValues)); //Cs108NotificatiionData cs108NotificatiionData = new Cs108NotificatiionData(); switch (connectorData.dataValues[1]) { case 0: - if (DEBUG) appendToLog("matched batteryFailed data is found."); + Logger.debug("matched batteryFailed data is found."); csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_BATTERY_FAILED; csReaderNotificationData.dataValues = null; if (true) notificationToRead.add(csReaderNotificationData); - if (DEBUG_PKDATA) appendToLog("PkData: Notification.Uplink.Reserve is processed"); + Logger.pkData("PkData: Notification.Uplink.Reserve is processed"); found = true; break; case 1: - if (DEBUG) appendToLog("matched Error data is found, " + byteArrayToString(connectorData.dataValues)); + Logger.debug("matched Error data is found, {}", byteArrayToString(connectorData.dataValues)); csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_BATTERY_ERROR; csReaderNotificationData.dataValues = data1; if (true) notificationToRead.add(csReaderNotificationData); //btSendTime = System.currentTimeMillis() - btSendTimeOut + 50; - if (DEBUG_PKDATA) appendToLog("PkData: Notification.Uplink.ErrorCode with value = " + byteArrayToString(data1) + " is addded to mNotificationToRead"); + Logger.pkData("PkData: Notification.Uplink.ErrorCode with value = {} is addded to mNotificationToRead", byteArrayToString(data1)); found = true; break; case 2: csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_TRIGGER_PUSHED; csReaderNotificationData.dataValues = data1; setTriggerStatus(true); - if (DEBUG) appendToLog("BARTRIGGER: isNotificationToRead finds trigger = " + getTriggerStatus()); + Logger.debug("BARTRIGGER: isNotificationToRead finds trigger = {}", getTriggerStatus()); if (false) notificationToRead.add(csReaderNotificationData); - if (DEBUG_PKDATA) appendToLog("PkData: Notification.Uplink.TriggerPushed is processed as trigger = " + getTriggerStatus()); + Logger.pkData("PkData: Notification.Uplink.TriggerPushed is processed as trigger = {}", getTriggerStatus()); found = true; break; case 3: csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_TRIGGER_RELEASED; csReaderNotificationData.dataValues = data1; setTriggerStatus(false); - if (DEBUG) appendToLog("BARTRIGGER: isNotificationToRead finds trigger = " + getTriggerStatus()); + Logger.debug("BARTRIGGER: isNotificationToRead finds trigger = {}", getTriggerStatus()); if (false) notificationToRead.add(csReaderNotificationData); - if (DEBUG_PKDATA) appendToLog("PkData: Notification.Uplink.TriggerReleased is processed as trigger = " + getTriggerStatus()); + Logger.pkData("PkData: Notification.Uplink.TriggerReleased is processed as trigger = {}", getTriggerStatus()); found = true; break; default: - appendToLog("Notification.Uplink with mis-matched result"); + Logger.trace("Notification.Uplink with mis-matched result"); break; } } - if (DEBUG_PKDATA && found) appendToLog("found Notification.read data = " + byteArrayToString(connectorData.dataValues)); + Logger.pkData("found Notification.read data = {}", byteArrayToString(connectorData.dataValues)); if (found) utility.writeDebug2File("Up32 " + csReaderNotificationData.notificationPayloadEvent.toString() + ", " + byteArrayToString(csReaderNotificationData.dataValues)); return found; } Context context; Utility utility; boolean triggerReporting; short triggerReportingCountSetting; public NotificationConnector(Context context, Utility utility, boolean triggerReporting, short triggerReportingCountSetting) { this.context = context; - this.utility = utility; DEBUG_PKDATA = utility.DEBUG_PKDATA; + this.utility = utility; this.triggerReporting = triggerReporting; this.triggerReportingCountSetting = triggerReportingCountSetting; } - private void appendToLog(String s) { utility.appendToLog(s); } private String byteArrayToString(byte[] packet) { return utility.byteArrayToString(packet); } private boolean compareArray(byte[] array1, byte[] array2, int length) { return utility.compareByteArray(array1, array2, length); } - private void appendToLogView(String s) { utility.appendToLogView(s); } public boolean batteryLevelRequest() { CsReaderNotificationData csReaderNotificationData = new CsReaderNotificationData(); csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_GET_BATTERY_VOLTAGE; - 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()); + boolean bValue = notificationToWrite.add(csReaderNotificationData); + Logger.trace("notificationToWrite is added with length = {}", notificationToWrite.size()); + Logger.pkData("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); 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()); + boolean bValue = notificationToWrite.add(csReaderNotificationData); + Logger.trace("notificationToWrite is added with length = {}", notificationToWrite.size()); + Logger.pkData("PkData: add NOTIFICATION_GET_TRIGGER_STATUS to mNotificationToWrite with length = {}", notificationToWrite.size()); return bValue; } public boolean setBatteryAutoReport(boolean on) { CsReaderNotificationData csReaderNotificationData = new CsReaderNotificationData(); csReaderNotificationData.notificationPayloadEvent = (on ? NotificationPayloadEvents.NOTIFICATION_AUTO_BATTERY_VOLTAGE: NotificationPayloadEvents.NOTIFICATION_STOPAUTO_BATTERY_VOLTAGE); - boolean bValue = notificationToWrite.add(csReaderNotificationData); appendToLog("notificationToWrite is added with length = " + notificationToWrite.size()); - if (DEBUG_PKDATA) appendToLog("PkData: add " + csReaderNotificationData.notificationPayloadEvent.toString() + " to mNotificationToWrite with length = " + notificationToWrite.size()); + boolean bValue = notificationToWrite.add(csReaderNotificationData); + Logger.trace("notificationToWrite is added with length = {}", notificationToWrite.size()); + Logger.pkData("PkData: add {} to mNotificationToWrite with length = {}", csReaderNotificationData.notificationPayloadEvent, notificationToWrite.size()); return bValue; } public boolean setAutoRFIDAbort(boolean enable) { - if (false) appendToLog("BtDataOut: setAutoRFIDAbort with enable = " + enable + ", current autoRFIDAbort is " + autoRfidAbortStatus); + Logger.trace("BtDataOut: setAutoRFIDAbort with enable = {}, current autoRFIDAbort is {}", enable, autoRfidAbortStatus); if (autoRfidAbortStatusUpdate) { if ((enable && autoRfidAbortStatus) || (!enable && !autoRfidAbortStatus)) return true; @@ -354,8 +359,9 @@ public boolean setAutoRFIDAbort(boolean enable) { csReaderNotificationData.dataValues = new byte[1]; setAutoRfidAbortStatus(enable); csReaderNotificationData.dataValues[0] = (enable ? (byte)1 : 0); - boolean bValue = notificationToWrite.add(csReaderNotificationData); appendToLog("notificationToWrite is added with length = " + notificationToWrite.size()); - if (DEBUG_PKDATA) appendToLog("PkData: add NOTIFICATION_AUTO_RFIDINV_ABORT." + byteArrayToString(csReaderNotificationData.dataValues) + " to mNotificationToWrite with length = " + notificationToWrite.size()); + boolean bValue = notificationToWrite.add(csReaderNotificationData); + Logger.trace("notificationToWrite is added with length = {}", notificationToWrite.size()); + Logger.pkData("PkData: add NOTIFICATION_AUTO_RFIDINV_ABORT.{} to mNotificationToWrite with length = {}", byteArrayToString(csReaderNotificationData.dataValues), notificationToWrite.size()); return bValue; } public boolean getAutoRFIDAbort() { @@ -371,8 +377,9 @@ public boolean setAutoBarStartSTop(boolean enable) { csReaderNotificationData.dataValues = new byte[1]; setAutoBarStartStopStatus(enable); csReaderNotificationData.dataValues[0] = (enable ? (byte)1 : 0); - boolean bValue = notificationToWrite.add(csReaderNotificationData); appendToLog("notificationToWrite is added with length = " + notificationToWrite.size()); - if (DEBUG_PKDATA) appendToLog("PkData: add NOTIFICATION_AUTO_BARINV_STARTSTOP." + byteArrayToString(csReaderNotificationData.dataValues) + " to mNotificationToWrite with length = " + notificationToWrite.size()); + boolean bValue = notificationToWrite.add(csReaderNotificationData); + Logger.trace("notificationToWrite is added with length = {}", notificationToWrite.size()); + Logger.pkData("PkData: add NOTIFICATION_AUTO_BARINV_STARTSTOP.{} to mNotificationToWrite with length = {}", byteArrayToString(csReaderNotificationData.dataValues), notificationToWrite.size()); return bValue; } public boolean getAutoBarStartSTop() { return getAutoBarStartStopStatus(); } @@ -380,19 +387,19 @@ public boolean setAutoBarStartSTop(boolean enable) { public boolean getTriggerReporting() { return triggerReporting; } public boolean setTriggerReporting(boolean triggerReporting) { boolean bValue = false; - appendToLog("FileA setTriggerReporting starts with triggerReporting as " + triggerReporting); + Logger.trace("FileA setTriggerReporting starts with triggerReporting as {}", triggerReporting); //if (this.triggerReporting == triggerReporting) return true; if (triggerReporting) { - appendToLog("FileA going to setAutoTriggerReporting 3 with triggerReportingCountSetting as " + triggerReportingCountSetting); + Logger.trace("FileA going to setAutoTriggerReporting 3 with triggerReportingCountSetting as {}", triggerReportingCountSetting); byte byteWord = (byte) triggerReportingCountSetting; - appendToLog("FileA going to setAutoTriggerReporting 4 with byteWord as " + byteWord); + Logger.trace("FileA going to setAutoTriggerReporting 4 with byteWord as {}", byteWord); bValue = setAutoTriggerReporting(byteWord); } else { - appendToLog("FileA going to stopAutoTriggerReporting 3"); + Logger.trace("FileA going to stopAutoTriggerReporting 3"); bValue = stopAutoTriggerReporting(); } if (bValue) this.triggerReporting = triggerReporting; - appendToLog("FileA setTriggerReporting ends"); + Logger.trace("FileA setTriggerReporting ends"); return bValue; } @@ -415,37 +422,39 @@ public boolean setTriggerReportingCount(short triggerReportingCount) { return true; } public boolean setAutoTriggerReporting(byte timeSecond) { - appendToLog("FileA setAutoTriggerReporting with checkVersion = " + checkVersion() + ", timeSecond = " + timeSecond); + Logger.trace("FileA setAutoTriggerReporting with checkVersion = {}, timeSecond = {}", checkVersion(), timeSecond); if (!checkVersion()) return false; CsReaderNotificationData csReaderNotificationData = new CsReaderNotificationData(); csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_AUTO_TRIGGER_REPORT; csReaderNotificationData.dataValues = new byte[1]; csReaderNotificationData.dataValues[0] = timeSecond; - boolean bValue = notificationToWrite.add(csReaderNotificationData); appendToLog("notificationToWrite is added with length = " + notificationToWrite.size()); - if (DEBUG_PKDATA) appendToLog("PkData: add NOTIFICATION_AUTO_TRIGGER_REPORT." + byteArrayToString(csReaderNotificationData.dataValues) + " to mNotificationToWrite with length = " + notificationToWrite.size()); + boolean bValue = notificationToWrite.add(csReaderNotificationData); + Logger.trace("notificationToWrite is added with length = {}", notificationToWrite.size()); + Logger.pkData("PkData: add NOTIFICATION_AUTO_TRIGGER_REPORT.{} to mNotificationToWrite with length = {}", byteArrayToString(csReaderNotificationData.dataValues), notificationToWrite.size()); return bValue; } public boolean stopAutoTriggerReporting() { - appendToLog("NotificationConnector.stopAutoTriggerReporting ***"); + Logger.trace("NotificationConnector.stopAutoTriggerReporting ***"); if (!checkVersion()) return false; CsReaderNotificationData csReaderNotificationData = new CsReaderNotificationData(); csReaderNotificationData.notificationPayloadEvent = NotificationPayloadEvents.NOTIFICATION_STOP_TRIGGER_REPORT; - boolean bValue = notificationToWrite.add(csReaderNotificationData); appendToLog("notificationToWrite is added with length = " + notificationToWrite.size()); - if (DEBUG_PKDATA) appendToLog("PkData: add NOTIFICATION_STOP_TRIGGER_REPORT to mNotificationToWrite with length = " + notificationToWrite.size()); + boolean bValue = notificationToWrite.add(csReaderNotificationData); + Logger.trace("notificationToWrite is added with length = {}", notificationToWrite.size()); + Logger.pkData("PkData: add NOTIFICATION_STOP_TRIGGER_REPORT to mNotificationToWrite with length = {}", notificationToWrite.size()); return bValue; } public void setVersion(String stringVersion) { this.stringVersion = stringVersion; } boolean checkVersion() { - boolean DEBUG = true, bValue = false; + boolean bValue = false; String stringCompare = "1.0."; if (stringVersion == null) return true; - appendToLog("FileA setVersion with stringVersion as " + stringVersion + ", stringCompare as " + stringCompare); + Logger.trace("FileA setVersion with stringVersion as {}, stringCompare as {}", stringVersion, stringCompare); int index = stringVersion.indexOf(stringCompare); - if (DEBUG) appendToLog("index = " + index); + Logger.debug("index = {}", index); if (index >= 0) { - if (DEBUG) appendToLog("substring = " + stringVersion.substring(index + stringCompare.length())); + Logger.debug("substring = {}", stringVersion.substring(index + stringCompare.length())); if (Integer.parseInt(stringVersion.substring(index + stringCompare.length())) >= 16) bValue = true; } else return true; return bValue; diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/ReaderDevice.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/ReaderDevice.java index 7c9dc95..a972939 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/ReaderDevice.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/ReaderDevice.java @@ -13,7 +13,8 @@ public class ReaderDevice implements Comparable { private int phase, channel, port; public final int INVALID_STATUS = -1; private int status = INVALID_STATUS; - public static final int INVALID_BACKPORT = -1, INVALID_CODESENSOR = -1, INVALID_CODERSSI = -1, INVALID_BRAND = -1, INVALID_SENSORDATA = 0x1000; public final float INVALID_CODETEMPC = -300; + public static final int INVALID_BACKPORT = -1, INVALID_CODESENSOR = -1, INVALID_CODERSSI = -1, INVALID_BRAND = -1, INVALID_SENSORDATA = 0x1000; + public final float INVALID_CODETEMPC = -300; private int backport1 = INVALID_BACKPORT, backport2 = INVALID_BACKPORT; private int codeSensor = INVALID_CODESENSOR, codeSensorMax = INVALID_CODESENSOR, codeRssi = INVALID_CODERSSI, sensorData = INVALID_SENSORDATA; private float codeTempC = INVALID_CODETEMPC; private String brand; private boolean isConnected; diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidConnector.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidConnector.java index 0b6cb21..4153554 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidConnector.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidConnector.java @@ -14,8 +14,6 @@ public RfidConnector(Context context, 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); } - private void appendToLog(String s) { utility.appendToLog(s); } - private void appendToLogView(String s) { utility.appendToLogView(s); } public enum RfidPayloadEvents { RFID_POWER_ON, RFID_POWER_OFF, RFID_COMMAND, @@ -82,70 +80,75 @@ public byte[] writeRfid(RfidConnector.CsReaderRfidData data) { } }*/ if (arrayTypeSet(dataOut, 9, data.rfidPayloadEvent)) { - if (false) appendToLogView(byteArrayToString(dataOut)); - 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); + // Logger.toLogView(byteArrayToString(dataOut)).trace(); + Logger.pkData(String.format("PkData: write Rfid.%s.%s with mRfidDevice.sendRfidToWriteSent = %d", data.rfidPayloadEvent.toString(), byteArrayToString(data.dataValues), sendRfidToWriteSent)); + if (sendRfidToWriteSent != 0) Logger.trace("!!! mRfidDevice.sendRfidToWriteSent = {}", sendRfidToWriteSent); return dataOut; } return null; } public int rfidPowerOnTimeOut = 0; //int barcodePowerOnTimeOut = 0; public boolean isMatchRfidToWrite(ConnectorData connectorData) { - boolean match = false, DEBUG = false; - if (mRfidToWrite.size() != 0 && connectorData.dataValues[0] == (byte)0x80) { + boolean match = false; + if (!mRfidToWrite.isEmpty() && connectorData.dataValues[0] == (byte)0x80) { byte[] dataInCompare = new byte[]{(byte) 0x80, 0}; if (arrayTypeSet(dataInCompare, 1, mRfidToWrite.get(0).rfidPayloadEvent) && (connectorData.dataValues.length == dataInCompare.length + 1)) { 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 (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)); + Logger.pkData("PkData: matched Rfid.Reply with payload = {} for writeData Rfid.{}.{}", byteArrayToString(connectorData.dataValues), mRfidToWrite.get(0).rfidPayloadEvent, byteArrayToString(mRfidToWrite.get(0).dataValues)); if (connectorData.dataValues[2] != 0) { - if (DEBUG) appendToLog("Rfid.reply data is found with error"); + Logger.debug("Rfid.reply data is found with error"); } else { if (mRfidToWrite.get(0).rfidPayloadEvent == RfidConnector.RfidPayloadEvents.RFID_POWER_ON) { rfidPowerOnTimeOut = 3000; onStatus = true; - if (utility.DEBUG_PKDATA) appendToLog("PkData: matched Rfid.Reply.PowerOn with result 0 and onStatus = " + onStatus); + Logger.pkData("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 (utility.DEBUG_PKDATA) appendToLog("PkData: matched Rfid.Reply.PowerOff with result 0 and onStatus = " + onStatus); + Logger.pkData("PkData: matched Rfid.Reply.PowerOff with result 0 and onStatus = {}", onStatus); bprocessed = true; } else { bprocessed = true; - if (utility.DEBUG_PKDATA) appendToLog("PkData: matched Rfid.Other.Reply data is found."); + Logger.pkData("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 (utility.DEBUG_PKDATA) appendToLog("PkData: mRfidToWrite.downlinkResponsed is set and waiting uplink data"); + Logger.pkData("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) - if (DEBUG) appendToLog("mRx0000ToRead with COMMAND_END is removed"); + Logger.debug("mRx0000ToRead with COMMAND_END is removed"); } - if (DEBUG) appendToLog("mRx000ToRead.clear !!!"); + Logger.debug("mRx000ToRead.clear !!!"); } - rfidReaderChip.mRfidReaderChip.mRx000ToRead.clear(); if (DEBUG) appendToLog("mRx000ToRead.clear !!!");*/ + rfidReaderChip.mRfidReaderChip.mRx000ToRead.clear(); + Logger.debug("mRx000ToRead.clear !!!");*/ utility.writeDebug2File("Up31 " + mRfidToWrite.get(0).rfidPayloadEvent.toString() + ", " + byteArrayToString(data1)); return true; } - if (DEBUG) appendToLog("matched Rfid.reply data is found with mRfidToWrite.size=" + mRfidToWrite.size()); + Logger.debug("matched Rfid.reply data is found with mRfidToWrite.size={}", mRfidToWrite.size()); } 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 (utility.DEBUG_PKDATA) appendToLog("PkData: new mRfidToWrite size = " + mRfidToWrite.size()); + mRfidToWrite.remove(0); + sendRfidToWriteSent = 0; + mRfidToWriteRemoved = true; + Logger.debug("mmRfidToWrite remove 1 with remained write size = {}", mRfidToWrite.size()); + Logger.pkData("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) - if (DEBUG) appendToLog("mRx0000ToRead with COMMAND_END is removed"); + Logger.debug("mRx0000ToRead with COMMAND_END is removed"); } - if (DEBUG) appendToLog("mRx000ToRead.clear !!!"); + Logger.debug("mRx000ToRead.clear !!!"); } - rfidReaderChip.mRfidReaderChip.mRx000ToRead.clear(); if (DEBUG) appendToLog("mRx000ToRead.clear !!!");*/ + rfidReaderChip.mRfidReaderChip.mRx000ToRead.clear(); + Logger.debug("mRx000ToRead.clear !!!");*/ } } } @@ -155,34 +158,33 @@ public boolean isMatchRfidToWrite(ConnectorData connectorData) { public int sendRfidToWriteSent = 0; public boolean mRfidToWriteRemoved = false; public boolean rfidFailure = false; public boolean rfidValid = false; public byte[] sendRfidToWrite() { - boolean DEBUG = false; boolean bValue = false; - //if (DEBUG) appendToLog("Timeout: btSendTimeOut = " + btSendTimeOut); + //Logger.debug("Timeout: btSendTimeOut = {}", btSendTimeOut); RfidConnector.RfidPayloadEvents rfidPayloadEvents = mRfidToWrite.get(0).rfidPayloadEvent; int sendRfidToWriteSentMax = 5; if (rfidPayloadEvents == RfidConnector.RfidPayloadEvents.RFID_COMMAND /*&& mRfidToWrite.get(0).dataValues[0] == 0x40*/) sendRfidToWriteSentMax = 5; if (sendRfidToWriteSent >= sendRfidToWriteSentMax) { - mRfidToWrite.remove(0); sendRfidToWriteSent = 0; mRfidToWriteRemoved = true; if (DEBUG) appendToLog("mmRfidToWrite remove 2"); - if (DEBUG) appendToLog("Removed after sending count-out."); + mRfidToWrite.remove(0); sendRfidToWriteSent = 0; mRfidToWriteRemoved = true; + Logger.debug("mmRfidToWrite remove 2"); + Logger.debug("Removed after sending count-out."); if (true) { - appendToLog("Rfdid data transmission failure !!! clear mRfidToWrite buffer !!!"); + Logger.trace("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)); + //Logger.trace("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"); + Logger.trace("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(); - appendToLog("disconnect d"); + Logger.trace("disconnect d"); disconnect(); }*/ - if (DEBUG) appendToLog("done"); + Logger.debug("done"); } else { - if (DEBUG) - appendToLog("size = " + mRfidToWrite.size() + ", PayloadEvents = " + rfidPayloadEvents.toString() + ", data=" + byteArrayToString(mRfidToWrite.get(0).dataValues)); + Logger.debug("size = {}, PayloadEvents = {}, data={}", mRfidToWrite.size(), rfidPayloadEvents, byteArrayToString(mRfidToWrite.get(0).dataValues)); boolean retValue = false; return writeRfid(mRfidToWrite.get(0)); } @@ -192,7 +194,6 @@ public byte[] sendRfidToWrite() { public boolean found; public int invalidUpdata; public boolean isRfidToRead(ConnectorData connectorData) { - boolean DEBUG = false; found = false; if (connectorData.dataValues[0] == (byte) 0x81) { RfidConnector.CsReaderRfidData cs108RfidReadData = new RfidConnector.CsReaderRfidData(); @@ -208,12 +209,12 @@ public boolean isRfidToRead(ConnectorData connectorData) { cs108RfidReadData.invalidSequence = connectorData.invalidSequence; cs108RfidReadData.milliseconds = connectorData.milliseconds; mRfidToRead.add(cs108RfidReadData); - if (utility.DEBUG_PKDATA) appendToLog("PkData: Got Rfid.Uplink.DataRead with updated mRfidToRead data as " + byteArrayToString(dataValues)); + Logger.pkData("PkData: Got Rfid.Uplink.DataRead with updated mRfidToRead data as {}", byteArrayToString(dataValues)); found = true; break; default: invalidUpdata++; - if (utility.DEBUG_PKDATA) appendToLog("PkData: !!! found INVALID Rfid.Uplink with payload = " + byteArrayToString(connectorData.dataValues)); + Logger.pkData("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 e273525..a4230ab 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReader.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReader.java @@ -14,7 +14,6 @@ import java.util.List; public class RfidReader { - final boolean DEBUG = false; public boolean bFirmware_reset_before = false; RfidConnector rfidConnector; public RfidReaderChipR2000 rfidReaderChipR2000; public RfidReaderChipE710 rfidReaderChipE710; ArrayList mRx000ToWrite; @@ -32,12 +31,12 @@ public RfidReader(Context context, Utility utility, CsReaderConnector csReaderCo rfidConnector = new RfidConnector(context, utility); mRfidToWrite = rfidConnector.mRfidToWrite; if (bis108) { - appendToLog("bis108: new RfidReaderChipR2000 is created"); + Logger.trace("bis108: new RfidReaderChipR2000 is created"); rfidReaderChipR2000 = new RfidReaderChipR2000(context, utility, csReaderConnector); mRx000ToWrite = rfidReaderChipR2000.mRx000ToWrite; mRx000ToRead = rfidReaderChipR2000.mRx000ToRead; } else { - appendToLog("bis108: new RfidReaderChipE710 is created"); + Logger.trace("bis108: new RfidReaderChipE710 is created"); rfidReaderChipE710 = new RfidReaderChipE710(context, utility, csReaderConnector); mRx000ToWrite = rfidReaderChipE710.mRx000ToWrite; mRx000ToRead = rfidReaderChipE710.mRx000ToRead; @@ -55,7 +54,7 @@ public boolean callbackMethod(byte[] dataValues) { countryChannelData.fccFreqTableIdx[countryChannelData.fccFreqSortedIdx[i]] = i; } for (int i = 0; i < 50; i++) { - if (false) appendToLog("fccFreqTableIdx[" + i + "] = " + countryChannelData.fccFreqTableIdx[i]); + Logger.trace("fccFreqTableIdx[{}] = {}", i, countryChannelData.fccFreqTableIdx[i]); } } @@ -187,16 +186,16 @@ public void adjustExtraBank1() { } 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); + Logger.select("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 !!!"); + Logger.trace("Hello123: Set Sense at Select !!!"); } else { //if (MainActivity.mDid.matches("E280B12A")) { //setSelectCriteriaDisable(-1); - appendToLog("Hello123: Set Sense at BOOT !!!"); + Logger.trace("Hello123: Set Sense at BOOT !!!"); } } else if (mDid.matches("E203510")) { setSelectCriteria(0, true, 7, 4, 0, 2, 0, mDid); @@ -207,7 +206,7 @@ public int setSelectData4Inventory(RfidReader.TagType tagType, String mDid, bool iValue = selectFor; } } else if (mDid.matches("E282402")) { - appendToLog("selectFor = " + selectFor); + Logger.trace("selectFor = {}", selectFor); if (selectFor != 2) { setSelectCriteria(0, true, 4, 2, 0, 3, 0xA0, "20"); selectFor = 2; @@ -228,7 +227,7 @@ public int setSelectData4Inventory(RfidReader.TagType tagType, String mDid, bool iValue = selectFor; } } else { - appendToLog("MainActivity.selectFor = " + selectFor); + Logger.trace("MainActivity.selectFor = {}", selectFor); if (selectFor != -1) { //setSelectCriteriaDisable(-1); selectFor = -1; @@ -237,17 +236,17 @@ public int setSelectData4Inventory(RfidReader.TagType tagType, String mDid, bool } if (mDid.indexOf("E2806894") == 0) { - appendToLog("RfidReader.setSelectData 0 found " + mDid + ".indexOf[E2806894] == 0"); + Logger.trace("RfidReader.setSelectData 0 found {}.indexOf[E2806894] == 0", mDid); if (mDid.matches("E2806894A")) { - appendToLog("RfidReader.setSelectData 1 found E2806894A"); + Logger.trace("RfidReader.setSelectData 1 found E2806894A"); //setSelectCriteriaDisable(1); } else if (mDid.matches("E2806894B")) { - appendToLog("RfidReader.setSelectData 2 found E2806894B"); - appendToLog("BtDataOut BBB 2"); + Logger.trace("RfidReader.setSelectData 2 found E2806894B"); + Logger.trace("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); + Logger.trace("RfidReader.setSelectData 3 found {}", mDid); setSelectCriteria(0, true, 4, 0, 1, 0x204, "1", true); setSelectCriteria(1, true, 4, 2, 2, 0, "E2806894", false); } @@ -259,7 +258,7 @@ public int setSelectData4Inventory(RfidReader.TagType tagType, String mDid, bool if (strMdid.indexOf("E28011") == 0) { int iValue1 = Integer.valueOf(strMdid.substring(6, 8), 16); iValue1 &= 0x0F; - appendToLog(String.format("iValue1 = 0x%X", iValue1)); + Logger.trace(String.format("iValue1 = 0x%X", iValue1)); if (iValue1 == 1) strMdid = "E2C011A2"; else if (iValue1 == 2) strMdid = "E28011C"; else if (iValue1 == 3) strMdid = "E28011B"; @@ -274,10 +273,10 @@ public int setSelectData4Inventory(RfidReader.TagType tagType, String mDid, bool if (stringProtectPassword != null) { if (stringProtectPassword.trim().length() == 0) stringProtectPassword = "00000000"; - if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectCriteria: Going to setSelectCriteria"); + Logger.select("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"); + Logger.select("Debug_Select: RfidReader.setSelectCriteria: Going to setSelectedByTID"); setSelectedTagByTID(strMdid, -1); } } @@ -285,8 +284,6 @@ public int setSelectData4Inventory(RfidReader.TagType tagType, String mDid, bool } //============ utility ============ - private void appendToLog(String s) { utility.appendToLog(s); } - //============ Rfid ============ //============ Rfid ============ //============ Rfid ============ @@ -294,26 +291,26 @@ public int setSelectData4Inventory(RfidReader.TagType tagType, String mDid, bool //============ Rfid ============ public boolean setInvAlgoNoSave(boolean dynamicAlgo) { - appendToLog("writeBleStreamOut: going to setInvAlgo with dynamicAlgo = " + dynamicAlgo); + Logger.trace("writeBleStreamOut: going to setInvAlgo with dynamicAlgo = {}", dynamicAlgo); return setInvAlgo1(dynamicAlgo); } public boolean setInvAlgo1(boolean dynamicAlgo) { - boolean bValue = true, DEBUG = false; - if (DEBUG) appendToLog("2 setInvAlgo1"); + boolean bValue = true; + Logger.debug("2 setInvAlgo1"); int iAlgo = getInvAlgoInChip(); int iRetry = getRetryCount(); int iAbFlip = (bis108 ? rfidReaderChipR2000.rx000Setting.getAlgoAbFlip() : rfidReaderChipE710.rx000Setting.getAlgoAbFlip()); - if (DEBUG) appendToLog("2 setInvAlgo1: going to setInvAlgo with dynamicAlgo = " + dynamicAlgo + ", iAlgo = " + iAlgo + ", iRetry = " + iRetry + ", iabFlip = " + iAbFlip); + Logger.debug("2 setInvAlgo1: going to setInvAlgo with dynamicAlgo = {}, iAlgo = , iRetry = , iabFlip = {}", dynamicAlgo, iAlgo, iRetry, iAbFlip); if ( (dynamicAlgo && iAlgo == 0) || (dynamicAlgo == false && iAlgo == 3)) { bValue = (bis108 ? rfidReaderChipR2000.rx000Setting.setInvAlgo(dynamicAlgo ? 3 : 0) : rfidReaderChipE710.rx000Setting.setInvAlgo(dynamicAlgo ? 3 : 0)); - if (DEBUG) appendToLog("After setInvAlgo, bValue = " + bValue); - if (DEBUG) appendToLog("Before setPopulation, population = " + getPopulation()); + Logger.debug("After setInvAlgo, bValue = {}", bValue); + Logger.debug("Before setPopulation, population = {}", getPopulation()); if (bValue) bValue = setPopulation(getPopulation()); - if (DEBUG) appendToLog("After setPopulation, bValue = " + bValue); + Logger.debug("After setPopulation, bValue = {}", bValue); if (bValue) bValue = setRetryCount(iRetry); - if (DEBUG) appendToLog("After setRetryCount, bValue = " + bValue); + Logger.debug("After setRetryCount, bValue = {}", bValue); if (bValue) bValue = (bis108 ? rfidReaderChipR2000.rx000Setting.setAlgoAbFlip(iAbFlip) : rfidReaderChipE710.rx000Setting.setAlgoAbFlip(iAbFlip)); - if (DEBUG) appendToLog("After setAlgoAbFlip, bValue = " + bValue); + Logger.debug("After setAlgoAbFlip, bValue = {}", bValue); } return bValue; } @@ -1449,7 +1446,7 @@ public double[] GetAvailableFrequencyTable(RegionCodes regionCode) { return countryChannelData.LH2TableOfFreq; case ETSI: - appendToLog("Got ETSI Table of Frequencies"); + Logger.trace("Got ETSI Table of Frequencies"); return countryChannelData.ETSITableOfFreq; case IN: return countryChannelData.IDATableOfFreq; @@ -1469,34 +1466,34 @@ public double[] GetAvailableFrequencyTable(RegionCodes regionCode) { } } else { int iRegionEnum = regionCode.ordinal() - RegionCodes.Albania1.ordinal() + 1; - if (DEBUG) appendToLog("regionCode = " + regionCode.toString() + ", iRegionEnum = " + iRegionEnum); + Logger.debug("regionCode = {}, iRegionEnum = {}", regionCode, iRegionEnum); 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); + Logger.debug("strChannelCount = {}, iChannelCount = {}", strChannelCount, iChannelCount); 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); + Logger.debug("strChannelSeparation = {},iChannelSeparation = {}", strChannelSeparation, iChannelSeparation); String strChannelFirst = countryChannelData.strCountryEnumInfo[(iRegionEnum - 1) * countryChannelData.iCountryEnumInfoColumn + 6]; double dChannelFirst = -1; try { dChannelFirst = Double.parseDouble(strChannelFirst); } catch (Exception ex) { } - if (DEBUG) appendToLog("strChannelFirst = " + strChannelFirst + ", dChannelFirst = " + dChannelFirst); + Logger.debug("strChannelFirst = {}, dChannelFirst = {}", strChannelFirst, dChannelFirst); if (iChannelCount > 0) { freqText = new double[iChannelCount]; for (int i = 0; i < iChannelCount; i++) { freqText[i] = dChannelFirst + ((double) iChannelSeparation) / 1000 * i; - if (DEBUG) appendToLog("Frequency freqTable[" + i + "] = " + freqText[i]); + Logger.debug("Frequency freqTable[{}] = {}", i, freqText[i]); } } return freqText; @@ -1526,13 +1523,13 @@ public int[] FreqIndex(RegionCodes regionCode) { case PR: if (freqSortedIdx == null) { freqSortedIdx = new int[countryChannelData.PRTableOfFreq.length]; - if (DEBUG) appendToLog("PR: freqSortedIdx size = " + freqSortedIdx.length); + Logger.debug("PR: freqSortedIdx size = {}", freqSortedIdx.length); ArrayList list = new ArrayList(); for (int i = 0; i < freqSortedIdx.length; i++) list.add(new Integer(i)); Collections.shuffle(list); for (int i = 0; i < freqSortedIdx.length; i++) { freqSortedIdx[i] = list.get(i); - if (DEBUG) appendToLog("PR: Random Value = " + freqSortedIdx[i]); + Logger.debug("PR: Random Value = {}", freqSortedIdx[i]); } } return freqSortedIdx; @@ -1618,7 +1615,7 @@ public int[] FreqIndex(RegionCodes regionCode) { iFreqSortedIdx = new int[iFreqChnCnt]; for (int i = 0; i < iFreqChnCnt; i++) { iFreqSortedIdx[i] = (byte)i; - if (false) appendToLog("Frequency index[" + i + "] = " + iFreqSortedIdx[i]); + Logger.trace("Frequency index[{}] = {}", i, iFreqSortedIdx[i]); } } return iFreqSortedIdx; @@ -1638,7 +1635,7 @@ public int[] FreqTable(RegionCodes regionCode) { // int[] freqTableIdx = fccFreqTableIdx; // int[] freqSortedIdx; // int[] freqTable = new int[50]; -// if (DEBUG) appendToLog("gerVersionCode = " + mRfidDevice.mRx000Device.mRx000OemSetting.getVersionCode()); +// Logger.debug("gerVersionCode = {}", mRfidDevice.mRx000Device.mRx000OemSetting.getVersionCode()); // switch (mRfidDevice.mRx000Device.mRx000OemSetting.getVersionCode()) { // case 0: // freqSortedIdx = fccFreqSortedIdx0; @@ -1652,7 +1649,7 @@ public int[] FreqTable(RegionCodes regionCode) { // } // for (int i = 0; i < 50; i++) { // freqTable[i] = fccFreqTable[fccFreqTableIdx[freqSortedIdx[i]]]; -// if (DEBUG) appendToLog("i = " + i + ", freqSortedIdx = " + freqSortedIdx[i] + ", fccFreqTableIdx = " + fccFreqTableIdx[freqSortedIdx[i]] + ", freqTable[" + i + "] = " + freqTable[i]); +// Logger.debug("i = " + i + ", freqSortedIdx = " + freqSortedIdx[i] + ", fccFreqTableIdx = " + fccFreqTableIdx[freqSortedIdx[i]] + ", freqTable[" + i + "] = " + freqTable[i]); // } // return freqTable; return countryChannelData.fccFreqTable; @@ -1669,7 +1666,7 @@ public int[] FreqTable(RegionCodes regionCode) { freqTable[i] = countryChannelData.fccFreqTable[countryChannelData.fccFreqTableIdx[j]]; } } else - if (DEBUG) appendToLog("NULL freqSortedIndex"); + Logger.debug("NULL freqSortedIndex"); return freqTable; // return prFreqTable; case VZ: return countryChannelData.vzFreqTable; @@ -1794,7 +1791,7 @@ byte[] string2ByteArray(String string) { bytesNew[bytesNew.length - 1] = (byte) (sValue & 0xFF); bytes = bytesNew; } catch (Exception ex) { - appendToLog("Exception in i = " + i + ", substring = " + string.substring(i, i+2)); + Logger.trace("Exception in i = " + i + ", substring = " + string.substring(i, i+2)); break; } } @@ -1841,7 +1838,7 @@ public int getMinQValue() { return (bis108 ? rfidReaderChipR2000.rx000Setting.getAlgoMinQ(3) : rfidReaderChipE710.rx000Setting.getAlgoMinQ(3)); } public boolean setDynamicQParms(int startQValue, int minQValue, int maxQValue, int retryCount) { - appendToLog("setTagGroup: going to setAlgoSelect with input as 3"); + Logger.trace("setTagGroup: going to setAlgoSelect with input as 3"); boolean result; result = (bis108 ? rfidReaderChipR2000.rx000Setting.setAlgoSelect(3) : rfidReaderChipE710.rx000Setting.setAlgoSelect(3)); if (result) { @@ -1861,12 +1858,12 @@ public boolean getRepeatUnitNoTags() { return rfidReaderChipE710.rx000Setting.getAlgoRunTilZero(0) == 1 ? true : false; } public boolean setFixedQParms(int qValue, int retryCount, boolean repeatUnitNoTags) { - boolean result, DEBUG = false; - if (DEBUG) appendToLog("qValue=" + qValue + ", retryCount = " + retryCount + ", repeatUntilNoTags = " + repeatUnitNoTags); + boolean result; + Logger.debug("qValue={}, retryCount = {}, repeatUntilNoTags = {}", qValue, retryCount, repeatUnitNoTags); result = (bis108 ? rfidReaderChipR2000.rx000Setting.setAlgoSelect(0) : rfidReaderChipE710.rx000Setting.setAlgoSelect(0)); - if (DEBUG) appendToLog("after setAlgoSelect, result = " + result); + Logger.debug("after setAlgoSelect, result = {}", result); if (qValue == getFixedQValue() && retryCount == getFixedRetryCount() && repeatUnitNoTags == getRepeatUnitNoTags()) { - appendToLog("!!! Skip repeated repeated data with qValue=" + qValue + ", retryCount = " + retryCount + ", repeatUntilNoTags = " + repeatUnitNoTags); + Logger.trace("!!! Skip repeated repeated data with qValue={}, retryCount = {}, repeatUntilNoTags = {}", qValue, retryCount, repeatUnitNoTags); return true; } @@ -1905,8 +1902,7 @@ 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] + Logger.select("Debug_Select: RfidReader.setSelectCriteria3 with index = {}, enable = {}, bSelectEnable = {}", index, enable, bSelectEnabled[index] + ", target = " + target + ", action = " + action + ", delay = " + delay + ", bank = " + bank + ", offset = " + offset + ", mask = " + mask + ", maskbitlen = " + maskblen); if (!enable) { @@ -1919,34 +1915,34 @@ boolean setSelectCriteria3(int index, boolean enable, int target, int action, in (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"); + Logger.select("Debug_Select: RfidReader.setSelectCriteria3 goes to setInvSelectIndex"); result = (bis108 ? rfidReaderChipR2000.rx000Setting.setInvSelectIndex(index) : rfidReaderChipE710.rx000Setting.setInvSelectIndex(index)); - if (DEBUG) appendToLog("After setInvSelectIndex, result = " + result); + Logger.debug("After setInvSelectIndex, result = {}", result); } - if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectCriteria3 goes to setSelectEnable"); + Logger.select("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); + Logger.debug("After setSelectEnable, result = {}", result); if (result) result = (bis108 ? rfidReaderChipR2000.rx000Setting.setSelectMaskBank(bank) : rfidReaderChipE710.rx000Setting.setSelectMaskBank(bank)); - if (DEBUG) appendToLog("After setSelectMaskBank, result = " + result); + Logger.debug("After setSelectMaskBank, result = {}",result); if (result) result = (bis108 ? rfidReaderChipR2000.rx000Setting.setSelectMaskOffset(offset) : rfidReaderChipE710.rx000Setting.setSelectMaskOffset(offset)); - if (DEBUG) appendToLog("After setSelectMaskOffset, result = " + result + " and mask = " + mask); + Logger.debug("After setSelectMaskOffset, result = {} and mask = {}", result, mask); if (mask == null) return false; if (result) result = (bis108 ? rfidReaderChipR2000.rx000Setting.setSelectMaskLength(maskblen) : rfidReaderChipE710.rx000Setting.setSelectMaskLength(maskblen)); - if (DEBUG) appendToLog("After setSelectMaskLength, result = " + result); + Logger.debug("After setSelectMaskLength, result = {}", result); if (result) result = (bis108 ? rfidReaderChipR2000.rx000Setting.setSelectMaskData(mask) : rfidReaderChipE710.rx000Setting.setSelectMaskData(mask)); - if (DEBUG) appendToLog("After setSelectMaskData, result = " + result); + Logger.debug("After setSelectMaskData, result = {}", result); if (result) { - if (DEBUG) appendToLog("RfidReader.setSelectCriteria3 with enable = " + enable); + Logger.debug("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); + Logger.debug("After setTagSelect[1], result = {}", result); if (result) result = (bis108 ? rfidReaderChipR2000.rx000Setting.setQuerySelect(3) : rfidReaderChipE710.rx000Setting.setQuerySelect(3)); - if (DEBUG) appendToLog("After setQuerySelect[3], result = " + result); + Logger.debug("After setQuerySelect[3], result = {}", result); } else { result = (bis108 ? rfidReaderChipR2000.rx000Setting.setTagSelect(0) : rfidReaderChipE710.rx000Setting.setTagSelect(0)); - if (DEBUG) appendToLog("After setTagSelect[0], result = " + result); + Logger.debug("After setTagSelect[0], result = {}", result); if (result) result = (bis108 ? rfidReaderChipR2000.rx000Setting.setQuerySelect(0) : rfidReaderChipE710.rx000Setting.setQuerySelect(0)); - if (DEBUG) appendToLog("After setQuerySelect[0], result = " + result); + Logger.debug("After setQuerySelect[0], result = {}", result); } } if (result) { @@ -1957,14 +1953,14 @@ 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(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; + Logger.select("Debug_Select: RfidReader.setSelectedTag1[selectOne = {}, selectMask = {}, selectBank = {}, selectOffset = {}, delay = {}, pwrlevel = {}, qValue = {}, matchRep = {}", + selectOne, selectMask, selectBank, selectOffset, delay, pwrlevel, qValue, matchRep); + boolean setSuccess = true; if (selectMask == null) selectMask = ""; if (preMatchDataChanged == false) { - preMatchDataChanged = true; if (DEBUG) appendToLog("setSelectCriteria preMatchDataChanged is SET with preMatchData = " + (preMatchData != null ? "valid" : "null")); + preMatchDataChanged = true; + Logger.debug("setSelectCriteria preMatchDataChanged is SET with preMatchData = {}", preMatchData != null ? "valid" : "null"); if (preMatchData == null) { preMatchData = new RfidReader.PreMatchData(false, (bis108 ? rfidReaderChipR2000.rx000Setting.getQueryTarget() : rfidReaderChipE710.rx000Setting.getQueryTarget()), 0, 0, 0, "", 0, @@ -1974,59 +1970,59 @@ public boolean setSelectedTag1(boolean selectOne, String selectMask, int selectB } 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); + Logger.select("Debug_Select: RfidReader.setSelectedTag1 1 goes to setInvSelectIndex with i = {}", i); if (bis108) rfidReaderChipR2000.rx000Setting.setInvSelectIndex(i); else rfidReaderChipE710.rx000Setting.setInvSelectIndex(i); 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"); + Logger.select("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); + Logger.debug("setSelectCriteria after setSelectCriteria, setSuccess = {}", setSuccess); break; } } - if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectedTag1 2 goes to setInvSelectIndex with indexCurrent = " + indexCurrent); + Logger.select("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); - if (DEBUG) appendToLog("setSelectCriteria after setOnlyPowerLevel, setSuccess = " + setSuccess); + Logger.debug("setSelectCriteria after setOnlyPowerLevel, setSuccess = {}", setSuccess); if (false) { if (setSuccess) setSuccess = setFixedQParms(qValue, 5, false); - if (DEBUG) appendToLog("setSelectCriteria after setFixedQParms, setSuccess = " + setSuccess); + Logger.debug("setSelectCriteria after setFixedQParms, setSuccess = {}", setSuccess); if (setSuccess) setSuccess = (bis108 ? rfidReaderChipR2000.rx000Setting.setAlgoAbFlip(1) : rfidReaderChipE710.rx000Setting.setAlgoAbFlip(1)); - if (DEBUG) appendToLog("setSelectCriteria after setAlgoAbFlip, setSuccess = " + setSuccess); + Logger.debug("setSelectCriteria after setAlgoAbFlip, setSuccess = {}", setSuccess); if (setSuccess) setSuccess = setInvAlgo1(false); - if (DEBUG) appendToLog("setSelectCriteria after setInvAlgo1, setSuccess = " + setSuccess); + Logger.debug("setSelectCriteria after setInvAlgo1, setSuccess = {}", setSuccess); } - if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReader.setSelectTag1 goes to setMatchRep with matchRep = " + matchRep); + Logger.invCfg("Debug_InvCfg: RfidReader.setSelectTag1 goes to setMatchRep with matchRep = {}", matchRep); if (setSuccess) setSuccess = setMatchRep(matchRep); - if (DEBUG) appendToLog("setSelectCriteria after setMatchRep, setSuccess = " + setSuccess); + Logger.debug("setSelectCriteria after setMatchRep, setSuccess = {}", setSuccess); if (setSuccess) setSuccess = setTagDelay2RfidReader(tagDelayDefaultNormalSetting); - if (DEBUG) appendToLog("setSelectCriteria after setTagDelay, setSuccess = " + setSuccess); + Logger.debug("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 (utility.DEBUG_COMPACT) appendToLog("Debug_Compact 3: RfidReadder.setSelectedTag1 goes to setInvModeCompact"); + Logger.debug("setSelectCriteria after setCycleDelay, setSuccess = {}", setSuccess); + Logger.compact("Debug_Compact 3: RfidReadder.setSelectedTag1 goes to setInvModeCompact"); if (setSuccess) setSuccess = setInvModeCompact(false); - if (DEBUG) appendToLog("setSelectCriteria after setInvModeCompact, setSuccess = " + setSuccess); + Logger.debug("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"); + Logger.select("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"); + //Logger.trace("BtDataOut: RfidReader.setSelectTag"); //isValid = setSelectCriteriaDisable(-1); - appendToLog("BtDataOut: RfidReader.setSelectedTag short goes to setSelectedTag1"); + Logger.trace("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"); + Logger.select("Debug_Select: RfidReader.setSelectedTagByTID goes to setSelectedTag1"); return setSelectedTag1(false, selectMask, 2, 0, 0, pwrlevel, 0, 0); } @@ -2157,10 +2153,9 @@ public String regionCode2StringArray(@NonNull RegionCodes region) { } public RegionCodes regionCode = null; RegionCodes[] getRegionList1() { - boolean DEBUG = false; RegionCodes[] regionList = null; regionCode = null; - if (DEBUG) appendToLog("3 getCountryList: getCountryCode is " + getCountryCode()); + Logger.debug("3 getCountryList: getCountryCode is {}", getCountryCode()); switch (getCountryCode()) { case 1: RegionCodes RegionCodes; @@ -2187,7 +2182,7 @@ RegionCodes[] getRegionList1() { break; case 2: String strSpecialCountryVersion = getSpecialCountryVersion(); - if (DEBUG) appendToLog("3A getCountryList: getSpecialCountryVersion is [" + strSpecialCountryVersion + "]"); + Logger.debug("3A getCountryList: getSpecialCountryVersion is [{}]", strSpecialCountryVersion); if (strSpecialCountryVersion == null || (strSpecialCountryVersion != null && strSpecialCountryVersion.length() == 0)) { regionList = new RegionCodes[]{ RfidReader.RegionCodes.Bolivia, RfidReader.RegionCodes.Canada, RfidReader.RegionCodes.Mexico, RfidReader.RegionCodes.USA @@ -2257,18 +2252,17 @@ RegionCodes[] getRegionList1() { break; } int iValue = rfidReaderChipE710.rx000Setting.getCountryEnum(); - if (DEBUG) appendToLog("3b getCountryList: getCountryEnum is " + iValue); + Logger.debug("3b getCountryList: getCountryEnum is {}", iValue); if (iValue < 0) return null; iValue += RfidReader.RegionCodes.Albania1.ordinal() - 1; regionCode = RfidReader.RegionCodes.values()[iValue]; - if (DEBUG) appendToLog("3C getCountryList: regionCode is " + regionCode.toString()); + Logger.debug("3C getCountryList: regionCode is {}", regionCode); return regionList; } public final RegionCodes regionCodeDefault4Country2 = RegionCodes.FCC; public RegionCodes[] getRegionList() { if (bis108) { - boolean DEBUG = false; RegionCodes[] regionList = null; { switch (getCountryCode()) { @@ -2365,24 +2359,26 @@ public RegionCodes[] getRegionList() { break; } } - countryInList = 0; if (DEBUG) appendToLog("saveSetting2File testpoint 1"); + countryInList = 0; + Logger.debug("saveSetting2File testpoint 1"); for (int i = 0; i < regionList.length; i++) { if (regionCode == regionList[i]) { - countryInList = i; if (DEBUG) appendToLog("saveSetting2File testpoint 2"); break; + countryInList = i; + Logger.debug("saveSetting2File testpoint 2"); + break; } } if (countryInListDefault < 0) countryInListDefault = countryInList; - appendToLog("countryInListDefault = " + countryInListDefault); + Logger.trace("countryInListDefault = {}", countryInListDefault); return regionList; } else { - boolean DEBUG = false; RegionCodes[] regionList; regionCode = null; - if (DEBUG) appendToLog("2 getCountryList"); + Logger.debug("2 getCountryList"); regionList = getRegionList1(); - if (DEBUG) appendToLog("2A getCountryList: regionList is " + (regionList != null ? "Valid" : "null")); + Logger.debug("2A getCountryList: regionList is {}", regionList != null ? "Valid" : "null"); if (regionList != null) { - if (DEBUG) appendToLog(String.format("2b getCountryList: countryInList = %d, regionCode = %s", countryInList, (regionCode != null ? regionCode.toString() : ""))); + Logger.debug("2b getCountryList: countryInList = {}, regionCode = {}", countryInList, regionCode != null ? regionCode : ""); if (countryInList < 0) { if (regionCode == null) regionCode = regionList[0]; countryInList = 0; @@ -2394,7 +2390,7 @@ public RegionCodes[] getRegionList() { } if (countryInListDefault < 0) countryInListDefault = countryInList; regionCode = regionList[countryInList]; - if (DEBUG) appendToLog(String.format("2C getCountryList: countryInList = %d, regionCode = %s", countryInList, regionCode.toString())); + Logger.debug("2C getCountryList: countryInList = {}, regionCode = {}", countryInList, regionCode); } } else regionCode = null; return regionList; @@ -2402,7 +2398,7 @@ public RegionCodes[] getRegionList() { } public boolean getChannelHoppingDefault() { int countryCode = getCountryCode(); - appendToLog("getChannelHoppingDefault: countryCode (for channelOrderType) = " + countryCode); + Logger.trace("getChannelHoppingDefault: countryCode (for channelOrderType) = {}", countryCode); { if (countryCode == 1 || countryCode == 8 || countryCode == 9) return false; return true; @@ -2410,39 +2406,39 @@ public boolean getChannelHoppingDefault() { } 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); + Logger.debug("getCountryEnum 0x3014 = {}", iValue); if (iValue > 0 && iValue < countryChannelData.strCountryEnumInfo.length/countryChannelData.iCountryEnumInfoColumn) { - if (DEBUG) { + if (Logger.LEVEL.ordinal() >= Logger.LogLevel.DEBUG.ordinal()) { for (int i = 1; i <= 160; i++) { - 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] + Logger.debug("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 = countryChannelData.strCountryEnumInfo[(iValue - 1) * countryChannelData.iCountryEnumInfoColumn + 2]; - if (DEBUG) appendToLog("strCountryCode 0 = " + strCountryCode); + Logger.debug("strCountryCode 0 = {}", strCountryCode); String[] countryCodePart = strCountryCode.split(" "); strCountryCode = countryCodePart[0].substring(1); - if (DEBUG) appendToLog("strCountryCode 1 = " + strCountryCode); + Logger.debug("strCountryCode 1 = {}", strCountryCode); try { iCountrycode = Integer.decode(strCountryCode); - if (DEBUG) appendToLog("iCountrycode = " + iCountrycode); + Logger.debug("iCountrycode = {}", iCountrycode); } catch (Exception ex) { } } if (true) { int iCountrycode1 = rfidReaderChipE710.rx000Setting.getCountryEnumOem(); - if (DEBUG) appendToLog("getCountryEnumOem 0x5040 = " + iCountrycode1); + Logger.debug("getCountryEnumOem 0x5040 = {}", iCountrycode1); int iCountrycode2 = rfidReaderChipE710.rx000Setting.getCountryCodeOem(); - if (DEBUG) appendToLog("getCountryCodeOem 0xef98 = " + iCountrycode2); + Logger.debug("getCountryCodeOem 0xef98 = {}", iCountrycode2); if (iCountrycode < 0 && iCountrycode1 > 0 && iCountrycode1 < 10) iCountrycode = iCountrycode1; if (iCountrycode < 0 && iCountrycode2 > 0 && iCountrycode2 < 10) iCountrycode = iCountrycode2; } @@ -2450,9 +2446,8 @@ public int getCountryCode() { } public int getFreqModifyCode() { if (bis108) return rfidReaderChipR2000.rx000OemSetting.getFreqModifyCode(); - boolean DEBUG = false; int iFreqModifyCode = rfidReaderChipE710.rx000Setting.getFreqModifyCode(); - if (DEBUG) appendToLog("getFreqModifyCode 0xefb0 = " + iFreqModifyCode); + Logger.debug("getFreqModifyCode 0xefb0 = {}", iFreqModifyCode); return iFreqModifyCode; } public boolean getRfidOnStatus() { @@ -2486,20 +2481,19 @@ public String getMacVer() { return (bis108 ? rfidReaderChipR2000.rx000Setting.getMacVer() : rfidReaderChipE710.rx000Setting.getMacVer()); } public String getRadioSerial() { - boolean DEBUG = true; String strValue, strValue1; strValue = getSerialNumber(); if (bis108 == false) { - if (DEBUG) appendToLog("getSerialNumber 0xEF9C = " + strValue); + Logger.debug("getSerialNumber 0xEF9C = {}", strValue); strValue1 = getProductSerialNumber(); - if (DEBUG) appendToLog("getProductSerialNumber 0x5020 = " + strValue1); + Logger.debug("getProductSerialNumber 0x5020 = {}", strValue1); if (strValue1 != null && false) strValue = strValue1; } if (strValue != null) { - appendToLog("strValue length = " + strValue.length()); + Logger.trace("strValue length = {}", strValue.length()); if (strValue.length() >= 13) strValue = strValue.substring(0, 13); - } else appendToLog("BBB"); - if (DEBUG) appendToLog("strValue = " + strValue); + } else Logger.trace("BBB"); + Logger.debug("strValue = {}", strValue); return strValue; } public String getRadioBoardVersion() { @@ -2524,20 +2518,20 @@ public String getRadioBoardVersion() { public int getAntennaSelect() { int iValue = 0; iValue = (bis108 ? rfidReaderChipR2000.rx000Setting.getAntennaSelect() : rfidReaderChipE710.rx000Setting.getAntennaPort()); - appendToLog("AntennaSelect = " + iValue); + Logger.trace("AntennaSelect = {}", iValue); return iValue; } public boolean setAntennaSelect(int number) { boolean bValue = false; bValue = (bis108 ? rfidReaderChipR2000.rx000Setting.setAntennaSelect(number) : rfidReaderChipE710.rx000Setting.setAntennaSelect(number)); - appendToLog("AntennaSelect = " + number + " returning " + bValue); + Logger.trace("AntennaSelect = {} returning {}", number, bValue); return bValue; } public boolean getAntennaEnable() { - int iValue; boolean DEBUG = false; - if (DEBUG) appendToLog("1 getAntennaEnable"); + long iValue = 0; + Logger.debug("1 getAntennaEnable"); iValue = (bis108 ? rfidReaderChipR2000.rx000Setting.getAntennaEnable() : rfidReaderChipE710.rx000Setting.getAntennaEnable()); - if (DEBUG) appendToLog("1A getAntennaEnable: AntennaEnable = " + iValue); + Logger.debug("1A getAntennaEnable: AntennaEnable = {}", iValue); if (iValue > 0) return true; else return false; } @@ -2545,24 +2539,24 @@ public boolean setAntennaEnable(boolean enable) { int iEnable = 0; if (enable) iEnable = 1; boolean bValue = false; - appendToLog("1A setAntennaEnable: iEnable = " + iEnable); + Logger.trace("1A setAntennaEnable: iEnable = " + iEnable); bValue = (bis108 ? rfidReaderChipR2000.rx000Setting.setAntennaEnable(iEnable) : rfidReaderChipE710.rx000Setting.setAntennaEnable(iEnable)); - appendToLog("AntennaEnable = " + iEnable + " returning " + bValue); + Logger.trace("AntennaEnable = {} returning {}", iEnable, bValue); if (bValue && bis108 == false) bValue = rfidReaderChipE710.rx000Setting.updateCurrentPort(); return bValue; } public long getAntennaDwell() { - long lValue = 0; boolean DEBUG = false; - if (DEBUG) appendToLog("1 getAntennaDwell"); + long lValue = 0; + Logger.debug("1 getAntennaDwell"); lValue = (bis108 ? rfidReaderChipR2000.rx000Setting.getAntennaDwell() : rfidReaderChipE710.rx000Setting.getAntennaDwell()); - if (DEBUG) appendToLog("1A getAntennaDwell: lValue = " + lValue); + Logger.debug("1A getAntennaDwell: lValue = {}", lValue); return lValue; } public boolean setAntennaDwell(long antennaDwell) { - boolean bValue = false, DEBUG = false; - if (DEBUG) appendToLog("1 AntennaDwell = " + antennaDwell + " returning " + bValue); + boolean bValue = false; + Logger.debug("1 AntennaDwell = {} returning {}", antennaDwell, bValue); bValue = (bis108 ? rfidReaderChipR2000.rx000Setting.setAntennaDwell(antennaDwell) : rfidReaderChipE710.rx000Setting.setAntennaDwell(antennaDwell)); - if (DEBUG) appendToLog("1A AntennaDwell = " + antennaDwell + " returning " + bValue); + Logger.debug("1A AntennaDwell = {} returning {}", antennaDwell, bValue); return bValue; } public long getPwrlevel() { @@ -2575,26 +2569,26 @@ public boolean setPowerLevel(long pwrlevel) { pwrlevelSetting = pwrlevel; boolean bValue = false; bValue = (bis108 ? rfidReaderChipR2000.rx000Setting.setAntennaPower(pwrlevel) : rfidReaderChipE710.rx000Setting.setAntennaPower(pwrlevel)); - if (false) appendToLog("PowerLevel = " + pwrlevel + " returning " + bValue); + Logger.trace("PowerLevel = {} returning {}", pwrlevel, bValue); return bValue; } public int getQueryTarget() { - int iValue; boolean DEBUG = false; + int iValue; iValue = (bis108 ? rfidReaderChipR2000.rx000Setting.getAlgoAbFlip() : rfidReaderChipE710.rx000Setting.getQueryTarget()); - if (DEBUG) appendToLog("getQueryTarget with bis108 = " + bis108 + ", iValue = " + iValue); + Logger.debug("getQueryTarget with bis108 = {}, iValue = {}", bis108, iValue); if (bis108) { if (iValue > 0) { rfidReaderChipR2000.rx000Setting.getQueryTarget(); return 2; } else { - if (DEBUG) appendToLog("getQueryTarget"); + Logger.debug("getQueryTarget"); iValue = rfidReaderChipR2000.rx000Setting.getQueryTarget(); if (iValue > 0) return 1; return 0; } } else { - if (DEBUG) appendToLog("1A getQueryTarget: iValue = " + iValue); + Logger.debug("1A getQueryTarget: iValue = {}", iValue); if (iValue < 0) iValue = 0; return iValue; } @@ -2608,12 +2602,12 @@ public int getQuerySelect() { public boolean setTagGroup(int sL, int session, int target1) { if (bis108) { rfidReaderChipR2000.rx000Setting.setAlgoSelect(getInvAlgoInChip()); //Must not delete this line - if (false) appendToLog("RfidReader.setTagGroup[" + target1 + ", " + session + ", " + sL); + Logger.trace("RfidReader.setTagGroup[{}, {}, {}]", target1, session, sL); return rfidReaderChipR2000.rx000Setting.setQueryTarget(target1, session, sL); } else { - //appendToLog("1d"); + //Logger.trace("1d"); int iAlgoAbFlip = rfidReaderChipE710.rx000Setting.getAlgoAbFlip(); - appendToLog("sL = " + sL + ", session = " + session + ", target = " + target1 + ", getAlgoAbFlip = " + iAlgoAbFlip); + Logger.trace("sL = {}, session = {}, target = {}, getAlgoAbFlip = {}", sL, session, target1, iAlgoAbFlip); boolean bValue = false; bValue = rfidReaderChipE710.rx000Setting.setQueryTarget(target1, session, sL); if (bValue) { @@ -2673,11 +2667,10 @@ public int getInvAlgoInChip() { return (bis108 ? rfidReaderChipR2000.rx000Setting.getInvAlgo() : rfidReaderChipE710.rx000Setting.getInvAlgo()); } public boolean setInvAlgo(boolean dynamicAlgo) { - boolean DEBUG = false; - if (DEBUG) appendToLog("1 setInvAlgo with dynamicAlgo = " + dynamicAlgo); + Logger.debug("1 setInvAlgo with dynamicAlgo = {}", dynamicAlgo); boolean bValue = setInvAlgo1(dynamicAlgo); if (bValue) invAlgoSetting = dynamicAlgo; - if (DEBUG) appendToLog("1A setInvAlgo with bValue = " + bValue); + Logger.debug("1A setInvAlgo with bValue = {}", bValue); return bValue; } public List getProfileList() { @@ -2688,15 +2681,14 @@ public List getProfileList() { } public int getCurrentProfile() { if (bis108) return rfidReaderChipR2000.rx000Setting.getCurrentProfile(); - boolean DEBUG = false; - if (DEBUG) appendToLog("1 getCurrentProfile"); + Logger.debug("1 getCurrentProfile"); int iValue; if (true) { iValue = rfidReaderChipE710.rx000Setting.getCurrentProfile(); - if (DEBUG) appendToLog("1A getCurrentProfile: getCurrentProfile = " + iValue); + Logger.debug("1A getCurrentProfile: getCurrentProfile = {}", iValue); if (iValue > 0) { List profileList = getProfileList(); - if (DEBUG) appendToLog("1b getCurrentProfile: getProfileList = " + (profileList != null ? "valid" : "")); + Logger.debug("1b getCurrentProfile: getProfileList = {}", profileList != null ? "valid" : ""); int index = 0; for (; index < profileList.size(); index++) { if (Integer.valueOf(profileList.get(index).substring(0, profileList.get(index).indexOf(":"))) == iValue) @@ -2706,7 +2698,7 @@ public int getCurrentProfile() { index = profileList.size()-1; setCurrentLinkProfile(index); } - if (DEBUG) appendToLog("1C getCurrentProfile: index in the profileList = " + index); + Logger.debug("1C getCurrentProfile: index in the profileList = {}", index); iValue = index; } } @@ -2716,7 +2708,7 @@ public boolean setBasicCurrentLinkProfile() { if (bis108) return setCurrentLinkProfile(1); int profile = 244; if (getCountryCode() == 1) profile = 241; - appendToLog("profile is " + profile); + Logger.trace("profile is {}", profile); return rfidReaderChipE710.rx000Setting.setCurrentProfile(profile); } public boolean setCurrentLinkProfile(int profile) { @@ -2729,30 +2721,29 @@ public boolean setCurrentLinkProfile(int profile) { result = rfidReaderChipR2000.sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_UPDATELINKPROFILE); } if (result && profile == 3) { - appendToLog("It is profile3"); + Logger.trace("It is profile3"); if (getTagDelay() < 2) result = setTagDelay((byte) 2); } return result; } - boolean DEBUG = true; - if (DEBUG) appendToLog("1 setCurrentLinkProfile: input profile = " + profile); + Logger.debug("1 setCurrentLinkProfile: input profile = {}", profile); if (true && profile < 50) { List profileList = getProfileList(); if (profile < 0 || profile >= profileList.size()) return false; int profile1 = Integer.valueOf(profileList.get(profile).substring(0, profileList.get(profile).indexOf(":"))); profile = profile1; } - if (DEBUG) appendToLog("1A setCurrentLinkProfile: adjusted profile = " + profile); + Logger.debug("1A setCurrentLinkProfile: adjusted profile = {}", profile); boolean result = rfidReaderChipE710.rx000Setting.setCurrentProfile(profile); - if (DEBUG) appendToLog("1b setCurrentLinkProfile: after setCurrentProfile, result = " + result); + Logger.debug("1b setCurrentLinkProfile: after setCurrentProfile, result = {}", result); if (result) { setPwrManagementMode(false); } - if (DEBUG) appendToLog("1C setCurrentLinkProfile: after setPwrManagementMode, result = " + result + ", profile = " + profile); + Logger.debug("1C setCurrentLinkProfile: after setPwrManagementMode, result = {}, profile = {}", result, profile); if (result && profile == 3) { if (getTagDelay() < 2) result = setTagDelay((byte)2); } - if (DEBUG) appendToLog("1d setCurrentLinkProfile: after setTagDelay, result = " + result); + Logger.debug("1d setCurrentLinkProfile: after setTagDelay, result = {}", result); getCurrentProfile(); return result; } @@ -2891,20 +2882,19 @@ public int FreqChnCnt(RegionCodes regionCode) { return 0; } } else { - boolean DEBUG = true; int iFreqChnCnt = -1, iValue = -1; //mRfidDevice.mRfidReaderChip.mRfidReaderChip.mRx000Setting.getCountryEnum(); //iValue--; iValue = regionCode.ordinal() - RegionCodes.Albania1.ordinal() + 1; - if (DEBUG) appendToLog("regionCode = " + regionCode.toString() + ", regionCodeEnum = " + iValue); + Logger.debug("regionCode = {}, regionCodeEnum = {}", regionCode, iValue); if (iValue > 0) { String strFreqChnCnt = countryChannelData.strCountryEnumInfo[(iValue - 1) * countryChannelData.iCountryEnumInfoColumn + 3]; - if (DEBUG) appendToLog("strFreqChnCnt = " + strFreqChnCnt); + Logger.debug("strFreqChnCnt = {}", strFreqChnCnt); try { iFreqChnCnt = Integer.parseInt(strFreqChnCnt); } catch (Exception ex) { - appendToLog("!!! CANNOT parse strFreqChnCnt = " + strFreqChnCnt); + Logger.trace("!!! CANNOT parse strFreqChnCnt = {}", strFreqChnCnt); } } - if (DEBUG) appendToLog("iFreqChnCnt = " + iFreqChnCnt); + Logger.debug("iFreqChnCnt = {}", iFreqChnCnt); return iFreqChnCnt; //1 for hopping, 0 for fixed } } @@ -2918,18 +2908,17 @@ public double getLogicalChannel2PhysicalFreq(int channel) { return -1; return freqTable[freqIndex[channel]]; } - boolean DEBUG = false; - if (DEBUG) appendToLog("regionCode = " + regionCode.toString()); + Logger.debug("regionCode = {}", regionCode.toString()); int TotalCnt = FreqChnCnt(regionCode); - if (DEBUG) appendToLog("TotalCnt = " + TotalCnt); + Logger.debug("TotalCnt = {}", TotalCnt); int[] freqIndex = FreqIndex(regionCode); - if (DEBUG) appendToLog("Frequency index " + (freqIndex != null ? ("length = " + freqIndex.length) : "null")); + Logger.debug("Frequency index {}", freqIndex != null ? ("length = " + freqIndex.length) : "null"); double[] freqTable = GetAvailableFrequencyTable(regionCode); - if (DEBUG) appendToLog("Frequency freqTable " + (freqTable != null ? ("length = " + freqTable.length) : "null")); - if (DEBUG) appendToLog("Check TotalCnt = " + TotalCnt + ", freqIndex.length = " + freqIndex.length + ", freqTable.length = " + freqTable.length + ", channel = " + channel); + Logger.debug("Frequency freqTable {}", freqTable != null ? ("length = " + freqTable.length) : "null"); + Logger.debug("Check TotalCnt = {}, freqIndex.length = {}, freqTable.length = {}, channel = {}", TotalCnt, freqIndex.length, freqTable.length, channel); if (freqIndex.length != TotalCnt || freqTable.length != TotalCnt || channel >= TotalCnt) return -1; double dRetvalue = freqTable[freqIndex[channel]]; - if (DEBUG) appendToLog("channel = " + channel + ", dRetvalue = " + dRetvalue); + Logger.debug("channel = {}, dRetvalue = {}", channel, dRetvalue); return dRetvalue; } public byte getTagDelay() { @@ -2967,7 +2956,7 @@ public void getAuthenticateReplyLength() { else rfidReaderChipE710.rx000Setting.getAuthenticateReplyLength(); } public boolean setTamConfiguration(boolean header, String matchData) { - appendToLog("header = " + header + ", matchData.length = " + matchData.length() + ", matchData = " + matchData); + Logger.trace("header = {}, matchData.length = {}, matchData = {}", header, matchData.length(), matchData); if (matchData == null) matchData = ""; if (matchData.length() != 12) return false; boolean retValue = false; String preChallenge = matchData.substring(0, 2); @@ -2977,34 +2966,34 @@ public boolean setTamConfiguration(boolean header, String matchData) { else iValue &= ~0x04; preChallenge = String.format("%02X", iValue); matchData = preChallenge + matchData.substring(2); - appendToLog("new matchData = " + matchData); + Logger.trace("new matchData = {}", matchData); if (bis108) { retValue = setAuthMatchData(matchData); - appendToLog("setAuthMatchData returns " + retValue); + Logger.trace("setAuthMatchData returns {}", retValue); if (retValue) { retValue = rfidReaderChipR2000.rx000Setting.setHST_AUTHENTICATE_CFG(true, true, 1, matchData.length() * 4); - appendToLog("setHST_AUTHENTICATE_CFG returns " + retValue); + Logger.trace("setHST_AUTHENTICATE_CFG returns {}", retValue); } return retValue; } else { boolean bValue = rfidReaderChipE710.rx000Setting.setAuthenticateConfig(((matchData.length() * 4) << 10) | (1 << 2) | 0x03); - appendToLog("setAuthenticateConfiguration 1 revised matchData = " + matchData + " with bValue = " + (bValue ? "true" : "false")); - appendToLog("revised bytes = " + utility.byteArrayToString(utility.string2ByteArray(matchData))); + Logger.trace("setAuthenticateConfiguration 1 revised matchData = {} with bValue = {}", matchData, bValue ? "true" : "false"); + Logger.trace("revised bytes = {}", utility.byteArrayToString(utility.string2ByteArray(matchData))); if (bValue) { bValue = rfidReaderChipE710.rx000Setting.setAuthenticateMessage(utility.string2ByteArray(matchData)); - appendToLog("setAuthenticateConfiguration 2: bValue = " + (bValue ? "true" : "false")); + Logger.trace("setAuthenticateConfiguration 2: bValue = {}", bValue ? "true" : "false"); } if (bValue) { int iLength = 8 * 8; if (header) iLength = 16 * 8; bValue = rfidReaderChipE710.rx000Setting.setAuthenticateResponseLen(iLength); - appendToLog("setAuthenticateConfiguration 3: bValue = " + (bValue ? "true" : "false")); + Logger.trace("setAuthenticateConfiguration 3: bValue = {}", bValue ? "true" : "false"); } return bValue; } } public boolean setTam1Configuration(int keyId, String matchData) { - appendToLog("keyId = " + keyId + ", matchData = " + matchData); + Logger.trace("keyId = {}, matchData = {}", keyId, matchData); if (keyId > 255) return false; if (matchData == null) matchData = ""; if (matchData.length() != 20) return false; @@ -3014,16 +3003,16 @@ public boolean setTam1Configuration(int keyId, String matchData) { matchData = preChallenge + matchData; if (bis108) { retValue = setAuthMatchData(matchData); - appendToLog("setAuthMatchData returns " + retValue); + Logger.trace("setAuthMatchData returns {}", retValue); if (retValue) { retValue = rfidReaderChipR2000.rx000Setting.setHST_AUTHENTICATE_CFG(true, true, 0, matchData.length() * 4); - appendToLog("setHST_AUTHENTICATE_CFG returns " + retValue); + Logger.trace("setHST_AUTHENTICATE_CFG returns {}", retValue); } return retValue; } else { boolean bValue = rfidReaderChipE710.rx000Setting.setAuthenticateConfig(((matchData.length() * 4) << 10) | (0 << 2) | 0x03); - appendToLog("setAuthenticateConfiguration 1 revised matchData = " + matchData + " with bValue = " + (bValue ? "true" : "false")); - appendToLog("revised bytes = " + utility.byteArrayToString(utility.string2ByteArray(matchData))); + Logger.trace("setAuthenticateConfiguration 1 revised matchData = {} with bValue = {}", matchData, bValue ? "true" : "false"); + Logger.trace("revised bytes = {}", utility.byteArrayToString(utility.string2ByteArray(matchData))); if (bValue) { if (true) bValue = rfidReaderChipE710.rx000Setting.setAuthenticateMessage(utility.string2ByteArray(matchData)); @@ -3032,11 +3021,11 @@ public boolean setTam1Configuration(int keyId, String matchData) { 0, 0, (byte) 0xFD, (byte) 0x5D, (byte) 0x80, 0x48, (byte) 0xF4, (byte) 0x8D, (byte) 0xD0, (byte) 0x9A, (byte) 0xAD, 0x22}); - appendToLog("setAuthenticateConfiguration 2: bValue = " + (bValue ? "true" : "false")); + Logger.trace("setAuthenticateConfiguration 2: bValue = {}", bValue ? "true" : "false"); } if (bValue) { bValue = rfidReaderChipE710.rx000Setting.setAuthenticateResponseLen(16 * 8); - appendToLog("setAuthenticateConfiguration 3: bValue = " + (bValue ? "true" : "false")); + Logger.trace("setAuthenticateConfiguration 3: bValue = {}", bValue ? "true" : "false"); } return bValue; } @@ -3067,8 +3056,8 @@ public boolean setTam2Configuration(int keyId, String matchData, int profile, in return retValue; } else { boolean bValue = rfidReaderChipE710.rx000Setting.setAuthenticateConfig(((matchData.length() * 4) << 10) | (0 << 2) | 0x03); - appendToLog("setAuthenticateConfiguration 1 revised matchData = " + matchData + " with bValue = " + (bValue ? "true" : "false")); - appendToLog("revised bytes = " + utility.byteArrayToString(utility.string2ByteArray(matchData))); + Logger.trace("setAuthenticateConfiguration 1 revised matchData = {} with bValue = {}", matchData, bValue ? "true" : "false"); + Logger.trace("revised bytes = {}", utility.byteArrayToString(utility.string2ByteArray(matchData))); if (bValue) { if (true) bValue = rfidReaderChipE710.rx000Setting.setAuthenticateMessage(utility.string2ByteArray(matchData)); @@ -3077,13 +3066,13 @@ public boolean setTam2Configuration(int keyId, String matchData, int profile, in 0, 0, (byte) 0xFD, (byte) 0x5D, (byte) 0x80, 0x48, (byte) 0xF4, (byte) 0x8D, (byte) 0xD0, (byte) 0x9A, (byte) 0xAD, 0x22}); - appendToLog("setAuthenticateConfiguration 2: bValue = " + (bValue ? "true" : "false")); + Logger.trace("setAuthenticateConfiguration 2: bValue = {}", bValue ? "true" : "false"); } if (bValue) { int iSize = 32; if (protMode > 2) iSize = 44; bValue = rfidReaderChipE710.rx000Setting.setAuthenticateResponseLen(iSize * 8); - appendToLog("setAuthenticateConfiguration 3: protMode = " + protMode + ", bValue = " + (bValue ? "true" : "false")); + Logger.trace("setAuthenticateConfiguration 3: protMode = {}, bValue = {}", protMode, bValue ? "true" : "false"); } return bValue; } @@ -3104,21 +3093,21 @@ public boolean setAuthenticateConfiguration() { if (bis108) { if (bValue) { bValue = rfidReaderChipR2000.rx000Setting.setAuthMatchData("049CA53E55EA"); //setAuthenticateMessage(new byte[] { 0x04, (byte)0x9C, (byte)0xA5, 0x3E, 0x55, (byte)0xEA } ); - appendToLog("setAuthenuateConfiguration 2: bValue = " + (bValue ? "true" : "false")); + Logger.trace("setAuthenuateConfiguration 2: bValue = {}", bValue ? "true" : "false"); } /*if (bValue) { bValue = mRfidDevice.mRfidReaderChip.mRfidReaderChip.mRx000Setting.setAuthenticateResponseLen(16 * 8); - appendToLog("setAuthenuateConfiguration 3: bValue = " + (bValue ? "true" : "false")); + Logger.trace("setAuthenuateConfiguration 3: bValue = " + (bValue ? "true" : "false")); }*/ return false; //bValue; } else { if (bValue) { bValue = rfidReaderChipE710.rx000Setting.setAuthenticateMessage(new byte[]{0x04, (byte) 0x9C, (byte) 0xA5, 0x3E, 0x55, (byte) 0xEA}); - appendToLog("setAuthenticateConfiguration 2: bValue = " + (bValue ? "true" : "false")); + Logger.trace("setAuthenticateConfiguration 2: bValue = {}", bValue ? "true" : "false"); } if (bValue) { bValue = rfidReaderChipE710.rx000Setting.setAuthenticateResponseLen(16 * 8); - appendToLog("setAuthenticateConfiguration 3: bValue = " + (bValue ? "true" : "false")); + Logger.trace("setAuthenticateConfiguration 3: bValue = {}", bValue ? "true" : "false"); } return bValue; } @@ -3166,23 +3155,23 @@ public String getSelectMaskData() { if (strValue == null) return null; int strLength = iValue1 / 4; if (strLength * 4 != iValue1) strLength++; - if (false) appendToLog("Mask data = iValue1 = " + iValue1 + ", strValue = " + strValue + ", strLength = " + strLength); + Logger.trace("Mask data = iValue1 = {}, strValue = {}, strLength = {}", iValue1, strValue, strLength); if (strValue.length() < strLength) strLength = strValue.length(); return strValue.substring(0, strLength); } public boolean setInvSelectIndex(int invSelect) { - if (false) appendToLog("BtDataOut: RfidReader.setSelectIndex goes to setInvSelectIndex"); + Logger.trace("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); + Logger.trace("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); + Logger.trace("cs710Library4A: setSelectCriteria 1 with New index = {}", iValue); break; } } @@ -3191,7 +3180,7 @@ public int findFirstEmptySelect() { 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"); + Logger.select("Debug_Select: RfidReader.setSelectCriteriaDisable[{}] goes to setSelectCriteria", index); boolean bValue = false; if (index < 0) { for (int i = 0; i < 3; i++) { @@ -3209,10 +3198,11 @@ 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, maskbit); if (index < 0) index = findFirstEmptySelect(); if (index < 0) { - appendToLog("cs710Library4A: no index is available !!!"); return false; + Logger.trace("cs710Library4A: no index is available !!!"); + return false; } - appendToLog("mask = " + mask + ", maskbit = " + maskbit); + Logger.trace("mask = {}, maskbit = {}", mask, maskbit); if (mask == null) mask = ""; int maskblen = mask.length() * 4; String maskHex = ""; int iHex = 0; @@ -3232,19 +3222,19 @@ public boolean setSelectCriteria(int index, boolean enable, int target, int acti maskblen = mask.length(); mask = maskHex; } - if (false) appendToLog("RfidReader.setSelectCriteria goes to setSelectCriteria3"); + Logger.trace("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]); + Logger.select("Debug_Select: RfidReader.setSelectCriteria with index = {}, enable = {}, bSelectedEnable[{}] = {}", index, enable, index, bSelectEnabled[index]); if (bis108) { if (!enable) { if (bSelectEnabled[index] == enable) return true; } - if (false) appendToLog("cs108Library4A: setSelectCriteria 2 with index = " + index + ", enable = " + enable + ", target = " + target + ", action = " + action + ", delay = " + delay + ", bank = " + bank + ", offset = " + offset + ", mask = " + mask); + Logger.trace("cs108Library4A: setSelectCriteria 2 with index = {}, enable = {}, target = {}, action = {}, delay = {}, bank = {}, offset = {}, mask = {}", index, enable, target, action, delay, bank, offset, mask); if (index < 0) index = findFirstEmptySelect(); if (index < 0) { - appendToLog("cs710Library4A: no index is available !!!"); + Logger.trace("cs710Library4A: no index is available !!!"); return false; } @@ -3256,14 +3246,14 @@ public boolean setSelectCriteria(int index, boolean enable, int target, int acti 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 (false) appendToLog("RfidReader.setSelectCriteria goes to setInvSelectIndex"); + Logger.trace("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); + Logger.trace("cs108Library4A: setSelectCriteria 2: no need to set as when index = {}, getSelectEnable() = {}, new enable = {}", index, rfidReaderChipR2000.rx000Setting.getSelectEnable(), enable); result = true; } else { - if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReader.setSelectCriteria goes to setSelectEnable with result = " + result); + Logger.select("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); @@ -3272,7 +3262,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); + Logger.trace("RfidReader.setSelectCriteria with result = {}, enable = {}", result, enable); if (result) { if (enable) { rfidReaderChipR2000.rx000Setting.setTagSelect(1); @@ -3288,22 +3278,23 @@ public boolean setSelectCriteria(int index, boolean enable, int target, int acti } return result; } else { - boolean bValue = false, DEBUG = false; - appendToLog("cs710Library4A: setSelectCriteria 2 with index = " + index + ", enable = " + enable + ", target = " + target + ", action = " + action + ", delay = " + delay + ", bank = " + bank + ", offset = " + offset + ", mask = " + mask); + boolean bValue = false; + Logger.trace("cs710Library4A: setSelectCriteria 2 with index = {}, enable = {}, target = {}, action = {}, delay = {}, bank = {}, offset = {}, mask = {}", index, enable, target, action, delay, bank, offset, mask); if (index < 0) index = findFirstEmptySelect(); if (index < 0) { - appendToLog("cs710Library4A: no index is available !!!"); return false; + Logger.trace("cs710Library4A: no index is available !!!"); + return false; } - if (rfidReaderChipE710.rx000Setting.selectConfiguration[index] == null) appendToLog("CANNOT continue as selectConfiguration[" + index + "] is null !!!"); + if (rfidReaderChipE710.rx000Setting.selectConfiguration[index] == null) Logger.trace("CANNOT continue as selectConfiguration[{}] is null !!!", index); else if (rfidReaderChipE710.rx000Setting.selectConfiguration[index][0] != 0 || enable != false) { - if (DEBUG) appendToLog("0 selectConfiguration[" + index + "] = " + utility.byteArrayToString(rfidReaderChipE710.rx000Setting.selectConfiguration[index])); + Logger.debug("0 selectConfiguration[{}] = {}", index, utility.byteArrayToString(rfidReaderChipE710.rx000Setting.selectConfiguration[index])); byte[] byteArrayMask = null; if (mask != null) byteArrayMask = utility.string2ByteArray(mask); bValue = rfidReaderChipE710.rx000Setting.setSelectConfiguration(index, enable, bank, offset, byteArrayMask, target, action, delay); - if (DEBUG) appendToLog("0 selectConfiguration[" + index + "] = " + utility.byteArrayToString(rfidReaderChipE710.rx000Setting.selectConfiguration[index])); + Logger.debug("0 selectConfiguration[{}] = {}", index, utility.byteArrayToString(rfidReaderChipE710.rx000Setting.selectConfiguration[index])); } else { - appendToLog("cs710Library4A: setSelectCriteria 2: no need to set as old selectConfiguration[" + index + "][0] = " + rfidReaderChipE710.rx000Setting.selectConfiguration[index][0] + ", new enable = " + enable); + Logger.trace("cs710Library4A: setSelectCriteria 2: no need to set as old selectConfiguration[{}][0] = {}, new enable = {}", index, rfidReaderChipE710.rx000Setting.selectConfiguration[index][0], enable); bValue = true; } return bValue; @@ -3350,23 +3341,23 @@ public double getRssiFilterThreshold1() { } public double getRssiFilterThreshold2() { int iValue = (bis108 ? rfidReaderChipR2000.rx000Setting.getRssiFilterThreshold2() : rfidReaderChipE710.rx000Setting.getRssiFilterThreshold2()); - appendToLog("iValue = " + iValue); + Logger.trace("iValue = {}", iValue); byte byteValue = (byte)(iValue & 0xFF); double dValue = (bis108 ? rfidReaderChipR2000.decodeNarrowBandRSSI(byteValue) : rfidReaderChipE710.decodeNarrowBandRSSI(byteValue)); return dValue; } public boolean setRssiFilterThreshold(double rssiFilterThreshold1, double rssiFilterThreshold2) { if (bis108) { - appendToLog("rssiFilterThreshold = " + rssiFilterThreshold1 + ", " + rssiFilterThreshold2); + Logger.trace("rssiFilterThreshold = {}, {}", rssiFilterThreshold1, rssiFilterThreshold2); return rfidReaderChipR2000.rx000Setting.setHST_INV_RSSI_FILTERING_THRESHOLD(rfidReaderChipR2000.encodeNarrowBandRSSI(rssiFilterThreshold1), rfidReaderChipR2000.encodeNarrowBandRSSI(rssiFilterThreshold2)); } else { - appendToLog("rssiFilterThreshold = " + rssiFilterThreshold1 + ", rssiFilterThreshold2 = " + rssiFilterThreshold2); + Logger.trace("rssiFilterThreshold = {}, rssiFilterThreshold2 = {}", rssiFilterThreshold1, rssiFilterThreshold2); rssiFilterThreshold1 -= dBuV_dBm_constant; rssiFilterThreshold2 -= dBuV_dBm_constant; - appendToLog("After adjustment, rssiFilterThreshold = " + rssiFilterThreshold1 + ", rssiFilterThreshold2 = " + rssiFilterThreshold2); + Logger.trace("After adjustment, rssiFilterThreshold = {}, rssiFilterThreshold2 = {}", rssiFilterThreshold1, rssiFilterThreshold2); rssiFilterThreshold1 *= 100; rssiFilterThreshold2 *= 100; - appendToLog("After multiplication, rssiFilterThreshold = " + rssiFilterThreshold1 + ", rssiFilterThreshold2 = " + rssiFilterThreshold2); + Logger.trace("After multiplication, rssiFilterThreshold = {}, rssiFilterThreshold2 = {}", rssiFilterThreshold1, rssiFilterThreshold2); return rfidReaderChipE710.rx000Setting.setHST_INV_RSSI_FILTERING_THRESHOLD((int) rssiFilterThreshold1, (int) rssiFilterThreshold2); } } @@ -3374,7 +3365,7 @@ public long getRssiFilterCount() { return (bis108 ? rfidReaderChipR2000.rx000Setting.getRssiFilterCount() : rfidReaderChipE710.rx000Setting.getRssiFilterCount()); } public boolean setRssiFilterCount(long rssiFilterCount) { - appendToLog("rssiFilterCount = " + rssiFilterCount); + Logger.trace("rssiFilterCount = {}", rssiFilterCount); return (bis108 ? rfidReaderChipR2000.rx000Setting.setHST_INV_RSSI_FILTERING_COUNT(rssiFilterCount) : rfidReaderChipE710.rx000Setting.setHST_INV_RSSI_FILTERING_COUNT(rssiFilterCount)); } public boolean getInvMatchEnable() { @@ -3397,25 +3388,24 @@ public String getInvMatchData() { return strValue.substring(0, strLength); } String getSpecialCountryVersion() { - boolean DEBUG = false; if (bis108) return rfidReaderChipR2000.rx000OemSetting.getSpecialCountryVersion(); String strSpecialCountryCode = null; int iValue = rfidReaderChipE710.rx000Setting.getCountryEnum(); - if (DEBUG) appendToLog("getCountryEnum 0x3014 = " + iValue); + Logger.debug("getCountryEnum 0x3014 = {}", iValue); if (iValue > 0 && iValue < countryChannelData.strCountryEnumInfo.length/countryChannelData.iCountryEnumInfoColumn) { String strCountryCode = countryChannelData.strCountryEnumInfo[(iValue - 1) * countryChannelData.iCountryEnumInfoColumn + 2]; - if (DEBUG) appendToLog("strCountryCode 0 = " + strCountryCode); + Logger.debug("strCountryCode 0 = {}", strCountryCode); String[] countryCodePart = strCountryCode.split(" "); - if (DEBUG) appendToLog("countryCodePart.length = " + countryCodePart.length); + Logger.debug("countryCodePart.length = {}", countryCodePart.length); if (countryCodePart.length >= 2) strSpecialCountryCode = countryCodePart[1]; else strSpecialCountryCode = ""; - if (DEBUG) appendToLog("strSpecialCountryCode = " + strSpecialCountryCode); + Logger.debug("strSpecialCountryCode = {}", strSpecialCountryCode); } if (true) { String strValue = rfidReaderChipE710.rx000Setting.getSpecialCountryCodeOem(); - if (DEBUG) appendToLog("getCountryCodeOem 0xefac = " + strValue); + Logger.debug("getCountryCodeOem 0xefac = {}", strValue); if (strSpecialCountryCode == null && strValue != null) { - if (DEBUG) appendToLog("strSpecialCountryCode is replaced with countryCodeOem"); + Logger.debug("strSpecialCountryCode is replaced with countryCodeOem"); strSpecialCountryCode = strValue; } } @@ -3446,7 +3436,7 @@ public int mrfidToWriteSize() { } public void mrfidToWritePrint() { for (int i = 0; i < mRfidToWrite.size(); i++) { - appendToLog(utility.byteArrayToString(mRfidToWrite.get(i).dataValues)); + Logger.trace(utility.byteArrayToString(mRfidToWrite.get(i).dataValues)); } } public long getTagRate() { @@ -3459,7 +3449,7 @@ 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()); + Logger.compact("Debug_Compact 0: RfidReadder.startOperation operationTypes is " + operationTypes.toString()); if (operationTypes == RfidReaderChipData.OperationTypes.TAG_INVENTORY_COMPACT) { setTagDelay2RfidReader(0); setMatchRep(0); if (false && tagFocus >= 1) { @@ -3471,7 +3461,7 @@ public boolean startOperation(RfidReaderChipData.OperationTypes operationTypes) rfidReaderChipE710.rx000Setting.setAntennaDwell(2000); } } - if (utility.DEBUG_COMPACT) appendToLog("Debug_Compact 4: RfidReadder.startOperation goes to setInvModeCompact"); + Logger.compact("Debug_Compact 4: RfidReadder.startOperation goes to setInvModeCompact"); setInvModeCompact(true); } else { setTagDelay2RfidReader(tagDelayDefaultNormalSetting); @@ -3481,7 +3471,7 @@ public boolean startOperation(RfidReaderChipData.OperationTypes operationTypes) rfidReaderChipE710.rx000Setting.setCycleDelay(cycleDelaySetting); } setInvModeCompact(false); - if (utility.DEBUG_COMPACT) appendToLog("Debug_Compact 5: RfidReadder.startOperation goes to setInvModeCompact"); + Logger.compact("Debug_Compact 5: RfidReadder.startOperation goes to setInvModeCompact"); if (operationTypes == RfidReaderChipData.OperationTypes.TAG_SEARCHING && bis108 == false) rfidReaderChipE710.rx000Setting.setDupElimRollWindow((byte)0); } if (bis108) { @@ -3489,7 +3479,7 @@ public boolean startOperation(RfidReaderChipData.OperationTypes operationTypes) notificationConnector.setAutoRFIDAbort(true); notificationConnector.getAutoRFIDAbort(); rfidReaderChipR2000.setPwrManagementMode(false); - appendToLog("going to sendHostRegRequestHST_CMD(Cs108Library4A.HostCommands.CMD_18K6CINV)"); + Logger.trace("going to sendHostRegRequestHST_CMD(Cs108Library4A.HostCommands.CMD_18K6CINV)"); retValue = true; RfidReaderChipData.HostCommands hostCommand = RfidReaderChipData.HostCommands.CMD_18K6CINV; @@ -3499,12 +3489,12 @@ public boolean startOperation(RfidReaderChipData.OperationTypes operationTypes) rfidReaderChipE710.rx000Setting.setEventPacketUplinkEnable((byte)0x09); rfidReaderChipE710.setPwrManagementMode(false); RfidReaderChipData.HostCommands hostCommands = RfidReaderChipData.HostCommands.CMD_18K6CINV; - appendToLog("BtData: tagFocus = " + rfidReaderChipE710.rx000Setting.getImpinjExtension()); + Logger.trace("BtData: tagFocus = {}", rfidReaderChipE710.rx000Setting.getImpinjExtension()); boolean bTagFocus = ((rfidReaderChipE710.rx000Setting.getImpinjExtension() & 0x04) != 0); - appendToLog("0 OperationTypes = " + operationTypes.toString() + ", hostCommands = " + hostCommands.toString() + ", bTagFocus = " + bTagFocus); + Logger.trace("0 OperationTypes = {}, hostCommands = {}, bTagFocus = {}", operationTypes, hostCommands, bTagFocus); if (operationTypes == RfidReaderChipData.OperationTypes.TAG_INVENTORY_COMPACT) hostCommands = RfidReaderChipData.HostCommands.CMD_18K6CINV_COMPACT; else if (rfidReaderChipE710.rx000Setting.getTagRead() != 0 && bTagFocus == false) hostCommands = RfidReaderChipData.HostCommands.CMD_18K6CINV_MB; - appendToLog("1 OperationTypes = " + operationTypes.toString() + ", hostCommands = " + hostCommands.toString()); + Logger.trace("1 OperationTypes = {}, hostCommands = {}", operationTypes, hostCommands); retValue = rfidReaderChipE710.sendHostRegRequestHST_CMD(hostCommands); break; } @@ -3536,34 +3526,28 @@ public int getCountryNumberInList() { } public boolean setCountryInList(int countryInList) { if (bis108) { - boolean DEBUG = true; - if (DEBUG) - appendToLog("this.countryInList =" + this.countryInList + ", countryInList = " + countryInList); + Logger.debug("this.countryInList ={}, countryInList = {}", this.countryInList, countryInList); if (this.countryInList == countryInList) return true; RegionCodes[] regionList = getRegionList(); - if (DEBUG) - appendToLog("regionList length =" + (regionList == null ? "NULL" : regionList.length)); + Logger.debug("regionList length ={}", regionList == null ? "NULL" : regionList.length); if (regionList == null) return false; if (countryInList < 0 || countryInList >= regionList.length) return false; int[] freqDataTableOld = FreqTable(regionCode); - if (DEBUG) - appendToLog("regionCode =" + regionCode + ", freqDataTableOld length = " + (freqDataTableOld == null ? "NULL" : freqDataTableOld.length)); + Logger.debug("regionCode ={}, freqDataTableOld length = {}", regionCode, freqDataTableOld == null ? "NULL" : freqDataTableOld.length); if (freqDataTableOld == null) return false; RegionCodes regionCodeNew = regionList[countryInList]; final int[] freqDataTable = FreqTable(regionCodeNew); - if (DEBUG) - appendToLog("regionCodeNew =" + regionCodeNew + ", freqDataTable length = " + (freqDataTable == null ? "NULL" : freqDataTable.length)); + Logger.debug("regionCodeNew ={}, freqDataTable length = {}", regionCodeNew, freqDataTable == null ? "NULL" : freqDataTable.length); if (freqDataTable == null) return false; this.countryInList = countryInList; - appendToLog("saveSetting2File testpoint 4"); + Logger.trace("saveSetting2File testpoint 4"); regionCode = regionCodeNew; - if (DEBUG) - appendToLog("getChannel =" + getChannel() + ", FreqChnCnt = " + FreqChnCnt()); - appendToLog("X channel = "); + Logger.debug("getChannel ={}, FreqChnCnt = {}", getChannel(), FreqChnCnt()); + Logger.trace("X channel = "); if (getChannel() >= FreqChnCnt()) setChannel(0); switch (getCountryCode()) { case 1: @@ -3573,7 +3557,7 @@ public boolean setCountryInList(int countryInList) { break; case 2: if (false && regionCode == regionCodeDefault4Country2) { - if (DEBUG) appendToLog("FCC Region is set"); + Logger.debug("FCC Region is set"); // toggledConnection = false; // mHandler.removeCallbacks(runnableToggleConnection); // mHandler.postDelayed(runnableToggleConnection, 500); @@ -3586,33 +3570,31 @@ public boolean setCountryInList(int countryInList) { if (freqDataTable[i] != freqDataTableOld[i]) break; } if (i == freqDataTable.length) { - if (DEBUG) appendToLog("Break as same freqDataTable"); + Logger.debug("Break as same freqDataTable"); break; } } - if (DEBUG) appendToLog("Finish as different freqDataTable"); + Logger.debug("Finish as different freqDataTable"); int k = 0; for (; k < freqDataTable.length; k++) { - if (DEBUG) appendToLog("Setting channel = " + k); + Logger.debug("Setting channel = {}", k); rfidReaderChipR2000.rx000Setting.setFreqChannelSelect(k); rfidReaderChipR2000.rx000Setting.setFreqChannelConfig(true); rfidReaderChipR2000.rx000Setting.setFreqPllMultiplier(freqDataTable[k]); } for (; k < 50; k++) { - if (DEBUG) appendToLog("Resetting channel = " + k); + Logger.debug("Resetting channel = {}", k); rfidReaderChipR2000.rx000Setting.setFreqChannelSelect(k); rfidReaderChipR2000.rx000Setting.setFreqChannelConfig(false); } break; } - if (DEBUG) - appendToLog("New regionCode = " + regionCode.toString() + ", channel = " + getChannel() + ", FreqChnCnt = " + FreqChnCnt()); + Logger.debug("New regionCode = {}, channel = {} FreqChnCnt = {}", regionCode.toString(), getChannel(), FreqChnCnt()); return true; } else { - boolean DEBUG = true; if (this.countryInList == countryInList) return true; - if (DEBUG) appendToLog("1 setCountryInList with countryInList = " + countryInList); + Logger.debug("1 setCountryInList with countryInList = {}", countryInList); RegionCodes[] regionList = getRegionList(); if (regionList == null) return false; @@ -3630,39 +3612,39 @@ public boolean setCountryInList(int countryInList) { boolean bValue = false; if (i < indexEnd + 1) { - appendToLog("countryEnum: i = " + i + ", indexEnd = " + indexEnd); + Logger.trace("countryEnum: i = {}, indexEnd = {}", i, indexEnd); bValue = rfidReaderChipE710.rx000Setting.setCountryEnum((short)(i - indexBegin + 1)); if (bValue) { this.countryInList = countryInList; channelOrderType = -1; } } - if (DEBUG) appendToLog("1A setCountryInList with bValue = " + bValue); + Logger.debug("1A setCountryInList with bValue = {}", bValue); return bValue; } } public int channelOrderType; // 0 for frequency hopping / agile, 1 for fixed frequencey public boolean getChannelHoppingStatus() { if (bis108) { - appendToLog("countryCode with channelOrderType = " + channelOrderType); + Logger.trace("countryCode with channelOrderType = {}", channelOrderType); if (channelOrderType < 0) { if (getChannelHoppingDefault()) channelOrderType = 0; else channelOrderType = 1; } return (channelOrderType == 0 ? true : false); } else { - boolean bValue = false, DEBUG = false; + boolean bValue = false; int iValue = rfidReaderChipE710.rx000Setting.getCountryEnum(); //iValue--; - if (DEBUG) appendToLog("getChannelHoppingStatus: countryEnum = " + iValue); + Logger.debug("getChannelHoppingStatus: countryEnum = {}", iValue); if (iValue > 0) { String strFixedHop = countryChannelData.strCountryEnumInfo[(iValue - 1) * countryChannelData.iCountryEnumInfoColumn + 4]; - if (DEBUG) appendToLog("getChannelHoppingStatus: FixedHop = " + strFixedHop); + Logger.debug("getChannelHoppingStatus: FixedHop = {}", strFixedHop); if (strFixedHop.matches("Hop")) { - if (DEBUG) appendToLog("getChannelHoppingStatus: matched"); + Logger.debug("getChannelHoppingStatus: matched"); bValue = true; } } - if (DEBUG) appendToLog("getChannelHoppingStatus: bValue = " + bValue); + Logger.debug("getChannelHoppingStatus: bValue = {}", bValue); return bValue; //1 for hopping, 0 for fixed } } @@ -3674,9 +3656,9 @@ public boolean setChannelHoppingStatus(boolean channelOrderHopping) { result = rfidReaderChipR2000.rx000Setting.setAntennaFreqAgile(channelOrderHopping ? 1 : 0); } int freqcnt = FreqChnCnt(); - appendToLog("FrequencyA Count = " + freqcnt); + Logger.trace("FrequencyA Count = {}", freqcnt); int channel = getChannel(); - appendToLog(" FrequencyA Channel = " + channel); + Logger.trace(" FrequencyA Channel = {}", channel); for (int i = 0; i < freqcnt; i++) { if (result == true) rfidReaderChipR2000.rx000Setting.setFreqChannelSelect(i); if (result == true) rfidReaderChipR2000.rx000Setting.setFreqChannelConfig(channelOrderHopping); @@ -3688,50 +3670,49 @@ public boolean setChannelHoppingStatus(boolean channelOrderHopping) { if (getChannelHoppingDefault() == false) { result = rfidReaderChipE710.rx000Setting.setAntennaFreqAgile(channelOrderHopping ? 1 : 0); } - int freqcnt = FreqChnCnt(); appendToLog("FrequencyA Count = " + freqcnt); - int channel = getChannel(); appendToLog(" FrequencyA Channel = " + channel); + int freqcnt = FreqChnCnt(); Logger.trace("FrequencyA Count = {}", freqcnt); + int channel = getChannel(); Logger.trace(" FrequencyA Channel = {}", channel); } - appendToLog(" FrequencyA: end of setting"); + Logger.trace(" FrequencyA: end of setting"); this.channelOrderType = (channelOrderHopping ? 0 : 1); - appendToLog("setChannelHoppingStatus: channelOrderType = " + channelOrderType); + Logger.trace("setChannelHoppingStatus: channelOrderType = {}", channelOrderType); } return true; } public String[] getChannelFrequencyList() { if (bis108) { - boolean DEBUG = true; - appendToLog("regionCode is " + regionCode.toString()); + Logger.trace("regionCode is {}", regionCode.toString()); double[] table = GetAvailableFrequencyTable(regionCode); - appendToLog("table length = " + table.length); - for (int i = 0; i < table.length; i++) appendToLog("table[" + i + "] = " + table[i]); + Logger.trace("table length = {}", table.length); + for (int i = 0; i < table.length; i++) Logger.trace("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]); + Logger.trace("strChannnelFrequencyList[{}] = {}", i, strChannnelFrequencyList[i]); } return strChannnelFrequencyList; } else { - boolean DEBUG = true; int iCountryEnum = rfidReaderChipE710.rx000Setting.getCountryEnum(); - appendToLog("countryEnum = " + iCountryEnum); - 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] + Logger.trace("countryEnum = {}", iCountryEnum); + Logger.trace("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(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); + Logger.trace("iFrequencyCount = {}, interval = {}, start = {}", iFrequencyCount, iFrequencyInterval, 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]); + Logger.trace("strChannnelFrequencyList[{}] = {}", i, strChannnelFrequencyList[i]); } return strChannnelFrequencyList; } @@ -3778,7 +3759,7 @@ public byte getPopulation2Q(int population) { if (dValue < 0) dValue = 0; if(dValue > 15) dValue = 15; byte iValue = (byte) dValue; - if (DEBUG || true) appendToLog("getPopulation2Q(" + population + "): log dValue = " + dValue + ", iValue = " + iValue); + Logger.debug("getPopulation2Q({}): log dValue = {}, iValue = {}", population, dValue, iValue); return iValue; } public int population = 30; @@ -3786,9 +3767,9 @@ public int getPopulation() { return population; } public boolean setPopulation(int population) { - if (true) appendToLog("setPopulation " + population); + Logger.trace("setPopulation {}", population); byte iValue = getPopulation2Q(population); - if (true) appendToLog("getPopulation2Q = " + iValue); + Logger.trace("getPopulation2Q = {}", iValue); this.population = population; return setQValue(iValue); } @@ -3798,7 +3779,7 @@ public byte getQValue() { } public boolean setQValue(byte byteValue) { qValueSetting = byteValue; - if (false) appendToLog("Stream population qValue = " + qValueSetting); + Logger.trace("Stream population qValue = {}", qValueSetting); return setQValue1(byteValue); } int getQValue1() { @@ -3810,8 +3791,7 @@ public boolean setQValue1(int iValue) { { int invAlgo = getInvAlgoInChip(); if (iValue != rfidReaderChipR2000.rx000Setting.getAlgoStartQ(invAlgo)) { - if (false) - appendToLog("setTagGroup: going to setAlgoSelect with invAlgo = " + invAlgo); + Logger.trace("setTagGroup: going to setAlgoSelect with invAlgo = {}", invAlgo); result = rfidReaderChipR2000.rx000Setting.setAlgoSelect(invAlgo); } } @@ -3821,7 +3801,7 @@ public boolean setQValue1(int iValue) { return result; } else { boolean result = true; - if (false) appendToLog("3 setAlgoStartQ with iValue = " + iValue); + Logger.trace("3 setAlgoStartQ with iValue = {}", iValue); result = rfidReaderChipE710.rx000Setting.setAlgoStartQ(iValue); return result; } @@ -3836,9 +3816,8 @@ public RfidReaderChipData.Rx000pkgData onRFIDEvent() { int index = 0; try { rx000pkgData = rfidReaderChipR2000.mRx000ToRead.get(index); - if (false) - appendToLog("rx000pkgData.type = " + rx000pkgData.responseType.toString()); - rfidReaderChipR2000.mRx000ToRead.remove(index); //appendToLog("mRx000ToRead.remove"); + Logger.trace("rx000pkgData.type = {}", rx000pkgData.responseType.toString()); + rfidReaderChipR2000.mRx000ToRead.remove(index); //Logger.trace("mRx000ToRead.remove"); } catch (Exception ex) { rx000pkgData = null; } @@ -3846,7 +3825,6 @@ public RfidReaderChipData.Rx000pkgData onRFIDEvent() { } return rx000pkgData; } else { - boolean DEBUG = false; RfidReaderChipData.Rx000pkgData rx000pkgData = null; //if (mrfidToWriteSize() != 0) mRfidDevice.mRfidReaderChip.mRfidReaderChip.mRx000ToRead.clear(); if (rfidReaderChipE710.bRx000ToReading == false && rfidReaderChipE710.mRx000ToRead.size() != 0) { @@ -3855,9 +3833,9 @@ public RfidReaderChipData.Rx000pkgData onRFIDEvent() { try { rx000pkgData = rfidReaderChipE710.mRx000ToRead.get(index); if (false && rx000pkgData.responseType == RfidReaderChipData.HostCmdResponseTypes.TYPE_COMMAND_END) - if (DEBUG) appendToLog("get mRx000ToRead with COMMAND_END"); + Logger.debug("get mRx000ToRead with COMMAND_END"); rfidReaderChipE710.mRx000ToRead.remove(index); - if (DEBUG) appendToLog("got one mRx000ToRead with responseType = " + rx000pkgData.responseType.toString() + ", and remained size = " + rfidReaderChipE710.mRx000ToRead.size()); + Logger.debug("got one mRx000ToRead with responseType = {}, and remaining size = {}", rx000pkgData.responseType, rfidReaderChipE710.mRx000ToRead.size()); } catch (Exception ex) { rx000pkgData = null; } @@ -3865,21 +3843,21 @@ public RfidReaderChipData.Rx000pkgData onRFIDEvent() { } if (rx000pkgData != null && rx000pkgData.responseType != null) { if (rx000pkgData.responseType == RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_INVENTORY || rx000pkgData.responseType == RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_INVENTORY_COMPACT) { - if (DEBUG) appendToLog("Before adjustment, decodedRssi = " + rx000pkgData.decodedRssi); + Logger.debug("Before adjustment, decodedRssi = {}", rx000pkgData.decodedRssi); rx000pkgData.decodedRssi += dBuV_dBm_constant; - if (DEBUG) appendToLog("After adjustment, decodedRssi = " + rx000pkgData.decodedRssi); + Logger.debug("After adjustment, decodedRssi = {}", rx000pkgData.decodedRssi); if (rfidReaderChipE710.rx000Setting.getInvMatchEnable() > 0) { byte[] bytesCompared = new byte[rx000pkgData.decodedEpc.length]; System.arraycopy(rx000pkgData.decodedEpc, 0, bytesCompared, 0, rx000pkgData.decodedEpc.length); //bytesCompared = new byte[] { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0x2F }; //bytesCompared = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) 0xFF, (byte) 0xFF, (byte) 0x2F }; - appendToLog("decodedEpc = " + utility.byteArrayToString(rx000pkgData.decodedEpc)); + Logger.trace("decodedEpc = {}", utility.byteArrayToString(rx000pkgData.decodedEpc)); if (rfidReaderChipE710.rx000Setting.getInvMatchOffset() > 0) { - appendToLog("getInvMatchOffset = " + rfidReaderChipE710.rx000Setting.getInvMatchOffset()); + Logger.trace("getInvMatchOffset = {}", rfidReaderChipE710.rx000Setting.getInvMatchOffset()); BigInteger bigInt = new BigInteger(bytesCompared); BigInteger shiftInt = bigInt.shiftLeft(rfidReaderChipE710.rx000Setting.getInvMatchOffset()); byte [] shifted = shiftInt.toByteArray(); - appendToLog("shifted = " + utility.byteArrayToString(shifted)); + Logger.trace("shifted = {}", utility.byteArrayToString(shifted)); if (shifted.length > bytesCompared.length) System.arraycopy(shifted, shifted.length - bytesCompared.length, bytesCompared, 0, bytesCompared.length); else if (shifted.length < bytesCompared.length) { System.arraycopy(shifted, 0, bytesCompared, bytesCompared.length - shifted.length, shifted.length); @@ -3888,25 +3866,25 @@ else if (shifted.length < bytesCompared.length) { else bytesCompared[i] = (byte)0xFF; } } - appendToLog("new bytesCompared 1 = " + utility.byteArrayToString(bytesCompared)); + Logger.trace("new bytesCompared 1 = {}", utility.byteArrayToString(bytesCompared)); } if (rfidReaderChipE710.rx000Setting.getInvMatchType() > 0) { - appendToLog("getInvMatchType = " + rfidReaderChipE710.rx000Setting.getInvMatchType()); + Logger.trace("getInvMatchType = {}", rfidReaderChipE710.rx000Setting.getInvMatchType()); for (int i = 0; i < bytesCompared.length; i++) { bytesCompared[i] ^= (byte) 0xFF; } } - appendToLog("new bytesCompared 2 = " + utility.byteArrayToString(bytesCompared)); - appendToLog("getInvMatchData = " + rfidReaderChipE710.rx000Setting.getInvMatchData()); + Logger.trace("new bytesCompared 2 = {}", utility.byteArrayToString(bytesCompared)); + Logger.trace("getInvMatchData = {}", rfidReaderChipE710.rx000Setting.getInvMatchData()); if (utility.byteArrayToString(bytesCompared).indexOf(rfidReaderChipE710.rx000Setting.getInvMatchData()) != 0) { - appendToLog("Post Mis-Matched !!!"); + Logger.trace("Post Mis-Matched !!!"); rx000pkgData = null; } } } } - if (rx000pkgData != null && DEBUG) appendToLog("response = " + rx000pkgData.responseType.toString() + ", " + utility.byteArrayToString(rx000pkgData.dataValues)); + if (rx000pkgData != null) Logger.debug("response = {}, {}", rx000pkgData.responseType, utility.byteArrayToString(rx000pkgData.dataValues)); return rx000pkgData; } } @@ -3914,7 +3892,7 @@ public String getModelNumber(String strModelName) { if (bis108) { int iCountryCode = getCountryCode(); String strCountryCode = ""; - appendToLog("iCountryCode = " + iCountryCode + ", strModelNumber = " + strModelName); + Logger.trace("iCountryCode = {}, strModelNumber = {}", iCountryCode, strModelName); if (strModelName != null && strModelName.length() != 0) { if (iCountryCode > 0) strCountryCode = strModelName + "-" + String.valueOf(iCountryCode) + " " + rfidReaderChipR2000.rx000OemSetting.getSpecialCountryVersion(); @@ -3922,18 +3900,17 @@ public String getModelNumber(String strModelName) { } return strCountryCode; } else { - boolean DEBUG = false; - if (DEBUG) appendToLog("getModelName = " + strModelName); + Logger.debug("getModelName = {}", strModelName); int iCountryCode = getCountryCode(); - if (DEBUG) appendToLog("getCountryCode = " + iCountryCode); + Logger.debug("getCountryCode = {}", iCountryCode); String strSpecialCountryVersion = getSpecialCountryVersion(); - if (DEBUG) appendToLog("getSpecialCountryVersion = " + strSpecialCountryVersion); + Logger.debug("getSpecialCountryVersion = {}", strSpecialCountryVersion); int iFreqModifyCode = getFreqModifyCode(); - if (DEBUG) appendToLog("getFreqModifyCode = " + iFreqModifyCode); + Logger.debug("getFreqModifyCode = {}", iFreqModifyCode); String strModelNumber = (strModelName == null ? "" : strModelName); if (iCountryCode > 0) strModelNumber += ("-" + String.valueOf(iCountryCode) + (strSpecialCountryVersion == null ? "" : (" " + strSpecialCountryVersion))); - if (DEBUG) appendToLog("strModelNumber = " + strModelNumber); + Logger.debug("strModelNumber = {}", strModelNumber); return strModelNumber; } } @@ -3947,7 +3924,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); + Logger.compact("Debug_Compact: RfidReader.setInvModeCompact as {}", invModeCompact); return (bis108 ? rfidReaderChipR2000.rx000Setting.setInvModeCompact(invModeCompact) : rfidReaderChipE710.rx000Setting.setInvModeCompact(invModeCompact)); } public boolean setAccessLockAction(int accessLockAction, int accessLockMask) { @@ -4031,7 +4008,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); + Logger.trace("ivalue = {}, impinjExtensionValue = {}", iValue, rfidReaderChipR2000.rx000Setting.impinjExtensionValue); boolean bRetValue; bRetValue = macWrite(0x203, iValue); } else { @@ -4047,11 +4024,11 @@ public boolean isInventoring() { boolean bValue; if (bis108) bValue = rfidReaderChipR2000.isInventoring(); else bValue = rfidReaderChipE710.isInventoring(); - //appendToLog("isInventoring " + bValue + " with bis108 " + bis108); + //Logger.trace("isInventoring " + bValue + " with bis108 " + bis108); return bValue; } public void setInventoring(boolean enable) { - appendToLog("setInventoring " + enable + " with bis108 " + bis108); + Logger.trace("setInventoring {} with bis108 {}", enable, bis108); if (bis108) rfidReaderChipR2000.setInventoring(enable); else rfidReaderChipE710.setInventoring(enable); } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipE710.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipE710.java index f95232f..eddf950 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipE710.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipE710.java @@ -11,26 +11,20 @@ import java.util.Date; public class RfidReaderChipE710 { - boolean DEBUG_PKDATA, DEBUG; boolean sameCheck = true; //RfidReaderChip mRfidReaderChip; - boolean DEBUGTHREAD = false, DEBUG_APDATA = false; int intervalRx000UplinkHandler; boolean aborting = false; Context context; Utility utility; CsReaderConnector csReaderConnector; public RfidReaderChipE710(Context context, Utility utility, CsReaderConnector csReaderConnector) { this.context = context; - this.utility = utility; DEBUG_PKDATA = utility.DEBUG_PKDATA; + this.utility = utility; //mRfidReaderChip = new RfidReaderChip(); this.csReaderConnector = csReaderConnector; - this.DEBUGTHREAD = csReaderConnector.DEBUGTHREAD; - this.DEBUG_APDATA = csReaderConnector.DEBUG_APDATA; this.intervalRx000UplinkHandler = csReaderConnector.intervalRx000UplinkHandler; } private String byteArrayToString(byte[] packet) { return utility.byteArrayToString(packet); } private boolean compareArray(byte[] array1, byte[] array2, int length) { return utility.compareByteArray(array1, array2, length); } - private void appendToLog(String s) { utility.appendToLog(s); } - private void appendToLogView(String s) { utility.appendToLogView(s); } void writeDebug2File(String stringDebug) { utility.writeDebug2File(stringDebug); } private String byteArray2DisplayString(byte[] byteData) { return utility.byteArray2DisplayString(byteData); } private int byteArrayToInt(byte[] bytes) { return utility.byteArrayToInt(bytes); } @@ -223,10 +217,10 @@ boolean writeMAC(int address, byte[] bytes, boolean bReady) { // && address != 0x3140 //) if (false && address == 0x3035) { - appendToLog(String.format("0 writeMAC[address = 0x%X, bytes = %s with antennaPortConfig = %s", address, byteArrayToString(bytes), byteArrayToString(rx000Setting.getAntennaPortConfig(0)))); + Logger.trace(String.format("0 writeMAC[address = 0x%X, bytes = %s with antennaPortConfig = %s", address, byteArrayToString(bytes), byteArrayToString(rx000Setting.getAntennaPortConfig(0)))); //bytes[1] = 0x1E; //(byte)0x86; //orginal 6, new 0x9E //bytes[8] = 1; //original 1, new 8 - appendToLog(String.format("0A writeMAC[address = 0x%X, bytes = %s with antennaPortConfig = %s", address, byteArrayToString(bytes), byteArrayToString(rx000Setting.getAntennaPortConfig(0)))); + Logger.trace(String.format("0A writeMAC[address = 0x%X, bytes = %s with antennaPortConfig = %s", address, byteArrayToString(bytes), byteArrayToString(rx000Setting.getAntennaPortConfig(0)))); //return true; } byte[] header = new byte[] {(byte) 0x80, (byte)0xb3, (byte)0x9A, 6, 0, 0, 4, 1, 0, 8, 0 }; @@ -239,7 +233,7 @@ boolean writeMAC(int address, byte[] bytes, boolean bReady) { msgBuffer[9] = (byte) (address & 0xFF); msgBuffer[10] = (byte) (bytes.length & 0XFF); System.arraycopy(bytes, 0, msgBuffer, 11, bytes.length); - if (false) appendToLog(String.format("3 writeMAC with address = 0x%X, msgBuffer = ", address) + byteArrayToString(msgBuffer)); + Logger.trace(String.format("3 writeMAC with address = 0x%X, msgBuffer = ", address) + byteArrayToString(msgBuffer)); return sendHostRegRequest(HostRegRequests.MAC_OPERATION, true, msgBuffer); } public boolean readMAC(int address) { @@ -250,7 +244,7 @@ public boolean readMAC(int address) { } public boolean writeMAC(int address, long value) { byte[] msgBuffer = null; - appendToLog(String.format("3A setTagFocus with address = 0x%X, value = 0x%X ", address, value)); + Logger.trace(String.format("3A setTagFocus with address = 0x%X, value = 0x%X ", address, value)); return sendHostRegRequest(HostRegRequests.MAC_OPERATION, true, msgBuffer); } @@ -260,7 +254,7 @@ public String getMacVer() { if (macVer == null) readMAC(8, 0x20); if (macVerBuild < 0 || macVer == null) return null; String strValue = macVer + " b" + macVerBuild; - if (false) appendToLog("2 getMacVer = " + strValue); + Logger.trace("2 getMacVer = {}", strValue); return strValue; } @@ -270,7 +264,7 @@ public boolean setAuthenticateConfig(int authenticateConfig) { data[0] = (byte) ((authenticateConfig >> 16) & 0xFF); data[1] = (byte) ((authenticateConfig >> 8) & 0xFF); data[2] = (byte) (authenticateConfig & 0xFF); - appendToLog("AAA: writing 390E with data " + byteArrayToString(data)); + Logger.trace("AAA: writing 390E with data {}", byteArrayToString(data)); boolean bValue = writeMAC(0x390E, data, true); if (bValue) this.authenticateConfig = authenticateConfig; //readMAC3(0x390E, 3); @@ -281,7 +275,7 @@ public boolean setAuthenticateMessage(byte[] authenticateMessage) { if (length > 32) length = 32; byte[] data = new byte[length]; System.arraycopy(authenticateMessage, 0, data, 0, length); - appendToLog("AAA: writing 3912 with data " + byteArrayToString(data)); + Logger.trace("AAA: writing 3912 with data {}", byteArrayToString(data)); boolean bValue = writeMAC(0x3912, data, true); //readMAC3(0x3912, 32); return bValue; @@ -290,7 +284,7 @@ public boolean setAuthenticateResponseLen(int authenticateResponseLen) { byte[] data = new byte[2]; data[0] = (byte) ((authenticateResponseLen >> 8) & 0xFF); data[1] = (byte) (authenticateResponseLen & 0xFF); - appendToLog("AAA: writing 3944 with data " + byteArrayToString(data)); + Logger.trace("AAA: writing 3944 with data {}", byteArrayToString(data)); boolean bValue = writeMAC(0x3944, data, true); //readMAC3(0x3944, 2); return bValue; @@ -301,19 +295,19 @@ public byte getCurrentPort() { byte byValue = (byte)-1; if (currentPort != null && currentPort.length == 1) byValue = currentPort[0]; else readMAC(0x3948, 1); - appendToLog("byValue = " + byValue); + Logger.trace("byValue = {}", byValue); return byValue; } boolean setCurrentPort(byte currentPortNew) { if (currentPortNew >= 0 && currentPort.length == 1 && currentPort[0] == currentPortNew && sameCheck) { - appendToLog("!!! Skip sending repeated data with currentPortNew = " + currentPortNew); + Logger.trace("!!! Skip sending repeated data with currentPortNew = {}", currentPortNew); return true; } byte[] bytes = new byte[1]; bytes[0] = currentPortNew; boolean bValue; bValue = rx000Setting.writeMAC(0x3948, bytes, true); - appendToLog("new currentPort = " + byteArrayToString(bytes) + ", old currentPort = " + byteArrayToString(currentPort)); + Logger.trace("new currentPort = {}, old currentPort = {}", byteArrayToString(bytes), byteArrayToString(currentPort)); if (bValue) currentPort = bytes; return true; } @@ -327,7 +321,7 @@ public boolean updateCurrentPort() { } } } - appendToLog("currentPortOld = " + currentPortOld + ", currentPortNew = " + currentPortNew); + Logger.trace("currentPortOld = {}, currentPortNew = {}", currentPortOld, currentPortNew); boolean bValue = false; if (currentPortOld != currentPortNew) bValue = setCurrentPort(currentPortNew); return bValue; @@ -362,7 +356,7 @@ public int getCountryEnum() { int iValue = -1; if (countryEnum == null) readMAC(0x3014, 2); else iValue = byteArrayToInt(countryEnum); - appendToLog("countryEnum = " + iValue); + Logger.trace("countryEnum = {}", iValue); return iValue; } public boolean setCountryEnum(short countryEnum) { @@ -371,7 +365,7 @@ public boolean setCountryEnum(short countryEnum) { data[1] = (byte) ((countryEnum) & 0xFF); if (this.countryEnum != null && compareArray(this.countryEnum, data, data.length) && sameCheck) return true; boolean bValue = writeMAC(0x3014, data, true); - appendToLog("new countryEnum = " + byteArrayToString(data) + ", with bValue = " + bValue); + Logger.trace("new countryEnum = {}, with bValue = {}", byteArrayToString(data), bValue); if (bValue) this.countryEnum = data; return bValue; } @@ -381,7 +375,7 @@ public int getFrequencyChannelIndex() { int iValue = -1; if (frequencyChannelIndex == null) readMAC(0x3018, 1); else iValue = byteArrayToInt(frequencyChannelIndex); - appendToLog("frequencyChannelIndex = " + iValue); + Logger.trace("frequencyChannelIndex = {}", iValue); return iValue; } public boolean setFrequencyChannelIndex(byte frequencyChannelIndex) { @@ -389,7 +383,7 @@ public boolean setFrequencyChannelIndex(byte frequencyChannelIndex) { data[0] = frequencyChannelIndex; if (this.frequencyChannelIndex != null && compareArray(this.frequencyChannelIndex, data, data.length) && sameCheck) return true; boolean bValue = writeMAC(0x3018, data, true); - appendToLog("new frequencyChannelIndex = " + byteArrayToString(data) + ", old frequencyChannelIndex = " + byteArrayToString(this.frequencyChannelIndex) + ", with bValue = " + bValue + ", sameCheck = " + sameCheck); + Logger.trace("new frequencyChannelIndex = {}, old frequencyChannelIndex = {}, with bValue = {}, sameCheck = {}", byteArrayToString(data), byteArrayToString(this.frequencyChannelIndex), bValue, sameCheck); if (bValue) this.frequencyChannelIndex = data; return bValue; } @@ -399,7 +393,7 @@ public int getCountryEnumOem() { int iValue = -1; if (countryEnumOem == null) readMAC(0x5040, 2); else iValue = byteArrayToInt(countryEnumOem); - appendToLog("countryEnumOem = " + iValue); + Logger.trace("countryEnumOem = {}", iValue); return iValue; } @@ -421,7 +415,7 @@ public String getBoardSerialNumber() { System.arraycopy(boardSerialNumber, 0, retValue, 0, boardSerialNumber.length); String string = new String(retValue).trim().replaceAll("[^\\x00-\\x7F]", ""); if (string == null || string.length() == 0) return byteArrayToString(retValue).substring(0, 13); - if (false) appendToLog("String = " + string + ", length = " + string.length()); + Logger.trace("String = {}, length = {}", string, string.length()); if (retValue.length > 13) { for (int i = 13; i < retValue.length; i++) { if (retValue[i] < 0x30) retValue[i] += 0x30; @@ -453,43 +447,43 @@ public int getFreqModifyCode() { final int DIAGCFG_INVALID = -1; final int DIAGCFG_MIN = 0; final int DIAGCFG_MAX = 0x3FF; int diagnosticCfg = DIAGCFG_INVALID; public int getAntennaPort() { - if (false) appendToLog("2 iAntennaPort = " + antennaSelect); + Logger.trace("2 iAntennaPort = {}", antennaSelect); return antennaSelect; } byte[][] antennaPortConfig = new byte[16][]; public byte[] getAntennaPortConfig(int iAntennaPort) { byte[] bytes = null; if (antennaPortConfig[iAntennaPort] == null) { - if (false) appendToLog("getAntennaPortConfig starts readMAC"); + Logger.trace("getAntennaPortConfig starts readMAC"); readMAC(0x3030 + iAntennaPort * 16, 16); } else { bytes = new byte[antennaPortConfig[iAntennaPort].length]; System.arraycopy(antennaPortConfig[iAntennaPort], 0, bytes, 0, bytes.length); } - if (false) appendToLog("getAntennaPortConfig[" + iAntennaPort + "] = " + byteArrayToString(antennaPortConfig[iAntennaPort])); + Logger.trace("getAntennaPortConfig[{}] = {}", iAntennaPort, byteArrayToString(antennaPortConfig[iAntennaPort])); return bytes; } int impinjExtensionValue = -1; public int getImpinjExtension() { - int iValue = -1; boolean DEBUG = true; - if (DEBUG) appendToLog("2 getImpinjExtension: iAntennaPort = " + antennaSelect); - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + int iValue = -1; + Logger.debug("2 getImpinjExtension: iAntennaPort = {}", antennaSelect); + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { - if (DEBUG) appendToLog("2A getImpinjExtension: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2A getImpinjExtension: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); iValue = (antennaPortConfig[antennaSelect][5] & 0x06); - if (DEBUG) appendToLog(String.format("2b getImpinjExtension: iValue = 0x%X", iValue)); + Logger.debug(String.format("2b getImpinjExtension: iValue = 0x%X", iValue)); } return iValue; } public boolean setImpinjExtension(boolean tagFocus, boolean fastId) { - boolean bValue = false, DEBUG = true; - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + boolean bValue = false; + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { - if (DEBUG) appendToLog("2 setImpinjExtension: tagFocus = " + tagFocus); - if (DEBUG) appendToLog("2A setImpinjExtension: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2 setImpinjExtension: tagFocus = {}", tagFocus); + Logger.debug("2A setImpinjExtension: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); byte[] bytes = new byte[1]; bytes[0] = antennaPortConfig[antennaSelect][5]; @@ -497,22 +491,21 @@ public boolean setImpinjExtension(boolean tagFocus, boolean fastId) { else bytes[0] &= ~0x04; if (fastId) bytes[0] |= 0x02; else bytes[0] &= ~0x02; - if (DEBUG) appendToLog(String.format("2A1 setImpinjExtension: bytes = 0x%X", bytes[0])); + Logger.debug(String.format("2A1 setImpinjExtension: bytes = 0x%X", bytes[0])); boolean bSame = false; if (sameCheck | true) { if (antennaPortConfig[antennaSelect][5] == bytes[0]) bSame = true; - if (DEBUG) appendToLog("2ab setImpinjExtension: the array is the same = " + bSame); + Logger.debug("2ab setImpinjExtension: the array is the same = {}", bSame); } - //bSame = false; appendToLog("!!! assme bSame is false before 1A writeMAC 0x3035"); if (bSame) { - if (DEBUG_PKDATA) appendToLog(String.format("!!! Skip sending repeated data %s in address 0x%X", byteArrayToString(bytes), 0x3030 + antennaSelect * 16 + 5)); + Logger.pkData(String.format("!!! Skip sending repeated data %s in address 0x%X", byteArrayToString(bytes), 0x3030 + antennaSelect * 16 + 5)); bValue = true; } else { - appendToLog("test 1"); + Logger.trace("test 1"); bValue = writeMAC(0x3030 + antennaSelect * 16 + 5, bytes, true); if (bValue) antennaPortConfig[antennaSelect][5] = bytes[0]; } - if (DEBUG) appendToLog("2b setImpinjExtension: with updated " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2b setImpinjExtension: with updated {}", byteArrayToString(antennaPortConfig[antennaSelect])); } return bValue; } @@ -523,14 +516,14 @@ public boolean setImpinjExtension(boolean tagFocus, boolean fastId) { public byte[] getSelectConfiguration(int iSelectPort) { byte[] bytes = null; if (selectConfiguration[iSelectPort] == null) { - if (false) appendToLog("getSelectConfiguration starts readMAC"); + Logger.trace("getSelectConfiguration starts readMAC"); readMAC(0x3140 + iSelectPort * 42, 42); } else { bytes = new byte[selectConfiguration[iSelectPort].length]; System.arraycopy(selectConfiguration[iSelectPort], 0, bytes, 0, bytes.length); } - if (false) appendToLog("getSelectConfiguration[" + iSelectPort + "] = " + byteArrayToString(selectConfiguration[iSelectPort])); + Logger.trace("getSelectConfiguration[{}] = {}", iSelectPort, byteArrayToString(selectConfiguration[iSelectPort])); return bytes; } public boolean setSelectConfiguration(int index, boolean enable, int bank, int offset, byte[] mask, int target, int action, int delay) { @@ -552,14 +545,14 @@ public boolean setSelectConfiguration(int index, boolean enable, int bank, int o bytes[39] = (byte) (target & 0xFF); bytes[40] = (byte) (action & 0xFF); bytes[41] = (byte) (delay & 0xFF); - if (false) appendToLog("1A writeMAC 0x3140"); + Logger.trace("1A writeMAC 0x3140"); if (compareArray(selectConfiguration[index], bytes, bytes.length) && sameCheck) { - appendToLog("!!! Skip sending repeated data " + byteArrayToString(bytes) + " to address 0x3140"); + Logger.trace("!!! Skip sending repeated data {} to address 0x3140", byteArrayToString(bytes)); return true; } bValue = writeMAC(0x3140 + index * 42, bytes, true); if (bValue) selectConfiguration[index] = bytes; - else appendToLog("!!! Failed to send data " + byteArrayToString(bytes) + " to address 0x3140"); + else Logger.trace("!!! Failed to send data {} to address 0x3140", byteArrayToString(bytes)); return bValue; } @@ -579,17 +572,17 @@ int getMultibankReadLength(int iSelectPort) { return iValue; } public byte[] getMultibankReadConfig(int iSelectPort) { - boolean DEBUG = false; int iPortSize = 7; + int iPortSize = 7; byte[] bytes = null; if (multibankReadConfig[iSelectPort] == null) { - if (DEBUG) appendToLog("getMultibankReadConfig starts readMAC"); + Logger.debug("getMultibankReadConfig starts readMAC"); readMAC(0x3270 + iSelectPort * iPortSize, iPortSize); } else { bytes = new byte[multibankReadConfig[iSelectPort].length]; System.arraycopy(multibankReadConfig[iSelectPort], 0, bytes, 0, bytes.length); } - if (DEBUG) appendToLog("getMultibankReadConfig[" + iSelectPort + "] = " + byteArrayToString(multibankReadConfig[iSelectPort])); + Logger.debug("getMultibankReadConfig[{}] = {}", iSelectPort, byteArrayToString(multibankReadConfig[iSelectPort])); return bytes; } byte[][] multibankWriteConfig = new byte[3][]; @@ -609,8 +602,8 @@ boolean setMultibankReadConfig(int index, boolean enable, int bank, int offset, } boolean setMultibankWriteConfig(int index, boolean enable, int bank, int offset, int length, byte[] data) { - boolean bValue = false, DEBUG = false; - if (DEBUG) appendToLog("Start with index = " + index + ", enable = " + enable + ", bank = " + bank + ", offset = " + offset + ", length = " + length + ", data = " + byteArrayToString(data)); + boolean bValue = false; + Logger.debug("Start with index = {}, enable = {}, bank = {}, offset = {}, length = {}, data = {}", index, enable, bank, offset, length, byteArrayToString(data)); byte[] bytes = new byte[7+data.length]; bytes[0] = (byte) (enable ? 1 : 0); bytes[1] = (byte) (bank & 0xFF); @@ -620,15 +613,15 @@ boolean setMultibankWriteConfig(int index, boolean enable, int bank, int offset, bytes[5] = (byte) (offset & 0xFF); bytes[6] = (byte) (length & 0xFF); System.arraycopy(data, 0, bytes, 7, data.length); - if (DEBUG) appendToLog("bytes = " + byteArrayToString(bytes)); + Logger.debug("bytes = {}", byteArrayToString(bytes)); bValue = writeMAC(0x3290 + index * 519, bytes, true); - if (DEBUG) appendToLog("After writeMAC, bValue = " + bValue); + Logger.debug("After writeMAC, bValue = {}", bValue); if (bValue) multibankWriteConfig[index] = bytes; return bValue; } int pwrMgmtStatus = -1; void getPwrMgmtStatus() { - appendToLog("pwrMgmtStatus: getPwrMgmtStatus "); + Logger.trace("pwrMgmtStatus: getPwrMgmtStatus "); pwrMgmtStatus = -1; readMAC(0x204); } @@ -650,7 +643,8 @@ public int getAntennaCycle() { } public boolean setAntennaCycle(int antennaCycle) { if (antennaCycle == this.antennaCycle) return true; - this.antennaCycle = antennaCycle; appendToLog(String.format("!!! Skip setAntennaCycle[0x%X]", antennaCycle)); + this.antennaCycle = antennaCycle; + Logger.trace(String.format("!!! Skip setAntennaCycle[0x%X]", antennaCycle)); return true; } boolean setAntennaCycle(int antennaCycle, int antennaFreqAgile) { @@ -665,7 +659,7 @@ boolean setAntennaCycle(int antennaCycle, int antennaFreqAgile) { } this.antennaCycle = antennaCycle; this.antennaFreqAgile = antennaFreqAgile; - appendToLog("3 Set HST_ANT_CYCLES"); + Logger.trace("3 Set HST_ANT_CYCLES"); return sendHostRegRequest(HostRegRequests.HST_ANT_CYCLES, true, msgBuffer); } @@ -677,7 +671,7 @@ int getAntennaFreqAgile() { return antennaFreqAgile; } public boolean setAntennaFreqAgile(int freqAgile) { - appendToLog("Set HST_ANT_CYCLES"); + Logger.trace("Set HST_ANT_CYCLES"); return setAntennaCycle(antennaCycle, freqAgile); } @@ -691,123 +685,122 @@ private boolean getHST_ANT_CYCLES() { public boolean setAntennaSelect(int antennaSelect) { if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) antennaSelect = mDefault.antennaSelect; if (this.antennaSelect == antennaSelect && sameCheck) return true; - this.antennaSelect = antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); + this.antennaSelect = antennaSelect; + Logger.trace("antennaSelect is set to {}", antennaSelect); return true; } AntennaSelectedData[] antennaSelectedData; public int getAntennaEnable() { - boolean DEBUG = false; int iValue = -1; if (antennaPortConfig[antennaSelect] == null) { rx000Setting.getAntennaPortConfig(antennaSelect); readMAC(0x3030 + antennaSelect * 16, 16); - appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); } else { - if (DEBUG) appendToLog("2 getAntennaEnable"); - if (DEBUG) appendToLog("2A getAntennaEnable: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2 getAntennaEnable"); + Logger.debug("2A getAntennaEnable: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); iValue = antennaPortConfig[antennaSelect][0] & 0xFF; } - if (DEBUG) appendToLog("2 getAntennaEnable: iValue = " + iValue); + Logger.debug("2 getAntennaEnable: iValue = {}", iValue); return iValue; } public boolean setAntennaEnable(int antennaEnable) { - boolean bValue = false, DEBUG = true; + boolean bValue = false; - appendToLog("antennaEnable is " + antennaEnable); + Logger.trace("antennaEnable is {}", antennaEnable); if (antennaEnable == 0) { boolean disableInvalid = true; for (int i = 0; i < 16; i++) { - appendToLog("i = " + i + ", antennaSelect = " + antennaSelect); + Logger.trace("i = {}, antennaSelect = {}", i, antennaSelect); if (i != antennaSelect && antennaPortConfig[i] != null) { if (antennaPortConfig[i][0] != 0) disableInvalid = false; - appendToLog("i = " + i + ", disableInvalid = " + disableInvalid); + Logger.trace("i = {}, disableInvalid = {}", i, disableInvalid); } } - appendToLog("disableInvalid is " + disableInvalid); + Logger.trace("disableInvalid is {}", disableInvalid); if (disableInvalid) return false; } - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { - if (DEBUG) appendToLog("2 setAntennaEnable with antennaEnable = " + antennaEnable); - if (DEBUG) appendToLog("2A setAntennaEnable: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2 setAntennaEnable with antennaEnable = {}", antennaEnable); + Logger.debug("2A setAntennaEnable: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); byte[] bytes = new byte[1]; if (antennaEnable > 0) bytes[0] = 1; else bytes[0] = 0; - if (DEBUG) appendToLog("2b setAntennaEnable: bytes = " + byteArrayToString(bytes)); + Logger.debug("2b setAntennaEnable: bytes = {}", byteArrayToString(bytes)); bValue = writeMAC(0x3030 + antennaSelect * 16, bytes, true); if (bValue) antennaPortConfig[antennaSelect][0] = bytes[0]; - if (DEBUG) appendToLog("2C setAntennaEnable: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2C setAntennaEnable: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); } - if (DEBUG) appendToLog("2d getAntennaEnable: bValue = " + bValue); + Logger.debug("2d getAntennaEnable: bValue = {}", bValue); return bValue; } public long getAntennaDwell() { - boolean DEBUG = false; long lValue = -1; - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { - if (DEBUG) appendToLog("2 getAntennaDwell"); - if (DEBUG) appendToLog("2A getAntennaDwell: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2 getAntennaDwell"); + Logger.debug("2A getAntennaDwell: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); lValue = (antennaPortConfig[antennaSelect][1] & 0xFF) << 8; lValue += (antennaPortConfig[antennaSelect][2] & 0xFF); } - if (DEBUG) appendToLog("2C getAntennaDwell: iValue = " + lValue); + Logger.debug("2C getAntennaDwell: iValue = {}", lValue); return lValue; } public boolean setAntennaDwell(long antennaDwell) { - boolean bValue = false, DEBUG = false; - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + boolean bValue = false; + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { - if (DEBUG) appendToLog("2 setAntennaDwell: antennaDwell = " + antennaDwell); - if (DEBUG) appendToLog("2A setAntennaDwell: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2 setAntennaDwell: antennaDwell = {}", antennaDwell); + Logger.debug("2A setAntennaDwell: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); byte[] bytes = new byte[2]; bytes[0] = (byte)((antennaDwell/256) & 0xFF); bytes[1] = (byte)((antennaDwell%256) & 0xFF); if (sameCheck | true) { byte[] bytesOld = new byte[2]; System.arraycopy(antennaPortConfig[antennaSelect], 1, bytesOld, 0, bytesOld.length); - if (DEBUG) appendToLog("2A2 setAntennaDwell: bytesOld = " + byteArrayToString(bytesOld)); + Logger.debug("2A2 setAntennaDwell: bytesOld = {}", byteArrayToString(bytesOld)); boolean bValue1 = compareArray(bytes, bytesOld, bytes.length); - if (DEBUG) appendToLog("2ab setAntennaDwell: the array is the same = " + bValue1); + Logger.debug("2ab setAntennaDwell: the array is the same = {}", bValue1); } bValue = writeMAC(0x3030 + antennaSelect * 16 + 1, bytes, true); if (bValue) System.arraycopy(bytes, 0, antennaPortConfig[antennaSelect], 1, bytes.length); - if (DEBUG) appendToLog("2b setAntennaDwell: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2b setAntennaDwell: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); } return bValue; } public long getAntennaPower(int portNumber) { - long lValue = -1; boolean DEBUG = false; - if (DEBUG) appendToLog("2 getAntennaPower: portNumber = " + portNumber); + long lValue = -1; + Logger.debug("2 getAntennaPower: portNumber = {}", portNumber); if (portNumber < 0) portNumber = antennaSelect; - if (antennaPortConfig[portNumber] == null) appendToLog("CANNOT continue as antennaPortConfig[" + portNumber + "] is null !!!"); + if (antennaPortConfig[portNumber] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", portNumber); else { - if (DEBUG) appendToLog("2A getAntennaPower: getAntennaPortConfig[" + portNumber + "] = " + byteArrayToString(antennaPortConfig[portNumber])); + Logger.debug("2A getAntennaPower: getAntennaPortConfig[{}] = {}", portNumber, byteArrayToString(antennaPortConfig[portNumber])); lValue = (antennaPortConfig[portNumber][3] & 0xFF) * 256; lValue += (antennaPortConfig[portNumber][4] & 0xFF); - if (DEBUG) appendToLog(String.format("2b getAntennaPower: lValue = 0x%X", lValue)); + Logger.debug(String.format("2b getAntennaPower: lValue = 0x%X", lValue)); lValue /= 10; } return lValue; } public boolean setAntennaPower(long antennaPower) { - boolean bValue = false, DEBUG = false; + boolean bValue = false; if (antennaPortConfig[antennaSelect] == null) { - if (DEBUG) appendToLog("4 bValue = " + bValue); - appendToLog("!!! CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null"); + Logger.debug("4 bValue = {}", bValue); + Logger.trace("!!! CANNOT continue as antennaPortConfig[{}] is null", antennaSelect); } else if (getAntennaPower(antennaSelect) == antennaPower && sameCheck) { - if (DEBUG) appendToLog("3 bValue = " + bValue); + Logger.debug("3 bValue = {}", bValue); return true; } else { - if (DEBUG) appendToLog("2 setAntennaPower: antennaPower = " + antennaPower); - if (DEBUG) appendToLog("2A setAntennaPower: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2 setAntennaPower: antennaPower = {}", antennaPower); + Logger.debug("2A setAntennaPower: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); antennaPower *= 10; byte[] bytes = new byte[2]; bytes[0] = (byte)((antennaPower/256) & 0xFF); @@ -815,24 +808,25 @@ else if (getAntennaPower(antennaSelect) == antennaPower && sameCheck) { if (sameCheck | true) { byte[] bytesOld = new byte[2]; System.arraycopy(antennaPortConfig[antennaSelect], 3, bytesOld, 0, bytesOld.length); - if (DEBUG) appendToLog("2A2 setAntennaPower: bytesOld = " + byteArrayToString(bytesOld)); + Logger.debug("2A2 setAntennaPower: bytesOld = {}", byteArrayToString(bytesOld)); boolean bValue1 = compareArray(bytes, bytesOld, bytes.length); - if (DEBUG) appendToLog("2ab setAntennaPower: the array is the same = " + bValue1); + Logger.debug("2ab setAntennaPower: the array is the same = {}", bValue1); } bValue = writeMAC(0x3030 + antennaSelect * 16 + 3, bytes, true); - if (DEBUG) appendToLog("2 bValue = " + bValue); + Logger.debug("2 bValue = {}", bValue); if (bValue) System.arraycopy(bytes, 0, antennaPortConfig[antennaSelect], 3, bytes.length); - if (DEBUG) appendToLog("2b setAntennaPower: with updated " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2b setAntennaPower: with updated {}", byteArrayToString(antennaPortConfig[antennaSelect])); } - if (DEBUG) appendToLog("1 bValue = " + bValue); + Logger.debug("1 bValue = {}", bValue); return bValue; } long antennaInvCount = -1; public boolean setAntennaInvCount(long antennaInvCount) { if (antennaInvCount == this.antennaInvCount) return true; - this.antennaInvCount = antennaInvCount; appendToLog(String.format("!!! Skip setAntennaInvCount[0x%X]", antennaInvCount)); + this.antennaInvCount = antennaInvCount; + Logger.trace(String.format("!!! Skip setAntennaInvCount[0x%X]", antennaInvCount)); return true; } @@ -841,18 +835,19 @@ public boolean setAntennaInvCount(long antennaInvCount) { public int invSelectIndex = INVSELECT_INVALID; public int getInvSelectIndex() { if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) { - invSelectIndex = 0; appendToLog("!!! Skip getInvSelectIndex with assumed value = 0"); + invSelectIndex = 0; + Logger.trace("!!! Skip getInvSelectIndex with assumed value = 0"); } return invSelectIndex; } public boolean setInvSelectIndex(int invSelect) { if (invSelect < INVSELECT_MIN || invSelect > INVSELECT_MAX) invSelect = mDefault.invSelectIndex; if (this.invSelectIndex == invSelect && sameCheck) { - appendToLog("!!! Skip sending repeated data with invSelect = " + invSelect); + Logger.trace("!!! Skip sending repeated data with invSelect = {}", invSelect); return true; } this.invSelectIndex = invSelect; - appendToLog(String.format("!!! Skip setInvSelectIndex[%d]", invSelect)); + Logger.trace("!!! Skip setInvSelectIndex[{}]", invSelect); return true; } @@ -860,17 +855,17 @@ public boolean setInvSelectIndex(int invSelect) { public int getSelectEnable() { int iValue = -1; if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; - if (selectConfiguration[invSelectIndex] == null) appendToLog("!!! CANNOT getSelectEnable as selectConfiguration[" + invSelectIndex + "] is null"); + if (selectConfiguration[invSelectIndex] == null) Logger.trace("!!! CANNOT getSelectEnable as selectConfiguration[{}] is null", invSelectIndex); else iValue = (byte)(selectConfiguration[invSelectIndex][0] & 0xFF); return iValue; } public boolean setSelectEnable(int enable, int selectTarget, int selectAction, int selectDelay) { - boolean bValue = false, DEBUG = false; - if (DEBUG) appendToLog("Start with enable = " + enable + ", selectTarget = " + selectTarget + ", selectAction = " + selectAction + ", selectDelay = " + selectDelay); + boolean bValue = false; + Logger.debug("Start with enable = {}, selectTarget = {}, selectAction = {}, selectDelay = {}", enable, selectTarget, selectAction, selectDelay); if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; - if (selectConfiguration[invSelectIndex] == null) appendToLog("!!! CANNOT setSelectEnable as selectConfiguration[" + invSelectIndex + "] is null"); + if (selectConfiguration[invSelectIndex] == null) Logger.trace("!!! CANNOT setSelectEnable as selectConfiguration[{}] is null", invSelectIndex); else { - if (DEBUG) appendToLog("Old selectConfiguration " + invSelectIndex + " = " + byteArrayToString(selectConfiguration[invSelectIndex])); + Logger.debug("Old selectConfiguration {} = {}", invSelectIndex, byteArrayToString(selectConfiguration[invSelectIndex])); byte[] bytes = new byte[42]; if (selectConfiguration[invSelectIndex] != null) System.arraycopy(selectConfiguration[invSelectIndex], 0, bytes, 0, bytes.length); bytes[0] = (byte)(enable & 0xFF); @@ -878,23 +873,23 @@ public boolean setSelectEnable(int enable, int selectTarget, int selectAction, i bytes[40] = (byte)(selectAction & 0xFF); bytes[41] = (byte)(selectDelay & 0xFF);; if (compareArray(selectConfiguration[invSelectIndex], bytes, bytes.length) && sameCheck) { - appendToLog("!!! Skip sending repeated data " + byteArrayToString(bytes) + " to address 0x3140"); + Logger.trace("!!! Skip sending repeated data {} to address 0x3140", byteArrayToString(bytes)); return true; } bValue = writeMAC(0x3140 + invSelectIndex * 42, bytes, true); - if (DEBUG) appendToLog("after writeMAC 0x3140, bValue = " + bValue); + Logger.debug("after writeMAC 0x3140, bValue = {}", bValue); if (bValue) selectConfiguration[invSelectIndex] = bytes; - else appendToLog("!!! Failed to send data " + byteArrayToString(bytes) + " to address 0x3140"); - if (DEBUG) appendToLog("bytes = " + byteArrayToString(bytes) + ", new selectConfiguration " + invSelectIndex + " = " + byteArrayToString(selectConfiguration[invSelectIndex])); + else Logger.trace("!!! Failed to send data {} to address 0x3140", byteArrayToString(bytes)); + Logger.debug("bytes = {}, new selectConfiguration {} = {}", byteArrayToString(bytes), invSelectIndex, byteArrayToString(selectConfiguration[invSelectIndex])); } - if (DEBUG) appendToLog("End with bValue = " + bValue); + Logger.debug("End with bValue = {}", bValue); return bValue; } public int getSelectTarget() { int iValue = -1; if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; - if (selectConfiguration[invSelectIndex] == null) appendToLog("!!! CANNOT getSelectTarget as selectConfiguration[" + invSelectIndex + "] is null"); + if (selectConfiguration[invSelectIndex] == null) Logger.trace("!!! CANNOT getSelectTarget as selectConfiguration[{}] is null", invSelectIndex); else iValue = (selectConfiguration[invSelectIndex][39] & 0xFF); return iValue; } @@ -902,7 +897,7 @@ public int getSelectTarget() { public int getSelectAction() { int iValue = -1; if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; - if (selectConfiguration[invSelectIndex] == null) appendToLog("!!! CANNOT getSelectTarget as selectConfiguration[" + invSelectIndex + "] is null"); + if (selectConfiguration[invSelectIndex] == null) Logger.trace("!!! CANNOT getSelectTarget as selectConfiguration[{}] is null", invSelectIndex); else iValue = (selectConfiguration[invSelectIndex][40] & 0xFF); return iValue; } @@ -910,31 +905,34 @@ public int getSelectAction() { public int getSelectMaskBank() { int iValue = -1; if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; - if (selectConfiguration[invSelectIndex] == null) appendToLog("!!! CANNOT getSelectMaskBank as selectConfiguration[" + invSelectIndex + "] is null"); + if (selectConfiguration[invSelectIndex] == null) Logger.trace("!!! CANNOT getSelectTarget as selectConfiguration[{}] is null", invSelectIndex); else iValue = (byte)(selectConfiguration[invSelectIndex][1] & 0xFF); return iValue; } public boolean setSelectMaskBank(int selectMaskBank) { - boolean bValue = false, DEBUG = false; + boolean bValue = false; if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; - if (selectConfiguration[invSelectIndex] == null) appendToLog("!!! CANNOT setSelectMaskBank[" + selectMaskBank + "] as selectConfiguration[" + invSelectIndex + "] is null"); + if (selectConfiguration[invSelectIndex] == null) Logger.trace("!!! CANNOT setSelectMaskBank[{}] as selectConfiguration[{}] is null", selectMaskBank, invSelectIndex); else { - if (DEBUG) appendToLog("Old selectConfiguration " + invSelectIndex + " = " + byteArrayToString(selectConfiguration[invSelectIndex])); + Logger.debug("Old selectConfiguration {} = {}", invSelectIndex,byteArrayToString(selectConfiguration[invSelectIndex])); byte[] bytes = new byte[1]; bytes[0] = (byte)(selectMaskBank & 0xFF); - if (false) { appendToLog("!!!! Skip 1A writeMAC 0x3141"); bValue = true; } + if (false) { + Logger.trace("!!!! Skip 1A writeMAC 0x3141"); + bValue = true; + } else bValue = writeMAC(0x3140 + invSelectIndex * 42 + 1, bytes, true); if (bValue) selectConfiguration[invSelectIndex][1] = bytes[0]; - if (DEBUG) appendToLog("bytes = " + byteArrayToString(bytes) + ", new selectConfiguration " + invSelectIndex + " = " + byteArrayToString(selectConfiguration[invSelectIndex])); + Logger.debug("bytes = {}, new selectConfiguration {} = {}" + byteArrayToString(bytes), invSelectIndex, byteArrayToString(selectConfiguration[invSelectIndex])); } - if (DEBUG) appendToLog("1 setSelectMaskBank with selectMaskBank = " + selectMaskBank + " and bValue = " + bValue); + Logger.debug("1 setSelectMaskBank with selectMaskBank = {} and bValue = {}", selectMaskBank, bValue); return bValue; } public int getSelectMaskOffset() { int iValue = -1; if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; - if (selectConfiguration[invSelectIndex] == null) appendToLog("!!! CANNOT getSelectMaskBank as selectConfiguration[" + invSelectIndex + "] is null"); + if (selectConfiguration[invSelectIndex] == null) Logger.trace("!!! CANNOT getSelectMaskBank as selectConfiguration[{}] is null", invSelectIndex); else { iValue = ((selectConfiguration[invSelectIndex][2] & 0xFF) << 24); iValue += ((selectConfiguration[invSelectIndex][3] & 0xFF) << 16); @@ -944,68 +942,74 @@ public int getSelectMaskOffset() { return iValue; } public boolean setSelectMaskOffset(int selectMaskOffset) { - boolean bValue = false, DEBUG = false; + boolean bValue = false; if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; - if (selectConfiguration[invSelectIndex] == null) appendToLog("!!! CANNOT setSelectMaskBank[" + selectMaskOffset + "] as selectConfiguration[" + invSelectIndex + "] is null"); + if (selectConfiguration[invSelectIndex] == null) Logger.trace("!!! CANNOT setSelectMaskBank[{}] as selectConfiguration[{}] is null", selectMaskOffset, invSelectIndex); else { - if (DEBUG) appendToLog("Old selectConfiguration " + invSelectIndex + " = " + byteArrayToString(selectConfiguration[invSelectIndex])); + Logger.debug("Old selectConfiguration {} = {}", invSelectIndex, byteArrayToString(selectConfiguration[invSelectIndex])); byte[] bytes = new byte[4]; bytes[0] = (byte)((selectMaskOffset >> 24) & 0xFF); bytes[1] = (byte)((selectMaskOffset >> 16) & 0xFF); bytes[2] = (byte)((selectMaskOffset >> 8) & 0xFF); bytes[3] = (byte)(selectMaskOffset & 0xFF); - if (false) { appendToLog("!!!! Skip 1A writeMAC 0x3142"); bValue = true; } + if (false) { + Logger.trace("!!!! Skip 1A writeMAC 0x3142"); + bValue = true; + } else bValue = writeMAC(0x3140 + invSelectIndex * 42 + 2, bytes, true); if (bValue) System.arraycopy(bytes, 0, selectConfiguration[invSelectIndex], 2, bytes.length); - if (DEBUG) appendToLog("bytes = " + byteArrayToString(bytes) + ", new selectConfiguration " + invSelectIndex + " = " + byteArrayToString(selectConfiguration[invSelectIndex])); + Logger.debug("bytes = {}, new selectConfiguration {} = {}", byteArrayToString(bytes), invSelectIndex, byteArrayToString(selectConfiguration[invSelectIndex])); } - if (DEBUG) appendToLog("1 setSelectMaskOffset with selectMaskOffset = " + selectMaskOffset + " and bValue = " + bValue); + Logger.debug("1 setSelectMaskOffset with selectMaskOffset = {} and bValue = {}", selectMaskOffset, bValue); return bValue; } public int getSelectMaskLength() { - int dataIndex = invSelectIndex, iValue = INVSELECT_INVALID; boolean DEBUG = false; + int dataIndex = invSelectIndex, iValue = INVSELECT_INVALID; if (dataIndex >= INVSELECT_MIN && dataIndex <= INVSELECT_MAX) { - if (DEBUG) appendToLog("selectConfiguration " + dataIndex + " = " + byteArrayToString(selectConfiguration[dataIndex])); + Logger.debug("selectConfiguration {} = {}", dataIndex, byteArrayToString(selectConfiguration[dataIndex])); if (selectConfiguration[dataIndex] != null) { iValue = selectConfiguration[dataIndex][6]; } } - if (DEBUG) appendToLog("iValue = " + iValue); + Logger.debug("iValue = {}", iValue); return iValue; } public boolean setSelectMaskLength(int selectMaskLength) { - boolean bValue = false, DEBUG = false; + boolean bValue = false; if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; - if (selectConfiguration[invSelectIndex] == null) appendToLog("!!! CANNOT setSelectMaskLength[" + selectMaskLength + "] as selectConfiguration[" + invSelectIndex + "] is null"); + if (selectConfiguration[invSelectIndex] == null) Logger.trace("!!! CANNOT setSelectMaskLength[{}] as selectConfiguration[{}] is null", selectMaskLength, invSelectIndex); else { - if (DEBUG) appendToLog("Old selectConfiguration " + invSelectIndex + " = " + byteArrayToString(selectConfiguration[invSelectIndex])); + Logger.debug("Old selectConfiguration {} = {}", invSelectIndex, byteArrayToString(selectConfiguration[invSelectIndex])); byte[] bytes = new byte[1]; bytes[0] = (byte)(selectMaskLength & 0xFF); - if (false) { appendToLog("!!!! Skip 1A writeMAC 0x3146"); bValue = true; } + if (false) { + Logger.trace("!!!! Skip 1A writeMAC 0x3146"); + bValue = true; + } else bValue = writeMAC(0x3140 + invSelectIndex * 42 + 6, bytes, true); if (bValue) selectConfiguration[invSelectIndex][6] = bytes[0]; - if (DEBUG) appendToLog("bytes = " + byteArrayToString(bytes) + ", new selectConfiguration " + invSelectIndex + " = " + byteArrayToString(selectConfiguration[invSelectIndex])); + Logger.debug("bytes = {}, new selectConfiguration {} = {}", byteArrayToString(bytes), invSelectIndex, byteArrayToString(selectConfiguration[invSelectIndex])); } - if (DEBUG) appendToLog("1 setSelectMaskOffset with setSelectMaskLength = " + selectMaskLength + " and bValue = " + bValue); + Logger.debug("1 setSelectMaskOffset with setSelectMaskLength = {} and bValue = {}", selectMaskLength, bValue); return bValue; } public String getSelectMaskData() { - String strValue = null; boolean DEBUG = false; + String strValue = null; if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; - if (selectConfiguration[invSelectIndex] == null) appendToLog("!!! CANNOT getSelectMaskBank as selectConfiguration[" + invSelectIndex + "] is null"); + if (selectConfiguration[invSelectIndex] == null) Logger.debug("!!! CANNOT getSelectMaskBank as selectConfiguration[{}] is null", invSelectIndex); else { if (selectConfiguration[invSelectIndex] != null && selectConfiguration[invSelectIndex].length > 39) { - if (DEBUG || true) appendToLog("selectConfiguration " + invSelectIndex + " = " + byteArrayToString(selectConfiguration[invSelectIndex])); + Logger.debug("selectConfiguration {} = {}", invSelectIndex, byteArrayToString(selectConfiguration[invSelectIndex])); byte[] bytes = new byte[32]; System.arraycopy(selectConfiguration[invSelectIndex], 7, bytes, 0, bytes.length); - if (DEBUG || true) appendToLog("bytes = " + byteArrayToString(bytes)); + Logger.debug("bytes = {}", byteArrayToString(bytes)); for (int i = 0; i < bytes.length; i++) { String string = String.format("%02X", bytes[i]); if (strValue == null) strValue = string; else strValue += string; - if (DEBUG) appendToLog("i = " + i + ", strValue = " + strValue); + Logger.debug("i = {}, strValue = {}", i, strValue); } if (strValue == null) strValue = ""; } @@ -1013,16 +1017,16 @@ public String getSelectMaskData() { return strValue; } public boolean setSelectMaskData(String maskData) { - boolean bValue = false, DEBUG = false; + boolean bValue = false; if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; - if (selectConfiguration[invSelectIndex] == null) appendToLog("!!! CANNOT setSelectMaskData[" + maskData + "] as selectConfiguration[" + invSelectIndex + "] is null"); + if (selectConfiguration[invSelectIndex] == null) Logger.trace("!!! CANNOT setSelectMaskData[{}] as selectConfiguration[{}] is null", maskData, invSelectIndex); else { - if (DEBUG) appendToLog("Old selectConfiguration " + invSelectIndex + " = " + byteArrayToString(selectConfiguration[invSelectIndex])); + Logger.debug("Old selectConfiguration {} = {}", invSelectIndex, byteArrayToString(selectConfiguration[invSelectIndex])); byte[] bytes = new byte[maskData.length() / 2 + maskData.length() % 2]; for (int i = 0; i < bytes.length; i++) { boolean bSingle = false; if (i * 2 + 2 > maskData.length()) bSingle = true; - if (DEBUG) appendToLog("substring i = " + i + " " + maskData.substring(i * 2, (bSingle ? i * 2 +1 : i * 2 + 2))); + Logger.debug("substring i = {} {}", i, maskData.substring(i * 2, (bSingle ? i * 2 +1 : i * 2 + 2))); try { String stringSub = null; if (bSingle) { @@ -1031,40 +1035,42 @@ public boolean setSelectMaskData(String maskData) { int iValue = Integer.parseInt(stringSub, 16); bytes[i] = (byte) (iValue & 0xFF); } catch (Exception ex) { - appendToLog("!!! Error in parsing maskdata " + maskData + " when i = " + i); + Logger.trace("!!! Error in parsing maskdata {} when i = {}", maskData, i); } } - if (false) { appendToLog("!!!! Skip 1A writeMAC 0x3147"); bValue = true; } + if (false) { + Logger.trace("!!!! Skip 1A writeMAC 0x3147"); + bValue = true; + } else bValue = writeMAC(0x3140 + invSelectIndex * 42 + 7, bytes, true); if (bValue) System.arraycopy(bytes, 0, selectConfiguration[invSelectIndex], 7, bytes.length); - if (DEBUG) appendToLog("bytes = " + byteArrayToString(bytes) + ", new selectConfiguration " + invSelectIndex + " = " + byteArrayToString(selectConfiguration[invSelectIndex])); + Logger.trace("bytes = {}, new selectConfiguration {} = {}", byteArrayToString(bytes), invSelectIndex, byteArrayToString(selectConfiguration[invSelectIndex])); } - if (DEBUG) appendToLog("1 setSelectMaskData with maskData = " + maskData + " and bValue = " + bValue); + Logger.debug("1 setSelectMaskData with maskData = {} and bValue = {}", maskData, bValue); return bValue; } public int getQueryTarget() { - int iValue = -1; boolean DEBUG = false; - if (DEBUG) appendToLog("2 getQueryTarget: iAntennaPort = " + antennaSelect); + int iValue = -1; + Logger.debug("2 getQueryTarget: iAntennaPort = {}", antennaSelect); if (antennaPortConfig[antennaSelect] == null) - appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!",antennaSelect); else { - if (DEBUG) - appendToLog("2A getQueryTarget: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2A getQueryTarget: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); if (antennaPortConfig[antennaSelect][13] != 0) iValue = 2; else if ((antennaPortConfig[antennaSelect][6] & 0x80) != 0) iValue = 1; else iValue = 0; - if (DEBUG) appendToLog(String.format("2b getQueryTarget: iValue = 0x%X", iValue)); + Logger.debug(String.format("2b getQueryTarget: iValue = 0x%X", iValue)); } return iValue; } 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 !!!"); + boolean bValue = false; + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { // queryTarget = 0; - if (DEBUG) appendToLog("2 setQueryConfig: queryTarget = " + queryTarget + ", querySession = " + querySession + ", querySelect = " + querySelect); - if (DEBUG) appendToLog("2A setQueryConfig: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2 setQueryConfig: queryTarget = {}, querySession = {}, querySelect = {}", queryTarget, querySession, querySelect); + Logger.debug("2A setQueryConfig: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); byte[] bytes = new byte[9]; System.arraycopy(antennaPortConfig[antennaSelect], 5, bytes, 0, bytes.length); @@ -1077,69 +1083,68 @@ public boolean setQueryTarget(int queryTarget, int querySession, int querySelect iValue = querySelect & 0x03; bytes[1] &= ~0x60; bytes[1] |= (iValue << 5); } - if (DEBUG) appendToLog("2b setQueryConfig: queryTarget = " + queryTarget); + Logger.debug("2b setQueryConfig: queryTarget = {}", queryTarget); if (queryTarget >= 0) { iValue = queryTarget & 0x01; bytes[1] &= ~0x80; bytes[1] |= (iValue << 7); if (queryTarget >= 2) bytes[8] = 1; else bytes[8] = 0; } - if (DEBUG) appendToLog("2C setQueryConfig: bytes = " + byteArrayToString(bytes)); + Logger.debug("2C setQueryConfig: bytes = {}", byteArrayToString(bytes)); boolean bSame = false; if (sameCheck | true) { byte[] bytesOld = new byte[9]; System.arraycopy(antennaPortConfig[antennaSelect], 5, bytesOld, 0, bytes.length); - if (DEBUG) appendToLog("2d setQueryConfig: bytesOld = " + byteArrayToString(bytesOld)); + Logger.debug("2d setQueryConfig: bytesOld = {}", byteArrayToString(bytesOld)); bSame = compareArray(bytes, bytesOld, bytes.length); - if (DEBUG) appendToLog("2E setQueryConfig: the array is the same = " + bSame); + Logger.debug("2E setQueryConfig: the array is the same = {}", bSame); } - //bSame = false; appendToLog("!!! assme bSame is false before 1b writeMAC 0x3035"); + //bSame = false; Logger.trace("!!! assme bSame is false before 1b writeMAC 0x3035"); if (bSame) { - if (DEBUG_PKDATA) appendToLog(String.format("!!! Skip sending repeated data %s in address 0x%X", byteArrayToString(bytes), 0x3030 + antennaSelect * 16 + 5)); + Logger.pkData(String.format("!!! Skip sending repeated data %s in address 0x%X", byteArrayToString(bytes), 0x3030 + antennaSelect * 16 + 5)); bValue = true; } else { - appendToLog("test 2"); + Logger.trace("test 2"); bValue = rx000Setting.writeMAC(0x3030 + antennaSelect * 16 + 5, bytes, true); if (bValue) System.arraycopy(bytes, 0, antennaPortConfig[antennaSelect], 5, bytes.length); } - if (DEBUG) appendToLog("2F setQueryConfig: with updated " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2F setQueryConfig: with updated {}", byteArrayToString(antennaPortConfig[antennaSelect])); } return bValue; } public int getQuerySession() { - int iValue = -1; boolean DEBUG = true; - if (DEBUG) appendToLog("2 getQuerySession: iAntennaPort = " + antennaSelect); - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + int iValue = -1; + Logger.debug("2 getQuerySession: iAntennaPort = {}", antennaSelect); + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { - if (DEBUG) appendToLog("2A getQuerySession: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2A getQuerySession: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); iValue = (antennaPortConfig[antennaSelect][6] & 0x18) >> 3; - if (DEBUG) appendToLog(String.format("2b getQuerySession: iValue = 0x%X", iValue)); + Logger.debug(String.format("2b getQuerySession: iValue = 0x%X", iValue)); } return iValue; } public int getQuerySelect() { - int iValue = -1; boolean DEBUG = false; - if (DEBUG) appendToLog("2 getQuerySession: iAntennaPort = " + antennaSelect); - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + int iValue = -1; + Logger.debug("2 getQuerySession: iAntennaPort = {}", antennaSelect); + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { - if (DEBUG) appendToLog("2A getQuerySession: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2A getQuerySession: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); iValue = (antennaPortConfig[antennaSelect][6] & 0x60) >> 5; - if (DEBUG) appendToLog(String.format("2b getQuerySession: iValue = 0x%X", iValue)); + Logger.debug(String.format("2b getQuerySession: iValue = 0x%X", iValue)); } return iValue; } public boolean setQuerySelect(int querySelect) { - boolean bValue = false, DEBUG = false; + boolean bValue = false; for (int antennaSelect = 0; antennaSelect < 16; antennaSelect++) { if (antennaPortConfig[antennaSelect] == null) - appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { // queryTarget = 0; - if (DEBUG) appendToLog("2 setQuerySelect: querySelect = " + querySelect); - if (DEBUG) - appendToLog("2A setQuerySelect: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2 setQuerySelect: querySelect = {}", querySelect); + Logger.debug("2A setQuerySelect: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); byte[] bytes = new byte[1]; bytes[0] = antennaPortConfig[antennaSelect][6]; @@ -1149,24 +1154,20 @@ public boolean setQuerySelect(int querySelect) { bytes[0] &= ~0x60; bytes[0] |= (iValue << 5); } - if (DEBUG) - appendToLog("2C setQueryConfig: bytes = " + byteArrayToString(bytes)); + Logger.debug("2C setQueryConfig: bytes = {}", byteArrayToString(bytes)); boolean bSame = false; if (sameCheck) { if (bytes[0] == antennaPortConfig[antennaSelect][6]) bSame = true; - if (DEBUG) - appendToLog("2E setQueryConfig: the array is the same = " + bSame); + Logger.debug("2E setQueryConfig: the array is the same = {}", bSame); } if (bSame) { - if (DEBUG_PKDATA) - appendToLog(String.format("!!! Skip sending repeated data %s in address 0x%X", byteArrayToString(bytes), 0x3030 + antennaSelect * 16 + 5)); + Logger.pkData(String.format("!!! Skip sending repeated data %s in address 0x%X", byteArrayToString(bytes), 0x3030 + antennaSelect * 16 + 5)); bValue = true; } else { bValue = rx000Setting.writeMAC(0x3030 + antennaSelect * 16 + 6, bytes, true); if (bValue) antennaPortConfig[antennaSelect][6] = bytes[0]; } - if (DEBUG) - appendToLog("2F setQueryConfig: with updated " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2F setQueryConfig: with updated {}", byteArrayToString(antennaPortConfig[antennaSelect])); if (bValue == false) break; } } @@ -1176,34 +1177,34 @@ public boolean setQuerySelect(int querySelect) { final int INVALGO_INVALID = -1; final int INVALGO_MIN = 0; final int INVALGO_MAX = 3; int invAlgo = INVALGO_INVALID; public int getInvAlgo() { - int iValue = -1; boolean DEBUG = false; - if (DEBUG) appendToLog("3 getInvAlgo: iAntennaPort = " + antennaSelect); - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + int iValue = -1; + Logger.debug("3 getInvAlgo: iAntennaPort = {}", antennaSelect); + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { - if (DEBUG) appendToLog("3A getInvAlgo: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("3A getInvAlgo: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); iValue = antennaPortConfig[antennaSelect][6]; - if (DEBUG) appendToLog(String.format("3b getInvAlgo: iValue = 0x%X", iValue)); + Logger.debug(String.format("3b getInvAlgo: iValue = 0x%X", iValue)); iValue &= 0x01; //iValue |= 0x01; - if (DEBUG) appendToLog(String.format("3c getInvAlgo: changed iValue = 0x%X", iValue)); + Logger.debug(String.format("3c getInvAlgo: changed iValue = 0x%X", iValue)); if (iValue == 0) iValue = 3; else iValue = 0; - if (DEBUG) appendToLog(String.format("3d getInvAlgo: after adjustement, iValue = 0x%X", iValue)); + Logger.debug(String.format("3d getInvAlgo: after adjustement, iValue = 0x%X", iValue)); } return iValue; } public boolean setInvAlgo(int invAlgo) { - boolean bValue = false, DEBUG = false; - if (DEBUG) appendToLog("3 setInvAlgo[" + invAlgo + "]"); - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + boolean bValue = false; + Logger.debug("3 setInvAlgo[{}]", invAlgo); + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { byte[] bytes = new byte[1]; bytes[0] = (byte)(antennaPortConfig[antennaSelect][6] & ~0x01); if (invAlgo == 0) bytes[0] |= 0x01; - if (DEBUG) appendToLog("3 setInvAlgo: bytes = " + byteArrayToString(bytes)); + Logger.debug("3 setInvAlgo: bytes = {}", byteArrayToString(bytes)); bValue = writeMAC(0x3036 + this.antennaSelect * 16, bytes, true); if (bValue) antennaPortConfig[antennaSelect][6] = bytes[0]; } - if (DEBUG) appendToLog("3A setInvAlgo with bValue = " + bValue); + Logger.debug("3A setInvAlgo with bValue = {}", bValue); return bValue; } @@ -1212,10 +1213,11 @@ public boolean setInvAlgo(int invAlgo) { public boolean setMatchRep(int matchRep) { if (matchRep == this.matchRep) return true; if (this.matchRep == matchRep && sameCheck) { - appendToLog("Skip sending repeated data with matchRep = " + matchRep); + Logger.trace("Skip sending repeated data with matchRep = {}", matchRep); return true; } - this.matchRep = matchRep; appendToLog(String.format("!!! Skip setMatchRep[0x%X]", matchRep)); + this.matchRep = matchRep; + Logger.trace(String.format("!!! Skip setMatchRep[0x%X]", matchRep)); return true; } @@ -1223,7 +1225,8 @@ public boolean setMatchRep(int matchRep) { int tagSelect = TAGSELECT_INVALID; public boolean setTagSelect(int tagSelect) { if (tagSelect == this.tagSelect) return true; - this.tagSelect = tagSelect; appendToLog(String.format("!!! Skip setTagSelect[%d]", tagSelect)); + this.tagSelect = tagSelect; + Logger.trace(String.format("!!! Skip setTagSelect[%d]", tagSelect)); return true; } @@ -1235,41 +1238,39 @@ public boolean setTagSelect(int tagSelect) { public int getTagRead() { int iValue = 0; if (rx000Setting.multibankReadConfig[0] == null) - appendToLog("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); + Logger.trace("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); else if (rx000Setting.multibankReadConfig[1] == null) - appendToLog("!!! CANNOT continue as multibankReadConfig[1] is null !!!"); + Logger.trace("!!! CANNOT continue as multibankReadConfig[1] is null !!!"); else if (rx000Setting.multibankReadConfig[0][0] != 0) { iValue++; if (rx000Setting.multibankReadConfig[1][0] != 0) iValue++; - appendToLog("getTagRead = " + iValue); - } else appendToLog("getTagRead = 0 as multibankReadConfig[0] = " + byteArrayToString(multibankReadConfig[0]) + ", [1] = " + byteArrayToString(multibankReadConfig[1])); + Logger.trace("getTagRead = {}", iValue); + } else Logger.trace("getTagRead = 0 as multibankReadConfig[0] = {}, [1] = {}", byteArrayToString(multibankReadConfig[0]), byteArrayToString(multibankReadConfig[1])); return iValue; } boolean isMultibankReplyNeed(int index) { boolean bValue = false; if (resReadNoReply) bValue = true; - appendToLog("multibankReadConfig[" + index + "] = " + byteArrayToString(rx000Setting.multibankReadConfig[index]) + ", bValue = " + bValue); + Logger.trace("multibankReadConfig[{}] = {}, bValue = {}", index, byteArrayToString(rx000Setting.multibankReadConfig[index]), bValue); return bValue; } boolean resReadNoReply = false; public boolean setResReadNoReply(boolean resReadNoReply) { - appendToLog("setResReadNoReply[" + resReadNoReply + "]"); + Logger.trace("setResReadNoReply[{}]", resReadNoReply); this.resReadNoReply = resReadNoReply; return true; } public boolean setTagRead(int tagRead) { - boolean bValue = false, DEBUG = false; - if (DEBUG) appendToLog("0 setTagRead with tagRead = " + tagRead); + boolean bValue = false; + Logger.debug("0 setTagRead with tagRead = {}", tagRead); if (rx000Setting.multibankReadConfig[0] == null) - appendToLog("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); + Logger.trace("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); else if (rx000Setting.multibankReadConfig[1] == null) - appendToLog("!!! CANNOT continue as multibankReadConfig[1] is null !!!"); + Logger.trace("!!! CANNOT continue as multibankReadConfig[1] is null !!!"); else { - if (DEBUG) { - appendToLog("0 multibankReadConfig[0] = " + byteArrayToString(rx000Setting.multibankReadConfig[0])); - appendToLog("0 multibankReadConfig[1] = " + byteArrayToString(rx000Setting.multibankReadConfig[1])); - } + Logger.debug("0 multibankReadConfig[0] = {}", byteArrayToString(rx000Setting.multibankReadConfig[0])); + Logger.debug("0 multibankReadConfig[1] = {}", byteArrayToString(rx000Setting.multibankReadConfig[1])); if ((tagRead == 0 && rx000Setting.multibankReadConfig[0][0] != 0) || (tagRead != 0 && rx000Setting.multibankReadConfig[0][0] == 0)) { byte[] bytes = new byte[1]; @@ -1279,11 +1280,9 @@ else if (rx000Setting.multibankReadConfig[1] == null) bValue = writeMAC(0x3270 + 7 * 0, bytes, true); if (bValue) rx000Setting.multibankReadConfig[0][0] = bytes[0]; - if (DEBUG) - appendToLog("0A multibankReadConfig[0] = " + byteArrayToString(rx000Setting.multibankReadConfig[0]) + ", with bValue = " + bValue); + Logger.debug("0A multibankReadConfig[0] = {}, with bValue = {}", byteArrayToString(rx000Setting.multibankReadConfig[0]), bValue); } else bValue = true; - if (DEBUG) - appendToLog("0 multibankReadConfig[1] = " + byteArrayToString(rx000Setting.multibankReadConfig[1])); + Logger.debug("0 multibankReadConfig[1] = {}", byteArrayToString(rx000Setting.multibankReadConfig[1])); if (bValue && ((tagRead < 2 && rx000Setting.multibankReadConfig[1][0] != 0) || (tagRead >= 2 && rx000Setting.multibankReadConfig[1][0] == 0))) { byte[] bytes = new byte[1]; @@ -1292,8 +1291,7 @@ else if (rx000Setting.multibankReadConfig[1] == null) bValue = writeMAC(0x3270 + 7 * 1, bytes, true); if (bValue) rx000Setting.multibankReadConfig[1][0] = bytes[0]; - if (DEBUG) - appendToLog("0A multibankReadConfig[1] = " + byteArrayToString(rx000Setting.multibankReadConfig[1])); + Logger.debug("0A multibankReadConfig[1] = {}", byteArrayToString(rx000Setting.multibankReadConfig[1])); } } return bValue; @@ -1304,10 +1302,11 @@ else if (rx000Setting.multibankReadConfig[1] == null) public boolean setTagDelay(int tagDelay) { if (tagDelay == this.tagDelay) return true; if (this.tagDelay == tagDelay && sameCheck) { - appendToLog("!!! Skip sending repeated data with tagDelay = " + tagDelay); + Logger.trace("!!! Skip sending repeated data with tagDelay = {}", tagDelay); return true; } - this.tagDelay = tagDelay; appendToLog(String.format("!!! Skip setTagDelay[%d]", tagDelay)); + this.tagDelay = tagDelay; + Logger.trace("!!! Skip setTagDelay[{}]", tagDelay); return true; } @@ -1319,7 +1318,7 @@ public byte getDupElimRollWindow() { } public boolean setDupElimRollWindow(byte dupElimDelay) { if (dupElimRollWindow != null && dupElimRollWindow.length == 1 && dupElimRollWindow[0] == dupElimDelay && sameCheck) { - appendToLog("!!! Skip sending repeated data with dupElimDelay = " + dupElimDelay); + Logger.trace("!!! Skip sending repeated data with dupElimDelay = {}", dupElimDelay); return true; } byte[] bytes = new byte[1]; @@ -1342,7 +1341,7 @@ public int getTagRate() { public int getEventPacketUplinkEnable() { if (eventPacketUplnkEnable != null && eventPacketUplnkEnable.length == 2) { int iValue = ((eventPacketUplnkEnable[0] & 0xFF) << 8) + (eventPacketUplnkEnable[1] & 0xFF); - appendToLog("eventPacketUplnkEnable iValue = " + iValue); + Logger.trace("eventPacketUplnkEnable iValue = {}", iValue); return iValue; } readMAC(0x3906, 2); @@ -1351,7 +1350,7 @@ public int getEventPacketUplinkEnable() { public boolean setEventPacketUplinkEnable(byte byteEventPacketUplinkEnable) { if (eventPacketUplnkEnable != null && eventPacketUplnkEnable.length == 2 && eventPacketUplnkEnable[1] == byteEventPacketUplinkEnable && sameCheck) { - appendToLog("!!! Skip sending repeated data with byteEventPacketUplinkEnable = " + byteEventPacketUplinkEnable); + Logger.trace("!!! Skip sending repeated data with byteEventPacketUplinkEnable = {}", byteEventPacketUplinkEnable); return true; } byte[] bytes = new byte[2]; @@ -1371,7 +1370,7 @@ public byte getIntraPacketDelay() { public boolean setIntraPacketDelay(byte intraPkDelay) { if (intraPkDelay >= 0 && intraPacketDelay != null && sameCheck) { if (intraPacketDelay.length == 1 && intraPacketDelay[0] == intraPkDelay) { - appendToLog("!!! Skip sending repeated data with intraPkDelay = " + intraPkDelay); + Logger.trace("!!! Skip sending repeated data with intraPkDelay = {}", intraPkDelay); return true; } } @@ -1389,10 +1388,11 @@ public long getCycleDelay() { public boolean setCycleDelay(long cycleDelay) { if (cycleDelay == this.cycleDelay) return true; if (this.cycleDelay == cycleDelay && sameCheck) { - appendToLog("!!! Skip sending repeated data with cycleDelay = " + cycleDelay); + Logger.trace("!!! Skip sending repeated data with cycleDelay = {}", cycleDelay); return true; } - this.cycleDelay = cycleDelay; appendToLog(String.format("!!! Skip setCycleDelay[%d]", cycleDelay)); + this.cycleDelay = cycleDelay; + Logger.trace("!!! Skip setCycleDelay[{}]", cycleDelay); return true; } @@ -1409,7 +1409,7 @@ private boolean getHST_AUTHENTICATE_CFG() { return sendHostRegRequest(HostRegRequests.HST_AUTHENTICATE_CFG, false, msgBuffer); } boolean setHST_AUTHENTICATE_CFG(boolean sendReply, boolean incReplyLenth, int csi, int length) { - appendToLog("sendReply = " + sendReply + ", incReplyLenth = " + incReplyLenth + ", length = " + length); + Logger.trace("sendReply = {}, incReplyLenth = {}, length = {}", sendReply, incReplyLenth, length); if (length < 0 || length > 0x3FF) return false; byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 0, (byte) 0x0F, 0, 0, 0, 0}; @@ -1428,7 +1428,7 @@ public String getAuthMatchData() { String strValue = ""; for (int i = 0; i < 3; i++) { if (length > 0) { - appendToLog("i = " + i + ", authMatchDataReady = " + authMatchDataReady); + Logger.trace("i = {}, authMatchDataReady = {}", i, authMatchDataReady); if ((authMatchDataReady & (0x01 << i)) == 0) { byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 1, (byte)0x0F, 0, 0, 0, 0}; msgBuffer[2] += i; @@ -1461,7 +1461,7 @@ private boolean getHST_UNTRACEABLE_CFG() { return sendHostRegRequest(HostRegRequests.HST_UNTRACEABLE_CFG, false, msgBuffer); } public boolean setHST_UNTRACEABLE_CFG(int range, boolean user, int tid, int epcLength, boolean epc, boolean uxpc) { - appendToLog("range = " + range + ", user = " + user + ", tid = " + tid + ", epc = " + epc + ", epcLength = " + epcLength + ", xcpc = " + uxpc); + Logger.trace("range = {}, user = {}, tid = {}, epc = {}, epcLength = {}, xcpc = {}", range, user, tid, epc, epcLength, uxpc); if (range < 0 || range > 3) return false; if (tid < 0 || tid > 2) return false; if (epcLength < 0 || epcLength > 31) return false; @@ -1474,7 +1474,7 @@ public boolean setHST_UNTRACEABLE_CFG(int range, boolean user, int tid, int epcL msgBuffer[5] |= ((epcLength & 0x18) >> 3); untraceableEpcLength = epcLength; if (epc) msgBuffer[5] |= 0x04; untraceableEpc = epc; if (uxpc) msgBuffer[5] |= 0x08; untraceableUXpc = uxpc; - appendToLog("going to do sendHostRegRequest(HostRegRequests.HST_UNTRACEABLE_CFG,"); + Logger.trace("going to do sendHostRegRequest(HostRegRequests.HST_UNTRACEABLE_CFG,"); return sendHostRegRequest(HostRegRequests.HST_UNTRACEABLE_CFG, true, msgBuffer); } @@ -1483,10 +1483,11 @@ public boolean setHST_UNTRACEABLE_CFG(int range, boolean user, int tid, int epcL public boolean setInvModeCompact(boolean bInvModeCompact) { int invModeCompact = (bInvModeCompact ? 1 : 0); if (invModeCompact == this.invModeCompact && sameCheck) { - appendToLog("!!! Skip sending repeated data with bInvModeCompact = " + bInvModeCompact); + Logger.trace("!!! Skip sending repeated data with bInvModeCompact = {}", bInvModeCompact); return true; } - this.invModeCompact = invModeCompact; appendToLog(String.format("!!! Skip setInvModeCompact[%s]", (bInvModeCompact ? "true" : "false"))); + this.invModeCompact = invModeCompact; + Logger.trace("!!! Skip setInvModeCompact[{}]", bInvModeCompact ? "true" : "false"); return true; } @@ -1498,7 +1499,7 @@ boolean getInvBrandId() { } public boolean setInvBrandId(boolean invBrandId) { if (invBrandId == getInvBrandId()) return true; - this.invBrandId = (invBrandId ? 1 : 0); appendToLog("!!! Skip setInvBrandId[" + invBrandId + "]"); + this.invBrandId = (invBrandId ? 1 : 0); Logger.trace("!!! Skip setInvBrandId[{}]", invBrandId); return true; } @@ -1509,30 +1510,30 @@ private boolean getHST_INV_CFG() { final int ALGOSELECT_INVALID = -1; final int ALGOSELECT_MIN = 0; final int ALGOSELECT_MAX = 3; //DataSheet says Max=1 int algoSelect = ALGOSELECT_INVALID; public boolean setAlgoSelect(int algoSelect) { - boolean bValue = false, DEBUG = false; - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + boolean bValue = false; + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { //algoSelect = 0; - if (DEBUG) appendToLog("2 setAlgoSelect: algoSelect = " + algoSelect); - if (DEBUG) appendToLog("2A setAlgoSelect: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2 setAlgoSelect: algoSelect = {}", algoSelect); + Logger.debug("2A setAlgoSelect: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); byte[] bytes = new byte[1]; bytes[0] = antennaPortConfig[antennaSelect][6]; if (algoSelect >= 3) bytes[0] &= ~0x01; else bytes[0] |= 0x01; - if (DEBUG) appendToLog(String.format("2A1 setAlgoSelect: bytes = 0x%X with sameCheck = ", bytes[0]) + sameCheck); + Logger.debug(String.format("2A1 setAlgoSelect: bytes = 0x%X with sameCheck = ", bytes[0]) + sameCheck); boolean bSame = false; if (sameCheck) { - if (DEBUG) appendToLog(String.format("2A2 setAlgoSelect: bytesOld = 0x%X", antennaPortConfig[antennaSelect][6])); + Logger.debug(String.format("2A2 setAlgoSelect: bytesOld = 0x%X", antennaPortConfig[antennaSelect][6])); if (antennaPortConfig[antennaSelect][6] == bytes[0]) bSame = true; - if (DEBUG) appendToLog("2ab setAlgoSelect: the array is the same = " + bSame); + Logger.debug("2ab setAlgoSelect: the array is the same = {}", bSame); } if (bSame) { - if (DEBUG_PKDATA) appendToLog(String.format("!!! Skip sending repeated data %s in address 0x%X", byteArrayToString(bytes), 0x3030 + antennaSelect * 16 + 6)); + Logger.pkData(String.format("!!! Skip sending repeated data %s in address 0x%X", byteArrayToString(bytes), 0x3030 + antennaSelect * 16 + 6)); bValue = true; } else { bValue = rx000Setting.writeMAC(0x3030 + antennaSelect * 16 + 6, bytes, true); if (bValue) antennaPortConfig[antennaSelect][6] = bytes[0]; } - if (DEBUG) appendToLog("2b setAlgoSelect: with updated array " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2b setAlgoSelect: with updated array {}", byteArrayToString(antennaPortConfig[antennaSelect])); } return bValue; } @@ -1552,29 +1553,29 @@ public int getAlgoStartQ() { } } public boolean setAlgoStartQ(int algoStartQ) { - boolean bValue = false, DEBUG = false; - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + boolean bValue = false; + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { //algoStartQ = 6; - if (DEBUG) appendToLog("2 setAlgoStartQ: algoStartQ = " + algoStartQ); - if (DEBUG) appendToLog("2A setAlgoStartQ: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2 setAlgoStartQ: algoStartQ = {}", algoStartQ); + Logger.debug("2A setAlgoStartQ: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); byte[] bytes = new byte[1]; bytes[0] = antennaPortConfig[antennaSelect][8]; bytes[0] &= ~0x0F; bytes[0] |= (algoStartQ & 0x0F); - if (DEBUG) appendToLog(String.format("2A1 setAlgoStartQ: bytes = 0x%X with sameCheck = ", bytes[0]) + sameCheck); + Logger.debug(String.format("2A1 setAlgoStartQ: bytes = 0x%X with sameCheck = ", bytes[0]) + sameCheck); boolean bSame = false; if (sameCheck) { if (antennaPortConfig[antennaSelect][8] == bytes[0]) bSame = true; - if (DEBUG) appendToLog("2ab setAlgoStartQ: the array is the same = " + bSame); + Logger.debug("2ab setAlgoStartQ: the array is the same = {}", bSame); } if (bSame) { - if (DEBUG_PKDATA) appendToLog(String.format("!!! Skip sending repeated data %s in address 0x%X", byteArrayToString(bytes), 0x3030 + antennaSelect * 16 + 8)); + Logger.pkData(String.format("!!! Skip sending repeated data %s in address 0x%X", byteArrayToString(bytes), 0x3030 + antennaSelect * 16 + 8)); bValue = true; } else { bValue = writeMAC(0x3030 + antennaSelect * 16 + 8, bytes, true); if (bValue) antennaPortConfig[antennaSelect][8] = bytes[0]; } - if (DEBUG) appendToLog("2b setAlgoStartQ: with updated " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2b setAlgoStartQ: with updated {}", byteArrayToString(antennaPortConfig[antennaSelect])); } return bValue; } @@ -1602,29 +1603,29 @@ public int getAlgoMinQ(int algoSelect) { final int ALGORETRY_INVALID = -1, ALGORETRY_MIN = 0, ALGORETRY_MAX = 255, ALGORETRY_DEFAULT = 1; int algoRetry = ALGORETRY_INVALID; public int getAlgoMinQCycles() { - int iValue = -1; boolean DEBUG = false; - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + int iValue = -1; + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { - if (DEBUG) appendToLog("3A getAlgoMinQCycles: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("3A getAlgoMinQCycles: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); iValue = ((antennaPortConfig[antennaSelect][7] >> 4) & 0x0F); - if (DEBUG) appendToLog(String.format("3b getAlgoMinQCycles: iValue = 0x%X", iValue)); + Logger.debug(String.format("3b getAlgoMinQCycles: iValue = 0x%X", iValue)); } return iValue; } public boolean setAlgoMinQCycles(int minQCycles) { - boolean bValue = false, DEBUG = true; - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + boolean bValue = false; + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect ); else if (getAlgoMinQCycles() == minQCycles && sameCheck) { - appendToLog("!!! Skip sending repeated data with algoRetry = " + algoRetry); + Logger.trace("!!! Skip sending repeated data with algoRetry = {}", algoRetry); return true; } else { - if (DEBUG) appendToLog("3A setAlgoMinQCycles: minQCycles = " + minQCycles + ", getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("3A setAlgoMinQCycles: minQCycles = {}, getAntennaPortConfig[{}] = {}", minQCycles, antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); byte[] data = new byte[1]; data[0] = (byte) (antennaPortConfig[antennaSelect][7] & 0x0F); data[0] |= (byte)(minQCycles << 4); bValue = writeMAC(0x3037 + this.antennaSelect * 16, data, true); if (bValue) antennaPortConfig[antennaSelect][7] = data[0]; - if (DEBUG) appendToLog("3C setAlgoMinQCycles: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("3C setAlgoMinQCycles: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); } return bValue; } @@ -1637,34 +1638,34 @@ int getAlgoAbFlip(int algoSelect) { } } public int getAlgoAbFlip() { - int iValue = -1; boolean DEBUG = false; - if (DEBUG) appendToLog("3 getAlgoAbFlip: iAntennaPort = " + antennaSelect); - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + int iValue = -1; + Logger.debug("3 getAlgoAbFlip: iAntennaPort = {}", antennaSelect); + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { - if (DEBUG) appendToLog("3A getAlgoAbFlip: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("3A getAlgoAbFlip: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); iValue = antennaPortConfig[antennaSelect][13]; - if (DEBUG) appendToLog(String.format("3b getAlgoAbFlip: iValue = 0x%X", iValue)); + Logger.debug(String.format("3b getAlgoAbFlip: iValue = 0x%X", iValue)); } return iValue; } public boolean setAlgoAbFlip(int algoAbFlip) { - boolean bValue = false, DEBUG = false; - if (DEBUG) appendToLog("3 setAlgoAbFlip: iAntennaPort = " + antennaSelect); - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + boolean bValue = false; + Logger.debug("3 setAlgoAbFlip: iAntennaPort = {}" + antennaSelect); + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { - if (DEBUG) appendToLog("3A setAlgoAbFlip: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("3A setAlgoAbFlip: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); byte[] data = new byte[1]; data[0] = (byte)(algoAbFlip & 0xFF); bValue = writeMAC(0x303d + this.antennaSelect * 16, data, true); if (bValue) antennaPortConfig[antennaSelect][13] = data[0]; - if (DEBUG) appendToLog("3b setAlgoAbFlip: bValue = " + bValue); - if (DEBUG) appendToLog("3C setAlgoAbFlip: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("3b setAlgoAbFlip: bValue = {}", bValue); + Logger.debug("3C setAlgoAbFlip: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); } return bValue; } boolean setAlgoAbFlip(int algoAbFlip, int algoRunTilZero) { if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) return false; - appendToLog("algoSelect = " + algoSelect + ", algoAbFlip = " + algoAbFlip + ", algoRunTilZero = " + algoRunTilZero); + Logger.trace("algoSelect = {}, algoAbFlip = {}, algoRunTilZero = {}", algoSelect, algoAbFlip, algoRunTilZero); return algoSelectedData[algoSelect].setAlgoAbFlip(algoAbFlip, algoRunTilZero); } @@ -1687,10 +1688,11 @@ public boolean setAlgoRunTilZero(int algoRunTilZero) { if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) return false; else if (algoRunTilZero < ALGORUNTILZERO_MIN || algoRunTilZero > ALGORUNTILZERO_MAX) algoRunTilZero = ALGORUNTILZERO_DEFAULT; if (this.algoRunTilZero == algoRunTilZero && sameCheck) { - appendToLog("!!! Skip sending repeated data with algoRunTilZero = " + algoRunTilZero); + Logger.trace("!!! Skip sending repeated data with algoRunTilZero = {}", algoRunTilZero); return true; } - this.algoRunTilZero = algoRunTilZero; appendToLog(String.format("!!! Skip setAlgoRunTilZero[%d]", algoRunTilZero)); + this.algoRunTilZero = algoRunTilZero; + Logger.trace("!!! Skip setAlgoRunTilZero[{}]", algoRunTilZero); return true; } @@ -1712,7 +1714,7 @@ private boolean getHST_INV_RSSI_FILTERING_CONFIG() { return sendHostRegRequest(HostRegRequests.HST_INV_RSSI_FILTERING_CONFIG, false, msgBuffer); } public boolean setHST_INV_RSSI_FILTERING_CONFIG(int rssiFilterType, int rssiFilterOption) { - appendToLog("rssiFilterType = " + rssiFilterType + ", rssiFilterOption = " + rssiFilterOption); + Logger.trace("rssiFilterType = {}, rssiFilterOption = {}", rssiFilterType, rssiFilterOption); byte[] bytes = new byte[] { 0 }; if (rssiFilterType > 0) { if (rssiFilterOption > 0) bytes[0] = 2; @@ -1764,21 +1766,21 @@ private boolean getHST_INV_RSSI_FILTERING_COUNT() { return sendHostRegRequest(HostRegRequests.HST_INV_RSSI_FILTERING_THRESHOLD, false, msgBuffer); } public boolean setHST_INV_RSSI_FILTERING_COUNT(long rssiFilterCount) { - appendToLog("entry: rssiFilterCount = " + rssiFilterCount + ", this.rssiFilterCount = " + this.rssiFilterCount); + Logger.trace("entry: rssiFilterCount = {}, this.rssiFilterCount = {}", rssiFilterCount, this.rssiFilterCount); byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 9, 9, 0, 0, 0, 0}; if (rssiFilterCount < RSSIFILTERCOUNT_MIN || rssiFilterCount > RSSIFILTERCOUNT_MAX) rssiFilterCount = mDefault.rssiFilterCount; - appendToLog("rssiFilterCount 1 = " + rssiFilterCount + ", this.rssiFilterCount = " + this.rssiFilterCount); + Logger.trace("rssiFilterCount 1 = {}, this.rssiFilterCount = {}", rssiFilterCount, this.rssiFilterCount); if (this.rssiFilterCount == rssiFilterCount && sameCheck) return true; - appendToLog("rssiFilterCount 2 = " + rssiFilterCount + ", this.rssiFilterCount = " + this.rssiFilterCount); + Logger.trace("rssiFilterCount 2 = {}, this.rssiFilterCount = {}", rssiFilterCount, this.rssiFilterCount); msgBuffer[4] |= (byte) (rssiFilterCount & 0xFF); msgBuffer[5] |= (byte) ((rssiFilterCount >> 8) & 0xFF); msgBuffer[6] |= (byte) ((rssiFilterCount >> 16) & 0xFF); msgBuffer[7] |= (byte) ((rssiFilterCount >> 24) & 0xFF); this.rssiFilterCount = rssiFilterCount; - appendToLog("entering to sendHostRegRequest: rssiFilterCount = " + rssiFilterCount); + Logger.trace("entering to sendHostRegRequest: rssiFilterCount = {}", rssiFilterCount); boolean bValue = sendHostRegRequest(HostRegRequests.HST_INV_RSSI_FILTERING_COUNT, true, msgBuffer); - appendToLog("after sendHostRegRequest: rssiFilterCount = " + rssiFilterCount); + Logger.trace("after sendHostRegRequest: rssiFilterCount = {}", rssiFilterCount); return bValue; } @@ -1839,33 +1841,35 @@ public boolean setInvMatchData(String matchData) { int accessRetry = ACCRETRY_INVALID; 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 + "]"); + this.accessVerfiy = accessVerfiy; + this.accessRetry = accessRetry; + Logger.trace("!!! Skip setAccessRetry[{}, {}]", accessVerfiy, accessRetry); return true; } boolean setAccessEnable(int accessEnable, int accessEnable2) { - boolean bValue = false, DEBUG = false; - if (DEBUG) appendToLog("0 setAccessEnable with accessEnable = " + accessEnable + ", accessEnable2 = " + accessEnable2); - if (rx000Setting.multibankReadConfig[0] == null) appendToLog("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); - else if (rx000Setting.multibankReadConfig[1] == null) appendToLog("!!! CANNOT continue as multibankReadConfig[1] is null !!!"); + boolean bValue = false; + Logger.debug("0 setAccessEnable with accessEnable = {}, accessEnable2 = {}", accessEnable, accessEnable2); + if (rx000Setting.multibankReadConfig[0] == null) Logger.trace("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); + else if (rx000Setting.multibankReadConfig[1] == null) Logger.trace("!!! CANNOT continue as multibankReadConfig[1] is null !!!"); else { - if (DEBUG) appendToLog("0 multibankReadConfig[0] = " + byteArrayToString(rx000Setting.multibankReadConfig[0])); + Logger.debug("0 multibankReadConfig[0] = {}", byteArrayToString(rx000Setting.multibankReadConfig[0])); if (accessEnable == rx000Setting.multibankReadConfig[0][0] && sameCheck) bValue = true; else { byte[] bytes = new byte[1]; bytes[0] = (byte) (accessEnable & 0xFF); bValue = writeMAC(0x3270 + 7 * 0, bytes, true); if (bValue) rx000Setting.multibankReadConfig[0][0] = bytes[0]; - if (DEBUG) appendToLog("0A multibankReadConfig[0] = " + byteArrayToString(rx000Setting.multibankReadConfig[0])); + Logger.debug("0A multibankReadConfig[0] = {}", byteArrayToString(rx000Setting.multibankReadConfig[0])); } - if (DEBUG) appendToLog("0 multibankReadConfig[1] = " + byteArrayToString(rx000Setting.multibankReadConfig[1])); + Logger.debug("0 multibankReadConfig[1] = {}", byteArrayToString(rx000Setting.multibankReadConfig[1])); if (accessEnable2 == rx000Setting.multibankReadConfig[1][0] && sameCheck) { } else if (bValue) { byte[] bytes = new byte[1]; bytes[0] = (byte) (accessEnable2 & 0xFF); bValue = writeMAC(0x3270 + 7 * 1, bytes, true); if (bValue) rx000Setting.multibankReadConfig[1][0] = bytes[0]; - if (DEBUG) appendToLog("0A multibankReadConfig[1] = " + byteArrayToString(rx000Setting.multibankReadConfig[1])); + Logger.debug("0A multibankReadConfig[1] = {}", byteArrayToString(rx000Setting.multibankReadConfig[1])); } } return bValue; @@ -1873,35 +1877,35 @@ else if (bValue) { final int ACCBANK_INVALID = -1; final int ACCBANK_MIN = 0; final int ACCBANK_MAX = 3; int accessBank = ACCBANK_INVALID; int accessBank2 = ACCBANK_INVALID; int getAccessBank() { - boolean DEBUG = false; int iValue = -1; - if (accessBank >= 0 && accessBank <= 3 && rx000Setting.multibankReadConfig[0] == null) appendToLog("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); + int iValue = -1; + if (accessBank >= 0 && accessBank <= 3 && rx000Setting.multibankReadConfig[0] == null) Logger.trace("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); else iValue = rx000Setting.multibankReadConfig[0][1]; return iValue; } public boolean setAccessBank(int accessBank) { return setAccessBank(accessBank, 0); } public boolean setAccessBank(int accessBank, int accessBank2) { - boolean bValue = false, DEBUG = true; - if (DEBUG) appendToLog("0 setAccessBank with accessBank = " + accessBank + ", accessBank2 = " + accessBank2); - if (accessBank >= 0 && accessBank <= 3 && rx000Setting.multibankReadConfig[0] == null) appendToLog("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); - else if (accessBank2 >= 0 && accessBank2 <= 3 && rx000Setting.multibankReadConfig[1] == null) appendToLog("!!! CANNOT continue as multibankReadConfig[1] is null !!!"); + boolean bValue = false; + Logger.debug("0 setAccessBank with accessBank = {}, accessBank2 = {}", accessBank, accessBank2); + if (accessBank >= 0 && accessBank <= 3 && rx000Setting.multibankReadConfig[0] == null) Logger.trace("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); + else if (accessBank2 >= 0 && accessBank2 <= 3 && rx000Setting.multibankReadConfig[1] == null) Logger.trace("!!! CANNOT continue as multibankReadConfig[1] is null !!!"); else { - if (DEBUG) appendToLog("0 multibankReadConfig[0] = " + byteArrayToString(rx000Setting.multibankReadConfig[0])); + Logger.debug("0 multibankReadConfig[0] = {}", byteArrayToString(rx000Setting.multibankReadConfig[0])); if (accessBank == rx000Setting.multibankReadConfig[0][1] && sameCheck) bValue = true; else if (accessBank >= 0 && accessBank <= 3) { byte[] bytes = new byte[1]; bytes[0] = (byte)(accessBank & 0xFF); bValue = writeMAC(0x3270 + 7 * 0 + 1, bytes, true); if (bValue) rx000Setting.multibankReadConfig[0][1] = bytes[0]; - if (DEBUG) appendToLog("0A multibankReadConfig[0] = " + byteArrayToString(rx000Setting.multibankReadConfig[0])); + Logger.debug("0A multibankReadConfig[0] = {}", byteArrayToString(rx000Setting.multibankReadConfig[0])); } - if (DEBUG) appendToLog("0 multibankReadConfig[1] = " + byteArrayToString(rx000Setting.multibankReadConfig[1])); + Logger.debug("0 multibankReadConfig[1] = {}", byteArrayToString(rx000Setting.multibankReadConfig[1])); if (accessBank2 == rx000Setting.multibankReadConfig[1][1] && sameCheck) { } else if (bValue && accessBank2 >= 0 && accessBank2 <= 3) { byte[] bytes = new byte[1]; bytes[0] = (byte)(accessBank2 & 0xFF); bValue = writeMAC(0x3270 + 7 * 1 + 1, bytes, true); if (bValue) rx000Setting.multibankReadConfig[1][1] = bytes[0]; - if (DEBUG) appendToLog("0A multibankReadConfig[1] = " + byteArrayToString(rx000Setting.multibankReadConfig[1])); + Logger.debug("0A multibankReadConfig[1] = {}", byteArrayToString(rx000Setting.multibankReadConfig[1])); } } return bValue; @@ -1909,8 +1913,8 @@ else if (bValue && accessBank2 >= 0 && accessBank2 <= 3) { 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 !!!"); + int iValue = -1; + if (accessBank >= 0 && accessBank <= 3 && rx000Setting.multibankReadConfig[0] == null) Logger.trace("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); else { iValue = (rx000Setting.multibankReadConfig[0][2] & 0xFF) << 24; iValue |= (rx000Setting.multibankReadConfig[0][3] & 0xFF) << 16; @@ -1920,15 +1924,15 @@ int getAccessOffset() { return iValue; } public boolean setAccessOffset(int accessOffset) { - //appendToLog("10 setAccessOffset with accessOffset = " + accessOffset); + //Logger.trace("10 setAccessOffset with accessOffset = " + accessOffset); return setAccessOffset(accessOffset, 0); } public boolean setAccessOffset(int accessOffset, int accessOffset2) { - boolean bValue = false, DEBUG = false; - if (DEBUG) appendToLog("0 setAccessOffset with accessOffset = " + accessOffset + ", accessOffset2 = " + accessOffset2); - if (accessOffset >= 0 && rx000Setting.multibankReadConfig[0] == null) appendToLog("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); - else if (accessOffset2 >= 0 && rx000Setting.multibankReadConfig[1] == null) appendToLog("!!! CANNOT continue as multibankReadConfig[1] is null !!!"); + boolean bValue = false; + Logger.debug("0 setAccessOffset with accessOffset = {}, accessOffset2 = {}", accessOffset, accessOffset2); + if (accessOffset >= 0 && rx000Setting.multibankReadConfig[0] == null) Logger.trace("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); + else if (accessOffset2 >= 0 && rx000Setting.multibankReadConfig[1] == null) Logger.trace("!!! CANNOT continue as multibankReadConfig[1] is null !!!"); else { - if (DEBUG) appendToLog("0 multibankReadConfig[0] = " + byteArrayToString(rx000Setting.multibankReadConfig[0])); + Logger.debug("0 multibankReadConfig[0] = {}", byteArrayToString(rx000Setting.multibankReadConfig[0])); if (accessOffset >= 0) { byte[] bytes = new byte[4]; bytes[0] = (byte)((accessOffset >> 24) & 0xFF); @@ -1940,10 +1944,10 @@ public boolean setAccessOffset(int accessOffset, int accessOffset2) { else { bValue = writeMAC(0x3270 + 7 * 0 + 2, bytes, true); if (bValue) System.arraycopy(bytes, 0, rx000Setting.multibankReadConfig[0], 2, bytes.length); - if (DEBUG) appendToLog("0A multibankReadConfig[0] = " + byteArrayToString(rx000Setting.multibankReadConfig[0])); + Logger.debug("0A multibankReadConfig[0] = {}", byteArrayToString(rx000Setting.multibankReadConfig[0])); } } - if (DEBUG) appendToLog("0 multibankReadConfig[1] = " + byteArrayToString(rx000Setting.multibankReadConfig[1])); + Logger.debug("0 multibankReadConfig[1] = {}", byteArrayToString(rx000Setting.multibankReadConfig[1])); if (bValue && accessOffset2 >= 0) { byte[] bytes = new byte[4]; bytes[0] = (byte)((accessOffset2 >> 24) & 0xFF); @@ -1955,7 +1959,7 @@ public boolean setAccessOffset(int accessOffset, int accessOffset2) { else { bValue = writeMAC(0x3270 + 7 * 1 + 2, bytes, true); if (bValue) System.arraycopy(bytes, 0, rx000Setting.multibankReadConfig[1], 2, bytes.length); - if (DEBUG) appendToLog("0A multibankReadConfig[1] = " + byteArrayToString(rx000Setting.multibankReadConfig[1])); + Logger.debug("0A multibankReadConfig[1] = {}", byteArrayToString(rx000Setting.multibankReadConfig[1])); } } } @@ -1968,28 +1972,28 @@ public boolean setAccessCount(int accessCount) { setAccessEnable(((accessCount != 0) ? 1 : 0), 0); return setAccessCount(accessCount, 0); } public boolean setAccessCount(int accessCount, int accessCount2) { - boolean bValue = false, DEBUG = false; - if (DEBUG) appendToLog("0 setAccessCount with accessCount = " + accessCount + ", accessCount2 = " + accessCount2); - if (rx000Setting.multibankReadConfig[0] == null) appendToLog("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); - else if (rx000Setting.multibankReadConfig[1] == null) appendToLog("!!! CANNOT continue as multibankReadConfig[1] is null !!!"); + boolean bValue = false; + Logger.debug("0 setAccessCount with accessCount = {}, accessCount2 = {}", accessCount, accessCount2); + if (rx000Setting.multibankReadConfig[0] == null) Logger.trace("!!! CANNOT continue as multibankReadConfig[0] is null !!!"); + else if (rx000Setting.multibankReadConfig[1] == null) Logger.trace("!!! CANNOT continue as multibankReadConfig[1] is null !!!"); else { - if (DEBUG) appendToLog("0 multibankReadConfig[0] = " + byteArrayToString(rx000Setting.multibankReadConfig[0])); + Logger.debug("0 multibankReadConfig[0] = {}", byteArrayToString(rx000Setting.multibankReadConfig[0])); if (accessCount == rx000Setting.multibankReadConfig[0][6] && sameCheck) bValue = true; else { byte[] bytes = new byte[1]; bytes[0] = (byte)(accessCount & 0xFF); bValue = writeMAC(0x3270 + 7 * 0 + 6, bytes, true); if (bValue) rx000Setting.multibankReadConfig[0][6] = bytes[0]; - if (DEBUG) appendToLog("0A multibankReadConfig[0] = " + byteArrayToString(rx000Setting.multibankReadConfig[0])); + Logger.debug("0A multibankReadConfig[0] = {}", byteArrayToString(rx000Setting.multibankReadConfig[0])); } - if (DEBUG) appendToLog("0 multibankReadConfig[1] = " + byteArrayToString(rx000Setting.multibankReadConfig[1])); + Logger.debug("0 multibankReadConfig[1] = {}", byteArrayToString(rx000Setting.multibankReadConfig[1])); if (accessCount2 == rx000Setting.multibankReadConfig[1][6] && sameCheck) { } else if (bValue) { byte[] bytes = new byte[1]; bytes[0] = (byte)(accessCount2 & 0xFF); bValue = writeMAC(0x3270 + 7 * 1 + 6, bytes, true); if (bValue) rx000Setting.multibankReadConfig[1][6] = bytes[0]; - if (DEBUG) appendToLog("0A multibankReadConfig[1] = " + byteArrayToString(rx000Setting.multibankReadConfig[1])); + Logger.debug("0A multibankReadConfig[1] = {}", byteArrayToString(rx000Setting.multibankReadConfig[1])); } } return bValue; @@ -2007,7 +2011,7 @@ boolean getHST_TAGACC_LOCKCFG() { byte[] lockMask, lockAction; public boolean setAccessLockAction(int accessLockAction, int accessLockMask) { - appendToLog("accessLockAction = " + accessLockAction + ", accessLockMask = " + accessLockMask); + Logger.trace("accessLockAction = {}, accessLockMask = {}", accessLockAction, accessLockMask); boolean bValue = false; byte[] bytes = new byte[2]; bytes[0] = (byte) (accessLockMask / 256); @@ -2029,11 +2033,11 @@ public boolean getRx000AccessPassword() { return readMAC(0x38A6, 4); } public boolean setRx000AccessPassword(String password) { - boolean bValue = false, DEBUG = true; - if (DEBUG) appendToLog("0 setRx000AccessPassword with password = " + password); - if (accessPassword == null) appendToLog("!!! CANNOT continue as accessPassword is null !!!"); + boolean bValue = false; + Logger.debug("0 setRx000AccessPassword with password = {}", password); + if (accessPassword == null) Logger.trace("!!! CANNOT continue as accessPassword is null !!!"); else { - if (DEBUG) appendToLog("0 accessPassword = " + byteArrayToString(accessPassword)); + Logger.debug("0 accessPassword = {}", byteArrayToString(accessPassword)); byte[] bytes = new byte[4]; if (password == null) password = ""; String hexString = "0123456789ABCDEF"; @@ -2056,13 +2060,12 @@ public boolean setRx000AccessPassword(String password) { } byte[] bytesOld = new byte[4]; System.arraycopy(accessPassword, 0, bytesOld, 0, bytesOld.length); - if (DEBUG) appendToLog("0 bytes = " + byteArrayToString(bytes)); + Logger.debug("0 bytes = {}", byteArrayToString(bytes)); if (compareArray(bytes, bytesOld, bytesOld.length) && sameCheck) bValue = true; else { bValue = writeMAC(0x38A6, bytes, true); if (bValue) accessPassword = bytes; - if (DEBUG) - appendToLog("0A accessPassword = " + byteArrayToString(accessPassword)); + Logger.debug("0A accessPassword = {}", byteArrayToString(accessPassword)); } } return bValue; @@ -2074,21 +2077,20 @@ public boolean getRx000KillPassword() { return readMAC(0x38AA, 4); } public boolean setRx000KillPassword(String password) { - boolean bValue = false, DEBUG = true; - if (DEBUG) appendToLog("0 setRx000KillPassword with password = " + password); - if (killPassword == null) appendToLog("!!! CANNOT continue as killPassword is null !!!"); + boolean bValue = false; + Logger.debug("0 setRx000KillPassword with password = {}", password); + if (killPassword == null) Logger.trace("!!! CANNOT continue as killPassword is null !!!"); else { - if (DEBUG) appendToLog("0 killPassword = " + byteArrayToString(killPassword)); + Logger.debug("0 killPassword = {}", byteArrayToString(killPassword)); byte[] bytes = utility.stringToByteArray(password); byte[] bytesOld = new byte[4]; System.arraycopy(accessPassword, 0, bytesOld, 0, bytesOld.length); - if (DEBUG) appendToLog("0 bytes = " + byteArrayToString(bytes)); + Logger.debug("0 bytes = {}", byteArrayToString(bytes)); if (compareArray(bytes, bytesOld, bytesOld.length) && sameCheck) bValue = true; else { bValue = writeMAC(0x38AA, bytes, true); if (bValue) killPassword = bytes; - if (DEBUG) - appendToLog("0A killPassword = " + byteArrayToString(killPassword)); + Logger.debug("0A killPassword = {}", byteArrayToString(killPassword)); } } return bValue; @@ -2099,53 +2101,56 @@ public boolean setRx000KillPassword(String password) { byte[] accWriteData0_63; int accWriteDataReady = 0; public boolean setAccessWriteData(String dataInput) { - boolean bVAlue = false, DEBUG = false; - if (DEBUG) appendToLog("Start with dataInput = " + dataInput); + boolean bVAlue = false; + Logger.debug("Start with dataInput = {}", dataInput); dataInput = dataInput.trim(); int writeBufLength = 16 * 2; //16 int wrieByteSize = 4; //8 int length = dataInput.length(); - if (DEBUG) appendToLog("Check dataInput length = " + length + " with maximum length = " + wrieByteSize * writeBufLength); + Logger.debug("Check dataInput length = {} with maximum length = {}", length, wrieByteSize * writeBufLength); if (length > wrieByteSize * writeBufLength) return false; byte[] msgBuffer = new byte[length/2 + (length%2 != 0 ? 1 : 0)]; for (int i = 0; i < writeBufLength; i++) { - if (DEBUG) appendToLog("Before processing 4 nibbles, check length = " + length); + Logger.debug("Before processing 4 nibbles, check length = {}", length); if (length > 0) { length -= wrieByteSize; String hexString = "0123456789ABCDEF"; for (int j = 0; j < wrieByteSize; j++) { - if (DEBUG) appendToLog("Check dataInput = " + dataInput + ", i = " + i + ", wrieByteSize = " + wrieByteSize + ", j = " + j); + Logger.debug("Check dataInput = {}, i = {}, wrieByteSize = {}, j = {}", dataInput, i, wrieByteSize, j); if (i * wrieByteSize + j >= dataInput.length()) break; String subString = dataInput.substring(i * wrieByteSize + j, i * wrieByteSize + j + 1).toUpperCase(); - if (DEBUG) appendToLog("subString = " + subString); + Logger.debug("subString = {}", subString); int k = 0; for (k = 0; k < 16; k++) { - if (DEBUG && false) appendToLog("k = " + k + ", with hexString = " + hexString); + Logger.debug("k = {}, with hexString = {}", k , hexString); if (subString.matches(hexString.substring(k, k + 1))) { break; } } - if (k == 16) { appendToLog("!!! Cannot decode the data, with with i= " + i + ", j=" + j + ", subString = " + subString); return false; } + if (k == 16) { + Logger.trace("!!! Cannot decode the data, with with i = {}, j = {}, subString = {}", i, j, subString); + return false; + } if ((j / 2) * 2 == j) { msgBuffer[i * 2 + j / 2] |= (byte) (k << 4); } else { msgBuffer[i * 2 + j / 2] |= (byte) (k); } - if (DEBUG) appendToLog("j = " + j + " with updated data : " + byteArrayToString(msgBuffer)); + Logger.debug("j = {} with updated data : {}", j, byteArrayToString(msgBuffer)); } - if (DEBUG) appendToLog("complete 4 bytes: " + byteArrayToString(msgBuffer)); + Logger.debug("complete 4 bytes: {}", byteArrayToString(msgBuffer)); } else break; } bVAlue = setMultibankWriteConfig(0,true, getAccessBank(), getAccessOffset(), (msgBuffer.length/2 + (msgBuffer.length%2 != 0 ? 1 : 0)), msgBuffer); - if (DEBUG) appendToLog("after setMultibankWriteConfig, bvalue = " + bVAlue); + Logger.debug("after setMultibankWriteConfig, bvalue = {}", bVAlue); if (bVAlue) { //mRfidReaderChip.mRx000Setting.accWriteDataReady |= (0x01 << i); - if (DEBUG) appendToLog("accWriteReady=" + accWriteDataReady); + Logger.debug("accWriteReady={}", accWriteDataReady); for (int k = 0; k < 4; k++) { //accWriteData0_63[i * 4 + k] = msgBuffer[7 - k]; } - if (DEBUG) appendToLog("Data=" + byteArrayToString(accWriteData0_63)); + Logger.debug("Data={}", byteArrayToString(accWriteData0_63)); } return bVAlue; } @@ -2155,11 +2160,11 @@ public boolean setAccessWriteData(String dataInput) { int currentProfile = PROFILE_INVALID; int iRfidModeSingleByte = -1; public int getCurrentProfile() { - int iValue = -1; boolean DEBUG = false; - if (DEBUG) appendToLog("2 getCurrentProfile: antennaSelect = " + antennaSelect); - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + int iValue = -1; + Logger.debug("2 getCurrentProfile: antennaSelect = {}", antennaSelect); + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else { - if (DEBUG) appendToLog("2A getCurrentProfile: getAntennaPortConfig[" + antennaSelect + "] = " + byteArrayToString(antennaPortConfig[antennaSelect])); + Logger.debug("2A getCurrentProfile: getAntennaPortConfig[{}] = {}", antennaSelect, byteArrayToString(antennaPortConfig[antennaSelect])); if (antennaPortConfig[antennaSelect][14] != 0 && antennaPortConfig[antennaSelect][15] == 0) { iRfidModeSingleByte = 1; iValue = antennaPortConfig[antennaSelect][14]; @@ -2168,14 +2173,14 @@ public int getCurrentProfile() { iValue = (antennaPortConfig[antennaSelect][14] & 0xFF) << 8; iValue += (antennaPortConfig[antennaSelect][15] & 0xFF); } - if (DEBUG) appendToLog(String.format("2b getCurrentProfile: iValue = 0x%X", iValue)); + Logger.debug(String.format("2b getCurrentProfile: iValue = 0x%X", iValue)); } return iValue; } public boolean setCurrentProfile(int currentProfile) { - byte[] data; boolean DEBUG = true, bValue = false; - if (DEBUG) appendToLog("2 setCurrentProfile: currentProfile = " + currentProfile + ", iRfidModeSingleByte = " + iRfidModeSingleByte); - if (antennaPortConfig[antennaSelect] == null) appendToLog("CANNOT continue as antennaPortConfig[" + antennaSelect + "] is null !!!"); + byte[] data; boolean bValue = false; + Logger.debug("2 setCurrentProfile: currentProfile = {}, iRfidModeSingleByte = {}", currentProfile, iRfidModeSingleByte); + if (antennaPortConfig[antennaSelect] == null) Logger.trace("CANNOT continue as antennaPortConfig[{}] is null !!!", antennaSelect); else if (getCurrentProfile() == currentProfile && sameCheck) bValue = true; else { if (iRfidModeSingleByte < 0) getCurrentProfile(); @@ -2188,11 +2193,9 @@ public boolean setCurrentProfile(int currentProfile) { data[0] = (byte) (currentProfile / 256); data[1] = (byte) (currentProfile & 0xFF); } - if (DEBUG) - appendToLog("2A setCurrentProfile: data = " + byteArrayToString(data)); + Logger.debug("2A setCurrentProfile: data = {}", byteArrayToString(data)); bValue = writeMAC(0x3030 + this.antennaSelect * 16 + 14, data, true); - if (DEBUG) - appendToLog("2b setCurrentProfile: after writeMAC, bValue = " + bValue); + Logger.debug("2b setCurrentProfile: after writeMAC, bValue = {}", bValue); if (bValue && antennaPortConfig[antennaSelect] != null) System.arraycopy(data, 0, antennaPortConfig[antennaSelect], 14, data.length); } @@ -2227,7 +2230,7 @@ class AntennaSelectedData { antennaStatus = mDefault.antennaStatus; antennaDefine = mDefault.antennaDefine; antennaDwell = mDefault.antennaDwell; - antennaPower = mDefault.antennaPower; appendToLog("antennaPower is set to default " + antennaPower); + antennaPower = mDefault.antennaPower; Logger.trace("antennaPower is set to default {}", antennaPower); antennaInvCount = mDefault.antennaInvCount; } } @@ -2548,7 +2551,7 @@ int getAlgoStartQ(boolean getInvalid) { return algoStartQ; } boolean setAlgoStartQ(int algoStartQ) { - appendToLog("1A setAlgoStartQ with algoStartQ = " + algoStartQ); + Logger.trace("1A setAlgoStartQ with algoStartQ = {}", algoStartQ); return setAlgoStartQ(algoStartQ, algoMaxQ, algoMinQ, algoMaxRep, algoHighThres, algoLowThres); } @@ -2559,7 +2562,7 @@ int getAlgoMaxQ() { return algoMaxQ; } boolean setAlgoMaxQ(int algoMaxQ) { - appendToLog("1b setAlgoStartQ"); + Logger.trace("1b setAlgoStartQ"); return setAlgoStartQ(algoStartQ, algoMaxQ, algoMinQ, algoMaxRep, algoHighThres, algoLowThres); } @@ -2584,7 +2587,7 @@ private boolean getHST_INV_ALG_PARM_0() { return sendHostRegRequest(HostRegRequests.HST_INV_ALG_PARM_0, false, msgBuffer); } boolean setAlgoStartQ(int startQ, int algoMaxQ, int algoMinQ, int algoMaxRep, int algoHighThres, int algoLowThres) { - appendToLog("0 setAlgoStartQ with startQ = " + startQ); + Logger.trace("0 setAlgoStartQ with startQ = {}", startQ); 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; @@ -2644,7 +2647,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); + Logger.trace("this.algoAbFlip = {}, algoAbFlip = {}, this.algoRunTilZero = {}, algoRunTilZero = {}", this.algoAbFlip, algoAbFlip, this.algoRunTilZero, algoRunTilZero); if (false && 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) { @@ -2684,69 +2687,69 @@ public double decodeNarrowBandRSSI(byte byteRSSI) { 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); + Logger.trace("byteRSSI = {}, mantissa = {}, exponent = {}, dValue = {}", String.format("%X", byteRSSI), mantissa, exponent, dValue); return dValue; } public boolean bRx000ToReading = false; int getBytes2EpcLength(byte[] bytes) { int iValue = ((bytes[0] & 0xFF) >> 3) * 2; - if (false) appendToLog("bytes = " + byteArrayToString(bytes) + ", iValue = " + iValue); + Logger.trace("bytes = {}, iValue = {}", byteArrayToString(bytes), 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()); + if (csReaderConnector.rfidConnector.mRfidToRead.size() != 0) { + Logger.debug("mRx000UplinkHandler(): START with mRfidToRead size = {}, mRx000ToRead size = {}", csReaderConnector.rfidConnector.mRfidToRead.size(), mRx000ToRead.size()); + } else Logger.debug("START AAA with mRx000ToRead size = {}", mRx000ToRead.size()); + if (false && mRx000ToRead.size() != 0) Logger.trace("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()); + Logger.debug("Looping with mRfidToRead.size = {} with bleConnected = {}", csReaderConnector.rfidConnector.mRfidToRead.size(), csReaderConnector.isBleConnected()); if (csReaderConnector.isBleConnected() == false) { csReaderConnector.rfidConnector.mRfidToRead.clear(); - appendToLog("BLE DISCONNECTED !!! mRfidToRead.size() = " + csReaderConnector.rfidConnector.mRfidToRead.size()); + Logger.trace("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()); + Logger.toLogView("TIMEOUT !!! mRfidToRead.size() = {}", csReaderConnector.rfidConnector.mRfidToRead.size()).trace(); break; } else { - if (DEBUG) appendToLog("Check bFirst = " + bFirst); + Logger.debug("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)); + Logger.apData("ApData: found mRfidToRead data with invalidSequence= {}, bytes= {}", invalidSequence, byteArrayToString(dataIn)); csReaderConnector.rfidConnector.mRfidToRead.remove(0); - if (DEBUG) appendToLog("Check buffer size: data.length = " + dataIn.length+ ", mRfidToReading.length = " + mRfidToReading.length + ", mRfidToReadingOffset = " + mRfidToReadingOffset); + Logger.debug("Check buffer size: data.length = {}, mRfidToReading.length = {}, mRfidToReadingOffset = {}", dataIn.length, mRfidToReading.length, 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)); + Logger.toLogView("!!! ERROR insufficient buffer, mRfidToReadingOffset={}, dataIn.length={}, clear mRfidToReading: {}", mRfidToReadingOffset, dataIn.length, byteArrayToString(unhandledBytes)).trace(); 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)); + Logger.toLogView("!!! ERROR insufficient buffer, mRfidToReading.length={}, dataIn.length={}, clear mRfidToReading: {}", mRfidToReading.length, dataIn.length, byteArrayToString(dataIn)).trace(); csReaderConnector.invalidata++; break; } } - if (DEBUG) appendToLog("Check invalidSequence = " + invalidSequence + " with mRfidToReadingOffset = " + mRfidToReadingOffset); + Logger.debug("Check invalidSequence = {} with mRfidToReadingOffset = {}", invalidSequence, 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)); + Logger.trace("!!! ERROR invalidSequence with nonzero mRfidToReadingOffset={}, throw invalid unused data={}, {}", mRfidToReadingOffset, unhandledBytes.length, byteArrayToString(unhandledBytes)); mRfidToReadingOffset = 0; startIndex = 0; startIndexNew = 0; @@ -2757,10 +2760,10 @@ void uplinkHandler() { int iPayloadSizeMin = 7; //boolean bprinted = false; while (mRfidToReadingOffset - startIndex >= iPayloadSizeMin) { - //if (bprinted == false) { bprinted = true; appendToLog(byteArrayToString(mRfidToReading)); } + //if (bprinted == false) { bprinted = true; Logger.trace(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); + Logger.debug("Looping with startIndex = {}, mRfidToReadingOffset = {}, iPayloadSizeMin = {}, expectedLength = {}", startIndex, mRfidToReadingOffset, iPayloadSizeMin, expectedLength); if (true) { if (mRfidToReading[startIndex + 0] == 0x49 && mRfidToReading[startIndex + 1] == (byte) 0xdc @@ -2770,64 +2773,64 @@ void uplinkHandler() { 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)); + Logger.apData(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); + Logger.debug("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"); + Logger.trace("!!! 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); + Logger.debug("decoded decodedRssi = {}", dataA.decodedRssi); dataA.decodedPhase = (dataA.dataValues[6] & 0xFF) * 256 + (dataA.dataValues[7] & 0xFF); - if (DEBUG) appendToLog("decoded decodedPhase = " + dataA.decodedPhase); + Logger.debug("decoded decodedPhase = {}", dataA.decodedPhase); dataA.decodedPort = (dataA.dataValues[10] & 0xFF); - if (DEBUG) appendToLog("decoded decodedPort = " + dataA.decodedPort); + Logger.debug("decoded decodedPort = {}", dataA.decodedPort); dataA.decodedChidx = 1; //(dataA.dataValues[13] & 0xFF) * 256 + (dataA.dataValues[14] & 0xFF); - if (DEBUG) appendToLog("decoded decodedChidx = " + dataA.decodedChidx); + Logger.debug("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)); + Logger.debug("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)); + Logger.debug("dataA.dataValues.length = {}, iEpcLength = {} for data {}", dataA.dataValues.length, iEpcLength, 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)); + Logger.debug("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); + Logger.debug("i = {} getMultibankReadLength = {}", i, 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); + Logger.debug("Check iDataIndex = {}, iDataOffset = {}, iBankLength = {}, iMbDataLength = {}", iDataIndex, iDataOffset, iBankLength, iMbDataLength); + if (iDataOffset + iBankLength > iMbDataLength) Logger.trace("!!! iBankLength {} is too long for iDataOffset {}, iMbDataLength = {}", iBankLength, iDataOffset, 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)); + Logger.debug("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)); + Logger.debug("decodedData2 = {}", byteArrayToString(dataA.decodedData2)); iDataIndex++; iDataOffset += iBankLength; - } else appendToLog("!!! CANNOT handle the third multibank data"); + } else Logger.trace("!!! CANNOT handle the third multibank data"); } } } @@ -2839,33 +2842,32 @@ else if (iDataIndex == 0) { 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)); + Logger.trace("dataA.decodedPc,Epc = {}, {}, decodedData1,2 = {}, {}", byteArrayToString(dataA.decodedPc), byteArrayToString(dataA.decodedEpc), + dataA.decodedData1 == null ? "null" : byteArrayToString(dataA.decodedData1), dataA.decodedData2 == null ? "null" : byteArrayToString(dataA.decodedData2)); + if (iDataOffset != iMbDataLength) Logger.trace("!!! Some unhandled data as iDataOffset = {} for iMbDataLength = {}", iDataOffset, iMbDataLength); + else Logger.debug("iDataOffset = iMbDataLength = {}", iMbDataLength); + } else Logger.trace("!!! iEpcLength {} is too long for the data {}", iEpcLength, 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"); + Logger.debug("3001/3003 dataA.responseType = {}", dataA.responseType.toString()); + Logger.debug("decoded decodedEpc = {} with mRx000ToRead.size = {}", byteArrayToString(dataA.decodedEpc), mRx000ToRead.size()); + Logger.apData("ApData: uplink data UplinkPackage_Event_csl_tag_read_epc_only_new tag with Epc = {} is uploaded to mRx000ToRead with mRx000ToRead.size = {}", byteArrayToString(dataA.decodedEpc), mRx000ToRead.size()); + Logger.apData("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); + Logger.debug("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"); + Logger.trace("!!! 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)); + Logger.apData("ApData: found Rfid.Uplink.DataRead.UplinkPackage_Event_csl_tag_read_compact with payload header = {}, dataValuesFull = {}", byteArrayToString(dataHeader), byteArrayToString(dataValuesFull)); while (index < dataValuesFull.length) { //change from while - if (DEBUG) appendToLog("Looping with index = " + index + ", dataValuesFull.length = " + dataValuesFull.length); + Logger.debug("Looping with index = {}, dataValuesFull.length = {}", index, dataValuesFull.length); dataA.decodedTime = System.currentTimeMillis(); if (dataValuesFull.length >= index + 2) { dataA.decodedPc = new byte[2]; @@ -2874,41 +2876,40 @@ else if (iDataIndex == 0) { } else break; int epcLength = getBytes2EpcLength(dataA.decodedPc); //((dataA.decodedPc[0] & 0xFF) >> 3) * 2; - if (DEBUG) appendToLog("decoded decodedPc = " + byteArrayToString(dataA.decodedPc) + " with epclength = " + epcLength); + Logger.debug("decoded decodedPc = {} with epclength = {}", byteArrayToString(dataA.decodedPc), 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)); + Logger.debug("decoded decodedEpc = {}", byteArrayToString(dataA.decodedEpc)); if (dataValuesFull.length >= index + 2) { dataA.decodedRssi = get2BytesOfRssi(dataValuesFull, index); - if (DEBUG) appendToLog("decoded decodedRssi = " + dataA.decodedRssi); + Logger.debug("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()); + Logger.debug("3006 dataA.responseType = {}", dataA.responseType.toString()); + Logger.apData("ApData: uplink data UplinkPackage_Event_csl_tag_read_compact tag with Epc = {} is uploaded to mRx000ToRead with mRx000ToRead.size = {}", byteArrayToString(dataA.decodedEpc), 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); + Logger.debug("Exit while loop with index = {}, dataValuesFull.length = {}", index, 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)); + Logger.trace("!!! unhandled data: {}", byteArrayToString(bytesUnhandled)); } - if (DEBUG_APDATA) appendToLog("ApData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_tag_read_compact has been processed"); + Logger.apData("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); + Logger.debug("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"); + Logger.trace("!!! UplinkPackage_Event_csl_miscellaneous_event data length has length equal or less than 8"); } else { switch (iCommand) { case 1: @@ -2924,24 +2925,24 @@ else if (iDataIndex == 0) { 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)); + Logger.trace("!!! 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"); + Logger.pkData("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); + Logger.toLogView("mRx000UplinkHandler_3008: {}", byteArrayToString(dataA.dataValues)).trace(); + Logger.debug("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"); + Logger.trace("!!! 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); + Logger.apData("ApData: found Rfid.Uplink.DataRead.UplinkPackage_Event_csl_operation_complete"); + Logger.debug("Check iStatus = {}", iStatus); switch (iStatus) { case 0: dataA.decodedError = null; @@ -3005,19 +3006,19 @@ else if (iDataIndex == 0) { break; default: dataA.decodedError = "Unknown error"; - appendToLog("!!! CANNOT handle status type with " + byteArrayToString(header) + "." + byteArrayToString(payload)); + Logger.trace("!!! 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"); + Logger.debug("3008 dataA.responseType = {}", dataA.responseType.toString()); + Logger.apData("ApData: uplink data UplinkPackage_Event_csl_operation_complete with decodedError = {} is uploaded to mRx000ToRead with mRx000ToRead.size = {}", dataA.decodedError, mRx000ToRead.size()); + Logger.apData("ApData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_operation_complete has been processed"); } } 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); + Logger.debug("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"); + Logger.trace("!!! 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); @@ -3029,8 +3030,7 @@ else if (iDataIndex == 0) { 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)); + Logger.debug("bytesResponse = {}", byteArrayToString(bytesResponse)); } String string = null; switch (iTagError) { @@ -3107,11 +3107,10 @@ else if (iDataIndex == 0) { 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())); + Logger.trace(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))); + Logger.debug("decodedError2 = {}", dataA.decodedError); + Logger.trace("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))); @@ -3120,15 +3119,14 @@ else if (iDataIndex == 0) { else dataA.decodedResult += string; } } else dataA.decodedResult = ""; - if (DEBUG || true) - appendToLog("decodedResult = " + dataA.decodedResult); + Logger.debug("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"); + Logger.debug("3009 dataA.responseType = {}", dataA.responseType); + Logger.apData("ApData: uplink data UplinkPackage_Event_csl_access_complete tag with data = {} is uploaded to mRx000ToRead with mRx000ToRead.size = {}", byteArrayToString(dataA.dataValues), mRx000ToRead.size()); + Logger.apData("ApData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_access_complete has been processed"); } - else appendToLog(String.format("!!! CANNOT handle UplinkPackageType 0x%X", iUplinkPackageType) + " with uplink data " + byteArrayToString(header) + "." + byteArrayToString(payload)); + else Logger.trace("{} with uplink data {}.{}", String.format("!!! CANNOT handle UplinkPackageType 0x%X", iUplinkPackageType), byteArrayToString(header), byteArrayToString(payload)); packageFound = true; packageType = 4; startIndexNew = startIndex + expectedLength; @@ -3137,18 +3135,16 @@ else if (iDataIndex == 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) { + Logger.debug("Found package with packageType = {}, Check startIndex = {} with startIndexNew = {}, mRfidToReadingOffset = {}", packageType, startIndex, startIndexNew, mRfidToReadingOffset); + if (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)); + Logger.debug("!!! 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[] usedBytes = new byte[startIndexNew - startIndex]; + System.arraycopy(mRfidToReading, startIndex, usedBytes, 0, usedBytes.length); + Logger.debug("used data = {}, {}", usedBytes.length, byteArrayToString(usedBytes)); byte[] mRfidToReadingNew = new byte[RFID_READING_BUFFERSIZE]; System.arraycopy(mRfidToReading, startIndexNew, mRfidToReadingNew, 0, mRfidToReadingOffset - startIndexNew); mRfidToReading = mRfidToReadingNew; @@ -3156,24 +3152,24 @@ else if (iDataIndex == 0) { startIndex = 0; startIndexNew = 0; startIndexOld = 0; - if (DEBUG) appendToLog("Check new mRfidToReadingOffset = " + mRfidToReadingOffset + " with startIndex and startIndexNew = 0"); - if (DEBUG && mRfidToReadingOffset != 0) { + Logger.debug("Check new mRfidToReadingOffset = {} with startIndex and startIndexNew = 0", mRfidToReadingOffset); + if (mRfidToReadingOffset != 0) { byte[] remainedBytes = new byte[mRfidToReadingOffset]; System.arraycopy(mRfidToReading, 0, remainedBytes, 0, remainedBytes.length); - appendToLog("!!! moved with remained bytes=" + byteArrayToString(remainedBytes)); + Logger.debug("!!! moved with remained bytes={}", byteArrayToString(remainedBytes)); } } else { startIndex++; } } - if (DEBUG) appendToLog("Exit while loop with startIndex = " + startIndex + ", mRfidToReadingOffset = " + mRfidToReadingOffset + ", iPayloadSizeMin = " + iPayloadSizeMin); + Logger.debug("Exit while loop with startIndex = {}, mRfidToReadingOffset = {}, iPayloadSizeMin = {}", startIndex, mRfidToReadingOffset, 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); + //Logger.trace("exit while(-8) loop with startIndex = " + startIndex + ( startIndex == 0 ? "" : "(NON-ZERO)" ) + ", mRfidToReadingOffset=" + mRfidToReadingOffset); + if (startIndex > mRfidToReadingOffset) Logger.trace("!!! ERROR. startIndex = {} is greater than mRfidToReadingOffset = {}", startIndex, mRfidToReadingOffset); else { byte[] unhandled = new byte[startIndex]; System.arraycopy(mRfidToReading, 0, unhandled, 0, unhandled.length); - appendToLog("!!! Unhandled data: " + byteArrayToString(unhandled)); + Logger.trace("!!! Unhandled data: {}", byteArrayToString(unhandled)); byte[] mRfidToReadingNew = new byte[RFID_READING_BUFFERSIZE]; System.arraycopy(mRfidToReading, startIndex, mRfidToReadingNew, 0, mRfidToReadingOffset - startIndex); mRfidToReading = mRfidToReadingNew; @@ -3185,19 +3181,17 @@ else if (iDataIndex == 0) { } } } - if (DEBUG & bFirst == false) appendToLog("Exit while loop with mRfidToRead.size = " + csReaderConnector.rfidConnector.mRfidToRead.size()); - //if (DEBUG) appendToLog("mRfidToReadingOffset = " + mRfidToReadingOffset + ", startIndexNew = " + startIndexNew); + if (bFirst == false) Logger.trace("Exit while loop with mRfidToRead.size = {}", csReaderConnector.rfidConnector.mRfidToRead.size()); + //Logger.debug("mRfidToReadingOffset = {}, startIndexNew = {}", mRfidToReadingOffset, 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)); + // Logger.trace("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()); - } + if (mRx000ToRead.size() != 0) Logger.debug("mRx000UplinkHandler(): END with mRx000ToRead size = {}", mRx000ToRead.size()); } public boolean turnOn(boolean onStatus) { RfidConnector.CsReaderRfidData csReaderRfidData = new RfidConnector.CsReaderRfidData(); @@ -3220,7 +3214,8 @@ public boolean turnOn(boolean onStatus) { 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); + this.bLowPowerStandby = bLowPowerStandby; + Logger.trace("!!! Skip setPwrManagementMode[{}] with this.blowPowerStandby = {}", bLowPowerStandby, this.bLowPowerStandby); return true; } @@ -3228,7 +3223,8 @@ public boolean setPwrManagementMode(boolean bLowPowerStandby) { public int getwideRSSI() { if (wideRSSI < 0) { setPwrManagementMode(false); - wideRSSI = 0; appendToLog("!!! Skip getwideRSSI with assumed value = 0"); + wideRSSI = 0; + Logger.trace("!!! Skip getwideRSSI with assumed value = 0"); } return wideRSSI; } @@ -3239,7 +3235,8 @@ 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)); + rxGain = RXGAIN_DEFAULT; + Logger.trace(String.format("!!! Skip getHighCompression with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); } else iRetValue = (rxGain >> 8); return iRetValue; } @@ -3247,7 +3244,8 @@ 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)); + rxGain = RXGAIN_DEFAULT; + Logger.trace(String.format("!!! Skip getRflnaGain with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); } else iRetValue = ((rxGain & 0xC0) >> 6); return iRetValue; } @@ -3255,7 +3253,8 @@ 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)); + rxGain = RXGAIN_DEFAULT; + Logger.trace(String.format("!!! Skip getIflnaGain with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); } else iRetValue = ((rxGain & 0x38) >> 3); return iRetValue; } @@ -3263,7 +3262,8 @@ 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)); + rxGain = RXGAIN_DEFAULT; + Logger.trace(String.format("!!! Skip getAgcGain with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); } else iRetValue = (rxGain & 0x07); return iRetValue; } @@ -3271,7 +3271,8 @@ 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)); + rxGain = RXGAIN_DEFAULT; + Logger.trace(String.format("!!! Skip getRxGain with assumed rxGain = 0x%X", RXGAIN_DEFAULT)); } else iRetValue = rxGain; return iRetValue; } @@ -3283,13 +3284,14 @@ 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)); + rxGain = rxGain_new; + Logger.trace(String.format("!!! Skip setRxGain[0x%X]", rxGain_new)); } return bRetValue; } public boolean sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands hostCommand) { - appendToLog("!!! hostCommand = " + hostCommand.toString()); + Logger.trace("!!! hostCommand = {}", hostCommand.toString()); long hostCommandData = -1; switch (hostCommand) { case CMD_18K6CINV: @@ -3302,7 +3304,7 @@ public boolean sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands hostCom break; case CMD_18K6CINV_MB: hostCommandData = 0xA4; - appendToLog("getQuerySelect = " + rx000Setting.getQuerySelect() + ", getImpinjExtension = " + rx000Setting.getImpinjExtension()); + Logger.trace("getQuerySelect = {}, getImpinjExtension = {}", rx000Setting.getQuerySelect(), rx000Setting.getImpinjExtension()); if (rx000Setting.getQuerySelect() > 1 /*&& mRfidReaderChip.mRx000Setting.getImpinjExtension() == 0*/) hostCommandData = 0xA5; break; case NULL: @@ -3385,7 +3387,7 @@ public boolean sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands hostCom case CMD_FDM_LED_CTRL: hostCommandData = 0x5e; break; default: - appendToLog("!!! CANNOT handle with hostCommand = " + hostCommand.toString()); + Logger.trace("!!! CANNOT handle with hostCommand = {}", hostCommand); } if (hostCommandData == -1) { return false; @@ -3393,7 +3395,7 @@ public boolean sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands hostCom 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])); + Logger.trace("3030 data = {}", byteArrayToString(rx000Setting.antennaPortConfig[0])); return sendHostRegRequest(HostRegRequests.HST_CMD, true, msgBuffer); } } @@ -3404,12 +3406,12 @@ void addMacAccessHistory(byte[] msgBuffer) { 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)); + Logger.trace("macAccessHistory: deleted old record={}", byteArrayToString(macAccessHistory4)); macAccessHistory.remove(i); break; } } - appendToLog("macAccessHistory: added msgbuffer=" + byteArrayToString(msgBuffer)); + Logger.trace("macAccessHistory: added msgbuffer={}", byteArrayToString(msgBuffer)); macAccessHistory.add(msgBuffer); } @@ -3418,7 +3420,7 @@ boolean sendHostRegRequest(HostRegRequests hostRegRequests, boolean writeOperati boolean needResponse = false; boolean validRequest = false; - if (hostRegRequests == HostRegRequests.HST_ANT_DESC_DWELL) appendToLog("setAntennaDwell 4"); + if (hostRegRequests == HostRegRequests.HST_ANT_DESC_DWELL) Logger.trace("setAntennaDwell 4"); boolean bSkip = false; if ( (hostRegRequests != HostRegRequests.HST_CMD && hostRegRequests != HostRegRequests.MAC_OPERATION) || (hostRegRequests == HostRegRequests.HST_CMD @@ -3437,11 +3439,11 @@ boolean sendHostRegRequest(HostRegRequests hostRegRequests, boolean writeOperati ) || (hostRegRequests == HostRegRequests.MAC_OPERATION && writeOperation && msgBuffer[0] != (byte)0x80) ) bSkip = true; if (bSkip) { - appendToLog("!!! Skip sendingRegRequest with " + hostRegRequests.toString() + ", writeOperation = " + writeOperation + "." + byteArrayToString(msgBuffer)); + Logger.trace("!!! Skip sendingRegRequest with {}, writeOperation = {}.{}", hostRegRequests, writeOperation, byteArrayToString(msgBuffer)); return true; } if (csReaderConnector.isBleConnected() == false) { - appendToLog("!!! Skip sending as bleConnected is false"); + Logger.trace("!!! Skip sending as bleConnected is false"); return false; } if (false) addMacAccessHistory(msgBuffer); @@ -3511,7 +3513,7 @@ boolean sendHostRegRequest(HostRegRequests hostRegRequests, boolean writeOperati } if (msgBuffer == null || validRequest == false) { - appendToLog("invalid request for msgbuffer = " + (msgBuffer == null ? "NULL" : "Valid") + ", validRequst = " + validRequest); + Logger.trace("invalid request for msgbuffer = {}, validRequest = {}", msgBuffer == null ? "NULL" : "Valid", validRequest); return false; } else { RfidConnector.CsReaderRfidData csReaderRfidData = new RfidConnector.CsReaderRfidData(); @@ -3544,7 +3546,7 @@ boolean sendHostRegRequest(HostRegRequests hostRegRequests, boolean writeOperati void addRfidToWrite(RfidConnector.CsReaderRfidData csReaderRfidData) { boolean repeatRequest = false; if (false && csReaderRfidData.rfidPayloadEvent == RfidConnector.RfidPayloadEvents.RFID_COMMAND) { - appendToLog("!!! Skip " + csReaderRfidData.rfidPayloadEvent.toString() + "." + byteArrayToString(csReaderRfidData.dataValues)); + Logger.trace("!!! Skip {}.{}", csReaderRfidData.rfidPayloadEvent, byteArrayToString(csReaderRfidData.dataValues)); return; } if (csReaderConnector.rfidConnector.mRfidToWrite.size() != 0 && sameCheck) { @@ -3563,23 +3565,23 @@ void addRfidToWrite(RfidConnector.CsReaderRfidData csReaderRfidData) { } 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)); + Logger.pkData("PkData: add {}{}{}{}{} to mRfidToWrite with length = {}", csReaderRfidData.rfidPayloadEvent, csReaderRfidData.dataValues != null ? "." : "", byteArrayToString(csReaderRfidData.dataValues), + csReaderRfidData.waitUplinkResponse ? " waitUplinkResponse" : "", csReaderRfidData.waitUplink1Response ? " waitUplink1Response" : "", + csReaderConnector.rfidConnector.mRfidToWrite.size()); + } else Logger.pkData("!!! 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);} + void setInventoring(boolean enable) { inventoring = enable; utility.debugFileEnable(false); Logger.trace("setInventoring E710 is set as {}", inventoring);} boolean decode710Data(byte[] dataValues){ - if (DEBUG) appendToLog("mRfidToWrite.size = " + csReaderConnector.rfidConnector.mRfidToWrite.size()); + Logger.debug("mRfidToWrite.size = {}", csReaderConnector.rfidConnector.mRfidToWrite.size()); if (csReaderConnector.rfidConnector.mRfidToWrite.size() > 0) { RfidConnector.CsReaderRfidData csReaderRfidData = csReaderConnector.rfidConnector.mRfidToWrite.get(0); - if (DEBUG) appendToLog("downlinkResponsed = " + csReaderRfidData.downlinkResponded + ", uplinkResponsed = " + csReaderRfidData.uplinkResponded); + Logger.debug("downlinkResponsed = {}, uplinkResponsed = {}", csReaderRfidData.downlinkResponded, csReaderRfidData.uplinkResponded); if (csReaderRfidData.downlinkResponded || csReaderRfidData.uplinkResponded) { boolean matched = false, updatedUplinkResponse = false; - if (DEBUG) appendToLog("mRfidToWrite.dataValue = " + byteArrayToString(csReaderRfidData.dataValues) + ", dataValues = " + byteArrayToString(dataValues)); + Logger.debug("mRfidToWrite.dataValue = {}, dataValues = {}", byteArrayToString(csReaderRfidData.dataValues), byteArrayToString(dataValues)); if (csReaderRfidData.dataValues[0] == (byte)0x80 && csReaderRfidData.dataValues[1] == (byte)0xB3 && dataValues[0] == 0x51 @@ -3596,8 +3598,8 @@ boolean decode710Data(byte[] dataValues){ commandValue = new byte[iLength]; System.arraycopy(dataValues, 7, commandValue, 0, commandValue.length); } - if (DEBUG_PKDATA) appendToLog("PkData: found Rfid.Uplink.DataRead.CommandResponse" + (iLength != 0 ? " with payload = " + byteArrayToString(commandValue) : "")); - if (DEBUG) appendToLog("found iCommandCode = " + String.format("%4X", iCommandCode) + ", iLength = " + iLength + ", commandValue = " + byteArrayToString(commandValue)); + Logger.pkData("PkData: found Rfid.Uplink.DataRead.CommandResponse{}", iLength != 0 ? " with payload = " + byteArrayToString(commandValue) : ""); + Logger.debug("found iCommandCode = {}, iLength = {}, commandValue = {}", String.format("%4X", iCommandCode), iLength, byteArrayToString(commandValue)); if ((iCommandCode == 0x10A1 && iLength == 0) || (iCommandCode == 0x10A2 && iLength == 0) || (iCommandCode == 0x10A3 && iLength == 0) @@ -3631,37 +3633,36 @@ boolean decode710Data(byte[] dataValues){ csReaderConnector.rfidConnector.found = true; csReaderRfidData.uplinkResponded = true; updatedUplinkResponse = true; csReaderConnector.rfidConnector.mRfidToWrite.set(0, csReaderRfidData); - if (DEBUG_PKDATA) appendToLog("PkData: Rfid.Uplink.DataRead.CommandResponse_" + strCommandResponseType + " is processed to set mRfidToWrite.uplinkResponded and wait uplink data 1"); + Logger.pkData("PkData: Rfid.Uplink.DataRead.CommandResponse_{} is processed to set mRfidToWrite.uplinkResponded and wait uplink data 1", strCommandResponseType); } else { matched = true; - if (DEBUG) appendToLog(String.format("000 iCommandCode = 0x%X with writeData.dataValues = %s", iCommandCode, byteArrayToString(csReaderRfidData.dataValues))); - if (iCommandCode == 0x10A1) { if (DEBUG_PKDATA) appendToLog("PkData: uplink data is processed as CommandResponse.RfidStartSimpleInventory"); } - else if (iCommandCode == 0x10A2) { setInventoring(true); if (DEBUG_PKDATA) appendToLog("PkData: uplink data is processed as CommandResponse.RfidStartCompactInventory"); } - else if (iCommandCode == 0x10A3) { setInventoring(true); if (DEBUG_PKDATA) appendToLog("PkData: uplink data is processed as CommandResponse.RfidStartSelectInventory"); } - else if (iCommandCode == 0x10A4) { setInventoring(true); if (DEBUG_PKDATA) appendToLog("PkData: uplink data is processed as CommandResponse.RfidStartMBInventory"); } - else if (iCommandCode == 0x10A5) { setInventoring(true); if (DEBUG_PKDATA) appendToLog("PkData: uplink data is processed as CommandResponse.RfidStartSelectMBInventory"); } - else if (iCommandCode == 0x10A6) { setInventoring(true); if (DEBUG_PKDATA) appendToLog("PkData: uplink data is processed as CommandResponse.RfidStartSelectCompactInventory"); } - else if (iCommandCode == 0x10AE) { if (DEBUG_PKDATA) appendToLog("PkData: uplink data is processed as CommandResponse.RfidStopOperation"); } - else if (iCommandCode == 0x10B1) { if (DEBUG_PKDATA) appendToLog("PkData: uplink data is processed as CommandResponse.RfidReadMB"); } - else if (iCommandCode == 0x10B2) { if (DEBUG_PKDATA) appendToLog("PkData: uplink data is processed as CommandResponse.RfidWriteMB"); } - else if (iCommandCode == 0x10B7) { if (DEBUG_PKDATA) appendToLog("PkData: uplink data is processed as CommandResponse.RfidLock"); } - else if (iCommandCode == 0x10B8) { if (DEBUG_PKDATA) appendToLog("PkData: uplink data is processed as CommandResponse.RfidKill"); } - else if (iCommandCode == 0x10B9) { if (DEBUG_PKDATA) appendToLog("PkData: uplink data is processed as CommandResponse.RfidAuthenticate"); } - //else if ((iCommandCode & 0x7F00) == 0x1000) { if (DEBUG_PKDATA) appendToLog("PkData: uplink data is processed as CommandResponse.RFID??? !!!"); } + Logger.debug(String.format("000 iCommandCode = 0x%X with writeData.dataValues = %s", iCommandCode, byteArrayToString(csReaderRfidData.dataValues))); + if (iCommandCode == 0x10A1) { Logger.pkData("PkData: uplink data is processed as CommandResponse.RfidStartSimpleInventory"); } + else if (iCommandCode == 0x10A2) { setInventoring(true); Logger.pkData("PkData: uplink data is processed as CommandResponse.RfidStartCompactInventory"); } + else if (iCommandCode == 0x10A3) { setInventoring(true); Logger.pkData("PkData: uplink data is processed as CommandResponse.RfidStartSelectInventory"); } + else if (iCommandCode == 0x10A4) { setInventoring(true); Logger.pkData("PkData: uplink data is processed as CommandResponse.RfidStartMBInventory"); } + else if (iCommandCode == 0x10A5) { setInventoring(true); Logger.pkData("PkData: uplink data is processed as CommandResponse.RfidStartSelectMBInventory"); } + else if (iCommandCode == 0x10A6) { setInventoring(true); Logger.pkData("PkData: uplink data is processed as CommandResponse.RfidStartSelectCompactInventory"); } + else if (iCommandCode == 0x10AE) { Logger.pkData("PkData: uplink data is processed as CommandResponse.RfidStopOperation"); } + else if (iCommandCode == 0x10B1) { Logger.pkData("PkData: uplink data is processed as CommandResponse.RfidReadMB"); } + else if (iCommandCode == 0x10B2) { Logger.pkData("PkData: uplink data is processed as CommandResponse.RfidWriteMB"); } + else if (iCommandCode == 0x10B7) { Logger.pkData("PkData: uplink data is processed as CommandResponse.RfidLock"); } + else if (iCommandCode == 0x10B8) { Logger.pkData("PkData: uplink data is processed as CommandResponse.RfidKill"); } + else if (iCommandCode == 0x10B9) { Logger.pkData("PkData: uplink data is processed as CommandResponse.RfidAuthenticate"); } + //else if ((iCommandCode & 0x7F00) == 0x1000) { Logger.pkData("PkData: uplink data is processed as CommandResponse.RFID??? !!!"); } else if (iCommandCode == 0x1471 || iCommandCode == 0x9A06) { int iRegAddr = (csReaderRfidData.dataValues[8] & 0xFF) * 256 + (csReaderRfidData.dataValues[9] & 0xFF); boolean bprocessed = false; - if (DEBUG) appendToLog(String.format("1 iCommandCode = 0x%X with iRegAddr = 0x%X", iCommandCode, iRegAddr)); + Logger.debug(String.format("1 iCommandCode = 0x%X with iRegAddr = 0x%X", iCommandCode, iRegAddr)); if (iCommandCode == 0x9A06) { - if (DEBUG) appendToLog(String.format("2 CommandCode = 0x%X is processed here", iCommandCode)); + Logger.debug(String.format("2 CommandCode = 0x%X is processed here", iCommandCode)); bprocessed = true; } else if (iRegAddr == 8) { - if (DEBUG) appendToLog("2 iCommandCode"); + Logger.debug("2 iCommandCode"); try { rx000Setting.macVer = new String(commandValue, StandardCharsets.UTF_8).trim(); bprocessed = true; - if (false) - appendToLog("macVer = " + rx000Setting.macVer); + Logger.trace("macVer = {}", rx000Setting.macVer); } catch (Exception e) { //throw new RuntimeException(e); } @@ -3672,181 +3673,151 @@ else if (iCommandCode == 0x1471 || iCommandCode == 0x9A06) { } rx000Setting.macVerBuild = iValue; bprocessed = true; - if (false) - appendToLog("macVerBuild = " + rx000Setting.macVerBuild); + Logger.trace("macVerBuild = {}", rx000Setting.macVerBuild); } else if (iRegAddr == 0x3014) { rx000Setting.countryEnum = commandValue; bprocessed = true; - if (true) - appendToLog("countryEnum = " + byteArrayToString(rx000Setting.countryEnum)); + Logger.trace("countryEnum = {}", byteArrayToString(rx000Setting.countryEnum)); } else if (iRegAddr == 0x3018) { rx000Setting.frequencyChannelIndex = commandValue; bprocessed = true; - if (true) - appendToLog("frequencyChannelIndex = " + byteArrayToString(rx000Setting.frequencyChannelIndex)); + Logger.trace("frequencyChannelIndex = {}", byteArrayToString(rx000Setting.frequencyChannelIndex)); } else if (iRegAddr >= 0x3030 && iRegAddr < 0x3030 + 16 * 16) { int iPort = 0, iOffset = 0, iWidth = 0; for (iPort = 0; iPort < 16; iPort++) { - if (DEBUG) - appendToLog("antennaPortConfig: iPort = " + iPort + String.format(", iRegAddr = 0x%04X", iRegAddr)); + Logger.debug("antennaPortConfig: iPort = {}{}", iPort, String.format(", iRegAddr = 0x%04X", iRegAddr)); if (iRegAddr < 0x3030 + (iPort + 1) * 16) break; } iOffset = iRegAddr - 0x3030 - iPort * 16; - if (DEBUG) - appendToLog("antennaPortConfig: iOffset = " + iOffset); + Logger.debug("antennaPortConfig: iOffset = {}", iOffset); iWidth = commandValue.length; - if (DEBUG) - appendToLog("antennaPortConfig: iWidth = " + iWidth); + Logger.debug("antennaPortConfig: iWidth = {}", iWidth); if (iOffset == 0 && iWidth == 16) { rx000Setting.antennaPortConfig[iPort] = commandValue; bprocessed = true; - if (false) - appendToLog("antennaPortConfig[" + iPort + "] = " + byteArrayToString(rx000Setting.antennaPortConfig[iPort])); - } else - appendToLog("!!! CANNOT handle with iPort = " + iPort + ", iOffset = " + iOffset + ", iWidth = " + iWidth); + Logger.trace("antennaPortConfig[{}] = {}", iPort, byteArrayToString(rx000Setting.antennaPortConfig[iPort])); + } else Logger.trace("!!! CANNOT handle with iPort = {}, iOffset = {}, iWidth = {}", iPort, iOffset, iWidth); } else if (iRegAddr >= 0x3140 && iRegAddr < 0x3140 + 42 * 7) { int index = 0, iOffset = 0, iWidth = 0; for (index = 0; index < 7; index++) { - if (DEBUG) - appendToLog("selectConfiguration: index = " + index + String.format(", iRegAddr = 0x%04X", iRegAddr)); + Logger.debug("selectConfiguration: index = {}{}", index, String.format(", iRegAddr = 0x%04X", iRegAddr)); if (iRegAddr < 0x3140 + (index + 1) * 42) break; } iOffset = iRegAddr - 0x3140 - index * 42; - if (DEBUG) - appendToLog("selectConfiguration: iOffset = " + iOffset); + Logger.debug("selectConfiguration: iOffset = {}", iOffset); iWidth = commandValue.length; - if (DEBUG) - appendToLog("selectConfiguration: iWidth = " + iWidth); + Logger.debug("selectConfiguration: iWidth = {}", iWidth); if (iOffset == 0 && iWidth == 42) { rx000Setting.selectConfiguration[index] = commandValue; bprocessed = true; - if (false) - appendToLog("selectConfiguration[" + index + "] = " + byteArrayToString(rx000Setting.selectConfiguration[index])); - } else - appendToLog("!!! CANNOT handle with index = " + index + ", iOffset = " + iOffset + ", iWidth = " + iWidth); + Logger.trace("selectConfiguration[{}] = {}", index, byteArrayToString(rx000Setting.selectConfiguration[index])); + } else Logger.trace("!!! CANNOT handle with index = {}, iOffset = {}, iWidth = {}", index, iOffset, iWidth); } else if (iRegAddr >= 0x3270 && iRegAddr < 0x3270 + 7 * 3) { int index = 0, iOffset = 0, iWidth = 0, iPortStartAddr = 0x3270, iPortSize = 7; for (index = 0; index < 3; index++) { - if (DEBUG) - appendToLog("multibankReadConfig: index = " + index + String.format(", iRegAddr = 0x%04X", iRegAddr)); + Logger.debug("multibankReadConfig: index = {}{}", index, String.format(", iRegAddr = 0x%04X", iRegAddr)); if (iRegAddr < iPortStartAddr + (index + 1) * iPortSize) break; } iOffset = iRegAddr - iPortStartAddr - index * iPortSize; - if (DEBUG) - appendToLog("multibankReadConfig: iOffset = " + iOffset); + Logger.debug("multibankReadConfig: iOffset = {}", iOffset); iWidth = commandValue.length; - if (DEBUG) - appendToLog("multibankReadConfig: iWidth = " + iWidth); + Logger.debug("multibankReadConfig: iWidth = {}", iWidth); if (iOffset == 0 && iWidth == iPortSize) { rx000Setting.multibankReadConfig[index] = commandValue; bprocessed = true; - if (false) - appendToLog("multibankReadConfig[" + index + "] = " + byteArrayToString(rx000Setting.multibankReadConfig[index])); - } else - appendToLog("!!! CANNOT handle with index = " + index + ", iOffset = " + iOffset + ", iWidth = " + iWidth); + Logger.trace("multibankReadConfig[{}] = {}", index, byteArrayToString(rx000Setting.multibankReadConfig[index])); + } else Logger.trace("!!! CANNOT handle with index = {}, iOffset = {}, iWidth = {}", index, iOffset, iWidth); } else if (iRegAddr == 0x38A6) { rx000Setting.accessPassword = commandValue; bprocessed = true; - if (false) appendToLog("accessPassword = " + byteArrayToString(rx000Setting.accessPassword)); + Logger.trace("accessPassword = {}", byteArrayToString(rx000Setting.accessPassword)); } else if (iRegAddr == 0x38AA) { rx000Setting.killPassword = commandValue; bprocessed = true; - if (false) appendToLog("killPassword = " + byteArrayToString(rx000Setting.killPassword)); + Logger.trace("killPassword = {}", byteArrayToString(rx000Setting.killPassword)); } else if (iRegAddr == 0x3900) { rx000Setting.dupElimRollWindow = commandValue; bprocessed = true; - if (false) appendToLog("dupElimDelay = " + byteArrayToString(rx000Setting.dupElimRollWindow)); + Logger.trace("dupElimDelay = {}", byteArrayToString(rx000Setting.dupElimRollWindow)); } else if (iRegAddr == 0x3906) { rx000Setting.eventPacketUplnkEnable = commandValue; bprocessed = true; - if (false) appendToLog("eventPacketUplnkEnable = " + byteArrayToString(rx000Setting.eventPacketUplnkEnable)); + Logger.trace("eventPacketUplnkEnable = {}", byteArrayToString(rx000Setting.eventPacketUplnkEnable)); } else if (iRegAddr == 0x3908) { rx000Setting.intraPacketDelay = commandValue; bprocessed = true; - if (false) appendToLog("intraPacketDelay = " + byteArrayToString(rx000Setting.intraPacketDelay)); + Logger.trace("intraPacketDelay = {}", byteArrayToString(rx000Setting.intraPacketDelay)); } else if (iRegAddr == 0x3948) { rx000Setting.currentPort = commandValue; bprocessed = true; - if (true) appendToLog("currentPort = " + byteArrayToString(rx000Setting.currentPort)); + Logger.trace("currentPort = {}", byteArrayToString(rx000Setting.currentPort)); } else if (iRegAddr == 0x5000) { rx000Setting.modelCode = commandValue; bprocessed = true; - if (false) - appendToLog("modelCode = " + byteArrayToString(rx000Setting.modelCode)); + Logger.trace("modelCode = {}", byteArrayToString(rx000Setting.modelCode)); } else if (iRegAddr == 0x5020) { rx000Setting.productSerialNumber = commandValue; bprocessed = true; - if (false) - appendToLog("productSerialNumber = " + byteArrayToString(rx000Setting.productSerialNumber)); + Logger.trace("productSerialNumber = {}", byteArrayToString(rx000Setting.productSerialNumber)); } else if (iRegAddr == 0x5040) { rx000Setting.countryEnumOem = commandValue; bprocessed = true; - if (true) - appendToLog("countryEnumOem = " + byteArrayToString(rx000Setting.countryEnumOem)); + Logger.trace("countryEnumOem = {}", byteArrayToString(rx000Setting.countryEnumOem)); } else if (iRegAddr == 0xEF98) { rx000Setting.countryCodeOem = commandValue; bprocessed = true; - if (false) - appendToLog("countryCodeOem = " + byteArrayToString(rx000Setting.countryCodeOem)); + Logger.trace("countryCodeOem = {}", byteArrayToString(rx000Setting.countryCodeOem)); } else if (iRegAddr == 0xEF9C) { rx000Setting.boardSerialNumber = commandValue; bprocessed = true; - if (true) - appendToLog("boardSerialNumber = " + byteArrayToString(rx000Setting.boardSerialNumber)); + Logger.trace("boardSerialNumber = {}", byteArrayToString(rx000Setting.boardSerialNumber)); } else if (iRegAddr == 0xEFAC) { rx000Setting.specialcountryCodeOem = commandValue; bprocessed = true; - if (false) - appendToLog("specialcountryCodeOem = " + byteArrayToString(rx000Setting.specialcountryCodeOem)); + Logger.trace("specialcountryCodeOem = {}", byteArrayToString(rx000Setting.specialcountryCodeOem)); } else if (iRegAddr == 0xEFB0) { rx000Setting.freqModifyCode = commandValue; bprocessed = true; - if (false) - appendToLog("freqModifyCode = " + byteArrayToString(rx000Setting.freqModifyCode)); + Logger.trace("freqModifyCode = {}", byteArrayToString(rx000Setting.freqModifyCode)); } if (bprocessed) { - if (DEBUG_PKDATA) { - if (iCommandCode == 0x9A06) - appendToLog("PkData: Rfid.Uplink.DataRead.CommandResponse_WriteRegister with result " + byteArrayToString(commandValue) + " is processed for register address = " + String.format("0x%X", iRegAddr)); - else if (iCommandCode == 0x1471) - appendToLog("PkData: Rfid.Uplink.DataRead.CommandResponse_ReadRegister with result " + byteArrayToString(commandValue) + " is processed for register address = " + String.format("0x%X", iRegAddr)); - else { - appendToLog("PkData: Rfid.Uplink.DataRead.CommandResponse_xxx with result " + byteArrayToString(commandValue) + " is processed"); - } + if (iCommandCode == 0x9A06) + Logger.pkData("PkData: Rfid.Uplink.DataRead.CommandResponse_WriteRegister with result {} is processed for register address = {}", byteArrayToString(commandValue), String.format("0x%X", iRegAddr)); + else if (iCommandCode == 0x1471) + Logger.pkData("PkData: Rfid.Uplink.DataRead.CommandResponse_ReadRegister with result {} is processed for register address = {}", byteArrayToString(commandValue), String.format("0x%X", iRegAddr)); + else { + Logger.pkData("PkData: Rfid.Uplink.DataRead.CommandResponse_xxx with result {} is processed", byteArrayToString(commandValue)); } - } else - appendToLog("!!! Rfid.Uplink.DataRead.CommandResponse_ReadRegister CANNOT be processed for register address = " + String.format("0x%X", iRegAddr)); - } else appendToLog(String.format("!!! Rfid.Uplink.DataRead.CommandResponse_%X CANNOT be processed", iCommandCode)); + } else Logger.trace("!!! Rfid.Uplink.DataRead.CommandResponse_ReadRegister CANNOT be processed for register address = {}", String.format("0x%X", iRegAddr)); + } else Logger.trace(String.format("!!! Rfid.Uplink.DataRead.CommandResponse_%X CANNOT be processed", iCommandCode)); } - } else appendToLog("!!! Rfid.Uplink.DataRead.CommandResponse CANNOT be processed"); + } else Logger.trace("!!! Rfid.Uplink.DataRead.CommandResponse CANNOT be processed"); } else if (dataValues[0] == 0x49 && dataValues[1] == (byte)0xDC && dataValues[4] == 0 ) { - if (DEBUG) appendToLog("Ready 0"); + Logger.debug("Ready 0"); int iLength = dataValues[5] * 256 + dataValues[6]; - if (DEBUG) appendToLog("Ready 1 with length = " + iLength); + Logger.debug("Ready 1 with length = {}", iLength); if (dataValues.length == 7 + iLength) { byte[] dataValues1 = new byte[iLength]; System.arraycopy(dataValues, 7, dataValues1, 0, dataValues1.length); int iCommand = (dataValues[2] & 0xFF) * 256 + (dataValues[3] & 0xFF); if (iCommand == 0x3008) { setInventoring(false); - appendToLogView("isRfidToRead_3008: " + byteArrayToString(dataValues)); - if (DEBUG) appendToLog("Ready 2"); - if (DEBUG_PKDATA) - appendToLog("PkData: found Rfid.Uplink.DataRead.UplinkPackage_Event_csl_operation_complete with payload = " + byteArrayToString(dataValues1)); + Logger.toLogView("isRfidToRead_3008: {}", byteArrayToString(dataValues)).debug(); + Logger.debug("Ready 2"); + Logger.pkData("PkData: found Rfid.Uplink.DataRead.UplinkPackage_Event_csl_operation_complete with payload = {}", byteArrayToString(dataValues1)); if (csReaderRfidData.dataValues[2] == dataValues1[4] && csReaderRfidData.dataValues[3] == dataValues1[5]) { - if (DEBUG) appendToLog("Ready 3"); + Logger.debug("Ready 3"); int iStatus = dataValues1[6] * 256 + dataValues1[7]; if (csReaderRfidData.uplinkResponded) { matched = true; - if (DEBUG_PKDATA) - appendToLog("PkData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_operation_complete is processed with status = " + String.format("%04X", iStatus)); + Logger.pkData("PkData: Rfid.Uplink.DataRead.UplinkPackage_Event_csl_operation_complete is processed with status = {}", String.format("%04X", iStatus)); } - } else appendToLog("!!! mismatched command code"); + } else Logger.trace("!!! mismatched command code"); } } } @@ -3855,7 +3826,7 @@ else if (iCommandCode == 0x1471) if (barcodeToWrite.get(0).dataValues[0] == 0x1b) { commandType = BarcodeCommendTypes.COMMAND_COMMON; count = 1; - if (false) appendToLog("uplink data is processed with count = " + count + " for barcodeToWrite data = " + byteArrayToString(barcodeToWrite.get(0).dataValues)); + Logger.trace("uplink data is processed with count = " + count + " for barcodeToWrite data = " + byteArrayToString(barcodeToWrite.get(0).dataValues)); } else if (barcodeToWrite.get(0).dataValues[0] == 0x7E) { matched = true; commandType = BarcodeCommendTypes.COMMAND_QUERY; @@ -3884,7 +3855,7 @@ else if (iCommandCode == 0x1471) System.arraycopy(dataValues, index + 7 + prefixLength + 2, bytesBarcodeSuffix, 0, bytesBarcodeSuffix.length); } } - if (true) appendToLog("uplink data is processed as Barcode Prefix = " + byteArrayToString(bytesBarcodePrefix) + ", Suffix = " + byteArrayToString(bytesBarcodeSuffix)); + if (true) Logger.trace("uplink data is processed as Barcode Prefix = " + byteArrayToString(bytesBarcodePrefix) + ", Suffix = " + byteArrayToString(bytesBarcodeSuffix)); } else if (barcodeToWrite.get(0).dataValues[5] == 0x47 && length > 1) { matched = true; byte[] byteVersion = new byte[length - 1]; @@ -3896,7 +3867,7 @@ else if (iCommandCode == 0x1471) versionNumber = null; } strVersion = versionNumber; - if (true) appendToLog("uplink data " + byteArrayToString(byteVersion) + " is processsed as version = " + versionNumber); + if (true) Logger.trace("uplink data " + byteArrayToString(byteVersion) + " is processsed as version = " + versionNumber); } else if (barcodeToWrite.get(0).dataValues[5] == 0x48 && length >= 5) { if (dataValues[index+5] == barcodeToWrite.get(0).dataValues[6] && dataValues[index+6] == barcodeToWrite.get(0).dataValues[7]) { matched = true; //for ESN, S/N or Date @@ -3912,7 +3883,7 @@ else if (iCommandCode == 0x1471) } catch (Exception e) { serialNumber = null; } - appendToLog("uplink data is processed as Barcode serial number [" + serialNumber + "] for index = " + index); + Logger.trace("uplink data is processed as Barcode serial number [" + serialNumber + "] for index = " + index); if (dataValues[index+6] == (byte)0x32) strESN = serialNumber; else if (dataValues[index+6] == (byte)0x33) strSerialNumber = serialNumber; else if (dataValues[index+6] == (byte)0x34) strDate = serialNumber; @@ -3923,21 +3894,21 @@ else if (iCommandCode == 0x1471) if (barcodeToWrite.get(0).dataValues[6] == 0x30 && barcodeToWrite.get(0).dataValues[7] == 0x30 && barcodeToWrite.get(0).dataValues[8] == 0x30) { bBarcodeTriggerMode = dataValues[7]; if (dataValues[index + 7] == 0x30) { - appendToLog("uplink data is processed as Barcode Reading mode TRIGGER"); + Logger.trace("uplink data is processed as Barcode Reading mode TRIGGER"); } else - appendToLog("uplink data is processed as Barcode Reading mode " + String.valueOf(dataValues[7])); - } else appendToLog("uplink data is processed as incorrect response !!!"); + Logger.trace("uplink data is processed as Barcode Reading mode " + String.valueOf(dataValues[7])); + } else Logger.trace("uplink data is processed as incorrect response !!!"); } else if (true) { matched = true; - appendToLog("uplink data is processed as incorrect response !!!"); + Logger.trace("uplink data is processed as incorrect response !!!"); } } index += (length + 5); } else break; } else index++; } - if (matched) { if (DEBUG) appendToLog("Matched Query response"); } - else appendToLog("uplink data is processed as Mis-matched Query response"); + if (matched) { Logger.debug("Matched Query response"); } + else Logger.trace("uplink data is processed as Mis-matched Query response"); } else { String strData = null; try { @@ -3956,7 +3927,7 @@ else if (iCommandCode == 0x1471) } } if (count != 0) { - if (false) appendToLog("dataValues.length = " + dataValues.length + ", okCount = " + iOkCount + ", count = " + count + " for barcodeToWrite data = " + byteArrayToString(barcodeToWrite.get(0).dataValues)); + if (false) Logger.trace("dataValues.length = " + dataValues.length + ", okCount = " + iOkCount + ", count = " + count + " for barcodeToWrite data = " + byteArrayToString(barcodeToWrite.get(0).dataValues)); matched = false; boolean foundOk = false; for (int k = 0; k < dataValues.length; k++) { boolean match06 = false; @@ -3964,18 +3935,18 @@ else if (iCommandCode == 0x1471) if (match06 == false) break; foundOk = true; found = true; } - if (false) appendToLog("00 matcched = " + matched); - if (matched) appendToLog("uplink data is processed with matched = " + matched + ", OkCount = " + iOkCount + ", expected count = " + count + " for " + byteArrayToString(barcodeToWrite.get(0).dataValues)); - else if (foundOk) appendToLog("uplink data is processed with matched = " + matched + ", but OkCount = " + iOkCount + ", expected count = " + count + " for " + byteArrayToString(barcodeToWrite.get(0).dataValues)); + if (false) Logger.trace("00 matcched = " + matched); + if (matched) Logger.trace("uplink data is processed with matched = " + matched + ", OkCount = " + iOkCount + ", expected count = " + count + " for " + byteArrayToString(barcodeToWrite.get(0).dataValues)); + else if (foundOk) Logger.trace("uplink data is processed with matched = " + matched + ", but OkCount = " + iOkCount + ", expected count = " + count + " for " + byteArrayToString(barcodeToWrite.get(0).dataValues)); else { mBarcodeDevice.mBarcodeToRead.add(cs108BarcodeData); - appendToLog("uplink data Barcode.DataRead." + byteArrayToString(cs108BarcodeData.dataValues) + " is added to mBarcodeToRead"); + Logger.trace("uplink data Barcode.DataRead." + byteArrayToString(cs108BarcodeData.dataValues) + " is added to mBarcodeToRead"); } }*/ if (matched) { csReaderConnector.rfidConnector.found = true; csReaderConnector.rfidConnector.mRfidToWrite.remove(0); csReaderConnector.rfidConnector.sendRfidToWriteSent = 0; csReaderConnector.rfidConnector.mRfidToWriteRemoved = true; - if (DEBUG_PKDATA) appendToLog("PkData: new mRfidToWrite size = " + csReaderConnector.rfidConnector.mRfidToWrite.size()); + Logger.pkData("PkData: new mRfidToWrite size = " + csReaderConnector.rfidConnector.mRfidToWrite.size()); } if (matched || updatedUplinkResponse) return true; } diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipR2000.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipR2000.java index ba5733e..3e8fe85 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipR2000.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/RfidReaderChipR2000.java @@ -10,10 +10,8 @@ import java.util.Date; public class RfidReaderChipR2000 { - boolean DEBUG_PKDATA, DEBUG; boolean sameCheck = true; //RfidReaderChip mRfidReaderChip; - boolean DEBUGTHREAD = false; int intervalRx000UplinkHandler; public int invalidUpdata; //invalidata, invalidUpdata, validata; boolean aborting = false; @@ -21,15 +19,12 @@ public class RfidReaderChipR2000 { public RfidReaderChipR2000(Context context, Utility utility, CsReaderConnector csReaderConnector) { this.context = context; this.utility = utility; - appendToLog("csReaderConnector 1 is " + (csReaderConnector == null ? "null" : "valid")); + Logger.trace("csReaderConnector 1 is {}", csReaderConnector == null ? "null" : "valid"); this.csReaderConnector = csReaderConnector; - this.DEBUGTHREAD = csReaderConnector.DEBUGTHREAD; this.intervalRx000UplinkHandler = csReaderConnector.intervalRx000UplinkHandler; } private String byteArrayToString(byte[] packet) { return utility.byteArrayToString(packet); } private boolean compareArray(byte[] array1, byte[] array2, int length) { return utility.compareByteArray(array1, array2, length); } - private void appendToLog(String s) { utility.appendToLog(s); } - private void appendToLogView(String s) { utility.appendToLogView(s); } void writeDebug2File(String stringDebug) { utility.writeDebug2File(stringDebug); } public enum ControlCommands { NULL, @@ -90,7 +85,7 @@ public class Rx000Setting { //queryTarget = mDefault.queryTarget; //querySession = mDefault.querySession; //querySelect = mDefault.querySelect; - //appendToLog("BtDataOut: RfidReaderChipR2000.Rx000Setting new querySelect = " + querySelect); + //appendLogger.trace("BtDataOut: RfidReaderChipR2000.Rx000Setting new querySelect = {}", querySelect); //invAlgo = mDefault.invAlgo; matchRep = mDefault.matchRep; tagSelect = mDefault.tagSelect; @@ -208,7 +203,7 @@ public boolean readMAC(int address) { byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 0, 0, 0, 0, 0, 0}; msgBuffer[2] = (byte) (address % 256); msgBuffer[3] = (byte) ((address >> 8) % 256); - if (false) appendToLog("readMac buffer = " + byteArrayToString(msgBuffer)); + Logger.trace("readMac buffer = {}", byteArrayToString(msgBuffer)); return sendHostRegRequest(HostRegRequests.MAC_OPERATION, false, msgBuffer); } public boolean writeMAC(int address, long value) { @@ -219,7 +214,7 @@ public boolean writeMAC(int address, long value) { msgBuffer[5] = (byte) ((value >> 8) % 256); msgBuffer[6] = (byte) ((value >> 16) % 256); msgBuffer[7] = (byte) ((value >> 24) % 256); - if (false) appendToLog("writeMac buffer = " + byteArrayToString(msgBuffer)); + Logger.trace("writeMac buffer = {}", byteArrayToString(msgBuffer)); return sendHostRegRequest(HostRegRequests.MAC_OPERATION, true, msgBuffer); } @@ -275,7 +270,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); + Logger.trace("BtDataOut 11: ivalue = {}, impinjExtensionValue ={}", iValue, rx000Setting.impinjExtensionValue); boolean bRetValue = writeMAC(0x203, iValue); if (bRetValue) impinjExtensionValue = iValue; return bRetValue; @@ -283,7 +278,7 @@ public boolean setImpinjExtension(boolean tagFocus, boolean fastId) { int pwrMgmtStatus = -1; void getPwrMgmtStatus() { - if (false) appendToLog("pwrMgmtStatus: getPwrMgmtStatus "); + Logger.trace("pwrMgmtStatus: getPwrMgmtStatus "); pwrMgmtStatus = -1; readMAC(0x204); } @@ -297,7 +292,7 @@ boolean setMBPAddress(long mbpAddress) { //msgBuffer[4] = (byte) (mbpAddress % 256); //msgBuffer[5] = (byte) ((mbpAddress >> 8) % 256); this.mbpAddress = mbpAddress; - if (false) appendToLog("Going to writeMAC"); + Logger.trace("Going to writeMAC"); return writeMAC(0x400, (int) mbpAddress); //mRfidDevice.mRx000Device.sendHostRegRequest(HostRegRequests.HST_MBP_ADDR, true, msgBuffer); } @@ -384,7 +379,7 @@ private boolean getHST_ANT_CYCLES() { final int ANTSELECT_INVALID = -1; final int ANTSLECT_MIN = 0; final int ANTSELECT_MAX = 15; int antennaSelect = ANTSELECT_INVALID; //default value = 0 public int getAntennaSelect() { - appendToLog("AntennaSelect = " + antennaSelect); + Logger.trace("AntennaSelect = {}", antennaSelect); if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 1, 7, 0, 0, 0, 0}; sendHostRegRequest(HostRegRequests.HST_ANT_DESC_SEL, false, msgBuffer); @@ -395,7 +390,8 @@ public boolean setAntennaSelect(int antennaSelect) { byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, 7, 0, 0, 0, 0}; if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) antennaSelect = mDefault.antennaSelect; if (this.antennaSelect == antennaSelect && sameCheck) return true; - this.antennaSelect = antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); + this.antennaSelect = antennaSelect; + Logger.trace("antennaSelect is set to {}", antennaSelect); msgBuffer[4] = (byte) (antennaSelect); return sendHostRegRequest(HostRegRequests.HST_ANT_DESC_SEL, true, msgBuffer); } @@ -409,12 +405,18 @@ public int getAntennaEnable() { } } public boolean setAntennaEnable(int antennaEnable) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } + if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { + antennaSelect = mDefault.antennaSelect; + Logger.trace("antennaSelect is set to {}", antennaSelect); + } return antennaSelectedData[antennaSelect].setAntennaEnable(antennaEnable); } 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); } + if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { + antennaSelect = mDefault.antennaSelect; + Logger.trace("antennaSelect is set to {}", antennaSelect); + } return antennaSelectedData[antennaSelect].setAntennaEnable(antennaEnable, antennaInventoryMode, antennaLocalAlgo, antennaLocalStartQ, antennaProfileMode, antennaLocalProfile, antennaFrequencyMode, antennaLocalFrequency); } @@ -427,7 +429,10 @@ int getAntennaInventoryMode() { } } boolean setAntennaInventoryMode(int antennaInventoryMode) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } + if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { + antennaSelect = mDefault.antennaSelect; + Logger.trace("antennaSelect is set to {}", antennaSelect); + } return antennaSelectedData[antennaSelect].setAntennaInventoryMode(antennaInventoryMode); } @@ -439,7 +444,10 @@ int getAntennaLocalAlgo() { } } boolean setAntennaLocalAlgo(int antennaLocalAlgo) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } + if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { + antennaSelect = mDefault.antennaSelect; + Logger.trace("antennaSelect is set to {}", antennaSelect); + } return antennaSelectedData[antennaSelect].setAntennaLocalAlgo(antennaLocalAlgo); } @@ -451,7 +459,10 @@ int getAntennaLocalStartQ() { } } boolean setAntennaLocalStartQ(int antennaLocalStartQ) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } + if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { + antennaSelect = mDefault.antennaSelect; + Logger.trace("antennaSelect is set to {}", antennaSelect); + } return antennaSelectedData[antennaSelect].setAntennaLocalStartQ(antennaLocalStartQ); } @@ -463,7 +474,10 @@ int getAntennaProfileMode() { } } boolean setAntennaProfileMode(int antennaProfileMode) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } + if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { + antennaSelect = mDefault.antennaSelect; + Logger.trace("antennaSelect is set to {}", antennaSelect); + } return antennaSelectedData[antennaSelect].setAntennaProfileMode(antennaProfileMode); } @@ -475,7 +489,10 @@ int getAntennaLocalProfile() { } } boolean setAntennaLocalProfile(int antennaLocalProfile) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } + if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { + antennaSelect = mDefault.antennaSelect; + Logger.trace("antennaSelect is set to {}", antennaSelect); + } return antennaSelectedData[antennaSelect].setAntennaLocalProfile(antennaLocalProfile); } @@ -487,7 +504,10 @@ int getAntennaFrequencyMode() { } } boolean setAntennaFrequencyMode(int antennaFrequencyMode) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } + if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { + antennaSelect = mDefault.antennaSelect; + Logger.trace("antennaSelect is set to " + antennaSelect); + } return antennaSelectedData[antennaSelect].setAntennaFrequencyMode(antennaFrequencyMode); } @@ -499,7 +519,10 @@ int getAntennaLocalFrequency() { } } boolean setAntennaLocalFrequency(int antennaLocalFrequency) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } + if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { + antennaSelect = mDefault.antennaSelect; + Logger.trace("antennaSelect is set to {}", antennaSelect); + } return antennaSelectedData[antennaSelect].setAntennaLocalFrequency(antennaLocalFrequency); } @@ -527,7 +550,10 @@ public long getAntennaDwell() { } } public boolean setAntennaDwell(long antennaDwell) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } + if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { + antennaSelect = mDefault.antennaSelect; + Logger.trace("antennaSelect is set to {}", antennaSelect); + } return antennaSelectedData[antennaSelect].setAntennaDwell(antennaDwell); } @@ -542,7 +568,10 @@ public long getAntennaPower(int portNumber) { } } public boolean setAntennaPower(long antennaPower) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } + if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { + antennaSelect = mDefault.antennaSelect; + Logger.trace("antennaSelect is set to {}", antennaSelect); + } return antennaSelectedData[antennaSelect].setAntennaPower(antennaPower); } @@ -554,7 +583,10 @@ long getAntennaInvCount() { } } public boolean setAntennaInvCount(long antennaInvCount) { - if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { antennaSelect = mDefault.antennaSelect; appendToLog("antennaSelect is set to " + antennaSelect); } + if (antennaSelect < ANTSLECT_MIN || antennaSelect > ANTSELECT_MAX) { + antennaSelect = mDefault.antennaSelect; + Logger.trace("antennaSelect is set to {}", antennaSelect); + } return antennaSelectedData[antennaSelect].setAntennaInvCount(antennaInvCount); } @@ -571,7 +603,7 @@ public int getInvSelectIndex() { return invSelectIndex; } public boolean setInvSelectIndex(int invSelect) { - if (utility.DEBUG_SELECT) appendToLog("Debug_Select: RfidReaderChipR2000.setInvSelectIndex[" + invSelect); + Logger.select("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; @@ -586,9 +618,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); + Logger.select("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); + Logger.trace("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); } @@ -633,7 +665,7 @@ public int getSelectMaskLength() { } } public boolean setSelectMaskLength(int selectMaskLength) { - if (false) appendToLog("btDataOut: setSelectMaskLength with selectMaskLength = " + selectMaskLength); + Logger.trace("btDataOut: setSelectMaskLength with selectMaskLength = {}", selectMaskLength); if (invSelectIndex < INVSELECT_MIN || invSelectIndex > INVSELECT_MAX) invSelectIndex = mDefault.invSelectIndex; return invSelectData[invSelectIndex].setSelectMaskLength(selectMaskLength); } @@ -662,16 +694,16 @@ 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 (DEBUG) appendToLog("RfidReaderChipR2000.getQueryTarget with queryTarget = " + queryTarget); + Logger.debug("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); + Logger.debug("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); + Logger.trace("setQueryTarget[{}, {}, {}] with sameCheck = {}, old queryTarget/Session/Select = {}, {}, {}" + queryTarget, querySession, querySelect, sameCheck, this.queryTarget, this.querySession, this.querySelect); if (queryTarget >= 2) { rx000Setting.setAlgoAbFlip(1); } else if (queryTarget >= 0) { rx000Setting.setAlgoAbFlip(0); } @@ -719,7 +751,7 @@ public int getQuerySession() { return ANTSELECT_INVALID; } else { { - //appendToLog("BtDataOut: RfidReaderChipR2000.getQuerySession with querySession = " + querySession); + //Logger.trace("BtDataOut: RfidReaderChipR2000.getQuerySession with querySession = {}", querySession); if (querySession < QUERYSESSION_MIN || querySession > QUERYSESSION_MAX) getHST_QUERY_CFG(); return querySession; @@ -728,26 +760,26 @@ public int getQuerySession() { } boolean setQuerySession(int querySession) { - if (true) appendToLog("4 setQueryTargetis callled from BtDataOut: RfidReaderChipR2000.setQuerySession[" + querySession); + Logger.trace("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); + Logger.trace("BtDataOut: RfidReaderChipR2000.getQuerySelect with querySelect = {}", querySelect); if (querySelect < QUERYSELECT_MIN || querySelect > QUERYSELECT_MAX) getHST_QUERY_CFG(); - if (false) appendToLog("Stream querySelect = " + querySelect); + Logger.trace("Stream querySelect = {}", querySelect); return querySelect; } public boolean setQuerySelect(int querySelect) { - if (false) appendToLog("5 setQueryTarget is callled from RfidReaderChipR2000.setQuerySelect[" + querySelect); + Logger.trace("5 setQueryTarget is callled from RfidReaderChipR2000.setQuerySelect[{}]", querySelect); if (querySelect == this.querySelect) return true; return setQueryTarget((getAlgoAbFlip() > 0 ? 2 : queryTarget), querySession, querySelect); } private boolean getHST_QUERY_CFG() { - //appendToLog("BtDataOut: RfidReaderChipR2000.getHST_QUERY_CFG"); + //Logger.trace("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); } @@ -759,7 +791,7 @@ public int getInvAlgo() { return invAlgo; } public boolean setInvAlgo(int invAlgo) { - if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setInvAlog goes to setInvAlgo with invAlgo = " + invAlgo); + Logger.invCfg("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setInvAlog goes to setInvAlgo with invAlgo = {}", invAlgo); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact,invBrandId); } @@ -770,7 +802,7 @@ int getMatchRep() { return matchRep; } public boolean setMatchRep(int matchRep) { - if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setMatchRep goes to setInvAlgo with matchRep = " + matchRep); + Logger.invCfg("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setMatchRep goes to setInvAlgo with matchRep = {}", matchRep); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, invBrandId); } @@ -781,7 +813,7 @@ int getTagSelect() { return tagSelect; } public boolean setTagSelect(int tagSelect) { - if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setTagSelect goes to setInvAlgo with tagSelect = " + tagSelect); + Logger.invCfg("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setTagSelect goes to setInvAlgo with tagSelect = {}", tagSelect); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, invBrandId); } @@ -792,7 +824,7 @@ int getNoInventory() { return noInventory; } boolean setNoInventory(int noInventory) { - if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setNoInventory goes to setInvAlgo with noInventory = " + noInventory); + Logger.invCfg("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setNoInventory goes to setInvAlgo with noInventory = {}", noInventory); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, invBrandId); } @@ -803,7 +835,7 @@ int getTagRead() { return tagRead; } public boolean setTagRead(int tagRead) { - if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setTagRead goes to setInvAlgo with tagRead = " + tagRead); + Logger.invCfg("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setTagRead goes to setInvAlgo with tagRead = {}", tagRead); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, invBrandId); } @@ -814,36 +846,36 @@ int getTagDelay() { return tagDelay; } public boolean setTagDelay2RfidReader(int tagDelay) { - if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setTagDelay goes to setInvAlgo with tagDelay = " + tagDelay); + Logger.invCfg("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setTagDelay goes to setInvAlgo with tagDelay = {}", tagDelay); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, invBrandId); } byte intraPacketDelay = 4; public byte getIntraPacketDelay() { - appendToLog("intraPacketDelay = " + intraPacketDelay); + Logger.trace("intraPacketDelay = {}", intraPacketDelay); return intraPacketDelay; } public boolean setIntraPacketDelay(byte intraPkDelay) { if (intraPacketDelay == intraPkDelay && sameCheck) { - appendToLog("!!! Skip sending repeated data with intraPkDelay = " + intraPkDelay); + Logger.trace("!!! Skip sending repeated data with intraPkDelay = {}", intraPkDelay); return true; } - appendToLog("Skip setDupElim with intraPkDelay = " + intraPkDelay); + Logger.trace("Skip setDupElim with intraPkDelay = {}", intraPkDelay); intraPacketDelay = intraPkDelay; return true; } byte dupElimRollWindow = 0; public byte getDupElimRollWindow() { - appendToLog("dupElim = " + dupElimRollWindow); + Logger.trace("dupElim = {}", dupElimRollWindow); return dupElimRollWindow; } public boolean setDupElimRollWindow(byte dupElimDelay) { if (dupElimRollWindow == dupElimDelay && sameCheck) { - appendToLog("!!! Skip sending repeated data with dupElimDelay = " + dupElimDelay); + Logger.trace("!!! Skip sending repeated data with dupElimDelay = {}", dupElimDelay); return true; } - appendToLog("Skip setDupElim with dupElimDelay = " + dupElimDelay); + Logger.trace("Skip setDupElim with dupElimDelay = {}", dupElimDelay); dupElimRollWindow = dupElimDelay; return true; } @@ -880,7 +912,7 @@ private boolean getHST_AUTHENTICATE_CFG() { return sendHostRegRequest(HostRegRequests.HST_AUTHENTICATE_CFG, false, msgBuffer); } public boolean setHST_AUTHENTICATE_CFG(boolean sendReply, boolean incReplyLenth, int csi, int length) { - appendToLog("sendReply = " + sendReply + ", incReplyLenth = " + incReplyLenth + ", length = " + length); + Logger.trace("sendReply = {}, incReplyLenth = {}, length = {}", sendReply, incReplyLenth, length); if (length < 0 || length > 0x3FF) return false; byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 0, (byte) 0x0F, 0, 0, 0, 0}; @@ -899,7 +931,7 @@ public String getAuthMatchData() { String strValue = ""; for (int i = 0; i < 3; i++) { if (length > 0) { - appendToLog("i = " + i + ", authMatchDataReady = " + authMatchDataReady); + Logger.trace("i = {}, authMatchDataReady = {}", i, authMatchDataReady); if ((authMatchDataReady & (0x01 << i)) == 0) { byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 1, (byte)0x0F, 0, 0, 0, 0}; msgBuffer[2] += i; @@ -917,7 +949,7 @@ public String getAuthMatchData() { } public boolean setAuthMatchData(String matchData) { int length = matchData.length(); - appendToLog("matchData is " + length + ", " + matchData); + Logger.trace("matchData is {}, {}", length, matchData); for (int i = 0; i < 6; i++) { if (length > 0) { length -= 8; @@ -942,12 +974,12 @@ public boolean setAuthMatchData(String matchData) { } } msgBuffer[2] = (byte) ((msgBuffer[2] & 0xFF) + i); - if (sendHostRegRequest(HostRegRequests.HST_AUTHENTICATE_MSG, true, msgBuffer) == false) + if (!sendHostRegRequest(HostRegRequests.HST_AUTHENTICATE_MSG, true, msgBuffer)) 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)); + System.arraycopy(msgBuffer, 4, authMatchData0_63, i * 4, 4); //Logger.trace("Data={}", byteArrayToString(mRx000Setting.invMatchData0_63)); +// Logger.trace("invMatchDataReady=" + Integer.toString(mRx000Setting.invMatchDataReady, 16) + ", message=" + byteArrayToString(msgBuffer)); } } } @@ -970,7 +1002,7 @@ private boolean getHST_UNTRACEABLE_CFG() { return sendHostRegRequest(HostRegRequests.HST_UNTRACEABLE_CFG, false, msgBuffer); } public boolean setHST_UNTRACEABLE_CFG(int range, boolean user, int tid, int epcLength, boolean epc, boolean uxpc) { - appendToLog("range1 = " + range + ", user = " + user + ", tid = " + tid + ", epc = " + epc + ", epcLength = " + epcLength + ", xcpc = " + uxpc); + Logger.trace("range1 = {}, user = {}, tid = {}, epc = {}, epcLength = {}, xcpc = {}", range, user, tid, epc, epcLength, uxpc); if (range < 0 || range > 3) return false; if (tid < 0 || tid > 2) return false; if (epcLength < 0 || epcLength > 31) return false; @@ -983,7 +1015,7 @@ public boolean setHST_UNTRACEABLE_CFG(int range, boolean user, int tid, int epcL msgBuffer[5] |= ((epcLength & 0x18) >> 3); untraceableEpcLength = epcLength; if (epc) msgBuffer[5] |= 0x04; untraceableEpc = epc; if (uxpc) msgBuffer[5] |= 0x08; untraceableUXpc = uxpc; - appendToLog("msgbuffer = " + byteArrayToString(msgBuffer)); + Logger.trace("msgbuffer = {}", byteArrayToString(msgBuffer)); return sendHostRegRequest(HostRegRequests.HST_UNTRACEABLE_CFG, true, msgBuffer); } @@ -991,10 +1023,10 @@ public boolean setHST_UNTRACEABLE_CFG(int range, boolean user, int tid, int epcL int invModeCompact = TAGJOIN_INVALID; boolean getInvModeCompact() { if (invModeCompact < TAGDELAY_MIN || invModeCompact > TAGDELAY_MAX) { getHST_INV_CFG(); return false; } - return (invModeCompact == 1 ? true : false); + return (invModeCompact == 1); } public boolean setInvModeCompact(boolean invModeCompact) { - if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setInvModeCompact goes to setInvAlgo with invModeCompact = " + invModeCompact); + Logger.invCfg("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setInvModeCompact goes to setInvAlgo with invModeCompact = {}", invModeCompact); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, (invModeCompact ? 1 : 0), invBrandId); } @@ -1002,10 +1034,10 @@ public boolean setInvModeCompact(boolean invModeCompact) { int invBrandId = BRAND_INVALID; boolean getInvBrandId() { if (invBrandId < BRANDID_MIN || invBrandId > BRANDID_MAX) { getHST_INV_CFG(); return false; } - return (invModeCompact == 1 ? true : false); + return (invModeCompact == 1); } public boolean setInvBrandId(boolean invBrandId) { - if (utility.DEBUG_INVCFG) appendToLog("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setInvBrandId goes to setInvAlgo with invBrandId = " + invBrandId); + Logger.invCfg("Debug_InvCfg: RfidReaderChipR2000.Rx000setting.setInvBrandId goes to setInvAlgo with invBrandId = {}", invBrandId); return setInvAlgo(invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, (invBrandId ? 1 : 0)); } @@ -1014,8 +1046,7 @@ 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 = utility.DEBUG_INVCFG; - if (DEBUG) appendToLog("Debug_InvCfg: 0 tagRead is " + tagRead); + Logger.invCfg("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; @@ -1024,20 +1055,21 @@ 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("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); + Logger.invCfg("Debug_InvCfg: Old invAlgo = {}, matchRep = {}, tagSelect = {}, noInventory = {}, tagRead = {}, tagDelay = {}, invModeCompact = {}, invBrandId = {}", this.invAlgo, this.matchRep, this.tagSelect, this.noInventory, this.tagRead, this.tagDelay, this.invModeCompact, this.invBrandId); + Logger.invCfg("Debug_InvCfg: New invAlgo = {}, matchRep = {}, tagSelect = {}, noInventory = {}, tagRead = {}, tagDelay = {}, invModeCompact = {}, invBrandId = {}, sameCheck = {}", invAlgo, matchRep, tagSelect, noInventory, tagRead, tagDelay, invModeCompact, invBrandId, 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); + Logger.invCfg("Debug_InvCfg: tagRead = {}, this.tagRead = {}", 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); + Logger.invCfg("Debug_InvCfg: There is difference with {}, {}, {}, {}, {}, {}, {}, {}", bool1, bool2, bool3, bool4, bool5, bool6, bool7, bool8); + this.invAlgo = invAlgo; + Logger.invCfg("Hello6: invAlgo = {}, queryTarget = {}", invAlgo, queryTarget); this.matchRep = matchRep; this.tagSelect = tagSelect; this.noInventory = noInventory; @@ -1045,7 +1077,7 @@ boolean setInvAlgo(int invAlgo, int matchRep, int tagSelect, int noInventory, in this.tagDelay = tagDelay; this.invModeCompact = invModeCompact; this.invBrandId = invBrandId; - if (DEBUG) appendToLog("Debug_InvCfg: Stored tagDelay = " + this.tagDelay); + Logger.invCfg("Debug_InvCfg: Stored tagDelay = {}", this.tagDelay); byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, 9, 0, 0, 0, 0}; msgBuffer[4] |= invAlgo; @@ -1086,11 +1118,11 @@ public int getAlgoSelect() { } boolean dummyAlgoSelected = false; public boolean setAlgoSelect(int algoSelect) { - if (false) appendToLog("setTagGroup: algoSelect = " + algoSelect + ", this.algoSelct = " + this.algoSelect + ", dummyAlgoSelected = " + dummyAlgoSelected); + Logger.trace("setTagGroup: algoSelect = {}, this.algoSelct = {}, dummyAlgoSelected = {}", algoSelect, this.algoSelect, dummyAlgoSelected); byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 2, 9, 0, 0, 0, 0}; if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) algoSelect = mDefault.algoSelect; - if (algoSelect == this.algoSelect && dummyAlgoSelected == false) return true; + if (algoSelect == this.algoSelect && !dummyAlgoSelected) return true; msgBuffer[4] = (byte) (algoSelect & 0xFF); msgBuffer[5] = (byte) ((algoSelect & 0xFF00) >> 8); msgBuffer[6] = (byte) ((algoSelect & 0xFF0000) >> 16); @@ -1229,7 +1261,7 @@ public boolean setAlgoAbFlip(int algoAbFlip) { } boolean setAlgoAbFlip(int algoAbFlip, int algoRunTilZero) { if (algoSelect < ALGOSELECT_MIN || algoSelect > ALGOSELECT_MAX) return false; - appendToLog("algoSelect = " + algoSelect + ", algoAbFlip = " + algoAbFlip + ", algoRunTilZero = " + algoRunTilZero); + Logger.trace("algoSelect = {}, algoAbFlip = {}, algoRunTilZero = {}", algoSelect, algoAbFlip, algoRunTilZero); return algoSelectedData[algoSelect].setAlgoAbFlip(algoAbFlip, algoRunTilZero); } @@ -1329,21 +1361,21 @@ private boolean getHST_INV_RSSI_FILTERING_COUNT() { return sendHostRegRequest(HostRegRequests.HST_INV_RSSI_FILTERING_THRESHOLD, false, msgBuffer); } public boolean setHST_INV_RSSI_FILTERING_COUNT(long rssiFilterCount) { - appendToLog("entry: rssiFilterCount = " + rssiFilterCount + ", this.rssiFilterCount = " + this.rssiFilterCount); + Logger.trace("entry: rssiFilterCount = {}, this.rssiFilterCount = {}", rssiFilterCount, this.rssiFilterCount); byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 9, 9, 0, 0, 0, 0}; if (rssiFilterCount < RSSIFILTERCOUNT_MIN || rssiFilterCount > RSSIFILTERCOUNT_MAX) rssiFilterCount = mDefault.rssiFilterCount; - appendToLog("rssiFilterCount 1 = " + rssiFilterCount + ", this.rssiFilterCount = " + this.rssiFilterCount); + Logger.trace("rssiFilterCount 1 = {}, this.rssiFilterCount = {}", rssiFilterCount, this.rssiFilterCount); if (this.rssiFilterCount == rssiFilterCount && sameCheck) return true; - appendToLog("rssiFilterCount 2 = " + rssiFilterCount + ", this.rssiFilterCount = " + this.rssiFilterCount); + Logger.trace("rssiFilterCount 2 = {}, this.rssiFilterCount = {}", rssiFilterCount, this.rssiFilterCount); msgBuffer[4] |= (byte) (rssiFilterCount & 0xFF); msgBuffer[5] |= (byte) ((rssiFilterCount >> 8) & 0xFF); msgBuffer[6] |= (byte) ((rssiFilterCount >> 16) & 0xFF); msgBuffer[7] |= (byte) ((rssiFilterCount >> 24) & 0xFF); this.rssiFilterCount = rssiFilterCount; - appendToLog("entering to sendHostRegRequest: rssiFilterCount = " + rssiFilterCount); + Logger.trace("entering to sendHostRegRequest: rssiFilterCount = {}", rssiFilterCount); boolean bValue = sendHostRegRequest(HostRegRequests.HST_INV_RSSI_FILTERING_COUNT, true, msgBuffer); - appendToLog("after sendHostRegRequest: rssiFilterCount = " + rssiFilterCount); + Logger.trace("after sendHostRegRequest: rssiFilterCount = {}", rssiFilterCount); return bValue; } @@ -1470,12 +1502,12 @@ public boolean setInvMatchData(String matchData) { } } msgBuffer[2] = (byte) ((msgBuffer[2] & 0xFF) + i); - if (sendHostRegRequest(HostRegRequests.HST_INV_EPCDAT_0_3, true, msgBuffer) == false) + if (!sendHostRegRequest(HostRegRequests.HST_INV_EPCDAT_0_3, true, msgBuffer)) return false; else { invMatchDataReady |= (0x01 << i); - System.arraycopy(msgBuffer, 4, invMatchData0_63, i * 4, 4); //appendToLog("Data=" + byteArrayToString(mRx000Setting.invMatchData0_63)); -// appendToLog("invMatchDataReady=" + Integer.toString(mRx000Setting.invMatchDataReady, 16) + ", message=" + byteArrayToString(msgBuffer)); + System.arraycopy(msgBuffer, 4, invMatchData0_63, i * 4, 4); //Logger.trace("Data=" + byteArrayToString(mRx000Setting.invMatchData0_63)); +// Logger.trace("invMatchDataReady=" + Integer.toString(mRx000Setting.invMatchDataReady, 16) + ", message=" + byteArrayToString(msgBuffer)); } } } @@ -1495,7 +1527,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); + Logger.debug("setAccessRetry[{}, {}] with tagRead = {}, sameCheck = {}, old accessVerfiy = {}, accessRetry = {}", accessVerfiy, accessRetry, tagRead, sameCheck, this.accessVerfiy, this.accessRetry); if (accessRetry < ACCRETRY_MIN || accessRetry > ACCRETRY_MAX) accessRetry = mDefault.accessRetry; if (this.accessVerfiy == accessVerfiy && this.accessRetry == accessRetry && sameCheck) return true; @@ -1517,7 +1549,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); + Logger.debug("setAccessBank[{}] with tagRead = {}, sameCheck = {}, old accessBank = {}", accessBank, tagRead, sameCheck, this.accessBank); if (accessBank < ACCBANK_MIN || accessBank > ACCBANK_MAX) accessBank = mDefault.accessBank; if (this.accessBank == accessBank && this.accessBank2 == 0 && sameCheck) return true; @@ -1527,7 +1559,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 + ", sameCheck = " + sameCheck + ", old accessBank = " + this.accessBank + ", " + this.accessBank2); + Logger.debug("setAccessBank[{}, {}] with tagRead = {}, sameCheck = {}, old accessBank = {}, {}", accessBank, accessBank2, tagRead, sameCheck, this.accessBank, this.accessBank2); if (tagRead != 2) accessBank2 = 0; if (accessBank < ACCBANK_MIN || accessBank > ACCBANK_MAX) accessBank = mDefault.accessBank; @@ -1551,7 +1583,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); + Logger.trace("setAccessOffset[{}] with tagRead = {}, sameCheck = {}, old accessOffset = {}", accessOffset, tagRead, sameCheck, this.accessOffset); if (accessOffset < ACCOFFSET_MIN || accessOffset > ACCOFFSET_MAX) accessOffset = mDefault.accessOffset; if (this.accessOffset == accessOffset && this.accessOffset2 == 0 && sameCheck) return true; @@ -1564,7 +1596,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); + Logger.trace("setAccessOffset[{}, {}] with tagRead = {}, sameCheck = {} old accessOffset = {}, {}, {}", accessOffset, accessOffset2, tagRead, sameCheck, this.accessOffset, this.accessOffset2); if (tagRead != 2) accessOffset2 = 0; if (accessOffset < ACCOFFSET_MIN || accessOffset > ACCOFFSET_MAX) accessOffset = mDefault.accessOffset; @@ -1590,7 +1622,7 @@ public 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); + Logger.debug("BtDataOut: SetAccessCount[{}] with tagRead = {}, sameCheck = {}, old accessCount = {}", accessCount, tagRead, sameCheck, this.accessCount); if (accessCount < ACCCOUNT_MIN || accessCount > ACCCOUNT_MAX) accessCount = mDefault.accessCount; if ((this.accessCount == accessCount || accessCount == -1) && this.accessCount2 == 0 && sameCheck) return true; @@ -1600,7 +1632,7 @@ public boolean setAccessCount(int accessCount) { } 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); + Logger.debug("setAccessCount[{}, {}] with tagRead = {}, sameCheck = {}, old accessCount = {}, {}", accessCount, accessCount2, tagRead, sameCheck, this.accessCount, this.accessCount2); if (tagRead != 2) accessCount2 = 0; if (accessCount < ACCCOUNT_MIN || accessCount > ACCCOUNT_MAX) accessCount = mDefault.accessCount; @@ -1659,7 +1691,7 @@ public boolean setAccessLockAction(int accessLockAction, int accessLockMask) { final int ACCPWD_INVALID = 0; final long ACCPWD_MIN = 0; final long ACCPWD_MAX = 0x0FFFFFFFF; String stringAccessPasword = "00000000"; public boolean setRx000AccessPassword(String password) { - //appendToLog("BtDataOut: setRx000AccessPassword with password = " + password + ", stringAccessPasword = " + stringAccessPasword); + //Logger.trace("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 = ""; @@ -1682,7 +1714,7 @@ public boolean setRx000AccessPassword(String password) { } } boolean retValue = sendHostRegRequest(HostRegRequests.HST_TAGACC_ACCPWD, true, msgBuffer); - if (DEBUG) appendToLog("sendHostRegRequest(): retValue = " + retValue); + Logger.debug("sendHostRegRequest(): retValue = {}", retValue); if (retValue) stringAccessPasword = password; return retValue; } @@ -1708,7 +1740,7 @@ public boolean setRx000KillPassword(String password) { } } boolean retValue = sendHostRegRequest(HostRegRequests.HST_TAGACC_KILLPWD, true, msgBuffer); - if (DEBUG) appendToLog("sendHostRegRequest(): retValue = " + retValue); + Logger.debug("sendHostRegRequest(): retValue = {}", retValue); return retValue; } @@ -1763,20 +1795,24 @@ public boolean setAccessWriteData(String dataInput) { dataInput = dataInput.trim(); int writeBufLength = 16 * 2; //16 int wrieByteSize = 4; //8 - int length = dataInput.length(); appendToLog("length = " + length); - if (length > wrieByteSize * writeBufLength) { appendToLog("1"); return false; } + int length = dataInput.length(); + Logger.trace("length = {}", length); + if (length > wrieByteSize * writeBufLength) { + Logger.trace("1"); + return false; + } for (int i = 0; i < writeBufLength; i++) { if (length > 0) { length -= wrieByteSize; if ((i / 16) * 16 == i) { if (true) { - if (setAccessWriteDataSelect(i/16) == false) return false; + if (!setAccessWriteDataSelect(i / 16)) 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"); + if (!sendHostRegRequest(HostRegRequests.HST_TAGWRDAT_SEL, true, msgBuffer)) { + Logger.trace("23"); return false; } } @@ -1785,18 +1821,21 @@ public boolean setAccessWriteData(String dataInput) { String hexString = "0123456789ABCDEF"; for (int j = 0; j < wrieByteSize; j++) { // if (i * wrieByteSize + j + 1 <= dataInput.length()) { - appendToLog("dataInput = " + dataInput + ", i = " + i + ", wrieByteSize = " + wrieByteSize + ", j = " + j); + Logger.trace("dataInput = {}, i = {}, wrieByteSize = {}, j = {}", dataInput, i, wrieByteSize, j); if (i * wrieByteSize + j >= dataInput.length()) break; String subString = dataInput.substring(i * wrieByteSize + j, i * wrieByteSize + j + 1).toUpperCase(); - appendToLog("subString = " + subString); - if (DEBUG) appendToLog(subString); + Logger.trace("subString = {}", subString); + Logger.debug(subString); int k = 0; for (k = 0; k < 16; k++) { if (subString.matches(hexString.substring(k, k + 1))) { break; } } - if (k == 16) { appendToLog("2: i= " + i + ", j=" + j + ", subString = " + subString); return false; } + if (k == 16) { + Logger.trace("2: i= {}, j={}, subString = {}", i, j, subString); + return false; + } if ((j / 2) * 2 == j) { msgBuffer[5- j / 2] |= (byte) (k << 4); } else { @@ -1804,7 +1843,7 @@ public boolean setAccessWriteData(String dataInput) { } // } } - appendToLog("complete 4 bytes: " + byteArrayToString(msgBuffer)); + Logger.trace("complete 4 bytes: {}", byteArrayToString(msgBuffer)); msgBuffer[2] = (byte) ((msgBuffer[2] & 0xFF) + (i % 16)); if (wrieByteSize == 4) { msgBuffer[6] = (byte)(i); @@ -1816,17 +1855,17 @@ public boolean setAccessWriteData(String dataInput) { 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"); + Logger.trace("BtDataOut: RfidReaderChipR2000.setAccessWriteData msgBuffer = {}, debugBuffer = {}", byteArrayToString(msgBuffer), byteArrayToString(debugBuffer)); + if (!sendHostRegRequest(HostRegRequests.HST_TAGWRDAT_0, true, msgBuffer)) { + Logger.trace("3"); return false; } else { rx000Setting.accWriteDataReady |= (0x01 << i); - if (DEBUG) appendToLog("accWriteReady=" + accWriteDataReady); + Logger.debug("accWriteReady={}", accWriteDataReady); for (int k1 = 0; k1 < 4; k1++) { accWriteData0_63[i * 4 + k1] = msgBuffer[7 - k1]; } - if (DEBUG) appendToLog("Data=" + byteArrayToString(accWriteData0_63)); + Logger.debug("Data={}", byteArrayToString(accWriteData0_63)); } } } else break; @@ -1870,7 +1909,7 @@ public boolean setCurrentProfile(int currentProfile) { final int FREQCHANSEL_INVALID = -1; final int FREQCHANSEL_MIN = 0; final int FREQCHANSEL_MAX = 49; int freqChannelSelect = FREQCHANSEL_INVALID; public int getFreqChannelSelect() { - appendToLog("freqChannelSelect = " + freqChannelSelect); + Logger.trace("freqChannelSelect = {}", freqChannelSelect); if (freqChannelSelect < FREQCHANSEL_MIN || freqChannelSelect > FREQCHANSEL_MAX) { { byte[] msgBuffer = new byte[]{(byte) 0x70, 0, 1, 0x0C, 0, 0, 0, 0}; @@ -1883,7 +1922,7 @@ public boolean setFreqChannelSelect(int freqChannelSelect) { byte[] msgBuffer = new byte[]{(byte) 0x70, 1, 1, 0x0C, 0, 0, 0, 0}; if (freqChannelSelect < FREQCHANSEL_MIN || freqChannelSelect > FREQCHANSEL_MAX) freqChannelSelect = mDefault.freqChannelSelect; //if (this.freqChannelSelect == freqChannelSelect && sameCheck) return true; - appendToLog("freqChannelSelect = " + freqChannelSelect); + Logger.trace("freqChannelSelect = {}", freqChannelSelect); msgBuffer[4] = (byte) (freqChannelSelect); this.freqChannelSelect = freqChannelSelect; freqChannelSelect = FREQCHANCONFIG_INVALID; freqPllMultiplier = FREQPLLMULTIPLIER_INVALID; @@ -1968,7 +2007,8 @@ class AntennaSelectedData { antennaStatus = mDefault.antennaStatus; antennaDefine = mDefault.antennaDefine; antennaDwell = mDefault.antennaDwell; - antennaPower = mDefault.antennaPower; appendToLog("antennaPower is set to default " + antennaPower); + antennaPower = mDefault.antennaPower; + Logger.trace("antennaPower is set to default {}", antennaPower); antennaInvCount = mDefault.antennaInvCount; } } @@ -2296,7 +2336,7 @@ int getSelectEnable() { return selectEnable; } boolean setSelectEnable(int selectEnable) { - appendToLog("BtDataOut: RfidReaderChipR200.setSelectEnable"); + Logger.trace("BtDataOut: RfidReaderChipR200.setSelectEnable"); return setRx000HostReg_HST_TAGMSK_DESC_CFG(selectEnable, this.selectTarget, this.selectAction, this.selectDelay); } @@ -2335,9 +2375,8 @@ 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); + Logger.select("Debug_Select: RfidReaderR2000.setRx000HostReg_HST_TAGMSK_DESC_CFG[{}, {}, {}, {}] with old SelectEnable/Target/Action/Delay = {}, {}, {}, {}", + selectEnable, selectTarget, selectAction, selectDelay, 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) @@ -2401,7 +2440,7 @@ boolean setSelectMaskOffset(int selectMaskOffset) { 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); + Logger.trace("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); @@ -2421,7 +2460,7 @@ boolean setSelectMaskLength(int selectMaskLength) { byte[] selectMaskData0_31 = new byte[4 * 8]; byte selectMaskDataReady = 0; String getRx000SelectMaskData() { - if (false) appendToLog("getSelectMaskData with selectMaskData0_31 = " + byteArrayToString(selectMaskData0_31)); + Logger.trace("getSelectMaskData with selectMaskData0_31 = {}", byteArrayToString(selectMaskData0_31)); int length = selectMaskLength; String strValue = ""; if (length < 0) { @@ -2438,7 +2477,7 @@ String getRx000SelectMaskData() { break; } else { for (int j = 0; j < 4; j++) { - if (DEBUG) appendToLog("i = " + i + ", j = " + j + ", selectMaskData0_31 = " + selectMaskData0_31[i * 4 + j]); + Logger.debug("i = {}, j = {}, selectMaskData0_31 = {}", i , j , selectMaskData0_31[i * 4 + j]); strValue += String.format("%02X", selectMaskData0_31[i * 4 + j]); } } @@ -2466,7 +2505,7 @@ boolean setRx000SelectMaskData(String maskData) { } } if (k == 16) return false; -// appendToLog("setSelectMaskData(" + maskData +"): i=" + i + ", j=" + j + ", k=" + k); +// Logger.trace("setSelectMaskData(" + maskData +"): i=" + i + ", j=" + j + ", k=" + k); if ((j / 2) * 2 == j) { msgBuffer[4 + j / 2] |= (byte) (k << 4); } else { @@ -2475,13 +2514,13 @@ boolean setRx000SelectMaskData(String maskData) { } } msgBuffer[2] = (byte) ((msgBuffer[2] & 0xFF) + i); - if (sendHostRegRequest(HostRegRequests.HST_TAGMSK_0_3, true, msgBuffer) == false) + if (!sendHostRegRequest(HostRegRequests.HST_TAGMSK_0_3, true, msgBuffer)) return false; else { selectMaskDataReady |= (0x01 << i); - if (DEBUG) appendToLog("Old selectMaskData0_31 = " + byteArrayToString(selectMaskData0_31)); + Logger.debug("Old selectMaskData0_31 = {}", byteArrayToString(selectMaskData0_31)); System.arraycopy(msgBuffer, 4, selectMaskData0_31, i * 4, 4); - if (DEBUG) appendToLog("New selectMaskData0_31 = " + byteArrayToString(selectMaskData0_31)); + Logger.debug("New selectMaskData0_31 = {}", byteArrayToString(selectMaskData0_31)); } } } @@ -2612,11 +2651,9 @@ private boolean getHST_INV_ALG_PARM_0() { return sendHostRegRequest(HostRegRequests.HST_INV_ALG_PARM_0, false, msgBuffer); } boolean setAlgoStartQ(int startQ, int algoMaxQ, int algoMinQ, int algoMaxRep, int algoHighThres, int algoLowThres) { - boolean DEBUG = false; - 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); + Logger.debug("BtDataOut: startQ = {}, algoMaxQ = {}, algoMinQ = {}, algoMaxRep = {}, algoHighThres = {}, algoLowThres = {}, Old = {}, {}, {}, {}, {}, {}", + startQ, algoMaxQ, algoMinQ, algoMaxRep, algoHighThres, algoLowThres, 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; @@ -2632,7 +2669,7 @@ boolean setAlgoStartQ(int startQ, int algoMaxQ, int algoMinQ, int algoMaxRep, in && this.algoMaxRep == algoMaxRep && this.algoHighThres == algoHighThres && this.algoLowThres == algoLowThres && sameCheck) return true; - if (DEBUG) appendToLog("algoMaxRep = " + algoMaxRep + ", algoMaxRep = " + algoMaxRep + ", algoLowThres = " + algoLowThres); + Logger.debug("algoMaxRep = {}, algoMaxRep = {}, algoLowThres = {}", algoMaxRep, algoMaxRep, algoLowThres); msgBuffer[4] |= (byte) (startQ & 0x0F); msgBuffer[4] |= (byte) ((algoMaxQ & 0x0F) << 4); msgBuffer[5] |= (byte) (algoMinQ & 0x0F); @@ -2641,7 +2678,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); + Logger.trace("this.algoStartQ is updated as {}", this.algoStartQ); this.algoMaxQ = algoMaxQ; this.algoMinQ = algoMinQ; this.algoMaxRep = algoMaxRep; @@ -2698,7 +2735,7 @@ boolean setAlgoAbFlip(int algoAbFlip, int algoRunTilZero) { algoAbFlip = mDefault.algoAbFlip; if (algoRunTilZero < ALGORUNTILZERO_MIN || algoRunTilZero > ALGORUNTILZERO_MAX) algoRunTilZero = mDefault.algoRunTilZero; - if (true) appendToLog("this.algoAbFlip = " + this.algoAbFlip + ", algoAbFlip = " + algoAbFlip + ", this.algoRunTilZero = " + this.algoRunTilZero + ", algoRunTilZero = " + algoRunTilZero); + Logger.trace("this.algoAbFlip = {}, algoAbFlip = {}, this.algoRunTilZero = {}, algoRunTilZero = {}", this.algoAbFlip, algoAbFlip, this.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) { @@ -2720,7 +2757,7 @@ public int getwideRSSI() { 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); + } else Logger.trace("Hello123: wideRSSI = {}", wideRSSI); return wideRSSI; } int getnarrowRSSI() { @@ -2729,7 +2766,7 @@ int getnarrowRSSI() { 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); + } else Logger.trace("Hello123: narrowRSSI = {}", wideRSSI); return wideRSSI; } public void resetRSSI() { @@ -2743,7 +2780,8 @@ public int getHighCompression() { int iRetValue = -1; if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { setPwrManagementMode(false); - rx000Setting.setMBPAddress(0x450); appendToLog("70010004: getHighCompression"); + rx000Setting.setMBPAddress(0x450); + Logger.trace("70010004: getHighCompression"); sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_MBPRDREG); } else iRetValue = (rxGain >> 8); return iRetValue; @@ -2752,7 +2790,8 @@ public int getRflnaGain() { int iRetValue = -1; if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { setPwrManagementMode(false); - rx000Setting.setMBPAddress(0x450); appendToLog("70010004: getRflnaGain"); + rx000Setting.setMBPAddress(0x450); + Logger.trace("70010004: getRflnaGain"); sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_MBPRDREG); } else iRetValue = ((rxGain & 0xC0) >> 6); return iRetValue; @@ -2761,7 +2800,8 @@ public int getIflnaGain() { int iRetValue = -1; if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { setPwrManagementMode(false); - rx000Setting.setMBPAddress(0x450); appendToLog("70010004: getIflnaGain"); + rx000Setting.setMBPAddress(0x450); + Logger.trace("70010004: getIflnaGain"); sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_MBPRDREG); } else iRetValue = ((rxGain & 0x38) >> 3); return iRetValue; @@ -2770,7 +2810,8 @@ public int getAgcGain() { int iRetValue = -1; if (rxGain < RXGAIN_MIN || rxGain > RXGAIN_MAX) { setPwrManagementMode(false); - rx000Setting.setMBPAddress(0x450); appendToLog("70010004: getAgcGain"); + rx000Setting.setMBPAddress(0x450); + Logger.trace("70010004: getAgcGain"); sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands.CMD_MBPRDREG); } else iRetValue = (rxGain & 0x07); return iRetValue; @@ -2827,7 +2868,7 @@ public String getSerialNumber() { } } if (invalid) return null; - appendToLog("retValue = " + byteArrayToString(serialNumber)); + Logger.trace("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; @@ -2835,7 +2876,7 @@ public String getSerialNumber() { else retValue[i] = serialNumber[j]; if (retValue[i] == 0) retValue[i] = 0x30; } - appendToLog("retValue = " + byteArrayToString(retValue) + ", String = " + new String(retValue)); + Logger.trace("retValue = {}, String = {}", byteArrayToString(retValue), new String(retValue)); return new String(retValue); } @@ -2854,7 +2895,7 @@ public String getProductSerialNumber() { } } if (invalid) return null; - appendToLog("retValue = " + byteArrayToString(productserialNumber)); + Logger.trace("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; @@ -2862,7 +2903,7 @@ public String getProductSerialNumber() { else retValue[i] = productserialNumber[j]; if (retValue[i] == 0) retValue[i] = 0x30; } - appendToLog("retValue = " + byteArrayToString(retValue) + ", String = " + new String(retValue)); + Logger.trace("retValue = {}, String = {}", byteArrayToString(retValue), new String(retValue)); return new String(retValue); } @@ -2936,8 +2977,7 @@ public double decodeNarrowBandRSSI(byte byteRSSI) { 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); + Logger.trace("byteRSSI = {}, mantissa = {}, exponent = {}, dValue = {}", String.format("%X", byteRSSI), mantissa, exponent, dValue); return dValue; } @@ -2945,11 +2985,11 @@ public int encodeNarrowBandRSSI(double dRSSI) { double dValue = dRSSI / 20; dValue = pow(10, dValue); int exponent = 0; - if (false) appendToLog("exponent = " + exponent + ", dValue = " + dValue); + Logger.trace("exponent = {}, dValue = {}", exponent, dValue); while ((dValue + 0.062) >= 2) { dValue /= 2; exponent++; - if (false) appendToLog("exponent = " + exponent + ", dValue = " + dValue); + Logger.trace("exponent = {}, dValue = {}", exponent, dValue); } dValue--; int mantissa = (int) ((dValue * 8) + 0.5); @@ -2958,8 +2998,7 @@ public int encodeNarrowBandRSSI(double dRSSI) { exponent++; } int iValue = ((exponent & 0x1F) << 3) | (mantissa & 0x7); - if (false) - appendToLog("dRssi = " + dRSSI + ", exponent = " + exponent + ", mantissa = " + mantissa + ", iValue = " + String.format("%X", iValue)); + Logger.trace("dRssi = {}, exponent = {}, mantissa = {}, iValue = {}", dRSSI, exponent, mantissa, String.format("%X", iValue)); return iValue; } @@ -2968,7 +3007,6 @@ public int encodeNarrowBandRSSI(double dRSSI) { public boolean bRx000ToReading = false; void uplinkHandler() { - boolean DEBUG = false; if (bRx000ToReading) return; bRx000ToReading = true; int startIndex = 0; @@ -2978,24 +3016,23 @@ void uplinkHandler() { int packageType = 0; long lTime = System.currentTimeMillis(); boolean bdebugging = false; - if (csReaderConnector.rfidConnector.mRfidToRead.size() != 0) { + if (!csReaderConnector.rfidConnector.mRfidToRead.isEmpty()) { bdebugging = true; - if (DEBUGTHREAD) appendToLog("mRx000UplinkHandler(): START"); - } else if (DEBUGTHREAD) appendToLog("mRx000UplinkHandler(): START AAA"); + Logger.debug("mRx000UplinkHandler(): START"); + } else Logger.debug("mRx000UplinkHandler(): START AAA"); 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()); + while (!csReaderConnector.rfidConnector.mRfidToRead.isEmpty()) { + if (bLooping == false) Logger.apData("ApData: Entering loop with mRfidToRead.size as {}", csReaderConnector.rfidConnector.mRfidToRead.size()); bLooping = true; - if (csReaderConnector.isBleConnected() == false) { + if (!csReaderConnector.isBleConnected()) { csReaderConnector.rfidConnector.mRfidToRead.clear(); } else if (System.currentTimeMillis() - lTime > (intervalRx000UplinkHandler / 2)) { writeDebug2File("Up4 " + String.valueOf(intervalRx000UplinkHandler) + "ms Timeout"); - if (utility.DEBUG_APDATA) - appendToLogView("ApData: TIMEOUT !!! mRfidToRead.size() = " + csReaderConnector.rfidConnector.mRfidToRead.size()); + Logger.toLogView("ApData: TIMEOUT !!! mRfidToRead.size() = {}", csReaderConnector.rfidConnector.mRfidToRead.size()).debug(); break; } else { if (bFirst) { @@ -3004,15 +3041,13 @@ void uplinkHandler() { 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 (utility.DEBUG_APDATA) - appendToLog("ApData: mRfidToReadingOffset=" + mRfidToReadingOffset + ", mRfidToReading.length=" + mRfidToReading.length + ", dataIn.length=" + dataIn.length + ", dataIn=" + byteArrayToString(dataIn)); + Logger.apData("ApData: mRfidToReadingOffset={}, mRfidToReading.length={}, dataIn.length={}, dataIn={}", mRfidToReadingOffset, mRfidToReading.length, dataIn.length, 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 (utility.DEBUG_APDATA) - appendToLogView("ApData: ERROR insufficient buffer, mRfidToReadingOffset=" + mRfidToReadingOffset + ", dataIn.length=" + dataIn.length + ", clear mRfidToReading: " + byteArrayToString(unhandledBytes)); + Logger.toLogView("ApData: ERROR insufficient buffer, mRfidToReadingOffset={}, dataIn.length={}, clear mRfidToReading: {}", mRfidToReadingOffset, dataIn.length, byteArrayToString(unhandledBytes)); byte[] mRfidToReadingNew = new byte[RFID_READING_BUFFERSIZE]; mRfidToReading = mRfidToReadingNew; mRfidToReadingOffset = 0; @@ -3022,8 +3057,7 @@ void uplinkHandler() { if (mRfidToReadingOffset != 0 && invalidSequence) { byte[] unhandledBytes = new byte[mRfidToReadingOffset]; System.arraycopy(mRfidToReading, 0, unhandledBytes, 0, unhandledBytes.length); - if (utility.DEBUG_APDATA) - appendToLog("ApData: ERROR invalidSequence with nonzero mRfidToReadingOffset=" + mRfidToReadingOffset + ", throw invalid unused data=" + unhandledBytes.length + ", " + byteArrayToString(unhandledBytes)); + Logger.apData("ApData: ERROR invalidSequence with nonzero mRfidToReadingOffset={}, throw invalid unused data={}, {}", mRfidToReadingOffset, unhandledBytes.length, byteArrayToString(unhandledBytes)); mRfidToReadingOffset = 0; startIndex = 0; startIndexNew = 0; @@ -3031,43 +3065,38 @@ void uplinkHandler() { } System.arraycopy(dataIn, 0, mRfidToReading, mRfidToReadingOffset, dataIn.length); mRfidToReadingOffset += dataIn.length; - if (utility.DEBUG_APDATA) { + if (Logger.LOG_APDATA) { byte[] bufferData = new byte[mRfidToReadingOffset]; System.arraycopy(mRfidToReading, 0, bufferData, 0, bufferData.length); - appendToLog("ApData: new mRfidToReadingOffset=" + mRfidToReadingOffset + ", mRfidToReading=" + byteArrayToString(bufferData)); + Logger.apData("ApData: new mRfidToReadingOffset={}, mRfidToReading={}", mRfidToReadingOffset, byteArrayToString(bufferData)); } 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); + if (!bLooping2) Logger.apData("ApData: Entering second loop with mRfidToReadingOffset = {}, startIndex = {}", mRfidToReadingOffset, startIndex); bLooping2 = true; { int packageLengthRead = (mRfidToReading[startIndex + 5] & 0xFF) * 256 + (mRfidToReading[startIndex + 4] & 0xFF); int expectedLength = 8 + packageLengthRead * 4; - if (mRfidToReading[startIndex + 0] == 0x04) + if (mRfidToReading[startIndex] == 0x04) expectedLength = 8 + packageLengthRead; - if (utility.DEBUG_APDATA) - appendToLog("ApData: loop: 1Byte=" + mRfidToReading[startIndex + 0] + ", mRfidToReadingOffset=" + mRfidToReadingOffset + ", expectedLength=" + expectedLength); + Logger.apData("ApData: loop: 1Byte={}, mRfidToReadingOffset={}, expectedLength={}", mRfidToReading[startIndex], mRfidToReadingOffset, expectedLength); if (mRfidToReadingOffset - startIndex >= 8) { - if (mRfidToReading[startIndex + 0] == (byte) 0x40 + if (mRfidToReading[startIndex] == (byte) 0x40 && (mRfidToReading[startIndex + 1] == 2 || mRfidToReading[startIndex + 1] == 3 || mRfidToReading[startIndex + 1] == 7)) { //input as Control Command Response dataIn = mRfidToReading; - if (DEBUG) appendToLog("decoding CONTROL data"); - if (csReaderConnector.rfidConnector.mRfidToWrite.size() == 0) { - if (DEBUG) - appendToLog("Control Response is received with null mRfidToWrite"); + Logger.debug("decoding CONTROL data"); + if (csReaderConnector.rfidConnector.mRfidToWrite.isEmpty()) { + Logger.debug("Control Response is received with null mRfidToWrite"); } else if (csReaderConnector.rfidConnector.mRfidToWrite.get(0) == null) { - if (DEBUG) - appendToLog("Control Response is received with null mRfidToWrite.get(0)"); + Logger.debug("Control Response is received with null mRfidToWrite.get(0)"); } else if (csReaderConnector.rfidConnector.mRfidToWrite.get(0).dataValues == null) { csReaderConnector.rfidConnector.mRfidToWrite.remove(0); - if (DEBUG) appendToLog("mmRfidToWrite remove 5"); - if (DEBUG) - appendToLog("Control Response is received with null mRfidToWrite.dataValues"); - } else if (!(csReaderConnector.rfidConnector.mRfidToWrite.get(0).dataValues[0] == dataIn[startIndex + 0] && csReaderConnector.rfidConnector.mRfidToWrite.get(0).dataValues[1] == dataIn[startIndex + 1])) { - if (DEBUG) - appendToLog("Control Response is received with Mis-matched mRfidToWrite, " + startIndex + ", " + byteArrayToString(dataIn)); + Logger.debug("mmRfidToWrite remove 5"); + Logger.debug("Control Response is received with null mRfidToWrite.dataValues"); + } else if (!(csReaderConnector.rfidConnector.mRfidToWrite.get(0).dataValues[0] == dataIn[startIndex] && csReaderConnector.rfidConnector.mRfidToWrite.get(0).dataValues[1] == dataIn[startIndex + 1])) { + Logger.debug("Control Response is received with Mis-matched mRfidToWrite, {}, {}", startIndex, byteArrayToString(dataIn)); } else { byte[] dataInCompare = null; switch (csReaderConnector.rfidConnector.mRfidToWrite.get(0).dataValues[1]) { @@ -3087,15 +3116,13 @@ void uplinkHandler() { byte[] dataIn8 = new byte[8]; System.arraycopy(dataIn, startIndex, dataIn8, 0, dataIn8.length); if (!(compareArray(dataInCompare, dataIn8, 8))) { - if (DEBUG) - appendToLog("Control response with invalid data: " + byteArrayToString(dataIn8)); + Logger.debug("Control response with invalid data: {}", byteArrayToString(dataIn8)); } else { csReaderConnector.rfidConnector.mRfidToWrite.remove(0); csReaderConnector.rfidConnector.sendRfidToWriteSent = 0; csReaderConnector.rfidConnector.mRfidToWriteRemoved = true; - if (DEBUG) appendToLog("mmRfidToWrite remove 6"); - if (DEBUG) - appendToLog("matched control command with mRfidToWrite.size=" + csReaderConnector.rfidConnector.mRfidToWrite.size()); + Logger.debug("mmRfidToWrite remove 6"); + Logger.debug("matched control command with mRfidToWrite.size={}", csReaderConnector.rfidConnector.mRfidToWrite.size()); } } if (true) { @@ -3107,39 +3134,36 @@ void uplinkHandler() { dataA.dataValues = dataIn8; dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_COMMAND_ABORT_RETURN; mRx000ToRead.add(dataA); - if (DEBUG) - appendToLog("Abort Return data is found wth type = " + dataA.responseType.toString()); + Logger.debug("Abort Return data is found wth type = {}", dataA.responseType); setInventoring(false); } } packageFound = true; packageType = 1; //0x40 startIndexNew = startIndex + iPayloadSizeMin; - } else if ((mRfidToReading[startIndex + 0] == (byte) 0x00 || mRfidToReading[startIndex + 0] == (byte) 0x70) + } else if ((mRfidToReading[startIndex] == (byte) 0x00 || mRfidToReading[startIndex] == (byte) 0x70) && mRfidToReading[startIndex + 1] == 0 - && csReaderConnector.rfidConnector.mRfidToWrite.size() != 0 + && !csReaderConnector.rfidConnector.mRfidToWrite.isEmpty() && csReaderConnector.rfidConnector.mRfidToWrite.get(0).dataValues != null && csReaderConnector.rfidConnector.mRfidToWrite.get(0).dataValues[0] == 0x70 && csReaderConnector.rfidConnector.mRfidToWrite.get(0).dataValues[1] == 0 ) { //if input as HOST_REG_RESP - if (DEBUG) - appendToLog("loop: decoding HOST_REG_RESP data with startIndex = " + startIndex + ", mRfidToReading=" + byteArrayToString(mRfidToReading)); + Logger.debug("loop: decoding HOST_REG_RESP data with startIndex = {}, mRfidToReading={}", startIndex, byteArrayToString(mRfidToReading)); dataIn = mRfidToReading; byte[] dataInPayload = new byte[4]; System.arraycopy(dataIn, startIndex + 4, dataInPayload, 0, dataInPayload.length); //if (mRfidDevice.mRfidToWrite.size() == 0) { - // if (true) appendToLog("mRx000UplinkHandler(): HOST_REG_RESP is received with null mRfidToWrite: " + byteArrayToString(dataInPayload)); + // Logger.trace("mRx000UplinkHandler(): HOST_REG_RESP is received with null mRfidToWrite: " + byteArrayToString(dataInPayload)); //} else if (mRfidDevice.mRfidToWrite.get(0).dataValues == null) { - // if (true) appendToLog("mRx000UplinkHandler(): NULL mRfidToWrite.get(0).dataValues"); //.length = " + mRfidDevice.mRfidToWrite.get(0).dataValues.length); + // Logger.trace("mRx000UplinkHandler(): NULL mRfidToWrite.get(0).dataValues"); //.length = " + mRfidDevice.mRfidToWrite.get(0).dataValues.length); //} else if (!(mRfidDevice.mRfidToWrite.get(0).dataValues[0] == 0x70 && mRfidDevice.mRfidToWrite.get(0).dataValues[1] == 0)) { - // if (true) appendToLog("mRx000UplinkHandler(): HOST_REG_RESP is received with invalid mRfidDevice.mRfidToWrite.get(0).dataValues=" + byteArrayToString(mRfidDevice.mRfidToWrite.get(0).dataValues)); + // Logger.trace("mRx000UplinkHandler(): HOST_REG_RESP is received with invalid mRfidDevice.mRfidToWrite.get(0).dataValues=" + byteArrayToString(mRfidDevice.mRfidToWrite.get(0).dataValues)); //} else { int addressToWrite = csReaderConnector.rfidConnector.mRfidToWrite.get(0).dataValues[2] + csReaderConnector.rfidConnector.mRfidToWrite.get(0).dataValues[3] * 256; int addressToRead = dataIn[startIndex + 2] + dataIn[startIndex + 3] * 256; if (addressToRead != addressToWrite) { - if (DEBUG) - appendToLog("mRx000UplinkHandler(): HOST_REG_RESP is received with misMatch address: addressToRead=" + addressToRead + ", " + startIndex + ", " + byteArrayToString(dataInPayload) + ", addressToWrite=" + addressToWrite); + Logger.debug("mRx000UplinkHandler(): HOST_REG_RESP is received with misMatch address: addressToRead={}, {}, {}, addressToWrite={}", addressToRead, startIndex, byteArrayToString(dataInPayload), addressToWrite); } else { switch (addressToRead) { case 0: @@ -3147,42 +3171,36 @@ void uplinkHandler() { int minorVersion = (dataIn[startIndex + 5] >> 4) + dataIn[startIndex + 6] * 256; int majorVersion = dataIn[startIndex + 7]; rx000Setting.macVer = String.valueOf(majorVersion) + "." + String.valueOf(minorVersion) + "." + String.valueOf(patchVersion); - if (DEBUG) - appendToLog("found MacVer =" + rx000Setting.macVer); + Logger.debug("found MacVer = {}", rx000Setting.macVer); break; case 9: rx000Setting.mac_last_command_duration = (dataIn[startIndex + 4] & 0xFF) + (dataIn[startIndex + 5] & 0xFF) * 256 + (dataIn[startIndex + 6] & 0xFF) * 256 * 256 + (dataIn[startIndex + 7] & 0xFF) * 256 * 256 * 256; - if (DEBUG) - appendToLog("found mac_last_command_duration =" + rx000Setting.mac_last_command_duration); + Logger.debug("found mac_last_command_duration = {}", rx000Setting.mac_last_command_duration); break; case 0x0201: rx000Setting.diagnosticCfg = (dataIn[startIndex + 4] & 0x0FF) + ((dataIn[startIndex + 5] & 0x03) * 256); - if (DEBUG) - appendToLog("found diagnostic configuration: " + byteArrayToString(dataInPayload) + ", diagnosticCfg=" + rx000Setting.diagnosticCfg); + Logger.debug("found diagnostic configuration: {}, diagnosticCfg={}", byteArrayToString(dataInPayload), rx000Setting.diagnosticCfg); break; case 0x0203: rx000Setting.impinjExtensionValue = (dataIn[startIndex + 4] & 0x03F); break; case 0x204: rx000Setting.pwrMgmtStatus = (dataIn[startIndex + 4] & 0x07); - if (DEBUG) - appendToLog("pwrMgmtStatus = " + rx000Setting.pwrMgmtStatus); + Logger.debug("pwrMgmtStatus = {}", rx000Setting.pwrMgmtStatus); break; case 0x0700: rx000Setting.antennaCycle = (dataIn[startIndex + 4] & 0xFF) + (dataIn[startIndex + 5] & 0xFF) * 256; rx000Setting.antennaFreqAgile = 0; if ((dataIn[startIndex + 7] & 0x01) != 0) rx000Setting.antennaFreqAgile = 1; - if (DEBUG) - appendToLog("found antenna cycle: " + byteArrayToString(dataInPayload) + ", cycle=" + rx000Setting.antennaCycle + ", frequencyAgile=" + rx000Setting.antennaFreqAgile); + Logger.debug("found antenna cycle: {}, cycle={}, frequencyAgile={}", byteArrayToString(dataInPayload), rx000Setting.antennaCycle, rx000Setting.antennaFreqAgile); break; case 0x0701: rx000Setting.antennaSelect = (dataIn[startIndex + 4] & 0xFF) + (dataIn[startIndex + 5] & 0xFF) * 256 + (dataIn[startIndex + 6] & 0xFF) * 256 * 256 + (dataIn[startIndex + 7] & 0xFF) * 256 * 256 * 256; - if (DEBUG) - appendToLog("found antenna select, select=" + rx000Setting.antennaSelect); + Logger.debug("found antenna select, select={}", rx000Setting.antennaSelect); break; case 0x0702: rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaEnable = (dataIn[startIndex + 4] & 0x01); @@ -3193,95 +3211,81 @@ void uplinkHandler() { rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaLocalProfile = ((dataIn[startIndex + 5] & 0x1E) >> 1); rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaFrequencyMode = ((dataIn[startIndex + 5] & 0x20) >> 5); rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaLocalFrequency = (dataIn[startIndex + 5] & 0x0F) * 4 + ((dataIn[startIndex + 5] & 0xC0) >> 6); - if (DEBUG) - appendToLog("found antenna selectEnable: " + byteArrayToString(dataInPayload) - + ", selectEnable=" + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaEnable - + ", inventoryMode=" + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaInventoryMode - + ", localAlgo=" + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaLocalAlgo - + ", localStartQ=" + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaLocalStartQ - + ", profileMode=" + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaProfileMode - + ", localProfile=" + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaLocalProfile - + ", frequencyMode=" + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaFrequencyMode - + ", localFrequency=" + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaLocalFrequency - ); + Logger.debug("found antenna selectEnable: {}, selectEnable={}, inventoryMode={}, localAlgo={}, localStartQ={}, profileMode={}, localProfile={}, frequencyMode={}, localFrequency={}", + byteArrayToString(dataInPayload), + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaEnable, + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaInventoryMode, + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaLocalAlgo, + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaLocalStartQ, + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaProfileMode, + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaLocalProfile, + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaFrequencyMode, + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaLocalFrequency + ); break; case 0x0703: rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaStatus = (dataIn[startIndex + 4] & 0xFF) + (dataIn[startIndex + 5] & 0xFF) * 256 + (dataIn[startIndex + 6] & 0x0F) * 256 * 256; - if (DEBUG) - appendToLog("found antenna status: " + byteArrayToString(dataInPayload) + ", status=" + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaStatus); + Logger.debug("found antenna status: {}, status={}", byteArrayToString(dataInPayload), rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaStatus); break; case 0x0704: rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaDefine = (dataIn[startIndex + 4] & 0x3); // mRx000Setting.antennaSelectedData[mRx000Setting.antennaSelect].antennaRxDefine = (dataIn[startIndex + 6] & 0x3); - if (DEBUG) - appendToLog("found antenna define: " + byteArrayToString(dataInPayload) - + ", define=" + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaDefine - // + ", RxDefine=" + mRx000Setting.antennaSelectedData[mRx000Setting.antennaSelect].antennaRxDefine - ); + Logger.debug("found antenna define: {}, define={}", byteArrayToString(dataInPayload), rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaDefine); break; case 0x0705: rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaDwell = (dataIn[startIndex + 4] & 0xFF) + (dataIn[startIndex + 5] & 0xFF) * 256 + (dataIn[startIndex + 6] & 0xFF) * 256 * 256 + (dataIn[startIndex + 7] & 0xFF) * 256 * 256 * 256; - if (DEBUG) - appendToLog("found antenna dwell=" + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaDwell); + Logger.debug("found antenna dwell={}", rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaDwell); break; case 0x0706: - if (rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaPowerSet == false) + if (!rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaPowerSet) rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaPower = (dataIn[startIndex + 4] & 0xFF) + (dataIn[startIndex + 5] & 0xFF) * 256 + (dataIn[startIndex + 6] & 0xFF) * 256 * 256 + (dataIn[startIndex + 7] & 0xFF) * 256 * 256 * 256; break; case 0x0707: rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaInvCount = (dataIn[startIndex + 4] & 0xFF) + (dataIn[startIndex + 5] & 0xFF) * 256 + (dataIn[startIndex + 6] & 0xFF) * 256 * 256 + (dataIn[startIndex + 7] & 0xFF) * 256 * 256 * 256; - if (DEBUG) - appendToLog("found antenna InvCount=" + rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaInvCount); + Logger.debug("found antenna InvCount={}", rx000Setting.antennaSelectedData[rx000Setting.antennaSelect].antennaInvCount); break; case 0x0800: rx000Setting.invSelectIndex = (dataIn[startIndex + 4] & 0xFF) + (dataIn[startIndex + 5] & 0xFF) * 256 + (dataIn[startIndex + 6] & 0xFF) * 256 * 256 + (dataIn[startIndex + 7] & 0xFF) * 256 * 256 * 256; - if (DEBUG) - appendToLog("found inventory select: " + byteArrayToString(dataInPayload) + ", select=" + rx000Setting.invSelectIndex); + Logger.debug("found inventory select: {}, select={}", byteArrayToString(dataInPayload), rx000Setting.invSelectIndex); break; case 0x0801: { int dataIndex = rx000Setting.invSelectIndex; if (dataIndex < rx000Setting.INVSELECT_MIN || dataIndex > rx000Setting.INVSELECT_MAX) { - if (DEBUG) - appendToLog("found inventory select configuration: " + byteArrayToString(dataInPayload) + ", but invalid index=" + dataIndex); + Logger.debug("found inventory select configuration: {}, but invalid index={}", byteArrayToString(dataInPayload), dataIndex); } else { - appendToLog("BtDataOut 123A"); + Logger.trace("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); rx000Setting.invSelectData[dataIndex].selectDelay = dataIn[startIndex + 5]; - if (DEBUG) - appendToLog("found inventory select configuration: " + byteArrayToString(dataInPayload) - + ", selectEnable=" + rx000Setting.invSelectData[dataIndex].selectEnable - + ", selectTarget=" + rx000Setting.invSelectData[dataIndex].selectTarget - + ", selectAction=" + rx000Setting.invSelectData[dataIndex].selectAction - + ", selectDelay=" + rx000Setting.invSelectData[dataIndex].selectDelay - ); + Logger.debug("found inventory select configuration: {}, selectEnable={}, selectTarget={}, selectAction={}, selectDelay={}", + byteArrayToString(dataInPayload), + rx000Setting.invSelectData[dataIndex].selectEnable, + rx000Setting.invSelectData[dataIndex].selectTarget, + rx000Setting.invSelectData[dataIndex].selectAction, + rx000Setting.invSelectData[dataIndex].selectDelay + ); } break; } case 0x0802: { int dataIndex = rx000Setting.invSelectIndex; if (dataIndex < rx000Setting.INVSELECT_MIN || dataIndex > rx000Setting.INVSELECT_MAX) { - if (DEBUG) - appendToLog("found inventory select mask bank: " + byteArrayToString(dataInPayload) + ", but invalid index=" + dataIndex); + Logger.debug("found inventory select mask bank: {}, but invalid index={}", byteArrayToString(dataInPayload), dataIndex); } else { rx000Setting.invSelectData[dataIndex].selectMaskBank = (dataIn[startIndex + 4] & 0x03); - if (DEBUG) - appendToLog("found inventory select mask bank: " + byteArrayToString(dataInPayload) - + ", selectMaskBank=" + rx000Setting.invSelectData[dataIndex].selectMaskBank - ); + Logger.debug("found inventory select mask bank: {}, selectMaskBank={}", + byteArrayToString(dataInPayload), rx000Setting.invSelectData[dataIndex].selectMaskBank); } break; } case 0x0803: { int dataIndex = rx000Setting.invSelectIndex; if (dataIndex < rx000Setting.INVSELECT_MIN || dataIndex > rx000Setting.INVSELECT_MAX) { - if (DEBUG) - appendToLog("found inventory select mask offset: " + byteArrayToString(dataInPayload) + ", but invalid index=" + dataIndex); + Logger.debug("found inventory select mask offset: {}, but invalid index={}", byteArrayToString(dataInPayload), dataIndex); } else { rx000Setting.invSelectData[dataIndex].selectMaskOffset = (dataIn[startIndex + 4] & 0x0FF) + (dataIn[startIndex + 5] & 0x0FF) * 256 + (dataIn[startIndex + 6] & 0x0FF) * 256 * 256 + (dataIn[startIndex + 7] & 0x0FF) * 256 * 256 * 256; - if (DEBUG) - appendToLog("found inventory select mask offset: " + byteArrayToString(dataInPayload) + Logger.debug("found inventory select mask offset: " + byteArrayToString(dataInPayload) + ", selectMaskOffset=" + rx000Setting.invSelectData[dataIndex].selectMaskOffset ); } @@ -3290,16 +3294,12 @@ void uplinkHandler() { case 0x0804: { int dataIndex = rx000Setting.invSelectIndex; if (dataIndex < rx000Setting.INVSELECT_MIN || dataIndex > rx000Setting.INVSELECT_MAX) { - if (DEBUG) - appendToLog("found inventory select mask length: " + byteArrayToString(dataInPayload) + ", but invalid index=" + dataIndex); + Logger.debug("found inventory select mask length: {}, but invalid index={}", byteArrayToString(dataInPayload), dataIndex); } else { rx000Setting.invSelectData[dataIndex].selectMaskLength = (dataIn[startIndex + 4] & 0x0FF); - if (DEBUG) - appendToLog("getSelectMaskData with read selectMaskLength = " + rx000Setting.invSelectData[dataIndex].selectMaskLength); - if (DEBUG) - appendToLog("found inventory select mask length: " + byteArrayToString(dataInPayload) - + ", selectMaskLength=" + rx000Setting.invSelectData[dataIndex].selectMaskLength - ); + Logger.debug("getSelectMaskData with read selectMaskLength = {}", rx000Setting.invSelectData[dataIndex].selectMaskLength); + Logger.debug("found inventory select mask length: {}, selectMaskLength={}", + byteArrayToString(dataInPayload), rx000Setting.invSelectData[dataIndex].selectMaskLength); } break; } @@ -3313,18 +3313,14 @@ void uplinkHandler() { case 0x080C: { int dataIndex = rx000Setting.invSelectIndex; if (dataIndex < rx000Setting.INVSELECT_MIN || dataIndex > rx000Setting.INVSELECT_MAX) { - if (DEBUG) - appendToLog("found inventory select mask 0-3: " + byteArrayToString(dataInPayload) + ", but invalid index=" + dataIndex); + Logger.debug("found inventory select mask 0-3: {}, but invalid index={}", byteArrayToString(dataInPayload), dataIndex); } else { int maskDataIndex = addressToRead - 0x0805; - if (DEBUG) - appendToLog("Old selectMaskData0_31 = " + byteArrayToString(rx000Setting.invSelectData[dataIndex].selectMaskData0_31)); + Logger.debug("Old selectMaskData0_31 = {}", byteArrayToString(rx000Setting.invSelectData[dataIndex].selectMaskData0_31)); System.arraycopy(dataIn, startIndex + 4, rx000Setting.invSelectData[dataIndex].selectMaskData0_31, maskDataIndex * 4, 4); - if (DEBUG) - appendToLog("Old selectMaskData0_31 = " + byteArrayToString(rx000Setting.invSelectData[dataIndex].selectMaskData0_31)); + Logger.debug("Old selectMaskData0_31 = {}", byteArrayToString(rx000Setting.invSelectData[dataIndex].selectMaskData0_31)); rx000Setting.invSelectData[dataIndex].selectMaskDataReady |= (0x01 << maskDataIndex); - if (DEBUG) - appendToLog("found inventory select mask 0-3: " + byteArrayToString(dataInPayload)); + Logger.debug("found inventory select mask 0-3: {}", byteArrayToString(dataInPayload)); } break; } @@ -3333,7 +3329,7 @@ void uplinkHandler() { 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); - //appendToLog("BtDataOut: found query configuration: " + byteArrayToString(dataInPayload) + ", target=" + rx000Setting.queryTarget + ", session=" + rx000Setting.querySession + ", select=" + rx000Setting.querySelect); + //Logger.debug("BtDataOut: found query configuration: " + byteArrayToString(dataInPayload) + ", target=" + rx000Setting.queryTarget + ", session=" + rx000Setting.querySession + ", select=" + rx000Setting.querySelect); break; case 0x0901: rx000Setting.invAlgo = dataIn[startIndex + 4] & 0x3F; @@ -3343,24 +3339,21 @@ void uplinkHandler() { rx000Setting.tagRead = dataIn[startIndex + 6] & 0x03; rx000Setting.tagDelay = ((dataIn[startIndex + 7] & 0x03) * 16 + ((dataIn[startIndex + 6] & 0xF0) >> 4)); rx000Setting.invModeCompact = (dataIn[startIndex + 7] & 0x04); - if (DEBUG) - appendToLog("found inventory configuration: " + byteArrayToString(dataInPayload) + ", algorithm=" + rx000Setting.invAlgo + ", matchRep=" + rx000Setting.matchRep + ", tagSelect=" + rx000Setting.tagSelect + ", noInventory=" + rx000Setting.noInventory + ", tagRead=" + rx000Setting.tagRead + ", tagDelay=" + rx000Setting.tagDelay); + Logger.debug("found inventory configuration: {}, algorithm={}, matchRep={}, tagSelect={}, noInventory={}, tagRead={}, tagDelay={}", + byteArrayToString(dataInPayload), rx000Setting.invAlgo,+ rx000Setting.matchRep, rx000Setting.tagSelect, rx000Setting.noInventory, rx000Setting.tagRead, rx000Setting.tagDelay); break; case 0x0902: if (dataIn[startIndex + 6] != 0 || dataIn[startIndex + 7] != 0) { - if (DEBUG) - appendToLog("found inventory select, but too big: " + byteArrayToString(dataInPayload)); + Logger.debug("found inventory select, but too big: {}", byteArrayToString(dataInPayload)); } else { rx000Setting.algoSelect = (dataIn[startIndex + 4] & 0xFF) + (dataIn[startIndex + 5] & 0xFF) * 256; - if (DEBUG) - appendToLog("found inventory algorithm select=" + rx000Setting.algoSelect); + Logger.debug("found inventory algorithm select= {}", rx000Setting.algoSelect); } break; case 0x0903: { int dataIndex = rx000Setting.algoSelect; if (dataIndex < rx000Setting.ALGOSELECT_MIN || dataIndex > rx000Setting.ALGOSELECT_MAX) { - if (DEBUG) - appendToLog("found inventory algo parameter 0: " + byteArrayToString(dataInPayload) + ", but invalid index=" + dataIndex); + Logger.debug("found inventory algo parameter 0: {}, but invalid index={}", byteArrayToString(dataInPayload), dataIndex); } else { rx000Setting.algoSelectedData[dataIndex].algoStartQ = (dataIn[startIndex + 4] & 0x0F); rx000Setting.algoSelectedData[dataIndex].algoMaxQ = ((dataIn[startIndex + 4] & 0xF0) >> 4); @@ -3368,42 +3361,37 @@ void uplinkHandler() { 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 || 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 - + ", algoMaxRep=" + rx000Setting.algoSelectedData[dataIndex].algoMaxRep - + ", algoHighThres=" + rx000Setting.algoSelectedData[dataIndex].algoHighThres - + ", algoLowThres=" + rx000Setting.algoSelectedData[dataIndex].algoLowThres - ); + Logger.debug("BtDataOut: found inventory algo parameter 0: {}, algoStartQ={}, algoMaxQ={}, algoMinQ={}, algoMaxRep={}, algoHighThres={}, algoLowThres={}", + byteArrayToString(dataInPayload), + rx000Setting.algoSelectedData[dataIndex].algoStartQ, + rx000Setting.algoSelectedData[dataIndex].algoMaxQ, + rx000Setting.algoSelectedData[dataIndex].algoMinQ, + rx000Setting.algoSelectedData[dataIndex].algoMaxRep, + rx000Setting.algoSelectedData[dataIndex].algoHighThres, + rx000Setting.algoSelectedData[dataIndex].algoLowThres + ); } break; } case 0x0904: { int dataIndex = rx000Setting.algoSelect; if (dataIndex < rx000Setting.ALGOSELECT_MIN || dataIndex > rx000Setting.ALGOSELECT_MAX) { - if (DEBUG) - appendToLog("found inventory algo parameter 1: " + byteArrayToString(dataInPayload) + ", but invalid index=" + dataIndex); + Logger.debug("found inventory algo parameter 1: {}, but invalid index={}", byteArrayToString(dataInPayload), dataIndex); } else { rx000Setting.algoSelectedData[dataIndex].algoRetry = dataIn[startIndex + 4] & 0x0FF; - if (DEBUG) - appendToLog("found inventory algo parameter 1: " + byteArrayToString(dataInPayload) + ", algoRetry=" + rx000Setting.algoSelectedData[dataIndex].algoRetry); + Logger.debug("found inventory algo parameter 1: {}, algoRetry={}", byteArrayToString(dataInPayload), rx000Setting.algoSelectedData[dataIndex].algoRetry); } break; } case 0x0905: { int dataIndex = rx000Setting.algoSelect; if (dataIndex < rx000Setting.ALGOSELECT_MIN || dataIndex > rx000Setting.ALGOSELECT_MAX) { - if (DEBUG) - appendToLog("found inventory algo parameter 2: " + byteArrayToString(dataInPayload) + ", but invalid index=" + dataIndex); + Logger.debug("found inventory algo parameter 2: {}, but invalid index={}", byteArrayToString(dataInPayload), dataIndex); } else { - if (DEBUG) - appendToLog("found inventory algo parameter 2: " + byteArrayToString(dataInPayload) + ", dataIndex=" + dataIndex + ", algoAbFlip=" + rx000Setting.algoSelectedData[dataIndex].algoAbFlip + ", algoRunTilZero=" + rx000Setting.algoSelectedData[dataIndex].algoRunTilZero); + Logger.debug("found inventory algo parameter 2: {}, dataIndex={}, algoAbFlip={}, algoRunTilZero={}", byteArrayToString(dataInPayload), dataIndex, rx000Setting.algoSelectedData[dataIndex].algoAbFlip, rx000Setting.algoSelectedData[dataIndex].algoRunTilZero); rx000Setting.algoSelectedData[dataIndex].algoAbFlip = dataIn[startIndex + 4] & 0x01; rx000Setting.algoSelectedData[dataIndex].algoRunTilZero = (dataIn[startIndex + 4] & 0x02) >> 1; - if (DEBUG) - appendToLog("found inventory algo parameter 2: " + byteArrayToString(dataInPayload) + ", algoAbFlip=" + rx000Setting.algoSelectedData[dataIndex].algoAbFlip + ", algoRunTilZero=" + rx000Setting.algoSelectedData[dataIndex].algoRunTilZero); + Logger.debug("found inventory algo parameter 2: {}, algoAbFlip={}, algoRunTilZero={}", byteArrayToString(dataInPayload), rx000Setting.algoSelectedData[dataIndex].algoAbFlip, rx000Setting.algoSelectedData[dataIndex].algoRunTilZero); } break; } @@ -3428,8 +3416,7 @@ void uplinkHandler() { rx000Setting.matchType = ((dataIn[startIndex + 4] & 0x02) >> 1); rx000Setting.matchLength = ((dataIn[startIndex + 4] & 0x0FF) >> 2) + (dataIn[startIndex + 5] & 0x07) * 64; rx000Setting.matchOffset = ((dataIn[startIndex + 5] & 0x0FF) >> 3) + (dataIn[startIndex + 6] & 0x1F) * 32; - if (DEBUG) - appendToLog("found inventory match configuration: " + byteArrayToString(dataInPayload) + ", selectEnable=" + rx000Setting.matchEnable + ", matchType=" + rx000Setting.matchType + ", matchLength=" + rx000Setting.matchLength + ", matchOffset=" + rx000Setting.matchOffset); + Logger.debug("found inventory match configuration: {}, selectEnable={}, matchType={}, matchLength={}, matchOffset={}", byteArrayToString(dataInPayload), rx000Setting.matchEnable, rx000Setting.matchType, rx000Setting.matchLength, rx000Setting.matchOffset); break; case 0x0912: case 0x0913: @@ -3450,20 +3437,17 @@ void uplinkHandler() { int maskDataIndex = addressToRead - 0x0912; System.arraycopy(dataIn, startIndex + 4, rx000Setting.invMatchData0_63, maskDataIndex * 4, 4); rx000Setting.invMatchDataReady |= (0x01 << maskDataIndex); - if (DEBUG) - appendToLog("found inventory match Data 0-3: " + byteArrayToString(dataInPayload)); + Logger.debug("found inventory match Data 0-3: {}", byteArrayToString(dataInPayload)); break; } case 0x0A01: rx000Setting.accessRetry = (dataIn[startIndex + 4] & 0x0E) >> 1; - if (DEBUG) - appendToLog("found access algoRetry: " + byteArrayToString(dataInPayload) + ", accessRetry=" + rx000Setting.accessRetry); + Logger.debug("found access algoRetry: {}, accessRetry={}", byteArrayToString(dataInPayload), rx000Setting.accessRetry); break; case 0x0A02: rx000Setting.accessBank = (dataIn[startIndex + 4] & 0x03); rx000Setting.accessBank2 = ((dataIn[startIndex + 4] >> 2) & 0x03); - if (DEBUG) - appendToLog("found access bank: " + byteArrayToString(dataInPayload) + ", accessBank=" + rx000Setting.accessBank + ", accessBank2=" + rx000Setting.accessBank2); + Logger.debug("found access bank: {}, accessBank={}, accessBank2={}", byteArrayToString(dataInPayload), rx000Setting.accessBank, rx000Setting.accessBank2); break; case 0x0A03: if (rx000Setting.tagRead != 0) { @@ -3472,25 +3456,21 @@ void uplinkHandler() { } else { rx000Setting.accessOffset = (dataIn[startIndex + 4] & 0x0FF) + (dataIn[startIndex + 5] & 0x0FF) * 256 + (dataIn[startIndex + 6] & 0x0FF) * 256 * 256 + (dataIn[startIndex + 7] & 0x0FF) * 256 * 256 * 256; } - if (DEBUG) - appendToLog("found access offset: " + byteArrayToString(dataInPayload) + ", accessOffset=" + rx000Setting.accessOffset + ", accessOffset2=" + rx000Setting.accessOffset2); + Logger.debug("found access offset: {}, accessOffset={}, accessOffset2={}", byteArrayToString(dataInPayload), rx000Setting.accessOffset, rx000Setting.accessOffset2); break; case 0x0A04: rx000Setting.accessCount = (dataIn[startIndex + 4] & 0x0FF); rx000Setting.accessCount2 = (dataIn[startIndex + 5] & 0x0FF); - if (DEBUG) - appendToLog("found access count: " + byteArrayToString(dataInPayload) + ", accessCount=" + rx000Setting.accessCount + ", accessCount2=" + rx000Setting.accessCount2); + Logger.debug("found access count: {}, accessCount={}, accessCount2={}", byteArrayToString(dataInPayload), rx000Setting.accessCount, rx000Setting.accessCount2); break; case 0x0A05: rx000Setting.accessLockAction = (dataIn[startIndex + 4] & 0x0FF) + ((dataIn[startIndex + 5] & 0x03) * 256); rx000Setting.accessLockMask = ((dataIn[startIndex + 5] & 0x0FF) >> 2) + ((dataIn[startIndex + 6] & 0x0F) * 64); - if (DEBUG) - appendToLog("found access lock configuration: " + byteArrayToString(dataInPayload) + ", accessLockAction=" + rx000Setting.accessLockAction + ", accessLockMask=" + rx000Setting.accessLockMask); + Logger.debug("found access lock configuration: {}, accessLockAction={}, accessLockMask={}", byteArrayToString(dataInPayload), rx000Setting.accessLockAction, rx000Setting.accessLockMask); break; case 0x0A08: rx000Setting.accessWriteDataSelect = (dataIn[startIndex + 4] & 0x07); - if (DEBUG) - appendToLog("found write data select: " + byteArrayToString(dataInPayload) + ", accessWriteDataSelect=" + rx000Setting.accessWriteDataSelect); + Logger.debug("found write data select: {}, accessWriteDataSelect={}", byteArrayToString(dataInPayload), rx000Setting.accessWriteDataSelect); break; case 0x0A09: case 0x0A0A: @@ -3516,33 +3496,27 @@ void uplinkHandler() { rx000Setting.accWriteData0_63[(maskDataIndexH + maskDataIndex) * 4 + k] = dataIn[startIndex + 7 - k]; } rx000Setting.accWriteDataReady |= (0x01 << (maskDataIndexH + maskDataIndex)); - if (DEBUG) - appendToLog("accessWriteData=" + rx000Setting.accWriteData0_63); - if (DEBUG) - appendToLog("found access write data 0-3: " + byteArrayToString(dataInPayload)); + Logger.debug("accessWriteData={}", rx000Setting.accWriteData0_63); + Logger.debug("found access write data 0-3: {}", byteArrayToString(dataInPayload)); break; } case 0x0b60: rx000Setting.currentProfile = dataIn[startIndex + 4]; - if (DEBUG) - appendToLog("found current profile: " + byteArrayToString(dataInPayload) + ", profile=" + rx000Setting.currentProfile); + Logger.debug("found current profile: {}, profile={}", byteArrayToString(dataInPayload), rx000Setting.currentProfile); break; case 0x0c01: rx000Setting.freqChannelSelect = dataIn[startIndex + 4]; - if (DEBUG) - appendToLog("setFreqChannelSelect: found frequency channel select: " + byteArrayToString(dataInPayload) + ", freqChannelSelect=" + rx000Setting.freqChannelSelect); + Logger.debug("setFreqChannelSelect: found frequency channel select: {}, freqChannelSelect={}", byteArrayToString(dataInPayload), rx000Setting.freqChannelSelect); break; case 0x0c02: rx000Setting.freqChannelConfig = dataIn[startIndex + 4] & 0x01; - if (DEBUG) - appendToLog("found frequency channel configuration: " + byteArrayToString(dataInPayload) + ", channelConfig=" + rx000Setting.freqChannelConfig); + Logger.debug("found frequency channel configuration: {}, channelConfig={}", byteArrayToString(dataInPayload), rx000Setting.freqChannelConfig); break; case 0x0f00: - rx000Setting.authenticateSendReply = ((dataIn[startIndex + 4] & 1) != 0) ? true : false; - rx000Setting.authenticateIncReplyLength = ((dataIn[startIndex + 4] & 2) != 0) ? true : false; + rx000Setting.authenticateSendReply = (dataIn[startIndex + 4] & 1) != 0; + rx000Setting.authenticateIncReplyLength = (dataIn[startIndex + 4] & 2) != 0; rx000Setting.authenticateLength = ((dataIn[startIndex + 5] & 0xFC) >> 3) + (dataIn[startIndex + 6] & 0x3F); - if (DEBUG) - appendToLog("found authenticate configuration: " + byteArrayToString(dataInPayload)); + Logger.debug("found authenticate configuration: {}", byteArrayToString(dataInPayload)); break; case 0x0f01: case 0x0f02: @@ -3551,30 +3525,27 @@ void uplinkHandler() { int maskDataIndex = addressToRead - 0x0f01; System.arraycopy(dataIn, startIndex + 4, rx000Setting.authMatchData0_63, maskDataIndex * 4, 4); //mRx000Setting.authMatchDataReady |= (0x01 << maskDataIndex); - if (DEBUG) - appendToLog("found authenticate match Data 0-3: " + byteArrayToString(dataInPayload)); + Logger.debug("found authenticate match Data 0-3: {}", byteArrayToString(dataInPayload)); break; } case 0x0f05: rx000Setting.untraceableRange = dataIn[startIndex + 4] & 0x03; - rx000Setting.untraceableUser = ((dataIn[startIndex + 4] & 0x04) != 0) ? true : false; + rx000Setting.untraceableUser = (dataIn[startIndex + 4] & 0x04) != 0; rx000Setting.untraceableTid = ((dataIn[startIndex + 4] & 0x18) >> 3); rx000Setting.untraceableEpcLength = ((dataIn[startIndex + 4] & 0xE0) >> 5) + ((dataIn[startIndex + 5] & 0x3) << 3); - rx000Setting.untraceableEpc = ((dataIn[startIndex + 5] & 4) != 0) ? true : false; - rx000Setting.untraceableUXpc = ((dataIn[startIndex + 5] & 8) != 0) ? true : false; - if (DEBUG) - appendToLog("found untraceable configuration: " + byteArrayToString(dataInPayload)); + rx000Setting.untraceableEpc = (dataIn[startIndex + 5] & 4) != 0; + rx000Setting.untraceableUXpc = (dataIn[startIndex + 5] & 8) != 0; + Logger.debug("found untraceable configuration: {}", byteArrayToString(dataInPayload)); break; default: - if (DEBUG) - appendToLog("found OTHERS with addressToWrite=" + addressToWrite + ", addressToRead=" + addressToRead + ", " + byteArrayToString(dataInPayload)); + Logger.debug("found OTHERS with addressToWrite={}, addressToRead={}, {}", addressToWrite, addressToRead, byteArrayToString(dataInPayload)); break; } rfidDataReadTypes = RfidDataReadTypes.RFID_DATA_READ_REGREAD; csReaderConnector.rfidConnector.mRfidToWrite.remove(0); csReaderConnector.rfidConnector.sendRfidToWriteSent = 0; csReaderConnector.rfidConnector.mRfidToWriteRemoved = true; - if (DEBUG) appendToLog("mmRfidToWrite remove 7"); + Logger.debug("mmRfidToWrite remove 7"); } } packageFound = true; @@ -3587,14 +3558,14 @@ void uplinkHandler() { // && mRfidToReading[startIndex + 6] == 0 //for packageTypeRead = 0x3007, this byte is 0x20. Others are 0 && mRfidToReading[startIndex + 7] == 0) { //if input as command response { - if (DEBUG) appendToLog("loop: decoding 1_4 data"); + Logger.debug("loop: decoding 1_4 data"); if (mRfidToReadingOffset - startIndex < expectedLength) break; dataIn = mRfidToReading; byte[] dataInPayload = new byte[expectedLength - 4]; System.arraycopy(dataIn, startIndex + 4, dataInPayload, 0, dataInPayload.length); //if ((dataIn[startIndex + 3] == (byte) 0x80 && dataIn[startIndex + 6] == 0 && dataIn[startIndex + 7] == 0) == false) { - // appendToLog("mRx000UplinkHandler(): invalid command response is received with incorrect byte3= " + dataIn[startIndex + 3] + ", byte6=" + dataIn[startIndex + 6] + ", byte7=" + dataIn[startIndex + 7]); + // Logger.debug("mRx000UplinkHandler(): invalid command response is received with incorrect byte3= " + dataIn[startIndex + 3] + ", byte6=" + dataIn[startIndex + 6] + ", byte7=" + dataIn[startIndex + 7]); //} int packageTypeRead = dataIn[startIndex + 2] + (dataIn[startIndex + 3] & 0xFF) * 256; @@ -3622,17 +3593,14 @@ void uplinkHandler() { case 0x0000: case 0x8000: //RFID_PACKET_TYPE_COMMAND_BEGIN //original 0 if (dataIn[startIndex + 0] != 1 && dataIn[startIndex + 0] != 2) { - if (DEBUG) - appendToLog("command COMMAND_BEGIN is found without first byte as 0x01 or 0x02, " + byteArrayToString(dataInPayload)); - } else if (csReaderConnector.rfidConnector.mRfidToWrite.size() == 0) { - if (DEBUG) - appendToLog("command COMMAND_BEGIN is found without mRfidToWrite"); + Logger.debug("command COMMAND_BEGIN is found without first byte as 0x01 or 0x02, {}", byteArrayToString(dataInPayload)); + } else if (csReaderConnector.rfidConnector.mRfidToWrite.isEmpty()) { + Logger.debug("command COMMAND_BEGIN is found without mRfidToWrite"); } else { byte[] dataWritten = csReaderConnector.rfidConnector.mRfidToWrite.get(0).dataValues; if (dataWritten == null) { } else if (!(dataWritten[0] == (byte) 0x70 && dataWritten[1] == 1 && dataWritten[2] == 0 && dataWritten[3] == (byte) 0xF0)) { - if (DEBUG) - appendToLog("command COMMAND_BEGIN is found with invalid mRfidToWrite: " + byteArrayToString(dataWritten)); + Logger.debug("command COMMAND_BEGIN is found with invalid mRfidToWrite: {}", byteArrayToString(dataWritten)); } else { boolean matched = true; for (int i = 0; i < 4; i++) { @@ -3648,14 +3616,12 @@ void uplinkHandler() { multipler *= 256; } if (matched == false) { - if (DEBUG) - appendToLog("command COMMAND_BEGIN is found with mis-matched command:" + byteArrayToString(dataWritten)); + Logger.debug("command COMMAND_BEGIN is found with mis-matched command: {}", byteArrayToString(dataWritten)); } else { csReaderConnector.rfidConnector.mRfidToWrite.remove(0); csReaderConnector.rfidConnector.sendRfidToWriteSent = 0; csReaderConnector.rfidConnector.mRfidToWriteRemoved = true; - if (DEBUG) - appendToLog("mmRfidToWrite remove 8"); + Logger.debug("mmRfidToWrite remove 8"); setInventoring(true); Date date = new Date(); long date_time = date.getTime(); @@ -3668,13 +3634,11 @@ void uplinkHandler() { } if (lValue < expected_firmware_ontime_ms) { csReaderConnector.rfidReader.bFirmware_reset_before = true; - if (DEBUG) - appendToLogView("command COMMAND_BEGIN --- Firmware reset before !!!"); + Logger.toLogView("command COMMAND_BEGIN --- Firmware reset before !!!").debug(); } firmware_ontime_ms = lValue; date_time_ms = date_time; - if (DEBUG) - appendToLog("command COMMAND_BEGIN is found with packageLength=" + packageLengthRead + ", with firmware count=" + lValue + ", date_time=" + date_time + ", expected firmware count=" + expected_firmware_ontime_ms); + Logger.debug("command COMMAND_BEGIN is found with packageLength={}, with firmware count={}, date_time={}, expected firmware count={}", packageLengthRead, lValue, date_time, expected_firmware_ontime_ms); rfidDataReadTypes = RfidDataReadTypes.RFID_DATA_READ_COMMAND_BEGIN; } } @@ -3683,35 +3647,30 @@ void uplinkHandler() { case 0x0001: case 0x8001: //RFID_PACKET_TYPE_COMMAND_END //original 1 if (dataIn[startIndex + 0] != 1 && dataIn[startIndex + 0] != 2) { - if (DEBUG) - appendToLog("command COMMAND_END is found without first byte as 0x01 or 0x02, " + byteArrayToString(dataInPayload)); + Logger.debug("command COMMAND_END is found without first byte as 0x01 or 0x02, {}", byteArrayToString(dataInPayload)); break; } else { dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_COMMAND_END; setInventoring(false); - if (DEBUG) - appendToLog("command COMMAND_END is found with packageLength=" + packageLengthRead + ", length = " + dataA.dataValues.length + ", dataValues=" + byteArrayToString(dataA.dataValues)); + Logger.debug("command COMMAND_END is found with packageLength={}, length = {}, dataValues={}", packageLengthRead, dataA.dataValues.length, byteArrayToString(dataA.dataValues)); if (dataA.dataValues.length >= 8) { int status = dataA.dataValues[12 - 8] + dataA.dataValues[13 - 8] * 256; if (status != 0) dataA.decodedError = "Received COMMAND_END with status=" + String.format("0x%X", status) + ", error_port=" + dataA.dataValues[14 - 8]; if (dataA.decodedError != null) - if (DEBUG) - appendToLog(dataA.decodedError); + Logger.debug(dataA.decodedError); rfidDataReadTypes = RfidDataReadTypes.RFID_DATA_READ_COMMAND_END; } } int oldSize = mRx000ToRead.size(); mRx000ToRead.add(dataA); - if (DEBUG) - appendToLog("oldSize = " + oldSize + ", after adding 8001 mRx000ToRead.size = " + mRx000ToRead.size()); + Logger.debug("oldSize = {}, after adding 8001 mRx000ToRead.size = {}", oldSize, mRx000ToRead.size()); commandOperating = false; break; case 0x0005: case 0x8005: //RFID_PACKET_TYPE_18K6C_INVENTORY //original 5 if (dataIn[startIndex + 0] != 3 && dataIn[startIndex + 0] != 4) { - if (DEBUG) - appendToLog("command 18K6C_INVENTORY is found without first byte as 0x03, 0x04, " + byteArrayToString(dataInPayload)); + Logger.debug("command 18K6C_INVENTORY is found without first byte as 0x03, 0x04, {}", byteArrayToString(dataInPayload)); break; } else { if (dataIn[startIndex + 0] == 3) { @@ -3790,13 +3749,10 @@ void uplinkHandler() { } 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()); + Logger.apData("ApData: dataValues = {}, 1 decodedRssi = {}, decodedPhase = {}, decodedChidx = {}, decodedPort = {}", byteArrayToString(dataA.dataValues), dataA.decodedRssi, dataA.decodedPhase, dataA.decodedChidx, dataA.decodedPort); + Logger.apData("ApData: decodedPc/Epc/Crc = {}, {}, {}, decodedData1/2 = {}, {}", byteArrayToString(dataA.decodedPc), byteArrayToString(dataA.decodedEpc), byteArrayToString(dataA.decodedCrc), + byteArrayToString(dataA.decodedData1), byteArrayToString(dataA.decodedData2)); + Logger.debug("oldSize = {}, after adding 8005 mRx000ToRead.size = {}", oldSize2, mRx000ToRead.size()); } else { dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_INVENTORY_COMPACT; if (true) { @@ -3824,11 +3780,12 @@ void uplinkHandler() { dataA.decodedRssi = decodeNarrowBandRSSI(dataValuesFull[index]); index++; } - if (DEBUG) - 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)); + Logger.debug("{}2 decodedRssi = {}, decodedPc = {}, decodedEpc = {}", + (dataA.dataValues != null ? "mRfidToRead.size() = " + csReaderConnector.rfidConnector.mRfidToRead.size() + ", dataValues = " + byteArrayToString(dataA.dataValues) + ", " : ""), + dataA.decodedRssi, byteArrayToString(dataA.decodedPc), 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)); + Logger.apData("ApData: Got data to mRx000ToRead {}, with decodedEpc = {}", mRx000ToRead.size(), byteArrayToString(dataA.decodedEpc)); int iDecodedPortOld = dataA.decodedPort; dataA = new RfidReaderChipData.Rx000pkgData(); @@ -3841,26 +3798,22 @@ void uplinkHandler() { } 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()); + Logger.apData("ApData: Got data to mRx000ToRead {}, with decodedEpc = {}", mRx000ToRead.size(), byteArrayToString(dataA.decodedEpc)); + Logger.debug("oldSize = {}, after adding 8005 mRx000ToRead.size = {}", oldSize3, mRx000ToRead.size()); } - if (DEBUG) - appendToLog("command 18K6C_INVENTORY is found with data=" + byteArrayToString(dataA.dataValues)); + Logger.debug("command 18K6C_INVENTORY is found with data= {}", byteArrayToString(dataA.dataValues)); } break; case 6: //RFID_PACKET_TYPE_18K6C_TAG_ACCESS - if (dataIn[startIndex + 0] != 1) { - if (DEBUG) - appendToLog("command 18K6C_TAG_ACCESS is found without first byte as 0x02, " + byteArrayToString(dataInPayload)); + if (dataIn[startIndex] != 1) { + Logger.debug("command 18K6C_TAG_ACCESS is found without first byte as 0x02, {}", byteArrayToString(dataInPayload)); break; } else { dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_18K6C_TAG_ACCESS; if (true) { byte[] dataInPayload_full = new byte[expectedLength]; System.arraycopy(dataIn, startIndex, dataInPayload_full, 0, dataInPayload_full.length); - if (DEBUG) - appendToLog("command TYPE_18K6C_TAG_ACCESS is found with packageLength=" + packageLengthRead + ", " + byteArrayToString(dataInPayload_full)); + Logger.debug("command TYPE_18K6C_TAG_ACCESS is found with packageLength= {}, {}", packageLengthRead, byteArrayToString(dataInPayload_full)); } if (true) { int accessError, backscatterError; @@ -3881,7 +3834,7 @@ else if ((dataA.dataValues[1] & 1) != 0 && dataA.dataValues.length >= 8 + 12 + 4 byte[] dataRead = new byte[dataA.dataValues.length - 20]; System.arraycopy(dataA.dataValues, 20, dataRead, 0, dataRead.length); - if (backscatterError == 0 && accessError == 0 && timeoutError == false && crcError == false) { + if (backscatterError == 0 && accessError == 0 && !timeoutError && !crcError) { if ((dataA.dataValues[12] == (byte) 0xC3) || (dataA.dataValues[12] == (byte) 0xC4) || (dataA.dataValues[12] == (byte) 0xC5) || (dataA.dataValues[12] == (byte) 0xD5) || (dataA.dataValues[12] == (byte) 0xE2)) dataA.decodedResult = ""; @@ -3970,35 +3923,28 @@ else if ((dataA.dataValues[12] == (byte) 0xC2) || (dataA.dataValues[12] == (byte } int oldSize4 = mRx000ToRead.size(); mRx000ToRead.add(dataA); - if (DEBUG) - appendToLog("oldSize = " + oldSize4 + ", after adding 0006 mRx000ToRead.size = " + mRx000ToRead.size()); - if (DEBUG) { - appendToLog("mRx000UplinkHandler(): package read = " + byteArrayToString(dataA.dataValues)); - } + Logger.debug("oldSize = {}, after adding 0006 mRx000ToRead.size = {}", oldSize4, mRx000ToRead.size()); + Logger.debug("mRx000UplinkHandler(): package read = {}", byteArrayToString(dataA.dataValues)); break; case 0x0007: case 0x8007: //RFID_PACKET_TYPE_ANTENNA_CYCLE_END //original 7 if (dataIn[startIndex + 0] != 1 && dataIn[startIndex + 0] != 2) { - if (DEBUG) - appendToLog("command TYPE_ANTENNA_CYCLE_END is found without first byte as 0x01 or 0x02, " + byteArrayToString(dataInPayload)); + Logger.debug("command TYPE_ANTENNA_CYCLE_END is found without first byte as 0x01 or 0x02, {}", byteArrayToString(dataInPayload)); break; } else { dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_ANTENNA_CYCLE_END; - if (DEBUG) - appendToLog("command TYPE_ANTENNA_CYCLE_END is found with packageLength=" + packageLengthRead + ", " + byteArrayToString(dataInPayload)); + Logger.debug("command TYPE_ANTENNA_CYCLE_END is found with packageLength={}, {}", packageLengthRead, byteArrayToString(dataInPayload)); rfidDataReadTypes = RfidDataReadTypes.RFID_DATA_READ_COMMAND_END; } mRx000ToRead.add(dataA); break; case 0x000E: if (dataIn[startIndex + 0] != 1 && dataIn[startIndex + 0] != 2) { - if (DEBUG) - appendToLog("command TYPE_COMMAND_ACTIVE is found without first byte as 0x01 or 0x02, " + byteArrayToString(dataInPayload)); + Logger.debug("command TYPE_COMMAND_ACTIVE is found without first byte as 0x01 or 0x02, {}", byteArrayToString(dataInPayload)); break; } else { dataA.responseType = RfidReaderChipData.HostCmdResponseTypes.TYPE_COMMAND_ACTIVE; - if (DEBUG) - appendToLog("command TYPE_COMMAND_ACTIVE is found with packageLength=" + packageLengthRead + ", " + byteArrayToString(dataInPayload)); + Logger.debug("command TYPE_COMMAND_ACTIVE is found with packageLength={}, {}", packageLengthRead, byteArrayToString(dataInPayload)); rfidDataReadTypes = RfidDataReadTypes.RFID_DATA_READ_COMMAND_ACTIVE; } mRx000ToRead.add(dataA); @@ -4019,8 +3965,7 @@ else if ((dataA.dataValues[12] == (byte) 0xC2) || (dataA.dataValues[12] == (byte case 0x02: // dataIn[startIndex + 12] = 3; rx000OemSetting.countryCode = (dataIn[startIndex + 12] & 0xFF) + (dataIn[startIndex + 13] & 0xFF) * 256 + (dataIn[startIndex + 14] & 0xFF) * 256 * 256 + (dataIn[startIndex + 15] & 0xFF) * 256 * 256 * 256; - if (DEBUG) - appendToLog("countryCode = " + rx000OemSetting.countryCode); + Logger.debug("countryCode = {}", rx000OemSetting.countryCode); break; case 0x04: case 0x05: @@ -4034,7 +3979,7 @@ else if ((dataA.dataValues[12] == (byte) 0xC2) || (dataA.dataValues[12] == (byte if (true) { byte[] bytes = new byte[4]; System.arraycopy(dataIn, startIndex + 12, bytes, 0, 4); - appendToLog("product serial number, " + address + ": " + byteArrayToString(bytes)); + Logger.trace("product serial number, {}: {}", address, byteArrayToString(bytes)); } System.arraycopy(dataIn, startIndex + 12, rx000OemSetting.productserialNumber, 4 * (address - 8), 4); break; @@ -4045,8 +3990,7 @@ else if ((dataA.dataValues[12] == (byte) 0xC2) || (dataA.dataValues[12] == (byte } else if (dataIn[startIndex + 12] == 0x20 && dataIn[startIndex + 13] == 0x17 && dataIn[startIndex + 14] == 0) { rx000OemSetting.versionCode = (dataIn[startIndex + 14] & 0xFF) + (dataIn[startIndex + 15] & 0xFF) * 256; } - if (DEBUG) - appendToLog("versionCode = " + rx000OemSetting.versionCode); + Logger.debug("versionCode = {}", rx000OemSetting.versionCode); break; case 0x8E: /*dataIn[startIndex + 12] = 0x2A; //0x4F; @@ -4063,14 +4007,12 @@ else if ((dataA.dataValues[12] == (byte) 0xC2) || (dataA.dataValues[12] == (byte } byte[] dataInPart = new byte[4]; System.arraycopy(dataIn, startIndex + 12, dataInPart, 0, dataInPart.length); - if (DEBUG) - appendToLog("spcialCountryVersion = " + rx000OemSetting.spcialCountryVersion + ", data = " + byteArrayToString(dataInPart)); + Logger.debug("spcialCountryVersion = {}, data = {}", rx000OemSetting.spcialCountryVersion, byteArrayToString(dataInPart)); break; case 0x8F: //dataIn[startIndex + 12] = (byte)0xAA; rx000OemSetting.freqModifyCode = (dataIn[startIndex + 12] & 0xFF) + (dataIn[startIndex + 13] & 0xFF) * 256 + (dataIn[startIndex + 14] & 0xFF) * 256 * 256 + (dataIn[startIndex + 15] & 0xFF) * 256 * 256 * 256; - if (DEBUG) - appendToLog("freqModifyCode = " + rx000OemSetting.freqModifyCode); + Logger.debug("freqModifyCode = {}", rx000OemSetting.freqModifyCode); break; default: break; @@ -4080,24 +4022,20 @@ else if ((dataA.dataValues[12] == (byte) 0xC2) || (dataA.dataValues[12] == (byte mRx000OemSetting.serialNumber[(address - 4) * 4 + i] = dataIn[startIndex + 12 + i]; } }*/ - if (DEBUG) - appendToLog("command OEMCFG_READ is found with address = " + address + ", packageLength=" + packageLengthRead + ", " + byteArrayToString(dataInPayload)); + Logger.debug("command OEMCFG_READ is found with address = {}, packageLength={}, {}", address, packageLengthRead, byteArrayToString(dataInPayload)); rfidDataReadTypes = RfidDataReadTypes.RFID_DATA_READ_COMMAND_OEMREAD; break; case 0x3008: //RFID_PACKET_TYPE_ENG_RSSI - if (DEBUG) - appendToLog("Hello123: RFID_PACKET_TYPE_ENG_RSSI S is found: " + byteArrayToString(dataInPayload)); + Logger.debug("Hello123: RFID_PACKET_TYPE_ENG_RSSI S is found: {}", byteArrayToString(dataInPayload)); if ((dataIn[startIndex + 8] & 0x02) != 0) { rx000EngSetting.narrowRSSI = (dataIn[startIndex + 28] & 0xFF) + (dataIn[startIndex + 29] & 0xFF) * 256; rx000EngSetting.wideRSSI = (dataIn[startIndex + 30] & 0xFF) + (dataIn[startIndex + 31] & 0xFF) * 256; - if (DEBUG) - appendToLog("Hello123: narrorRSSI = " + String.format("%04X", rx000EngSetting.narrowRSSI) + ", wideRSSI = " + String.format("%04X", rx000EngSetting.wideRSSI)); + Logger.debug("Hello123: narrorRSSI = {}, wideRSSI = {}", String.format("%04X", rx000EngSetting.narrowRSSI), String.format("%04X", rx000EngSetting.wideRSSI)); rfidDataReadTypes = RfidDataReadTypes.RFID_DATA_READ_COMMAND_RSSI; } break; default: - if (DEBUG) - appendToLog("command OTHERS is found: " + byteArrayToString(dataInPayload) + ", with packagelength=" + packageLengthRead + ", packageTypeRead=" + packageTypeRead); + Logger.debug("command OTHERS is found: {}, with packagelength={}, packageTypeRead={}", byteArrayToString(dataInPayload), packageLengthRead, packageTypeRead); break; } packageFound = true; @@ -4110,13 +4048,11 @@ else if ((dataA.dataValues[12] == (byte) 0xC2) || (dataA.dataValues[12] == (byte if (packageFound) { packageFound = false; - if (false && utility.DEBUG_APDATA) - appendToLog("ApData: found packageType " + packageType + " with mRfidToReadingOffset=" + mRfidToReadingOffset + ", startIndexOld= " + startIndexOld + ", startIndex= " + startIndex + ", startIndexNew=" + startIndexNew); + Logger.apData("ApData: found packageType {} with mRfidToReadingOffset={}, startIndexOld= {}, startIndex= {}, startIndexNew={}", packageType, mRfidToReadingOffset, startIndexOld, startIndex, startIndexNew); if (startIndex != startIndexOld) { byte[] unhandledBytes = new byte[startIndex - startIndexOld]; System.arraycopy(mRfidToReading, startIndexOld, unhandledBytes, 0, unhandledBytes.length); - if (utility.DEBUG_APDATA) - appendToLog("ApData: packageFound with invalid unused data: " + unhandledBytes.length + ", " + byteArrayToString(unhandledBytes)); + Logger.apData("ApData: packageFound with invalid unused data: {}, {}", unhandledBytes.length, byteArrayToString(unhandledBytes)); invalidUpdata++; writeDebug2File("Up4 invalid " + unhandledBytes.length + ", " + byteArrayToString(unhandledBytes)); } else if (startIndexNew != startIndex) { @@ -4129,11 +4065,11 @@ 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 (utility.DEBUG_APDATA) appendToLog("ApData: Found startIndexNew=" + startIndexNew + ", string=" + string); - if (false && utility.DEBUG_APDATA) { + Logger.apData("ApData: Found startIndexNew={}, string= {}", startIndexNew, string); + if (Logger.LOG_APDATA) { byte[] usedBytes = new byte[startIndexNew - startIndex]; System.arraycopy(mRfidToReading, startIndex, usedBytes, 0, usedBytes.length); - appendToLog("ApData: used data = " + usedBytes.length + ", " + byteArrayToString(usedBytes)); + Logger.apData("ApData: used data = {}, {}", usedBytes.length, byteArrayToString(usedBytes)); } } @@ -4147,31 +4083,28 @@ 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 (utility.DEBUG_APDATA) - appendToLog("ApData: moved with remained bytes=" + byteArrayToString(remainedBytes)); + Logger.apData("ApData: moved with remained bytes= {}", byteArrayToString(remainedBytes)); } } else { startIndex++; } } - if (utility.DEBUG_APDATA && bLooping2) appendToLog("ApData: Exiting second loop with mRfidToReadingOffset = " + mRfidToReadingOffset + ", startIndex = " + startIndex); + if (bLooping2) Logger.apData("ApData: Exiting second loop with mRfidToReadingOffset = {}, startIndex = {}", mRfidToReadingOffset, 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); + Logger.apData("ApData: exit while(-8) loop with startIndex = {}{}, mRfidToReadingOffset={}", startIndex, startIndex == 0 ? "" : "(NON-ZERO)", mRfidToReadingOffset); } } } - if (utility.DEBUG_APDATA && bLooping) appendToLog("ApData: Exiting loop with mRfidToRead.size as " + csReaderConnector.rfidConnector.mRfidToRead.size()); + if (bLooping) Logger.apData("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); - if (DEBUG) - appendToLog("Up4 Invalid " + mRfidToReadingOffset + ", " + byteArrayToString(unusedData)); + Logger.debug("Up4 Invalid {}, {}", mRfidToReadingOffset, byteArrayToString(unusedData)); mRfidToReading = new byte[RFID_READING_BUFFERSIZE]; mRfidToReadingOffset = 0; utility.writeDebug2File("Up4 Invalid " + byteArrayToString(unusedData)); } - if (DEBUGTHREAD) appendToLog("mRx000UplinkHandler(): END"); + Logger.debug("mRx000UplinkHandler(): END"); bRx000ToReading = false; } @@ -4183,7 +4116,7 @@ public boolean turnOn(boolean onStatus) { clearTempDataIn_request = true; addRfidToWrite(csReaderRfidData); return true; - } else if (onStatus == false) { + } else if (!onStatus) { csReaderRfidData.rfidPayloadEvent = RfidConnector.RfidPayloadEvents.RFID_POWER_OFF; csReaderRfidData.waitUplinkResponse = false; clearTempDataIn_request = true; @@ -4197,7 +4130,7 @@ public boolean turnOn(boolean onStatus) { public 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; + if (!csReaderConnector.isBleConnected()) return false; switch (controlCommands) { default: msgBuffer = null; @@ -4231,7 +4164,7 @@ public boolean sendControlCommand(ControlCommands controlCommands) { } if (msgBuffer == null) { - if (DEBUG) appendToLog("Invalid control commands"); + Logger.debug("Invalid control commands"); return false; } else { clearTempDataIn_request = true; @@ -4240,12 +4173,12 @@ public boolean sendControlCommand(ControlCommands controlCommands) { csReaderRfidData.rfidPayloadEvent = RfidConnector.RfidPayloadEvents.RFID_COMMAND; csReaderRfidData.dataValues = msgBuffer; if (needResponse) { -// if (DEBUG) appendToLog("sendControlCommand() adds to mRx000ToWrite"); +// Logger.debug("sendControlCommand() adds to mRx000ToWrite"); csReaderRfidData.waitUplinkResponse = needResponse; addRfidToWrite(csReaderRfidData); // mRx000ToWrite.add(cs108RfidData); } else { -// if (DEBUG) appendToLog("sendControlCommand() adds to mRfidToWrite"); +// Logger.debug("sendControlCommand() adds to mRfidToWrite"); csReaderRfidData.waitUplinkResponse = needResponse; addRfidToWrite(csReaderRfidData); } @@ -4322,7 +4255,7 @@ boolean sendHostRegRequestHST_RFTC_FRQCH_DESC_PLLDIVMULT(int freqChannel) { boolean bLowPowerStandby = false; public boolean setPwrManagementMode(boolean bLowPowerStandby) { - if (false) appendToLog("pwrMgmtStatus: setPwrManagementMode(" + bLowPowerStandby + ")"); + Logger.trace("pwrMgmtStatus: setPwrManagementMode({}]", bLowPowerStandby); if (true) return false; //ignore this setting if (this.bLowPowerStandby == bLowPowerStandby) return true; boolean result = rx000Setting.writeMAC(0x200, (bLowPowerStandby ? 1 : 0)); @@ -4444,7 +4377,7 @@ public boolean sendHostRegRequestHST_CMD(RfidReaderChipData.HostCommands hostCom ArrayList macAccessHistory = new ArrayList<>(); boolean bifMacAccessHistoryData(byte[] msgBuffer) { - if (sameCheck == false) return false; + if (!sameCheck) 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; @@ -4454,29 +4387,26 @@ boolean bifMacAccessHistoryData(byte[] msgBuffer) { int findMacAccessHistory(byte[] msgBuffer) { int i = -1; for (i = 0; i < macAccessHistory.size(); i++) { -// appendToLog("macAccessHistory(" + i + ")=" + byteArrayToString(macAccessHistory.get(i))); +// Logger.trace("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)); + Logger.trace("macAccessHistory: returnValue = {}, msgBuffer={}", i, byteArrayToString(msgBuffer)); return i; } void addMacAccessHistory(byte[] msgBuffer) { - boolean DEBUG = false; 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)) { - if (DEBUG) - appendToLog("macAccessHistory: deleted old record=" + byteArrayToString(macAccessHistory4)); + Logger.debug("macAccessHistory: deleted old record={}", byteArrayToString(macAccessHistory4)); macAccessHistory.remove(i); break; } } - if (DEBUG) - appendToLog("macAccessHistory: added msgbuffer=" + byteArrayToString(msgBuffer)); + Logger.debug("macAccessHistory: added msgbuffer={}", byteArrayToString(msgBuffer)); macAccessHistory.add(msgBuffer); } @@ -4484,7 +4414,7 @@ boolean sendHostRegRequest(HostRegRequests hostRegRequests, boolean writeOperati boolean needResponse = false; boolean validRequest = false; - if (csReaderConnector.isBleConnected() == false) return false; + if (!csReaderConnector.isBleConnected()) return false; addMacAccessHistory(msgBuffer); switch (hostRegRequests) { case MAC_OPERATION: @@ -4551,26 +4481,24 @@ boolean sendHostRegRequest(HostRegRequests hostRegRequests, boolean writeOperati break; } - boolean DEBUG = false; - if (DEBUG) - appendToLog("checking msgbuffer = " + (msgBuffer == null ? "NULL" : "Valid") + ", validRequst = " + validRequest); - if (msgBuffer == null || validRequest == false) { - if (DEBUG) appendToLog("Invalid HST_REQ_REQ or null message"); + Logger.debug("checking msgbuffer = {}, validRequst = {}", msgBuffer == null ? "NULL" : "Valid", validRequest); + if (msgBuffer == null || !validRequest) { + Logger.debug("Invalid HST_REQ_REQ or null message"); return false; } else { - if (DEBUG) appendToLog("True Ending 0"); + Logger.debug("True Ending 0"); RfidConnector.CsReaderRfidData csReaderRfidData = new RfidConnector.CsReaderRfidData(); csReaderRfidData.rfidPayloadEvent = RfidConnector.RfidPayloadEvents.RFID_COMMAND; csReaderRfidData.dataValues = msgBuffer; - if (needResponse || writeOperation == false) { - csReaderRfidData.waitUplinkResponse = (needResponse || writeOperation == false); + if (needResponse || !writeOperation) { + csReaderRfidData.waitUplinkResponse = (needResponse || !writeOperation); // mRx000ToWrite.add(cs108RfidData); addRfidToWrite(csReaderRfidData); } else { - csReaderRfidData.waitUplinkResponse = (needResponse || writeOperation == false); + csReaderRfidData.waitUplinkResponse = (needResponse || !writeOperation); addRfidToWrite(csReaderRfidData); } - if (DEBUG) appendToLog("True Ending"); + Logger.debug("True Ending"); return true; } } @@ -4592,9 +4520,8 @@ 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)); + Logger.trace("add cs108RfidData to mRfidToWrite with rfidPayloadEvent = {}", csReaderRfidData.rfidPayloadEvent); + //Logger.debug("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) { @@ -4607,7 +4534,7 @@ void addRfidToWrite(RfidConnector.CsReaderRfidData csReaderRfidData) { 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)); + //Logger.debug("BtDataOut: matched data {}", byteArrayToString(csReaderRfidData.dataValues)); csReaderConnector.rfidConnector.mRfidToWrite.remove(i); break; } @@ -4622,5 +4549,9 @@ void addRfidToWrite(RfidConnector.CsReaderRfidData csReaderRfidData) { boolean inventoring = false; public boolean isInventoring() { return inventoring; } - void setInventoring(boolean enable) { inventoring = enable; utility.debugFileEnable(false); if (false) appendToLog("setInventoring R2000 is set as " + inventoring);} + void setInventoring(boolean enable) { + inventoring = enable; + utility.debugFileEnable(false); + Logger.trace("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 74a1678..e90e85b 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/SettingData.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/SettingData.java @@ -10,7 +10,6 @@ import java.io.InputStreamReader; public class SettingData { - final boolean DEBUG_FILE = true; public int channel = -1; int antennaPower = -1; @@ -22,30 +21,26 @@ public SettingData(Context context, Utility utility, BluetoothGatt bluetoothGatt this.utility = utility; this.bluetoothGatt = bluetoothGatt; this.csReaderConnector = csReaderConnector; - appendToLog("SettingData: this.bluetoothGatt is " + (this.bluetoothGatt == null ? "null" : "valid") - + "\nthis.csReaderConnector is " + (this.csReaderConnector == null ? "null" : "valid") - + "\nthis.utility is " + (this.utility == null ? "null" : "valid") - + "\nthis.context is " + (this.context == null ? "null" : "valid") + Logger.trace("SettingData: this.bluetoothGatt is {}\nthis.csReaderConnector is {}\nthis.utility is {}\nthis.context is {}", + this.bluetoothGatt == null ? "null" : "valid", + this.csReaderConnector == null ? "null" : "valid", + this.utility == null ? "null" : "valid", + this.context == null ? "null" : "valid" ); loadForegroundSettingFile(); } public void setConnectedConnectors(NotificationConnector notificationConnector, RfidReader rfidReader) { this.notificationConnector = notificationConnector; this.rfidReader = rfidReader; - appendToLog("SettingData: this.notificationConnector is " + (this.notificationConnector == null ? "null" : "valid") - + "\nthis.rfidReader is " + (this.rfidReader == null ? "null" : "valid") - ); + Logger.trace("SettingData: this.notificationConnector is {}\nthis.rfidReader is {}", this.notificationConnector == null ? "null" : "valid", + this.rfidReader == null ? "null" : "valid"); } - private void appendToLog(String s) { - utility.appendToLog(s); - } public void write2FileStream(FileOutputStream stream, String string) { - boolean DEBUG = true; try { stream.write(string.getBytes()); - if (true) appendToLog("FileA outData = " + string); + Logger.trace("FileA outData = {}", string); } catch (Exception ex) { } } @@ -149,8 +144,8 @@ boolean loadSettingFile(String strlibraryVersion, boolean bChannelHoppingStatus, fileName = "csReaderA_" + fileName.replaceAll(":", ""); fileSetting = new File(path, fileName); - boolean bNeedDefault = true, DEBUG = false; - if (DEBUG_FILE) utility.appendToLogView("FileName = " + fileName + ".exits = " + fileSetting.exists() + ", with beepEnable = " + inventoryBeep); + boolean bNeedDefault = true; + Logger.toLogView("FileName = {}.exits = {}, with beepEnable = {}", fileName, fileSetting.exists(), inventoryBeep).debug(); if (fileSetting.exists()) { InputStream instream = null; try { @@ -176,11 +171,11 @@ boolean loadSettingFile(String strlibraryVersion, boolean bChannelHoppingStatus, // } if (line == null) break; - if (DEBUG_FILE || true) appendToLog("FileA Data read = " + line); + Logger.debug("FileA Data read = {}", line); String[] dataArray = line.split(","); if (dataArray.length == 2) { if (dataArray[0].matches("appVersion")) { - appendToLog("datArray[1] = " + dataArray[1] + ", strlibraryVersion = " + strlibraryVersion); + Logger.trace("datArray[1] = {}, strlibraryVersion = {}", dataArray[1], strlibraryVersion); if (dataArray[1].matches(strlibraryVersion)) bNeedDefault = false; } else if (bNeedDefault == true) { } else if (dataArray[0].matches("countryInList")) { @@ -232,9 +227,9 @@ boolean loadSettingFile(String strlibraryVersion, boolean bChannelHoppingStatus, csReaderConnector.rfidReader.setDupDelay(Byte.valueOf(dataArray[1])); } else if (dataArray[0].matches(("triggerReporting"))) { - appendToLog("FileA: going to setTriggerReporting with notificationConnector as " + (notificationConnector == null ? "null" : "valid")); + Logger.trace("FileA: going to setTriggerReporting with notificationConnector as {}", notificationConnector == null ? "null" : "valid"); notificationConnector.setTriggerReporting(dataArray[1].matches("true") ? true : false); - appendToLog("FileA: setTriggerReporting is done"); + Logger.trace("FileA: setTriggerReporting is done"); } else if (dataArray[0].matches(("triggerReportingCount"))) { notificationConnector.setTriggerReportingCount(Short.valueOf(dataArray[1])); } else if (dataArray[0].matches(("inventoryBeep"))) { @@ -311,29 +306,28 @@ boolean loadSettingFile(String strlibraryVersion, boolean bChannelHoppingStatus, csReaderConnector.rfidReader.setTagGroup(querySelect, querySession, queryTarget); csReaderConnector.rfidReader.setTagFocus(csReaderConnector.rfidReader.tagFocus > 0 ? true : false); if (preFilterData != null && preFilterData.enable) { - if (utility.DEBUG_SELECT) appendToLog("Debug_Select: SettingData.loadingSettingFile. preFilterData is valid. Going to setSelectCriteria"); - appendToLog("BtDataOut BBB 5"); + Logger.select("Debug_Select: SettingData.loadingSettingFile. preFilterData is valid. Going to setSelectCriteria"); + Logger.trace("BtDataOut BBB 5"); csReaderConnector.rfidReader.setSelectCriteria(0, preFilterData.enable, preFilterData.target, preFilterData.action, preFilterData.bank, preFilterData.offset, preFilterData.mask, preFilterData.maskbit); } else { - if (utility.DEBUG_SELECT) appendToLog("Debug_Select: SettingData.loadingSettingFile. preFilterData is null or disabled. Going to setSelectCriteriaDisable"); + Logger.select("Debug_Select: SettingData.loadingSettingFile. preFilterData is null or disabled. Going to setSelectCriteriaDisable"); csReaderConnector.rfidReader.setSelectCriteriaDisable(0); } } try { instream.close(); } catch (Exception ex) { } - if (DEBUG_FILE) appendToLog("Data is read from FILE."); + Logger.debug("Data is read from FILE."); } if (bNeedDefault) { - appendToLog("saveSetting2File default !!!"); + Logger.trace("saveSetting2File default !!!"); csReaderConnector.rfidReader.setReaderDefault(); saveSetting2File(strlibraryVersion, bChannelHoppingStatus, iCurrentProfile); } return bNeedDefault; } public void saveSetting2File(String strLibraryVersion, boolean bChannelHoppingStatus, int iCurrentProfile) { - boolean DEBUG = true; - if (DEBUG) appendToLog("Start"); + Logger.debug("Start"); FileOutputStream stream; try { stream = new FileOutputStream(fileSetting); @@ -403,7 +397,7 @@ public void saveSetting2File(String strLibraryVersion, boolean bChannelHoppingSt write2FileStream(stream, "preFilterData.maskbit," + String.valueOf(preFilterData.maskbit + "\n")); } - write2FileStream(stream, "End of data\n"); //.getBytes()); if (DEBUG) appendToLog("outData = " + outData); + write2FileStream(stream, "End of data\n"); //.getBytes()); Logger.debug("outData = " + outData); stream.close(); } catch (Exception ex){ // @@ -417,24 +411,24 @@ boolean loadForegroundSettingFile() { File path = context.getFilesDir(); String fileName = "csReaderA_Foreground"; fileForegroundSetting = new File(path, fileName); - appendToLog("file0.exists = " + fileForegroundSetting.exists()); + Logger.trace("file0.exists = {}", fileForegroundSetting.exists()); if (fileForegroundSetting.exists()) { try { InputStream instream = new FileInputStream(fileForegroundSetting); - appendToLog("file0.instream is " + (instream == null ? "null" : "valid")); + Logger.trace("file0.instream is {}", instream == null ? "null" : "valid"); if (instream != null) { InputStreamReader inputStreamReader = new InputStreamReader(instream); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); String line; while ((line = bufferedReader.readLine()) != null) { - appendToLog("file0.line: " + line); + Logger.trace("file0.line: {}", line); String[] dataArray = line.split(","); if (dataArray.length == 2) { if (dataArray[0].matches("foreground.reader")) { - appendToLog("foregroundReader: set 5"); + Logger.trace("foregroundReader: set 5"); strForegroundReader = dataArray[1]; - appendToLog("file0.foreground.reader = " + strForegroundReader); - appendToLog("loaded strForegroundReader is " + this.strForegroundReader); + Logger.trace("file0.foreground.reader = {}", strForegroundReader); + Logger.trace("loaded strForegroundReader is {}", this.strForegroundReader); } } } @@ -447,8 +441,7 @@ boolean loadForegroundSettingFile() { return true; } public void saveForegroundSetting2File() { - boolean DEBUG = true; - if (DEBUG) appendToLog("Start"); + Logger.debug("Start"); FileOutputStream stream; try { @@ -456,7 +449,7 @@ public void saveForegroundSetting2File() { write2FileStream(stream, "Start of File0 data\n"); write2FileStream(stream, "foreground.enable," + "true" + "\n"); - appendToLog("strForegroundReader = " + strForegroundReader); + Logger.trace("strForegroundReader = {}", strForegroundReader); write2FileStream(stream, "foreground.reader," + strForegroundReader + "\n"); write2FileStream(stream, "End of File0 data\n"); stream.close(); @@ -472,11 +465,11 @@ public void saveForegroundSetting2File() { public int wedgeOutput = 0, wedgeDelimiter = 0x0a, wedgePower = 300; public String fileNameWedgeSetting = "csReaderA_SimpleWedge"; void loadWedgeSettingFile() { - appendToLog("KKK: loadWedgeSettingFile starts"); + Logger.trace("KKK: loadWedgeSettingFile starts"); File path = context.getFilesDir(); File file = new File(path, fileNameWedgeSetting); - boolean bNeedDefault = true, DEBUG = false; - appendToLog(fileNameWedgeSetting + "file.exists = " + file.exists()); + boolean bNeedDefault = true; + Logger.trace("{} file.exists = {}", fileNameWedgeSetting, file.exists()); if (file.exists()) { int length = (int) file.length(); byte[] bytes = new byte[length]; @@ -487,7 +480,7 @@ void loadWedgeSettingFile() { BufferedReader bufferedReader = new BufferedReader(inputStreamReader); String line; while ((line = bufferedReader.readLine()) != null) { - if (true) appendToLog("Data read = " + line); + Logger.trace("Data read = {}", line); String[] dataArray = line.split(","); if (dataArray.length == 2) { if (dataArray[0].matches("wedgeDeviceName")) { @@ -504,7 +497,7 @@ void loadWedgeSettingFile() { wedgeSuffix = dataArray[1]; } else if (dataArray[0].matches("wedgeDelimiter")) { wedgeDelimiter = Integer.valueOf(dataArray[1]); - appendToLog("MainActivity, loadWedgeSettingFile: wedgeDelimiter = " + wedgeDelimiter); + Logger.trace("MainActivity, loadWedgeSettingFile: wedgeDelimiter = {}", wedgeDelimiter); } else if (dataArray[0].matches("wedgeOutput")) { wedgeOutput = Integer.valueOf(dataArray[1]); } @@ -518,7 +511,7 @@ void loadWedgeSettingFile() { } } void saveWedgeSetting2File() { - appendToLog("KKK: saveWedgeSetting2File starts"); + Logger.trace("KKK: saveWedgeSetting2File starts"); File path = context.getFilesDir(); File file = new File(path, fileNameWedgeSetting); FileOutputStream stream; @@ -531,7 +524,8 @@ void saveWedgeSetting2File() { write2FileStream(stream, "wedgePower," + wedgePower + "\n"); write2FileStream(stream, "wedgePrefix," + wedgePrefix + "\n"); write2FileStream(stream, "wedgeSuffix," + wedgeSuffix + "\n"); - write2FileStream(stream, "wedgeDelimiter," + String.valueOf(wedgeDelimiter) + "\n"); appendToLog("SettingWedgeFragment, saveWedgeFragment: wedgeDelimiter = " + wedgeDelimiter); + write2FileStream(stream, "wedgeDelimiter," + String.valueOf(wedgeDelimiter) + "\n"); + Logger.trace("SettingWedgeFragment, saveWedgeFragment: wedgeDelimiter = {}", wedgeDelimiter); write2FileStream(stream, "wedgeOutput," + String.valueOf(wedgeOutput) + "\n"); write2FileStream(stream, "End of data\n"); stream.close(); diff --git a/cslibrary4a/src/main/java/com/csl/cslibrary4a/Utility.java b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Utility.java index abff9df..3a8d247 100644 --- a/cslibrary4a/src/main/java/com/csl/cslibrary4a/Utility.java +++ b/cslibrary4a/src/main/java/com/csl/cslibrary4a/Utility.java @@ -25,24 +25,21 @@ import java.util.Date; import java.util.Locale; +import info.mqtt.android.service.BuildConfig; + 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; + private Context mContext; + private TextView mLogView; public Utility(Context context, TextView mLogView) { mContext = context; + Logger.mLogView = mLogView; this.mLogView = mLogView; } private static long mReferenceTimeMs; public void setReferenceTimeMs() { mReferenceTimeMs = System.currentTimeMillis(); } - public long getReferencedCurrentTimeMs() { return System.currentTimeMillis() - mReferenceTimeMs; } + public static long getReferencedCurrentTimeMs() { return System.currentTimeMillis() - mReferenceTimeMs; } public boolean compareByteArray(byte[] array1, byte[] array2, int length) { int i = 0; @@ -60,7 +57,7 @@ public boolean compareByteArray(byte[] array1, byte[] array2, int length) { } public String byteArray2DisplayString(byte[] byteData) { - if (false) appendToLog("String0 = " + byteArrayToString(byteData)); + Logger.trace("String0 = {}", byteArrayToString(byteData)); String str = ""; try { str = new String(byteData, "UTF-8"); @@ -69,7 +66,7 @@ public String byteArray2DisplayString(byte[] byteData) { } catch (UnsupportedEncodingException e) { e.printStackTrace(); } - if (false) appendToLog("String1 = " + str); + Logger.trace("String1 = {}", str); return str; } public String byteArrayToString(byte[] packet) { @@ -117,7 +114,7 @@ public byte[] string2ByteArray(String string) { bytesNew[bytesNew.length - 1] = (byte) (sValue & 0xFF); bytes = bytesNew; } catch (Exception ex) { - appendToLog("Exception in i = " + i + ", substring = " + string.substring(i, i+2)); + Logger.error("Exception in i = {}, substring = {}", i, string.substring(i, i+2)); break; } } @@ -133,50 +130,13 @@ public int byteArrayToInt(byte[] bytes) { return iValue; } - private static Handler mHandler = new Handler(); - public void appendToLogRunnable(final String s) { - mHandler.post(new Runnable() { - @Override - public void run() { - appendToLog(s); - } - }); - } - public String appendToLog(String s) { - String TAG = ""; - StackTraceElement[] stacktrace = Thread.currentThread().getStackTrace(); - boolean foundMe = false; - for(int i=0; i= Build.VERSION_CODES.M) { if (mContext.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { writeExtPermission = false; - //appendToLog("requestPermissions WRITE_EXTERNAL_STORAGE 1"); + //Logger.trace("requestPermissions WRITE_EXTERNAL_STORAGE 1"); //requestPermissions((Activity) mContext, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); //if (false) Toast.makeText(mContext, R.string.toast_permission_not_granted, Toast.LENGTH_SHORT).show(); //return; @@ -197,7 +157,7 @@ public void debugFileSetup() { if (fileDebug == null) errorDisplay = "Error in making directory !!!"; } } - if (errorDisplay != null) appendToLog("Error in saving file with " + errorDisplay); + if (errorDisplay != null) Logger.warn("Error in saving file with {}", errorDisplay); } public void debugFileClose() { if (fileDebug != null) { @@ -215,7 +175,7 @@ public void writeDebug2File(String stringDebug) { try { FileOutputStream outputStreamDebug = new FileOutputStream(fileDebug, true); PrintWriter printWriterDebug = new PrintWriter(new OutputStreamWriter(new BufferedOutputStream(outputStreamDebug), "UTF-8")); - if (false) appendToLog(stringDebug); + Logger.trace(stringDebug); printWriterDebug.println(stringDebug); printWriterDebug.flush(); printWriterDebug.close(); outputStreamDebug.close(); @@ -240,14 +200,22 @@ public String getlast3digitVersion(String str) { public String getCombinedVersion(String string0) { String string1 = BuildConfig.VERSION_NAME; - int iValue1 = Integer.parseInt(string1); - appendToLog("string1 = " + string1 + ", iValue1 = " + iValue1); - int iPos0 = string0.indexOf("."); - int iPos1 = string0.substring(iPos0 + 1).indexOf("."); - int iValue0 = Integer.parseInt(string0.substring(iPos0 + iPos1 + 2)); - appendToLog("stringVersion = " + string0 + ", iPos0 = " + iPos0 + ", iPos1 = " + iPos1 + ", iValue0 = " + iValue0); - iValue0 += iValue1; - return string0.substring(0, iPos0 + iPos1 + 2) + String.valueOf(iValue0); + try { + int iValue1 = Integer.parseInt(string1); + Logger.info("string1 = {}, iValue1 = {}", string1, iValue1); + int iPos0 = string0.indexOf("."); + int iPos1 = string0.substring(iPos0 + 1).indexOf("."); + int iValue0 = Integer.parseInt(string0.substring(iPos0 + iPos1 + 2)); + Logger.info("stringVersion = {}, iPos0 = {}, iPos1 = {}, iValue0 = {}", string0, iPos0, iPos1, iValue0); + iValue0 += iValue1; + return string0.substring(0, iPos0 + iPos1 + 2) + iValue0; + } catch (NumberFormatException e) { + int iPos0 = string0.indexOf("."); + int iPos1 = string0.substring(iPos0 + 1).indexOf("."); + int iValue0 = Integer.parseInt(string0.substring(iPos0 + iPos1 + 2)); + Logger.info("stringVersion = {}, iPos0 = {}, iPos1 = {}, iValue0 = {}", string0, iPos0, iPos1, iValue0); + return string0.substring(0, iPos0 + iPos1 + 2) + iValue0; + } } public boolean isVersionGreaterEqual(String version, int majorVersion, int minorVersion, int buildVersion) { @@ -285,14 +253,14 @@ public double get2BytesOfRssi(byte[] bytes, int index) { float fTemperature_old = -500; public float decodeCtesiusTemperature(String strActData, String strCalData) { float fTemperature = -500; boolean invalid = false; - appendToLog("Hello9: strActData = " + strActData + ", strCalData = " + strCalData); + Logger.info("Hello9: strActData = {}, strCalData = {}", strActData, strCalData); if (strActData.length() != 8 || strCalData.length() != 8) { - if (strActData.length() != 8) appendToLogView("Warning: Invalid length of sensing data = " + strActData); - else appendToLogView("Warning: Invalid length of calibration data = " + strCalData); + if (strActData.length() != 8) Logger.toLogView("Warning: Invalid length of sensing data = {}", strActData).warn(); + else Logger.toLogView("Warning: Invalid length of calibration data = {}", strCalData).warn(); invalid = true; } else if ((strActData.substring(0, 1).matches("F") && strActData.substring(4, 5).matches("F")) == false) { - appendToLogView("Warning: Not F header of sensing data = " + strActData); + Logger.toLogView("Warning: Not F header of sensing data = {}", strActData).warn(); invalid = true; } else { @@ -303,16 +271,16 @@ else if ((strActData.substring(0, 1).matches("F") && strActData.substring(4, 5). iChecksum ^= (iTemp & 0x7); } if (iChecksum != 0) { - appendToLogView("Warning: Invalid checksum(" + String.valueOf(iChecksum) + ") for strActData = " + strActData); + Logger.toLogView("Warning: Invalid checksum({}) for strActData = {}", iChecksum, strActData).warn(); invalid = true; } } if (true || invalid == false) { int iDelta1 = Integer.parseInt(strCalData.substring(0,4), 16); if ((iDelta1 & 0x8000) != 0) { iDelta1 ^= 0xFFFF; iDelta1++; iDelta1 *= -1; } - appendToLog(String.format("iDelta1 = %d", iDelta1)); + Logger.trace("iDelta1 = {}", iDelta1); int iVersion = Integer.parseInt(strCalData.substring(4,5), 16); - appendToLog("Hello9: " + String.format("iDelta1 = %X, iVersion = %X", iDelta1, iVersion)); + Logger.trace(String.format("Hello9: iDelta1 = %X, iVersion = %X", iDelta1, iVersion)); float fDelta2 = ((float) iDelta1) / 100 - 101; String strTemp = strActData.substring(1,4) + strActData.substring(5,8); int iTemp = Integer.parseInt(strTemp, 16); @@ -322,8 +290,8 @@ else if ((strActData.substring(0, 1).matches("F") && strActData.substring(4, 5). else if (iVersion == 2) { fTemperature = (float) (11109.6 / (24 + (iD2 + iDelta1)/375.3) - 290); if (fTemperature >= 125) fTemperature = (float) (fTemperature * 1.2 - 25); - } else appendToLogView("Warning: Invalid version " + String.valueOf(iVersion)); - if (invalid) appendToLogView(String.format("Temperature = %f", fTemperature)); + } else Logger.toLogView("Warning: Invalid version {}", iVersion).warn(); + if (invalid) Logger.toLogView("Temperature = {}", fTemperature).info(); } if (fTemperature != -1) fTemperature_old = fTemperature; return fTemperature; @@ -388,27 +356,27 @@ public float decodeAsygnTemperature(String string) { break; } float temperature = -1; - appendToLog("input string " + string + ", user1 = " + stringUser1 + ", user5 = " + stringUser5 + ", user6 = " + stringUser6); + Logger.trace("input string {}, user1 = {}, user5 = {}, user6 = {}", string, stringUser1, stringUser5, stringUser6); //iUser1 = 495; iUser6 = 3811; - appendToLog("iUser1 = " + iUser1 + ", iUser5 = " + iUser5 + ", iUser6 = " + iUser6); + Logger.trace("iUser1 = {}, iUser5 = {}, iUser6 = {}", iUser1, iUser5, iUser6); if (iUser5 == 3000) { float calibOffset = (float) 3860.27 - (float) iUser6; - appendToLog("calibOffset = " + calibOffset); + Logger.trace("calibOffset = {}", calibOffset); float acqTempCorrected = (float) iUser1 + calibOffset / 8; - appendToLog("acqTempCorrected = " + acqTempCorrected); + Logger.trace("acqTempCorrected = {}", acqTempCorrected); temperature = (float) 0.3378 * acqTempCorrected - (float) 133; - appendToLog("temperature = " + temperature); + Logger.trace("temperature = {}", temperature); } else if (iUser5 == 1835) { float expAcqTemp = (float) 398.54 - (float) iUser5 / (float) 100; - appendToLog("expAcqTemp = " + expAcqTemp); + Logger.trace("expAcqTemp = {}", expAcqTemp); expAcqTemp /= (float) 0.669162; - appendToLog("expAcqTemp = " + expAcqTemp); + Logger.trace("expAcqTemp = {}", expAcqTemp); float calibOffset = ((float) 8 * expAcqTemp) - (float) iUser6; float acqTempCorrected = (float) iUser1 + calibOffset; acqTempCorrected /= 8; temperature = (float) -0.669162 * acqTempCorrected; temperature += 398.54; - appendToLog("expAcqTemp = " + expAcqTemp + ". calibOffset = " + calibOffset + ", acqTempCorrected = " + acqTempCorrected + ", temperature = " + temperature); + Logger.trace("expAcqTemp = {}, calibOffset = {}, acqTempCorrected = {}, temperature = {}", expAcqTemp, calibOffset, acqTempCorrected, temperature); } return temperature; } //4278 @@ -444,7 +412,7 @@ public String getEpc4upcSerial(EpcClass epcClass, String filter, String companyP String strValue = null; ParseSGTIN parseSGTIN = null; String strURI = "urn:epc:tag:"; - appendToLog("epcClass is " + epcClass.toString()); + Logger.trace("epcClass is {}", epcClass); switch (epcClass) { default: strURI += "sgtin-96:"; @@ -476,7 +444,7 @@ public String getUpcSerial(String strEpc) { String strHeader = "urn:epc:tag:"; if (strValue.indexOf(strHeader) == 0) strValue = strValue.substring(strHeader.length()); } catch (Exception e) { - appendToLog("parseSSCC exception: " + e.getMessage()); + Logger.trace("parseSSCC exception: {}", e.getMessage()); //throw new RuntimeException(e); } return strValue; @@ -520,7 +488,7 @@ public boolean checkHostProcessorVersion(String version, int majorVersion, int m if (version.length() == 0) return false; String[] versionPart = version.split("\\."); - if (versionPart == null) { appendToLog("NULL VersionPart"); return false; } + if (versionPart == null) { Logger.trace("NULL VersionPart"); return false; } try { int value = Integer.valueOf(versionPart[0]); if (value < majorVersion) return false; @@ -558,7 +526,7 @@ public float float16toFloat32(String strData) { fValue *= (1 + ((float)iMant / 1024)); if (iSign != 0) fValue *= -1; } - if (true) appendToLog("strData = " + strData + ", iValue = " + iValue + ", iSign = " + iSign + ", iExp = " + iExp + ", iMant = " + iMant + ", fValue = " + fValue); + Logger.trace("strData = {}, iValue = {}, iSign = {}, iExp = {}, iMant = {}, fValue = {}", strData, iValue, iSign, iExp, iMant, fValue); } return fValue; } @@ -591,7 +559,7 @@ public String str2float16(String strData) { } int iValue = (bSign ? 0x8000 : 0) + (iExp << 10) + iMant; strValue = String.format("%04X", iValue); - if (true) appendToLog("bSign = " + bSign + ", iExp = " + iExp + ", iMant = " + iMant + ", iValue = " + iValue + ", strValue = " + strValue); + Logger.trace("bSign = {}, iExp = {}, iMant = {}, iValue = {}, strValue = {}", bSign, iExp, iMant, iValue, strValue); } return strValue; }