Updated on 2022-02-24 GMT+08:00

Developing a Codec Online

Scenarios

Generally, devices report hexadecimal data to reduce power consumption. The codec converts the hexadecimal data into JSON data based on properties defined in the profile file so that the IoT platform and NAs can identify the data. In addition, when an NA remotely delivers a control command, the IoT platform converts the command in JSON format into hexadecimal and delivers the data to the device.

NOTE:

If a device (for example, an AgentLite device) reports data in JSON format, you do not need to define a codec.

Procedure

  1. On the Product Development page, enter the created product and click Codec Development.
  2. On the Online Codec Editor tab page, click Add Message.

  3. Set Message Name to LightData, select Data Reporting for Message Type, and click Add Field.

  4. In the dialog box displayed, set Name to LightIntensity, Data Type to int8u(8 bit unsigned integer), and Length to 1, and click OK.

  5. Click Add Field again to add switch status data reported.
  6. In the dialog box displayed, set Name to LightStatus, Data Type to int8u(8 bit unsigned integer), and Length to 1, and click OK.

  7. Click OK to complete the codec for data reporting messages.
  8. Click Add Message again to develop a codec for command delivery messages.
  9. Set Message Name to SwitchStatus, select Command Delivery for Message Type, and click Add Field.

  10. In the dialog box displayed, set Name to SwitchStatus, Data Type to string(string type), and Length to 3, and click OK.

  11. Click OK to complete the codec for command delivery messages.
  12. Drag the property and command fields (defined in the profile file) in the Device Model area on the right to map the fields in the data report and command delivery messages defined by the codec.

  13. Click Save in the upper right corner and click Deploy to complete codec deployment.