Cloud to device operation is not being listened on the device firmware script

Product/components used and version/fix level are you on:

Detailed explanation of the problem:

I have been trying to achieve real time control feature by attempting to execute function in device from cloud

For achieving the same ,i Invoke below endpoint as mentioned.

which always remaining pending and no callback function is invoked on my script through the topic which i subscribe to

below is my script code

image

i tenant i pass tenantid as string
and in device id i pass device id of the thin edge which i have created

I am not able to achieve call back through this implementation

Also all the invocation remains pending

Any help would be appreciated

Error messages / full error message screenshot / log fileL

Is your question related to the free trial, or to a production (customer) instance?

Have you installed all the latest fixes for the products and systems you are using?

n

Hi,

there are a few things you need to consider.

  1. When subscribing you don’t specify the tenant or the device-Id.
    To subscribe to standard messages, just subscribe to the topic s/ds as explained here.
    Important is the MQTT client ID you are setting (in your case “yourclientid”). This needs to match the c8y_Serial “Identity” of the actual device in Cumulocity.

  2. Then still the operation will stay in pending state, as you need to publish an MQTT message to tell the Cumulocity platform that you are working on it (hence set it to executing state.
    In your case the MQTT message would be 501,c8y_Command. Setting the operation to successful uses the template 503, see this example:

https://cumulocity.com/guides/reference/device-management-library/#send-a-command-to-a-device

See the full list of static templates here:

https://cumulocity.com/guides/reference/smartrest-two/#mqtt-static-templates

Thanks very much

I have doubt regarding c8y_Serial

I can see it in my device management,and will it be same as mentioned above?

but there is nothing such as this tag when i query twin from API .i can only see it in device management

also should i specify the serial of thin edge here or the downstream device such as sensor?

Also regarding the point no 2.

  1. is status Pending,executing ,succesful have to be changed manually or it is done manually once request passes through different stages?
  2. is there any place where i can learn about calling workflow?

Yes exactly. In your case the MQTT client ID needs to match this, here: FS012…

The external ID can be queried by this API: Identity-API

  1. The state changes always need to be performed by the device, by publishing MQTT messages to indicate which status the operation is in.
  2. Yes: MQTT client examples - Cumulocity IoT Guides

Thanks for the answer

I have been trying to connect and receive commands using python script given in example above,However i am not succcesful to receive the command yet

am i doing something wrong?

Are you actually using thin-edge.io in your setup here? Because all other comment (except for the one quoted above) would suggest no.

yes i am using thin edge
I am trying out with samples to invoke operations in thin edge

Though in that case, then your child connector (python script) should not be trying to connect to Cumulocity, but rather the local MQTT broker. Thin-edge.io takes care of the cloud connection (with the help of the mosquitto broker).

This new repository might be able to give you a few pointers

It provides a containerized thin-edge setup. It also has two containers which act as child devices where they run a python script which connects to local MQTT broker used by thin-edge.io. The child-device folder might be of some help regarding creating a python connector.

2 Likes

Hi

I have successfully installed edge with running containers

Which script exactly to run to simulate firmware with respect to this demo?

You should not need to start the script manually. Once you’ve done the four steps described in Getting Started section a Device and two child-devices should appear in your tenant. Now you can:

  • Go to Device Management > Management > Firmware Repository and create a new Entry
  • Go to your Device > Child Devices > Select one of both > Firmware. From there you can install your Firmware uploaded in the previous step.

You will then see the Operation transitioning from Pending to Executing to Successful. Also, two Events will be shown in the Devices “Events” Tab. I’ve just tested it and worked fine for me.

If you want to change what’s done with the downloaded Firmware File within the container, here seems a good place to look at.

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.