AWSIotDeviceProperty annotation does not accept updates from the shadow.

0

Java SDK version: 1.3.0 (https://github.com/aws/aws-iot-device-sdk-java)
The @AWSIotDeviceProperty does not work properly.
I have the following example:
public class MyDevice extends AWSIotDevice {

public MyDevice(String thingName) {
super(thingName);
}

@AWSIotDeviceProperty
private float data;

public float getData(){
return data;
}

public void setData(float data){
this.data = data;
}
}

Lets assume that data value > 0 in the Shadow (simply from previous updates).
Once the created device attached to the client, data value changed to be 0.0 (or null for non primitive types)
After debugging, here some conclusions:
1 - Fields never synchronized by Shadow values, so they still have 0.0/null values, although
allowUpdate has true value by default. (Setter function never called to sync attributes values).
2 - Shadow calls Getter function (getData) every 3 seconds to keep the shadow updates, but as described in the previous clause, fields still have 0.0/null values, so Shadow will be synced with 0.0/null values.
3 - Getter function called every 3 seconds and Setter functions never called.

Is there a way to let @AWSIotDeviceProperty works in a bidirectional way so MyDevice attributes synced with Shadow values immediately after the attach and before Getter function called with 0.0/null ?

Thanks

Fadikh
asked 5 years ago205 views
1 Answer
0

Problem solved.
Since desire Json section missed, the device shadow service failed calculating the delta by iterating through each field in the desired state and comparing it to the reported state.
So it also failed published delta message to update/delta and setter method never called.

Edited by: Fadikh on May 5, 2019 12:41 AM

Fadikh
answered 5 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions