Codec for Data Reporting and Command Delivery
Scenarios
A smoke detector provides the following functions:
- Reporting smoke alarms (fire severity) and temperature
- Remote command, which can enable the alarm function remotely
For example, the smoke detector can report the temperature on the fire scene and remotely trigger the smoke alarm for evacuation.
Defining the Profile File
- level: indicates the fire severity.
- temperature: indicates the temperature at the fire scene.
- SET_ALARM: indicates whether to enable or disable the alarm function. The value 0 indicates that the alarm is disabled, and the value 1 indicates that the alarm is enabled.
Developing a Codec
- In the development space of the smoke sensor, click Codec Development.
- Configure a data reporting message.
Add a level field to indicate the fire severity.
- Name can contain only letters, digits, underscores (_), and dollar signs ($) and cannot start with a digit.
- Data Type is configured based on the data reported by the device and must match the type defined in the profile file.
- The values of Length and Offset are automatically filled based on Data Type.
Add the temperature field to indicate the temperature at the fire scene. In the profile file, the maximum value of temperature is 1000. Therefore, set the data type of the temperature field to int16u in the codec to meet the value range requirement of temperature.
- Configure a command delivery message.
Add the value field to indicate the parameter value of the delivered command.
- Map the property fields and command fields in Device Model on the right with the fields in the data reporting message and command delivery message.
- Click Save and then Deploy to deploy the codec on the IoT platform.
Testing the Codec
- In the development space of the smoke sensor, click Online Testing and add a virtual device to test the codec.
Select No for Is Physical Device Available and click OK.
- Use the device simulator to report data. For example, a hexadecimal code stream (02013A) is reported. In this code stream, 02 indicates the fire severity and its length is one byte. 013A indicates the temperature and its length is two bytes.
View the data reporting result ({level=2, temperature=314}) in Application Simulator. 2 is the decimal number converted from the hexadecimal number 02 and 314 from the hexadecimal number 013A.
- Use the application simulator to deliver a command ({ "serviceId": "Smoke", "method": "SET_ALARM", "paras": "{\"value\":1}" }).
View the command receiving result in Device Simulator, which is 01. 01 is the hexadecimal number converted from the decimal number 1.
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