Skip to main content

imp.getcountry()

Returns the imp’s specified WiFi regulatory territory

Availability

Device (from impOS™ 30)

Returns

String — the imp’s set region

Description

This method tells you which geographical region the imp has been set to operate within.

An imp’s specified region primarily affects the number of channels within the 2.4GHz band that it is permitted to use by the region’s regulatory bodies. In the US, the device is limited to channels 1 through 11; elsewhere, this range is extended to channels 12 and 13.

As such, imp.getcountry() will return one of the following values:

  • "00005355" — US/Canada, may be returned by any imp
  • "00004247" — The rest of the world, may be returned by any imp
  • "00005A58" — Global, returned only by an imp005 running impOS™ 34 or up when connected by WiFi
  • "00235A58" — Global, returned only by an imp005 running impOS 34 or up when connected by Ethernet
  • "03B64143" — Canada, returned only by an imp005 running impOS 34 or up when connected by Ethernet
  • "037F3045" — Europe, returned only by an imp005 running impOS 34 or up when connected by Ethernet

Note Though imp.getcountry() returns region codes as strings, the regions are set by passing numeric constants into imp.setcountry(). You should also note that, for the imp005, there are two possible strings that may be returned by imp.getcountry() even though only a single numeric constant, 0x235A58, is used to select the global region.

Module-specific Information

impC001

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

Example Code

The following function can be used to identify the number of WiFi channels a device is able to utilize. You might use this information to provide, for example, debugging data to the device’s user through your mobile app. If the imp has been set to the US region, you can warn the user to make sure their WiFi router is not set to make use of channels 12 and 13. Many modern routers will automatically choose the least busy channel; if that is 12 or 13, this can prevent a device limited to channels 1 to 11 from connecting.