Regulatory Configuration

Applicable Devices : RFD40, RFD90, RFD8500

Overview

Gets and sets the regulatory parameters of an active RFID reader, using srfidGetRegulatoryConfig and srfidSetRegulatoryConfig.

Details

The SDK supports managing of regulatory related parameters of a particular active RFID reader. Regulatory configuration includes the following:

  • Code of selected region
  • Hopping
  • Set of enabled channels

A set of enabled channels shall include only such channels that are supported in the selected region. If hopping configuration is not allowed for the selected region a set of enabled channels shall not be specified.

Regulatory parameters could be retrieved and set via srfidGetRegulatoryConfig and srfidSetRegulatoryConfig API functions accordingly. The following examples demonstrate retrieving of current regulatory settings and configuring the RFID reader to operate in one of supported regions.

Get Regulatory Configuration

The getRegulatoryConfig method retrieves the current regulatory settings and prints them.


-(void)getRegulatoryConfig {

    /* allocate object for storage of regulatory settings */
    srfidRegulatoryConfig *regulatory_cfg = [[srfidRegulatoryConfig alloc] init];

    /* an object for storage of error response received from RFID reader */
    NSString *error_response = nil;

    /* retrieve regulatory parameters */
    SRFID_RESULT result = [apiInstance srfidGetRegulatoryConfig:readerID aRegulatoryConfig:&regulatory_cfg aStatusMessage:&error_response];
    if (SRFID_RESULT_SUCCESS == result)
    {
        /* regulatory configuration received */
        if (NSOrderedSame == [[regulatory_cfg getRegionCode] caseInsensitiveCompare:@"NA"])
        {
            NSLog(@"Regulatory: region is NOT set\n");
        }
        else
        {
            NSLog(@"Region code: %@\n", [regulatory_cfg getRegionCode]);
            SRFID_HOPPINGCONFIG hopping_cfg = [regulatory_cfg getHoppingConfig];
            NSLog(@"Hopping is %@\n", ((SRFID_HOPPINGCONFIG_DISABLED == hopping_cfg) ? @"off" : @"on"));
            NSArray *channels = [regulatory_cfg getEnabledChannelsList];
            for (NSString *str in channels)
            {
                NSLog(@"Enabled channel: %@\n", str);
            }
        }
    }
    else
    {
        NSLog(@"Failed to receive regulatory parameters\n");
    }
}

Set Regulatory Configuration

The setRegulatoryConfig method selects the last supported region, enables hopping and channels where the region allows it, and applies the settings.


-(void)setRegulatoryConfig {
    /* an object for storage of error response received from RFID reader */
    NSString *error_response = nil;
    SRFID_RESULT result = SRFID_RESULT_FAILURE;

    /* code of region to be set as current one */
    NSString *region_code = @"USA";
    /* an array of enabled channels to be set */
    NSMutableArray *enabled_channels = [[NSMutableArray alloc] init];
    /* hopping to be set */
    SRFID_HOPPINGCONFIG hopping_on = SRFID_HOPPINGCONFIG_DISABLED;

    /* allocate object for storage of region information */
    NSMutableArray *regions = [[NSMutableArray alloc] init];

    /* retrieve supported regions */
    result = [apiInstance srfidGetSupportedRegions:readerID aSupportedRegions:&regions aStatusMessage:&error_response];

    if (SRFID_RESULT_SUCCESS == result)
    {

        /* supported regions information received */
        /* select the last supported region to be set as current one */
        region_code = [NSString stringWithFormat:@"%@", [(srfidRegionInfo*)[regions lastObject] getRegionCode]];

    }

    /* allocate object for storage of supported channels information */
    NSMutableArray *supported_channels = [[NSMutableArray alloc] init];
    BOOL hopping_configurable = NO;

    /* retrieve detailed information about region specified by region code */
    result = [apiInstance srfidGetRegionInfo:readerID aRegionCode:region_code aSupportedChannels:&supported_channels aHoppingConfigurable:&hopping_configurable aStatusMessage:&error_response];

    if (SRFID_RESULT_SUCCESS == result)
    {
        /* region information received */
        if (YES == hopping_configurable)
        {

            /* region supports hopping */
            /* enable first and last channels from the set of supported channels */
            [enabled_channels addObject:[supported_channels firstObject]];
            [enabled_channels addObject:[supported_channels lastObject]];
            /* enable hopping */
            hopping_on = SRFID_HOPPINGCONFIG_ENABLED;

        }
        else
        {
            /* region does not support hopping */
            /* request to not configure hopping */
            hopping_on = SRFID_HOPPINGCONFIG_DEFAULT;
        }
    }
    error_response = nil;
    /* configure regulatory parameters to be set */
    srfidRegulatoryConfig *regulatory_cfg = [[srfidRegulatoryConfig alloc] init];
    [regulatory_cfg setRegionCode:region_code];
    [regulatory_cfg setEnabledChannelsList:enabled_channels];
    [regulatory_cfg setHoppingConfig:hopping_on];

    /* set regulatory parameters */
    result = [apiInstance srfidSetRegulatoryConfig:readerID aRegulatoryConfig:regulatory_cfg aStatusMessage:&error_response];
    if (SRFID_RESULT_SUCCESS == result)
    {
        /* regulatory configuration applied */
        NSLog(@"Regulatory configuration has been set\n");
    }
    else if (SRFID_RESULT_RESPONSE_ERROR == result)
    {
        NSLog(@"Error response from RFID reader: %@\n", error_response);
    }
    else
    {
        NSLog(@"Failed to set regulatory parameters\n");
    }
}