Develop a Tmall Genie ecosystem project for a smart socket

更新时间:
复制 MD 格式

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

  1. Create a Tmall Genie ecosystem project. For more information, see Create a project.

  2. Create a product of the Socket category.

    创建猫精产品

  3. Define product features.

    On the Feature Definition page, you can configure the product features. For more information, see Add a standard feature.

    Note

    For 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.

  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.

  5. 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.

    Note

    All letters in the MAC address must be lowercase.

    1. Example of querying a Wi-Fi MAC address

      #mac
      MAC address: 18-b9-05-c0-6e-d5
    2. Enter the lowercase MAC address, such as 18b905c06ed5 in the example, as the DeviceName to generate a test device.猫精测试三元组

    3. Copy the test device certificate.

      Note

      Make 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

  1. 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 ProductID
    • Reset the device to purge network provisioning information.

      reset
  2. 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.

  3. Set up network provisioning using a Tmall Genie speaker.

    Use the speech input "Tmall Genie, find teammates" to initiate zero-touch provisioning.

  4. 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.

Note

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.

  1. Go to the Operations Hub of IoT Platform.

  2. Go to the Device Data > Firmware Upgrade page and select the product under the relevant project.

    添加新版本固件

  3. 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.

    或者OTA文件和版本号

  4. Go to Firmware Upgrade and perform the following steps in the Firmware List window.

    1. Click Add Firmware.

    2. In the Firmware Version Number field, copy and enter the OTA firmware version number.

    3. In the Signature Algorithm field, select SHA256. This is required for the TG7100C chip firmware.

    4. Under Select Firmware, click Upload Firmware to select and upload the OTA.bin file.

    5. Click OK to add the firmware.

    添加固件

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

    OTA过程

  6. 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.

  1. 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.

      Note

      The 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.猫精三元组自动生成

  2. 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.三元组csv示例

    • Add the ProductSecret and ProductID content to the device certificate checklist. The spelling and capitalization of ProductSecret,ProductID in the first row must be strictly followed. You can process the file using a text editor or by writing a text handler.

      Note

      Do not edit the file with Excel. Excel might convert the CSV file to its own format.

      五元组清单示例

  3. 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.