International site device development
Developing products for the Chinese mainland website is different from developing for the Alibaba Cloud International Website. This topic describes the additional changes required for device development for the international website.
Background
IoT Platform supports three regions outside the Chinese mainland (including Hong Kong, Macao, and Taiwan): Singapore, US, and Germany. When devices outside the Chinese mainland are activated and connected to the network, they connect to a unified activation center in Singapore. When a device is attached, the platform automatically switches the device to the corresponding region based on the app user's location. For example:
- Example 1: If an app user selects the United States during registration, the platform switches the device to a server in the US region.
- Example 2: If an app user selects a European country during registration, the platform switches the device to a server in the Germany region.
- Example 3: If an app user selects a Southeast Asian country during registration, the device connects to a server in the Singapore region. In this case, no region switch is required.
Confirm that you are using IoT Platform SDK V1.1.0 or later. This SDK version includes the automatic region switchover feature for devices, so you do not need to modify the code. To obtain the SDK, see Get the SDK.
Compile using SDK V1.3.0 or later
When you develop using SDK V1.3.0 or later, follow these steps to compile the firmware for the international website.
- Modify the default variable parameters in build.sh.
For more information about the parameters in build.sh, see README.md.
Product type: default_type="example" Application name: default_app="smart_outlet" Module model: default_board="uno-91h" Cloud region: default_region=SINGAPORE // Set to MAINLAND to connect to the Chinese mainland. Cloud environment: default_env=ONLINE Debug log: default_debug=0 Other parameters: default_args="" // Configure other compile-time parameters.Note Set default_region to SINGAPORE to compile firmware for the international website. The script automatically handles other required configurations. To compile firmware for the Chinese mainland website, set this parameter to MAINLAND. - Run
./build.shto compile the firmware. The output firmware is stored in the out/smart_outlet@uno-91h/ folder.
Compile using SDK V1.1.0 (linkkitapp)
If you develop an application based on linkkitapp in AliOS Things, modify the following two configurations in the device firmware to support a unified connection to the Singapore activation center. Follow these steps:
- Change the domain type setting in the application code under the example folder.
In the
linkkit_main()function, change the value of domain_type from IOTX_CLOUD_REGION_SHANGHAI to IOTX_CLOUD_REGION_SINGAPORE, as shown in the following figure.
- In the example/linkkitapp/make.settings file, disable FEATURE_MQTT_DIRECT by setting it to n, as shown in the following figure.

- In the
application_startfunction, make sure thatset_iotx_info()is placed beforenetmgr_init(), as shown in the following figure.
- Compile the linkkitapp program.
For example, to compile the program for the mk3080 module, run the following command.
aos make linkkitapp@<module_name>The output firmware is stored in the out/linkkitapp@mk3080/binary/ folder.
Compile using SDK V1.1.0 (living_platform)
If you develop an application based on living_platform in AliOS Things, the example/living_platform/gen_firmware.sh compile script supports different options to compile firmware for the Chinese mainland and for regions outside the Chinese mainland. The domain type variable and the FEATURE_MQTT_DIRECT macro are automatically configured based on the selected option. You do not need to modify them manually.
Follow these steps to compile the firmware using the gen_firmware.sh script.
- Open the gen_firmware.sh file and specify the board as shown in the figure.

- Run the following command to run the script.
bash gen_firmware.sh
- Enter an option to compile the firmware.
The firmware encoding is as follows.
- c: Performs a clean operation before compilation.
- 3: Compiles firmware for the Chinese mainland website.
- 5: Compiles firmware for the international website.
- Find the compiled firmware.
The output firmware is stored in the out/living_platform@boardname/binary folder.
FAQ
Q: Can I leave FEATURE_MQTT_DIRECT enabled for devices on the international website?
A: No, you cannot. You must disable FEATURE_MQTT_DIRECT for devices on the international website. Otherwise, you may encounter GDPR compliance risks. Also, devices might fail to activate in some regions after they are configured and attached using a public version of the app.
Q: What should I do if I have already sent samples or shipped devices with FEATURE_MQTT_DIRECT enabled?
A: Modify the configuration as described in this topic as soon as possible. Then, perform an over-the-air (OTA) update for the device firmware. When you upgrade the device, select a silent upgrade (set the app confirmation option to No). Also, select a dynamic upgrade for the upgrade policy. A dynamic upgrade continuously updates the list of devices that require the upgrade, which includes devices that have already reported their version numbers and newly activated devices. You must first authenticate the firmware and then perform a batch upgrade. For more information about the OTA steps, see Firmware upgrade.
Q: What is the difference between enabling and disabling FEATURE_MQTT_DIRECT for devices on the Chinese mainland website?
A: Enabling FEATURE_MQTT_DIRECT uses the direct connection mode. Disabling FEATURE_MQTT_DIRECT uses the pre-authentication mode. Devices on the Chinese mainland website can establish connections in both modes. The difference is that the pre-authentication mode is slightly slower. Therefore, use the direct connection mode for devices on the Chinese mainland website and the pre-authentication mode for devices on the international website.
Q: Do I need to maintain two separate firmwares for devices on the Chinese mainland website and the international website?
A: Yes, you do. The ProductKey is different for devices on the Chinese mainland website and the international website. You must manage the device certificates and firmware accordingly during production and programming.
Q: Must I use IoT Platform SDK V1.1.0 or later for devices on the international website?
A: Yes, you must. The unified activation center for countries and regions outside the Chinese mainland (including Hong Kong, Macao, and Taiwan) requires that the device supports region switchover.
What to do next
After you finish device development for the international website, you must also develop the app. For more information, see Best practices for development for the international website.