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.
If a device (for example, an AgentLite device) reports data in JSON format, you do not need to define a codec.
Procedure
- On the Product Development page, enter the created product and click Codec Development.
- On the Online Codec Editor tab page, click Add Message.
- Set Message Name to LightData, select Data Reporting for Message Type, and click Add Field.
- In the dialog box displayed, set Name to LightIntensity, Data Type to int8u(8 bit unsigned integer), and Length to 1, and click OK.
- Click Add Field again to add switch status data reported.
- In the dialog box displayed, set Name to LightStatus, Data Type to int8u(8 bit unsigned integer), and Length to 1, and click OK.
- Click OK to complete the codec for data reporting messages.
- Click Add Message again to develop a codec for command delivery messages.
- Set Message Name to SwitchStatus, select Command Delivery for Message Type, and click Add Field.
- In the dialog box displayed, set Name to SwitchStatus, Data Type to string(string type), and Length to 3, and click OK.
- Click OK to complete the codec for command delivery messages.
- 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.
- Click Save in the upper right corner and click Deploy to complete codec deployment.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot