问题
When using a simulated device you can get its supported measurements (i.e. fragmentTypes) from the "c8y_SupportedMeasurements" field which for example for a temperature sensor looks as follows:
c8y_SupportedMeasurements: [ "c8y_TemperatureMeasurement" ]
When using a real device this field is not available. I can see the possible fragmentTypes when fetching the fetching the measurements for that particular device
/measurement/measurements?source=id
which gives me a list of measurements for the following fragmentTypes:
Humidity sensor
Temperature sensor
Battery
What is the correct way to fetch the supported fragmentTypes for a device in a similar way as it can be done with the simulators and the "c8y_SupportedMeasurements"-field?
回答1:
The c8y_SupportedMeasurements is an automatically generated fragement by Cumulocity. It updates when the device sends a measurement with a new fragment in it.
You can query supported measurements directly for a device like this (it will return only the c8y_SupportedMeasurements instead of the whole device object):
/inventory/managedObjects/{{deviceId}}/supportedMeasurements
This call will also trigger the initial calculation of supportedMeasurements based on the historic data of the device if the fragement did not exist at that point.
来源:https://stackoverflow.com/questions/37830322/how-to-get-supported-measurements-of-a-device-in-cumulocity