tencent cloud

IoT Hub

IoT Hub 정책
개인 정보 보호 정책
데이터 개인 정보 보호 및 보안 계약
문서IoT Hub

Device Status Reporting

포커스 모드
폰트 크기
마지막 업데이트 시간: 2024-12-27 09:54:58

Directions for SDK for C

Program implementation

As an example, the energy consumption status is reported to the device shadow through the call of IOT_Shadow_Update by the following function in the SDK code sample/scenarized/aircond_shadow_sample_v2.c. Then, the corresponding callback function is registered to handle the response of the device shadow. You can customize the reported attributes here.
_do_report_energy_consumption(...)
...
IOT_Shadow_Update(...)

Program compilation and execution

1. Run ./aircond_shadow_sample_v2. Please note that if MQTT asymmetric encryption is used, the root certificate, device certificate, and device key files should be placed in the parent directory of ./../certs.
2. Call the relevant RESTful API to get the status data of the shadow. For detailed directions, please see "Querying and getting device information". Observe the output log of the demo:
get_device_shadow_v1

3. Run ./door_mqtt_sample come_home/leave_home airConditioner1. door1 will communicate with airConditioner1, and then airConditioner1 will be instructed to turn on through the rule engine. The reported changes in energy consumption and indoor temperature can be observed in the log, and the shadow data is obtained again through the RESTful API (as detailed in step 2):
get_device_shadow_v2

It can be seen that after airConditioner1 is turned on, the air conditioner energy consumption is dynamically reported to the shadow, and the data can be successfully queried and obtained through the RESTful API.

Directions for SDK for Android

Program implementation

Program compilation and execution

Querying and getting device information

Call the RESTful API GetDeviceShadow to get the status data of the shadow, which is used by the application to display the device's energy consumption. The RESTful API request parameter is: deviceName=airConditioner1, productName=AirConditioner.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백