HarmonyOS Native SDK
Device Communication
Read Data Points

Read Data Points

Each transport capability provides a read API. Pass undefined for all data points or an array of names for selected data points.

Read through BLE

const allBleData = await device.bleCapability.readDataPoints(device, undefined);
const selectedBleData = await device.bleCapability.readDataPoints(device, ['power']);

Complete BLE connection and authentication first.

Read through LAN

const allLanData = await device.lanCapability.readDataPoints(device, undefined);
const selectedLanData = await device.lanCapability.readDataPoints(
  device,
  ['power', 'temperature']
);

Read through MQTT

const allCloudData = await device.mqttCapability.readDataPoints(device, undefined);
const selectedCloudData = await GizMqttManager.readDeviceDataPoints(device, ['power']);

Only one MQTT read command may wait for a response per device at a time.

Result

All three transports return GizDataPointEvent. Its data, alerts, and faults fields contain normal values, alerts, and faults. binary contains raw bytes and source identifies the transport. Use Event Listening for continuous reports.