Overview
Performs an inventory, an advanced inventory that reads from a particular memory bank at the same time, using srfidStartInventory and srfidStopInventory.
Details
Inventory is an advanced inventory operation being performed simultaneously with reading from a particular memory bank.
Inventory operation is performed similarly to the rapid read operation described above. Thus performing and aborting of the inventory operation is requested through srfidStartInventory and srfidStopInventory API functions accordingly. After request of operation performing the actual operation will be started in accordance with the configured start trigger parameters and will be stopped once conditions specified by stop trigger parameters are met. After the operation has stopped it might be started again if it is not aborted and the repeat monitoring option is enabled in start trigger configuration. The SDK informs the application about starting and stopping of the actual operation through corresponding asynchronous notifications.
The SDK will deliver asynchronous notifications to inform the application about tag data received from the RFID reader during the on-going operation if the application has subscribed for events of this type. Fields to be reported during asynchronous tag data related notification are configured via reportConfig parameter of srfidStartInventory API function.
The following examples demonstrate performing of a continuous inventory operation with reading from EPC memory bank that starts on a press of a physical trigger and stops on a release of a physical trigger or after a 25 second timeout.
Start and Stop Inventory
-(void)startStopInventory{
/* subscribe for tag data related events */
[apiInstance srfidSubsribeForEvents:SRFID_EVENT_MASK_READ];
/* subscribe for operation start/stop related events */
[apiInstance srfidSubsribeForEvents:SRFID_EVENT_MASK_STATUS];
/* identifier of one of active RFID readers is supposed to be stored in readerID variable */
/* allocate object for start trigger settings */
srfidStartTriggerConfig *start_trigger_cfg = [[srfidStartTriggerConfig alloc] init];
/* allocate object for stop trigger settings */
srfidStopTriggerConfig *stop_trigger_cfg = [[srfidStopTriggerConfig alloc] init];
/* allocate object for report parameters of inventory operation */
srfidReportConfig *report_cfg = [[srfidReportConfig alloc] init];
/* allocate object for access parameters of inventory operation */
srfidAccessConfig *access_cfg = [[srfidAccessConfig alloc] init];
/* an object for storage of error response received from RFID reader */
NSString *error_response = nil;
do {
/* configure start triggers parameters to start on physical trigger press */
[start_trigger_cfg setStartOnHandheldTrigger:YES];
[start_trigger_cfg setTriggerType:SRFID_TRIGGERTYPE_PRESS];
[start_trigger_cfg setStartDelay:0];
[start_trigger_cfg setRepeatMonitoring:YES];
/* configure stop triggers parameters to stop on physical trigger release or on 25 sec timeout */
[stop_trigger_cfg setStopOnHandheldTrigger:YES];
[stop_trigger_cfg setTriggerType:SRFID_TRIGGERTYPE_RELEASE];
[stop_trigger_cfg setStopOnTimeout:YES];
[stop_trigger_cfg setStopTimout:(25*1000)];
[stop_trigger_cfg setStopOnTagCount:NO];
[stop_trigger_cfg setStopOnInventoryCount:NO];
[stop_trigger_cfg setStopOnAccessCount:NO];
/* set start trigger parameters */
SRFID_RESULT result = [apiInstance srfidSetStartTriggerConfiguration:readerID aStartTriggeConfig:start_trigger_cfg aStatusMessage:&error_response];
if (SRFID_RESULT_SUCCESS == result) {
/* start trigger configuration applied */
NSLog(@"Start trigger configuration has been set\n");
}
else {
NSLog(@"Failed to set start trigger parameters\n");
break;
}
/* set stop trigger parameters */
result = [apiInstance srfidSetStopTriggerConfiguration:readerID aStopTriggeConfig:stop_trigger_cfg aStatusMessage:&error_response];
if (SRFID_RESULT_SUCCESS == result) {
/* stop trigger configuration applied */
NSLog(@"Stop trigger configuration has been set\n");
}
else {
NSLog(@"Failed to set stop trigger parameters\n");
break;
}
/* start and stop triggers have been configured */
error_response = nil;
/* configure report parameters to report RSSI and Channel Index fields */
[report_cfg setIncPC:NO];
[report_cfg setIncPhase:NO];
[report_cfg setIncChannelIndex:YES];
[report_cfg setIncRSSI:YES];
[report_cfg setIncTagSeenCount:NO];
[report_cfg setIncFirstSeenTime:NO];
[report_cfg setIncLastSeenTime:NO];
/* configure access parameters to perform the operation with 27.0 dBm antenna power level without application of pre-filters */
[access_cfg setPower:270];
[access_cfg setDoSelect:NO];
/* request performing of inventory operation with reading from EPC memory bank */
result = [apiInstance srfidStartInventory:readerID aMemoryBank:SRFID_MEMORYBANK_EPC aReportConfig:report_cfg aAccessConfig:access_cfg aStatusMessage:&error_response];
if (SRFID_RESULT_SUCCESS == result) {
NSLog(@"Request succeed\n");
/* request abort of an operation after 1 minute */
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(60 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[apiInstance srfidStopInventory:self->readerID aStatusMessage:nil];
});
}
else if (SRFID_RESULT_RESPONSE_ERROR == result) {
NSLog(@"Error response from RFID reader: %@\n", error_response);
}
else {
NSLog(@"Request failed\n");
}
} while (0);
}
Operation Status Event
The SDK calls srfidEventStatusNotify: when the radio operation starts and stops.
- (void)srfidEventStatusNotify:(int)readerID aEvent:(SRFID_EVENT_STATUS)event aNotification:(id)notificationData {
NSLog(@"Radio operation has %@\n", ((SRFID_EVENT_STATUS_OPERATION_START == event) ? @"started" : @"stopped"));
}
Tag Data Event
The SDK calls srfidEventReadNotify: for each tag received from the reader. The method also prints the memory bank data when the tag report includes it.
- (void)srfidEventReadNotify:(int)readerID aTagData:(srfidTagData *)tagData {
/* print the received tag data */
NSLog(@"Tag data received from RFID reader with ID = %d\n", readerID);
NSLog(@"Tag id: %@\n", [tagData getTagId]);
SRFID_MEMORYBANK bank = [tagData getMemoryBank];
if (SRFID_MEMORYBANK_NONE != bank) {
NSString *str_bank = @"";
switch (bank) {
case SRFID_MEMORYBANK_EPC:
str_bank = @"EPC";
break;
case SRFID_MEMORYBANK_TID:
str_bank = @"TID";
break;
case SRFID_MEMORYBANK_USER:
str_bank = @"USER";
break;
case SRFID_MEMORYBANK_RESV:
str_bank = @"RESV";
break;
case SRFID_MEMORYBANK_NONE:
str_bank = @"None";
break;
case SRFID_MEMORYBANK_ACCESS:
str_bank = @"Access";
break;
case SRFID_MEMORYBANK_KILL:
str_bank = @"Kill";
break;
case SRFID_MEMORYBANK_ALL:
str_bank = @"All";
break;
}
NSLog(@"%@ memory bank data: %@\n", str_bank, [tagData getMemoryBankData]);
}
}