Overview
Sets the batch mode (BATCHMODECONFIG) of the RFID reader, using srfidSetBatchModeConfig.
Details
Pass one of the SRFID_BATCHMODECONFIG values to srfidSetBatchModeConfig:
SRFID_BATCHMODECONFIG_DISABLE(0x00)SRFID_BATCHMODECONFIG_AUTO(0x01)SRFID_BATCHMODECONFIG_ENABLE(0x02)
A success result means that the reader accepted the command. To be sure that the reader applied it, read the value back with Get Batch Mode. The second example does that.
Set Batch Mode Configuration
- (SRFID_RESULT)setBatchModeConfig:(SRFID_BATCHMODECONFIG)batchMode statusMessage:(NSString **)statusMessage
{
SRFID_RESULT result = SRFID_RESULT_FAILURE;
for (int i = 0; i < 2; i++)
{
result = [apiInstance srfidSetBatchModeConfig:readerID aBatchModeConfig:batchMode aStatusMessage:statusMessage];
if ((result != SRFID_RESULT_RESPONSE_TIMEOUT) && (result != SRFID_RESULT_FAILURE)) {
break;
}
}
if (result == SRFID_RESULT_SUCCESS)
{
NSLog(@"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 and Confirm
This method sets the batch mode, reads it back and returns YES only if the reader reports the value you set.
- (BOOL)setBatchModeAndConfirm:(SRFID_BATCHMODECONFIG)batchMode
{
NSString *status = nil;
if ([self setBatchModeConfig:batchMode statusMessage:&status] != SRFID_RESULT_SUCCESS) {
return NO;
}
/* read the batch mode back to check that the reader kept it */
SRFID_BATCHMODECONFIG current;
if ([self getBatchModeConfig:¤t statusMessage:&status] != SRFID_RESULT_SUCCESS) {
NSLog(@"Could not read the batch mode back");
return NO;
}
if (current != batchMode) {
NSLog(@"The reader reports %@, not %@", [self batchModeName:current], [self batchModeName:batchMode]);
return NO;
}
return YES;
}