Skip to main content

imp.setcountry(regionCode)

Specifies the imp’s WiFi regulatory territory at blessing

Availability

Device
Available for use in Factory Firmware only

Parameters

Name Type Description
regionCode Integer A constant specifying the device’s usage region

Returns

Nothing

Description

This method allows you to specify geographical regions in which an imp-based connected product is expected to operate. This primarily affects the number of channels within the 2.4GHz band (and, for the imp005 and imp006 with suitable WiFi module, the 5GHz band) that the device is permitted to use by the region’s regulatory bodies.

It is the responsibility of you the product vendor to enable the channel set which is applicable (and legal for) the region in which the device will be sold. Before choosing a region code to be used for a country-specific product, you must ensure that the product meets all the regulatory needs of that territory.

Region Imp Type regionCode Notes
US/Canada* imp001, 002, 003, 004m 0x00005355 2.4GHz channels 1-11
imp005 US: 0x00115858 2.4GHz channels 1-11, 5GHz channels 36-165
Canada: 0x03B64143 2.4GHz channels 1-11, 5GHz channels 36-112, 116, 132-165
The Canada channel set is smaller than the US set for 5GHz due to local regulations but otherwise the same
Europe imp001, 002, 003, 004m 0x00004247 This enables 2.4GHz channels 1-13, which are generally legal across the EU
imp005 0x037F3045 This enables 2.4GHz channels 1-13 and 5GHz channels 36-136 in steps of 4, which are generally legal across the EU. Please see our test reports that can help guide your CE self-certification process. Power levels are generally lower than the US due to the EN300-328 PSD limits
Japan imp001, 002, 003, 004m 0x00004247 This enables 2.4GHz channels 1-13
imp005 0x03B8504A This enables 2.4GHz channels 1-13 and 5GHz channels 36-136 in steps of 4
Other Countries imp001, 002, 003, 004m 0x00004247 Most countries follow either US or European standards. A compliance test house can advise you on the exact details and certifications required for each country; please contact Electric Imp Customer Support if you have questions about country codes
imp005 0x03D75658

*These codes correspond to the FCC/IC modular approval, and must be used to reuse those certifications.

This method is only available for use within factory firmware in order to set a production device’s region code after the device has been blessed. Attempting to use this method in development code or application firmware will result in a Squirrel error.

If a new country code is set when the imp is already connected to a WiFi network, the new code will only take effect when the imp next connects to a WiFi network. This disconnection and reconnection is typical behavior: the imp disconnects from the factory network, is powered down and then reconnects to the end-user’s network (enforcing the new country code) after BlinkUp™.

Using values other than those listed here is not supported — Squirrel will throw an error if you try to set an invalid code (ie. one not listed above). If you require other channel sets and/or region codes, please contact Electric Imp Customer Support.

Module-specific Information

imp005

The settings applied via imp.setcountry() will only take effect after an imp restart, eg. by calling imp.reset() or physically power-cycling the device (other imps will continue to enable the new settings on the next connection attempt).

impC001

The impC001 does not currently implement imp.setcountry().

Example Code

The following example shows the use of the imp.setcountry() method call in typical factory firmware. The method is called in the device under test (DUT) code flow in the post-bless callback, provided blessing has been successful. The code calls the function getRegionCode() to get the integer value to be passed into imp.setcountry(). getRegionCode() takes a two-character string which identifies the desired country or region; it uses imp.info() to determine the DUT’s imp type and apply the appropriate code.