66import android .widget .TextView ;
77import android .widget .Toast ;
88
9- import com .csl .cs108library4a . Cs108Library4A ;
9+ import com .csl .cslibrary4a . RfidReaderChipData ;
1010
1111import java .util .ArrayList ;
1212
@@ -18,6 +18,7 @@ public enum TaskCancelRReason {
1818 }
1919 public TaskCancelRReason taskCancelReason ;
2020 public String accessResult ;
21+ public String accessTagEpc ;
2122 Handler mHandler = new Handler ();
2223 Runnable updateRunnable = null ;
2324
@@ -27,7 +28,7 @@ public enum TaskCancelRReason {
2728 boolean invalidRequest ;
2829 String selectMask ; int selectBank , selectOffset ;
2930 String strPassword ; int powerLevel ;
30- Cs108Library4A .HostCommands hostCommand ;
31+ RfidReaderChipData .HostCommands hostCommand ;
3132
3233 CustomMediaPlayer playerO , playerN ;
3334
@@ -46,10 +47,11 @@ public enum TaskCancelRReason {
4647
4748 boolean gotInventory ;
4849 int batteryCountInventory_old ;
50+ boolean bSkipClearFilter = false ;
4951
5052 public AccessTask (Button button , boolean invalidRequest ,
5153 String selectMask , int selectBank , int selectOffset ,
52- String strPassword , int powerLevel , Cs108Library4A .HostCommands hostCommand ,
54+ String strPassword , int powerLevel , RfidReaderChipData .HostCommands hostCommand ,
5355 boolean bEnableErrorPopWindow , Runnable updateRunnable ) {
5456 this .button = button ;
5557 this .registerTagGot = registerTagGot ;
@@ -72,10 +74,9 @@ public AccessTask(Button button, boolean invalidRequest,
7274 }
7375 public AccessTask (Button button , TextView textViewWriteCount , boolean invalidRequest ,
7476 String selectMask , int selectBank , int selectOffset ,
75- String strPassword , int powerLevel , Cs108Library4A .HostCommands hostCommand ,
76- int qValue , int repeat , boolean resetCount ,
77- TextView registerRunTime , TextView registerTagGot , TextView registerVoltageLevel ,
78- TextView registerYieldView , TextView registerTotalView ) {
77+ String strPassword , int powerLevel , RfidReaderChipData .HostCommands hostCommand ,
78+ int qValue , int repeat , boolean resetCount , boolean bSkipClearFilter ,
79+ TextView registerRunTime , TextView registerTagGot , TextView registerVoltageLevel , TextView registerYieldView , TextView registerTotalView ) {
7980 this .button = button ;
8081 this .registerTotal = textViewWriteCount ;
8182 this .registerRunTime = registerRunTime ;
@@ -94,6 +95,7 @@ public AccessTask(Button button, TextView textViewWriteCount, boolean invalidReq
9495 this .qValue = qValue ;
9596 if (repeat > 255 ) repeat = 255 ;
9697 this .repeat = repeat ;
98+ this .bSkipClearFilter = bSkipClearFilter ;
9799 if (resetCount ) {
98100 total = 0 ;
99101 tagList .clear ();
@@ -105,7 +107,7 @@ public void setRunnable(Runnable updateRunnable) {
105107 }
106108
107109 void preExecute () {
108- accessResult = null ;
110+ accessResult = null ; MainActivity . csLibrary4A . appendToLog ( "accessResult is set null" );
109111 playerO = MainActivity .sharedObjects .playerO ;
110112 playerN = MainActivity .sharedObjects .playerN ;
111113 //playerN.start();
@@ -135,7 +137,7 @@ void preExecute() {
135137
136138 if (invalidRequest == false ) {
137139 if (strPassword .length () != 8 ) { invalidRequest = true ; MainActivity .csLibrary4A .appendToLog ("strPassword.length = " + strPassword .length () + " (not 8)." ); }
138- else if (hostCommand == Cs108Library4A .HostCommands .CMD_18K6CKILL ) {
140+ else if (hostCommand == RfidReaderChipData .HostCommands .CMD_18K6CKILL ) {
139141 if (MainActivity .csLibrary4A .setRx000KillPassword (strPassword ) == false ) {
140142 invalidRequest = true ; MainActivity .csLibrary4A .appendToLog ("setRx000KillPassword is failed" );
141143 }
@@ -149,14 +151,21 @@ else if (hostCommand == Cs108Library4A.HostCommands.CMD_18K6CKILL) {
149151 invalidRequest = true ; MainActivity .csLibrary4A .appendToLog ("setAccessRetry is failed" );
150152 }
151153 }
154+ MainActivity .csLibrary4A .appendToLog ("setSelectCriteria: invalidRequest = " + invalidRequest + ", repeat = " + repeat + ", bSkipClearFilter = " + bSkipClearFilter + ", powerLevel = " + powerLevel + ", skipSelect = " + skipSelect );
152155 if (invalidRequest == false ) {
153156 if (DEBUG ) MainActivity .csLibrary4A .appendToLog ("AccessTask(): powerLevel = " + powerLevel );
154157 int matchRep = 1 ;
155158 if (repeat > 1 ) matchRep = repeat ;
159+ if (bSkipClearFilter == false ) {
160+ MainActivity .csLibrary4A .appendToLog ("Going to setSelectCriteria disable" );
161+ MainActivity .csLibrary4A .setSelectCriteriaDisable (-1 );
162+ }
156163 if (powerLevel < 0 || powerLevel > 330 ) invalidRequest = true ;
157- else if (skipSelect ) { }
158- else if (MainActivity .csLibrary4A .setSelectedTag (selectMask , selectBank , selectOffset , powerLevel , qValue , matchRep ) == false ) {
159- invalidRequest = true ; MainActivity .csLibrary4A .appendToLog ("setSelectedTag is failed with selectMask = " + selectMask + ", selectBank = " + selectBank + ", selectOffset = " + selectOffset + ", powerLevel = " + powerLevel );
164+ else if (skipSelect == false ) {
165+ MainActivity .csLibrary4A .appendToLog ("setSelectCriteria: Going to setSelectTag" );
166+ if (MainActivity .csLibrary4A .setSelectedTag (selectMask , selectBank , selectOffset , powerLevel , qValue , matchRep ) == false ) {
167+ invalidRequest = true ; MainActivity .csLibrary4A .appendToLog ("setSelectedTag is failed with selectMask = " + selectMask + ", selectBank = " + selectBank + ", selectOffset = " + selectOffset + ", powerLevel = " + powerLevel );
168+ }
160169 }
161170 }
162171 gotInventory = false ;
@@ -173,10 +182,13 @@ else if (MainActivity.csLibrary4A.setSelectedTag(selectMask, selectBank, selectO
173182 }
174183 }
175184
185+ boolean accessCompleteReceived = false ;
186+
176187 @ Override
177188 protected String doInBackground (Void ... a ) {
178189 boolean ending = false ;
179190 int iTimeOut = 5000 ;
191+ accessCompleteReceived = false ;
180192
181193 while (MainActivity .csLibrary4A .isBleConnected () && isCancelled () == false && ending == false ) {
182194 int batteryCount = MainActivity .csLibrary4A .getBatteryCount ();
@@ -189,12 +201,13 @@ protected String doInBackground(Void... a) {
189201 publishProgress ("WW" );
190202 }
191203 byte [] notificationData = MainActivity .csLibrary4A .onNotificationEvent ();
192- Cs108Library4A .Rx000pkgData rx000pkgData = MainActivity .csLibrary4A .onRFIDEvent ();
204+ RfidReaderChipData .Rx000pkgData rx000pkgData = MainActivity .csLibrary4A .onRFIDEvent ();
193205 if (MainActivity .csLibrary4A .mrfidToWriteSize () != 0 ) timeMillis = System .currentTimeMillis ();
194206 else if (rx000pkgData != null ) {
195207 if (rx000pkgData .responseType == null ) {
196208 publishProgress ("null response" );
197- } else if (rx000pkgData .responseType == Cs108Library4A .HostCmdResponseTypes .TYPE_18K6C_TAG_ACCESS ) {
209+ } else if (rx000pkgData .responseType == RfidReaderChipData .HostCmdResponseTypes .TYPE_18K6C_TAG_ACCESS ) {
210+ accessCompleteReceived = true ;
198211 MainActivity .csLibrary4A .appendToLog ("rx000pkgData.dataValues = " + MainActivity .csLibrary4A .byteArrayToString (rx000pkgData .dataValues ));
199212 if (rx000pkgData .decodedError == null ) {
200213 if (done == false ) {
@@ -207,7 +220,8 @@ else if (rx000pkgData != null) {
207220 done = true ;
208221 } else publishProgress (rx000pkgData .decodedError );
209222 iTimeOut = 1000 ;
210- } else if (rx000pkgData .responseType == Cs108Library4A .HostCmdResponseTypes .TYPE_COMMAND_END ) {
223+ } else if (rx000pkgData .responseType == RfidReaderChipData .HostCmdResponseTypes .TYPE_COMMAND_END ) {
224+ if (hostCommand == RfidReaderChipData .HostCommands .CMD_18K6CKILL && accessCompleteReceived == false ) accessResult = "" ;
211225 MainActivity .csLibrary4A .appendToLog ("BtData: repeat = " + repeat + ", decodedError = " + rx000pkgData .decodedError + ", resultError = " + resultError );
212226 if (rx000pkgData .decodedError != null ) { endingMessaage = rx000pkgData .decodedError ; ending = true ; }
213227 else if (repeat > 0 && resultError .length () == 0 ) {
@@ -218,7 +232,8 @@ else if (repeat > 0 && resultError.length() == 0) {
218232 endingMessaage = "" ;
219233 ending = true ;
220234 }
221- } else if (rx000pkgData .responseType == Cs108Library4A .HostCmdResponseTypes .TYPE_18K6C_INVENTORY ) {
235+ } else if (rx000pkgData .responseType == RfidReaderChipData .HostCmdResponseTypes .TYPE_18K6C_INVENTORY ) {
236+ accessTagEpc = MainActivity .csLibrary4A .byteArrayToString (rx000pkgData .decodedEpc );
222237 done = false ;
223238 publishProgress ("TT" , MainActivity .csLibrary4A .byteArrayToString (rx000pkgData .decodedEpc ));
224239 } else {
0 commit comments