I've registered a trial account to test Cumulocity and its mqtt api. I want to send operation to some device (currently emulated by java service) and receive operation result.
As manual I use the following links:
- https://www.cumulocity.com/guides/users-guide/device-management/#-a-name-operation-monitoring-a-working-with-operations
- https://cumulocity.com/guides/device-sdk/mqtt#hello-mqtt-java
The following code is used to make a response to Cumulocity.
if (payload.startsWith("510")) {
System.out.println("Simulating device restart...");
client.publish("s/us", "501,c8y_Restart".getBytes(), 2, false);
System.out.println("...restarting...");
Thread.sleep(TimeUnit.SECONDS.toMillis(1));
client.publish("s/us", "503,c8y_Restart".getBytes(), 2, false);
System.out.println("...done...");
}
501
code means that restart operation started and 503
code means that device restarted successfully.
But actually in Cumulocity UI operation status has changed to Pending
.
If I send restart
operation again the previous operation will changed to Success
but the new one to Pending
.
So, what am I doing wrong?
I expect to mark the operation as Failed
or Success
.