@@ -1376,7 +1376,7 @@ - (BOOL)sendAbortCommand {
13761376}
13771377
13781378- (BOOL )getTriggerKeyStatus {
1379-
1379+
13801380 @synchronized (self) {
13811381 if (connectStatus!=CONNECTED && connectStatus!=TAG_OPERATIONS) // reader is not idling for downlink command and not performing inventory
13821382 {
@@ -1385,11 +1385,11 @@ - (BOOL)getTriggerKeyStatus {
13851385 }
13861386 }
13871387 [cmdRespQueue removeAllObjects ];
1388-
1388+
13891389 // Initialize data
13901390 CSLBlePacket* packet= [[CSLBlePacket alloc ] init ];
13911391 // CSLBlePacket* recvPacket;
1392-
1392+
13931393 NSLog (@" ----------------------------------------------------------------------" );
13941394 NSLog (@" Get trigger key status command..." );
13951395 NSLog (@" ----------------------------------------------------------------------" );
@@ -1404,10 +1404,10 @@ - (BOOL)getTriggerKeyStatus {
14041404 packet.crc1 =0 ;
14051405 packet.crc2 =0 ;
14061406 packet.payload =[NSData dataWithBytes: getTriggerKeyStatus length: sizeof (getTriggerKeyStatus)];
1407-
1407+
14081408 NSLog (@" BLE packet sending: %@ " , [packet getPacketInHexString ]);
14091409 [self sendPackets: packet];
1410-
1410+
14111411 connectStatus=CONNECTED;
14121412 return true ;
14131413}
@@ -2985,7 +2985,10 @@ - (void)decodePacketsInBufferAsync;
29852985 }
29862986 }
29872987 else
2988+ {
2989+ [NSThread sleepForTimeInterval: 0 .001f ];
29882990 continue ;
2991+ }
29892992 }
29902993
29912994 NSLog (@" [decodePacketsInBufferAsync] RFID Packet buffer before arrival for packet: %@ " , [rfidPacketBuffer length ] == 0 ? @" (EMPTY)" : [CSLBleReader convertDataToHexString: rfidPacketBuffer]);
@@ -3331,20 +3334,20 @@ - (void)decodePacketsInBufferAsync;
33313334 NSUInteger findIndex = [filteredBuffer indexOfObject: tag
33323335 inSortedRange: searchRange
33333336 options: NSBinarySearchingInsertionIndex | NSBinarySearchingFirstEqual
3334- usingComparator: ^(id obj1, id obj2)
3335- {
3336- NSString * str1= ((CSLBleTag*)obj1).EPC ;
3337- NSString * str2= ((CSLBleTag*)obj2).EPC ;
3338- return [str1 compare: str2 options: NSCaseInsensitiveSearch];
3339- }];
3337+ usingComparator: ^(id obj1, id obj2) {
3338+ NSString * str1; NSString * str2;
3339+ str1 = ([obj1 isKindOfClass: [CSLReaderBarcode class ]]) ? ((CSLReaderBarcode*)obj1). barcodeValue : ((CSLBleTag*)obj1).EPC ;
3340+ str2 = ([obj2 isKindOfClass: [CSLReaderBarcode class ]]) ? ((CSLReaderBarcode*)obj2). barcodeValue : ((CSLBleTag*)obj2).EPC ;
3341+ return [str1 compare: str2 options: NSCaseInsensitiveSearch];
3342+ }];
33403343
33413344 if ( findIndex >= [filteredBuffer count ] ) // tag to be the largest. Append to the end.
33423345 {
33433346 [filteredBuffer insertObject: tag atIndex: findIndex];
33443347 uniqueTagCount++;
33453348
33463349 }
3347- else if ( [((CSLBleTag*)filteredBuffer[findIndex]).EPC caseInsensitiveCompare: tag.EPC] != NSOrderedSame)
3350+ else if ( [[filteredBuffer[findIndex] isKindOfClass: [CSLReaderBarcode class ]] ? ((CSLReaderBarcode*)filteredBuffer[findIndex]).barcodeValue : ((CSLBleTag*)filteredBuffer[findIndex]).EPC caseInsensitiveCompare: tag.EPC] != NSOrderedSame)
33483351 {
33493352 // new tag found. insert into buffer in sorted order
33503353 [filteredBuffer insertObject: tag atIndex: findIndex];
@@ -3467,20 +3470,19 @@ - (void)decodePacketsInBufferAsync;
34673470 NSUInteger findIndex = [filteredBuffer indexOfObject: tag
34683471 inSortedRange: searchRange
34693472 options: NSBinarySearchingInsertionIndex | NSBinarySearchingFirstEqual
3470- usingComparator: ^(id obj1, id obj2)
3471- {
3472- NSString * str1= ((CSLBleTag*)obj1).EPC ;
3473- NSString * str2= ((CSLBleTag*)obj2).EPC ;
3474- return [str1 compare: str2 options: NSCaseInsensitiveSearch];
3475- }];
3473+ usingComparator: ^(id obj1, id obj2) {
3474+ NSString * str1; NSString * str2;
3475+ str1 = ([obj1 isKindOfClass: [CSLReaderBarcode class ]]) ? ((CSLReaderBarcode*)obj1). barcodeValue : ((CSLBleTag*)obj1).EPC ;
3476+ str2 = ([obj2 isKindOfClass: [CSLReaderBarcode class ]]) ? ((CSLReaderBarcode*)obj2). barcodeValue : ((CSLBleTag*)obj2).EPC ;
3477+ return [str1 compare: str2 options: NSCaseInsensitiveSearch];
3478+ }];
34763479
34773480 if ( findIndex >= [filteredBuffer count ] ) // tag to be the largest. Append to the end.
34783481 {
34793482 [filteredBuffer insertObject: tag atIndex: findIndex];
34803483 uniqueTagCount++;
3481-
34823484 }
3483- else if ( [((CSLBleTag*)filteredBuffer[findIndex]).EPC caseInsensitiveCompare: tag.EPC] != NSOrderedSame)
3485+ else if ( [[filteredBuffer[findIndex] isKindOfClass: [CSLReaderBarcode class ]] ? ((CSLReaderBarcode*)filteredBuffer[findIndex]).barcodeValue : ((CSLBleTag*)filteredBuffer[findIndex]).EPC caseInsensitiveCompare: tag.EPC] != NSOrderedSame)
34843486 {
34853487 // new tag found. insert into buffer in sorted order
34863488 [filteredBuffer insertObject: tag atIndex: findIndex];
@@ -3672,16 +3674,16 @@ - (void)decodePacketsInBufferAsync;
36723674 NSUInteger findIndex = [filteredBuffer indexOfObject: barcode
36733675 inSortedRange: searchRange
36743676 options: NSBinarySearchingInsertionIndex | NSBinarySearchingFirstEqual
3675- usingComparator: ^(id obj1, id obj2)
3676- {
3677- NSString * str1= ((CSLReaderBarcode*)obj1).barcodeValue ;
3678- NSString * str2= ((CSLReaderBarcode*)obj2).barcodeValue ;
3679- return [str1 compare: str2 options: NSCaseInsensitiveSearch];
3680- }];
3677+ usingComparator: ^(id obj1, id obj2) {
3678+ NSString * str1; NSString * str2;
3679+ str1 = ([obj1 isKindOfClass: [CSLReaderBarcode class ]]) ? ((CSLReaderBarcode*)obj1).barcodeValue : ((CSLBleTag*)obj1). EPC ;
3680+ str2 = ([obj2 isKindOfClass: [CSLReaderBarcode class ]]) ? ((CSLReaderBarcode*)obj2).barcodeValue : ((CSLBleTag*)obj2). EPC ;
3681+ return [str1 compare: str2 options: NSCaseInsensitiveSearch];
3682+ }];
36813683
36823684 if ( findIndex >= [filteredBuffer count ] ) // tag to be the largest. Append to the end.
36833685 [filteredBuffer insertObject: barcode atIndex: findIndex];
3684- else if ( [((CSLReaderBarcode*)filteredBuffer[findIndex]).barcodeValue caseInsensitiveCompare: barcode.barcodeValue] != NSOrderedSame)
3686+ else if ( [[filteredBuffer[findIndex] isKindOfClass: [CSLReaderBarcode class ]] ? ((CSLReaderBarcode*)filteredBuffer[findIndex]).barcodeValue : ((CSLBleTag*)filteredBuffer[findIndex]).EPC caseInsensitiveCompare: barcode.barcodeValue] != NSOrderedSame)
36853687 // new tag found. insert into buffer in sorted order
36863688 [filteredBuffer insertObject: barcode atIndex: findIndex];
36873689 else // tag is duplicated, but will replace the existing tag information with the new one for updating the RRSI value.
0 commit comments