Codecs
How Can I Develop Codecs?
The IoT platform supports the codec online development. For details, see Online Development.
What Is the Code Rule for Fields of the string and varstring Types?
If Data Type of a field is string(string type) or varstring(variable-length string), the codec performs encoding and decoding using ACSII.
For details on the codec online development, see Codec for Strings and Variable-Length Strings.
What Is the Code Rule for Fields of the array and variant Types?
If Data Type is array(array type) or variant(variable-length array type), the codec performs encoding and decoding using Base64. For details on the codec online development, see Codec for Arrays and Variable-Length Arrays.
How Do I Use messageId During Online Codec Development?
When messages of the same type are created, such as two data reporting messages, messageId must be configured to distinguish these messages and this parameter in each message must be in the same place on the list. The messageId field applies to the following scenarios:
- There are two or more data reporting messages or command delivery messages.
- A command response can be regarded as a type of data reporting message. Therefore, if a command response exists, messageId must be added to the data reporting message.
- A data reporting response can be regarded as a type of command delivery message. Therefore, if a data reporting response exists, messageId must be added to the command delivery message.
How Do I Configure a Command Delivery Response During Online Codec Development?
- messageId must be configured in both the data reporting message and the command response, and this field in the two messages must be in the same place on the list, so that the codec can distinguish between the two.
- mid must be configured in the command delivery message and the command response, and this field in the two messages must be in the same place on the list, so that the codec can associate the two.
What Do I Do If a Codec That Was Developed Online Fails to Be Deployed?
Description:
You develop a codec on the development page and click Deploy. The deployment fails.
Possible Causes:
- If the codec is successfully downloaded but fails to be deployed, there may be network issues.
- If the codec fails to be downloaded, the possible causes are as follows:
- The value of messageId in the messages of the same type (for example, two data reporting messages) is duplicate or their positions in the messages are different.
- Data Type is not set to int for messageId.
- The default value of a field is not in hexadecimal format.
- A field name contains a Java keyword, for example, type or int.
Solutions:
- If the codec is successfully downloaded but fails to be deployed, check the network status and try again.
- If the codec fails to be downloaded, check whether the codec definition meets the requirements.
What Do I Do If a Script-based Codec or a Codec Developed Offline Fails in Encoding or Decoding?
- For a script-based codec, choose to debug the codec and modify the codec based on the debugging result.
- For a codec developed offline, debug the codec using the codec test tool and modify the codec based on the test result.
What Do I Do If a Codec That Was Developed Offline Fails to Be Deployed?
- Use the IoT codec test tool to check the codec.
- Rectify the fault based on the error code returned by the tool. For details on how to handle different errors, see User Guide for IoT Codec Test Tool in the tool package.
What Do I Do If a Codec That Was Developed Offline Fails to Be Uploaded?
Codecs that are developed offline must be checked before being uploaded to the IoT platform. Use the IoT codec test tool to check the codec package and rectify the fault based on the error message.
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