This topic uses the TG7100C chip as an example to describe how to develop a smart socket for a Tmall Genie ecosystem project. It covers how to debug network provisioning and cloud connections with a development board, perform over-the-air (OTA) updates, and use device certificates for mass production.
Create and configure a product
Create a Tmall Genie ecosystem project. For more information, see Create a project.
Create a product of the Socket category.

Define product features.
On the Feature Definition page, you can configure the product features. For more information, see Add a standard feature.
NoteFor a Tmall Genie ecosystem project, features related to device timers require the DeviceTimer property. This property is automatically added to the Feature Definition page after you configure the human-computer interaction timer service in step 4.
Configure human-computer interaction.
If you want to use Bluetooth-assisted network provisioning on the TG7100C chip, set the provisioning method to Bluetooth-assisted network provisioning.

For information about other configuration items, see Configure human-computer interaction.
On the Device Debugging interface, click Add Test Device to generate a test device certificate.
Bluetooth-assisted network provisioning requires the Wi-Fi MAC address to be the same as the DeviceName in the device certificate. On the TG7100C development board, you can run the mac command through the serial port after the firmware is running to query the current Wi-Fi MAC address of the chip. Use this MAC address as the DeviceName to request a test device certificate on the Device Debugging page.
NoteAll letters in the MAC address must be lowercase.
Example of querying a Wi-Fi MAC address
#mac MAC address: 18-b9-05-c0-6e-d5Enter the lowercase MAC address, such as 18b905c06ed5 in the example, as the DeviceName to generate a test device.

Copy the test device certificate.
NoteMake sure to copy the following items in order: 1. ProductKey, 2. DeviceName, 3. DeviceSecret, 4. ProductSecret, and 5. ProductID.

Provision the network and connect the device to the cloud
Set the device certificate.
After you flash the device firmware to the development board, run the linkkey command to set the device certificate. Then, run the reset command to reset the device.
After the device is powered on, write the complete device certificate information to the development board.
linkkey ProductKey DeviceName DeviceSecret ProductSecret ProductIDReset the device to purge network provisioning information.
reset
Set up network provisioning using the Tmall Genie app.
After you set the device certificate on the development board and reset the device, the device enters the pending provisioning state. It then broadcasts its Bluetooth-assisted network provisioning information over Bluetooth Low Energy (BLE).
The Tmall Genie app can discover devices in the pending provisioning state on its device discovery page. You can initiate Bluetooth-assisted network provisioning for the device from the app interface.
The network provisioning process in the Tmall Genie app is shown in the following figure.
Set up network provisioning using a Tmall Genie speaker.
Use the speech input "Tmall Genie, find teammates" to initiate zero-touch provisioning.
Key logs on the device during network provisioning and cloud connection.
Bluetooth-assisted network provisioning
Network Provisioning Status
Command/Action
Expected Log
Device reset
reset
start-----------hal
Enable Bluetooth-assisted network provisioning
ble_awss
ble_awss_open
Parse SSID/PWD
Device parses hot spot information
IOTX_AWSS_GOT_SSID_PASSWD
AP Connect
Device connects to the AP
IOTX_AWSS_CONNECT_ROUTER
DHCP Get IP
Device obtains an IP address
IOTX_AWSS_GOT_IP
Cloud Connect
Successfully connected to the cloud
Cloud Connected
Zero-touch provisioning
Provisioning State
Command/Action
Expected Log
Device reset
reset
start-----------hal
Dev Scan
awss
IOTX_AWSS_START
Awss Process
active_awss
IOTX_AWSS_ENABLE
Parse SSID/PWD
Device parses hot spot information
IOTX_AWSS_GOT_SSID_PASSWD
AP Connect
Device connects to the AP
IOTX_AWSS_CONNECT_ROUTER
DHCP Get IP
Device obtains an IP address
IOTX_AWSS_GOT_IP
Cloud Connect
Cloud connection successful
Cloud Connected
One-click provisioning
Provisioning State
Command/Action
Expected Log
Device reset
reset
start-----------hal
Dev Scan
awss
IOTX_AWSS_START
Awss Process
active_awss
IOTX_AWSS_ENABLE
Parse SSID/PWD
Device parses hot spot information
IOTX_AWSS_GOT_SSID_PASSWD
AP Connect
Device connects to the AP
IOTX_AWSS_CONNECT_ROUTER
DHCP Get IP
Device obtains an IP address
IOTX_AWSS_GOT_IP
Cloud Connect
Cloud connection successful
Cloud Connected
On-device timer feature
Developing the on-device timer feature for a Tmall Genie ecosystem project is different from developing it for a private brand project. The local timer feature for private brand projects is based on the LocalTimer property. The local timer feature for Tmall Genie ecosystem projects is based on the DeviceTimer property.
For information about developing the timer feature for private brand projects, see Develop the on-device local timer feature.
Therefore, when you define product features in the console, add the DeviceTimer property. Ensure that the scheduling widget is added to the panel.
For a detailed description of console configuration and device-side development, see Develop the on-device timer feature for a Tmall Genie project Wi-Fi product.
Firmware OTA
This section describes the OTA procedure for a Tmall Genie ecosystem project product.
Go to the Operations Hub of IoT Platform.
Go to the page and select the product under the relevant project.

Obtain the firmware file to be upgraded and its version information. After the TG7100C firmware is compiled, the version information is saved in the readme.txt file. The tg7100cevb_ota.bin file is the OTA binary file.

Go to Firmware Upgrade and perform the following steps in the Firmware List window.
Click Add Firmware.
In the Firmware Version Number field, copy and enter the OTA firmware version number.
In the Signature Algorithm field, select SHA256. This is required for the TG7100C chip firmware.
Under Select Firmware, click Upload Firmware to select and upload the OTA.bin file.
Click OK to add the firmware.

Open the Tmall Genie app. On the product page for the device you want to authenticate, click Update Now to start the OTA upgrade.

Once the upgrade is complete, you can check its status in the Operations Hub.

Mass Production Devices
As described in the previous section, the Bluetooth-assisted network provisioning solution requires you to write a device certificate to the device, and the DeviceName must be the same as the Wi-Fi MAC address. For testing, you can generate a device certificate on the Device Debugging page after you read the Wi-Fi address of the development board. This section describes how to generate and obtain device certificates during the mass production stage. For detailed instructions on mass producing devices on the IoT Platform, see Mass production flow and Mass produce devices.
Automatically generate device certificates.
IoT Platform provides MAC address segments for products in a Tmall Genie ecosystem project. On the Human-Computer Interaction page, you can select Bluetooth-assisted network provisioning in the Network Provisioning Guide. This lets you assign a valid MAC address as the DeviceName when you generate device certificates.
NoteThe downloaded DeviceName (MAC address) must be in all lowercase letters. Keep the text in lowercase during subsequent processing.
During flashing, use the mass production flashing tool to write the DeviceName and overwrite the chip's Wi-Fi MAC address. This ensures that the DeviceName and the Wi-Fi MAC address are the same.
When mass producing a Tmall Genie ecosystem project product, select automatic generation.

Add the ProductSecret and ProductID to the device certificate, which includes the ProductKey, DeviceName, and DeviceSecret by default.
The downloaded device certificate checklist must be processed by a text editor to generate a format that is compatible with the TG7100C batch flashing tool.

Add the
ProductSecretandProductIDcontent to the device certificate checklist. The spelling and capitalization ofProductSecret,ProductIDin the first row must be strictly followed. You can process the file using a text editor or by writing a text handler.NoteDo not edit the file with Excel. Excel might convert the CSV file to its own format.

Flash the device certificates.
In the Resource Center, download the TG7100C Mass Production Guide - Flashing. Follow the document to import the CSV file that contains the device certificates into the database, and then flash the certificates.






