0

How can I extract from Measurements like

  • c8y_MotionMeasurement
  • c8y_AnalogMeasurement
  • c8y_SignalStrength

the attributes with Java Client? Example for c8y_MotionMeasurement content:

"c8y_MotionMeasurement":{
    "x":{
        "unit":"m/s^2",
        "value":0.046882
    },
    "y":{
        "unit":"m/s^2",
        "value":0.140647
    },
    "z":{
        "unit":"m/s^2",
        "value":0.984529
    }
}

Thanks

Stilltorik
  • 1,662
  • 4
  • 19
  • 31

1 Answers1

1

You can take a look at device-capability-model project. It already includes a lot of commonly used fragments. If the fragments you need exist you can do something like this in java:

Measurement m = ... // get measurement from c8y
SignalStrength s = m.get(c8y.SignalStrength.class);

If the fragment does not exist in device-capability-model I would recommend creating a class for that fragment in your project. Of course you can always handle everything as a map and just get the fragment (as Object) by the key.

m.get("c8y_SignalStrength")
TyrManuZ
  • 2,039
  • 1
  • 14
  • 23