Overview
Sets the USB batch mode (BATCHMODECONFIG) of the RFID reader, using srfidSetUSBBatchModeConfig.
Details
Pass one of the SRFID_BATCHMODECONFIG values to srfidSetUSBBatchModeConfig. A success result means that the reader accepted the command. To be sure that the reader applied it, read the value back with Get USB Batch Mode. The second example does that.
Set USB Batch Mode Configuration
- (SRFID_RESULT)setUSBBatchModeConfig:(SRFID_BATCHMODECONFIG)batchMode statusMessage:(NSString **)statusMessage
{
SRFID_RESULT result = SRFID_RESULT_FAILURE;
for (int i = 0; i < 2; i++)
{
result = [apiInstance srfidSetUSBBatchModeConfig:readerID aBatchModeConfig:batchMode aStatusMessage:statusMessage];
if ((result != SRFID_RESULT_RESPONSE_TIMEOUT) && (result != SRFID_RESULT_FAILURE)) {
break;
}
}
if (result == SRFID_RESULT_SUCCESS)
{
NSLog(@"USB batch mode set to %@", [self batchModeName:batchMode]);
}
else if (result == SRFID_RESULT_RESPONSE_ERROR)
{
NSLog(@"Response error: %@", (statusMessage != NULL && *statusMessage != nil) ? *statusMessage : @"");
}
else
{
NSLog(@"Timeout or failure");
}
return result;
}
Set USB and Confirm
This method sets the USB batch mode, reads it back and returns YES only if the reader reports the value you set.
- (BOOL)setUSBBatchModeAndConfirm:(SRFID_BATCHMODECONFIG)batchMode
{
NSString *status = nil;
if ([self setUSBBatchModeConfig:batchMode statusMessage:&status] != SRFID_RESULT_SUCCESS) {
return NO;
}
/* read the USB batch mode back to check that the reader kept it */
SRFID_BATCHMODECONFIG current;
if ([self getUSBBatchModeConfig:¤t statusMessage:&status] != SRFID_RESULT_SUCCESS) {
NSLog(@"Could not read the USB batch mode back");
return NO;
}
if (current != batchMode) {
NSLog(@"The reader reports %@, not %@", [self batchModeName:current], [self batchModeName:batchMode]);
return NO;
}
return YES;
}