# Bidirectional communication between c8y platform and edge

**URL:** <https://community.cumulocity.com/t/bidirectional-communication-between-c8y-platform-and-edge/1068>\
**Category:** Forum\
**Tags:** thin-edge-io, cumulocity\
**Created:** [July 22, 2024, 7:24am UTC](https://community.cumulocity.com/t/bidirectional-communication-between-c8y-platform-and-edge/1068 "2024-07-22T07:24:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lorn\_Kjewlsvar](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/lorn_kjewlsvar/32/7097_2.png) [@Lorn\_Kjewlsvar](https://community.cumulocity.com/u/Lorn_Kjewlsvar)\
**Post date:** [July 22, 2024, 7:24am UTC](https://community.cumulocity.com/t/bidirectional-communication-between-c8y-platform-and-edge/1068/1 "2024-07-22T07:24:55Z")

</div>

#### _ **Product/components** used and **version/fix** level:_

thin edge latest, cumulocity platform

#### _Question related to a **free trial** , or to a **production (customer)** instance?_

customer instance

#### _Detailed explanation of the problem:_

Hello Cumulocity Community,

I have a question for SmartRest and custom SmartRest templates. We want to trigger an operation on the thinEdge edge device in a microservice to send data from the edge device to the cloud. Currently only one way works. We create an operation via the rest api with:

```auto
POST {{tenant_domain}}/devicecontrol/operations
Authorization: Basic {{user}} {{password}}

{
  "deviceId": "...",
  "description": "Execute maintenance command",
  "MaintenanceInformation": {
    "text": "maintenance command"
  }
}

```

And the microservice receives the message via smart rest. Now we also want to send specific data upstream into the cloud.

Probably I am misunderstanding something, but when the operation is triggered only the “response” is called and not the “message” part of the smart rest template. I thought that when I trigger an operation via the rest api it would send a message and not the response part of the smart rest template:

 ![grafik](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/2/7/272b99966df39bbfbe6a01e200af8e00828bb9e5.png)

 ![grafik](https://europe1.discourse-cdn.com/flex005/uploads/cumulocity/original/3X/3/7/37f137c881abef43318f24195d683b98d43fa039.png)

What I tried for sending the appropriate message was using the mqtt messages:

```auto
mqtt pub c8y/s/uc/MaintenanceInformation 5557,9876543210,test
mqtt pub c8y/s/uc/MaintenanceInformation 9876543210,test
mqtt pub c8y/s/uc/MaintenanceInformation/9876543210 test
mqtt pub c8y/s/uc/MaintenanceInformation/thinEdge-ID 9876543210,test
mqtt pub c8y/s/uc/MaintenanceInformation 5557,9876543210,test
mqtt pub c8y/s/us 501,MaintenanceInformation,test
mqtt pub c8y/s/us 501,MaintenanceInformation,test
mqtt pub c8y/s/us 504,MaintenanceInformation,test
mqtt pub c8y/s/us 504,9876543210,test
mqtt pub c8y/s/us 502,MaintenanceInformation,test
mqtt pub c8y/s/us 5557,9876543210,test
mqtt pub c8y/s/us/MaintenanceInformation 5557,9876543210,test
mqtt pub c8y/s/us/MaintenanceInformation 9876543210,test
mqtt pub c8y/s/us 506,9876543210,test
mqtt pub c8y/s/us 506,5557,test
mqtt pub c8y/s/us 506,5557
mqtt pub c8y/s/us 506,9876543210
mqtt pub c8y/s/us 501,MaintenanceInformation
mqtt pub c8y/s/us 506,MaintenanceInformation
mqtt pub c8y/s/us 503,MaintenanceInformation,test

```

The messages for setting the status of the operation worked for the smart rest template id. But I did not see any message related to an answer or possible data I need in the c8y platform. Or should I configure the smart rest template to another rest endpoint e.g. measurement or event api? Or am I using the wrong mqtt message path? I tried us and uc.

Also is there a detailed explaination somewhere what the different channels mean? I tried to figure it out like “u” for upstream and “d” for downstream and “us” would be upstream static for static templates etc. but I am not 100% sure.

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![Stefan\_Witschel](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/stefan_witschel/32/31955_2.png) [@Stefan\_Witschel](https://community.cumulocity.com/u/Stefan_Witschel)\
**Post date:** [July 22, 2024, 8:45am UTC](https://community.cumulocity.com/t/bidirectional-communication-between-c8y-platform-and-edge/1068/2 "2024-07-22T08:45:05Z")

</div>

The response templates are intended to be messages that are created in C8Y and should be handled by any device which are subscribed. Therefor if you create a message via REST and a fragment is matching the defined condition, it will always generate response messages (only).

Vice versa if a message should be created from a device into C8Y you can define message templates. It will be used by a device to send data to C8Y.

In your example you are trying to update an operation which is only meant to update the status of an operation with additionally adding fragments. See this example from the documentation:

```auto
# Creation:
# 10,msgId,method,api,response,fragment,custom1.path,custom1.type,custom1.value
10,999,PUT,OPERATION,,c8y_MyOperation,status,OPERATIONSTATUS,SUCCESSFUL,c8y_Fragment.val,NUMBER,
# Usage:
999,24

```

Which will add a new fragment “c8y\_Fragment” with value “val” 24 and sets the status of the operation to successful. Btw. it will always take the latest Operation type Executing and Pending.  
For you the message should look like this:

```auto
mqtt pub c8y/s/uc/MaintenanceInformation 5557,MaintenanceInformation,test

```

MaintenanceInformation should be the fragment that is used to identify the operation, test is the message send to your “text” fragment. You could also hard code “MaintenanceInformation” in your template, so it will only be `5557,test`

If you want in general send additional data I would suggest to create new events instead updating an operation which is kind of limited in its functionality due to the updating of latest Executing/Pending functionality.

---

<div class="post-metadata">

**Author:** ![Lorn\_Kjewlsvar](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/lorn_kjewlsvar/32/7097_2.png) [@Lorn\_Kjewlsvar](https://community.cumulocity.com/u/Lorn_Kjewlsvar)\
**Post date:** [August 7, 2024, 7:44am UTC](https://community.cumulocity.com/t/bidirectional-communication-between-c8y-platform-and-edge/1068/3 "2024-08-07T07:44:14Z")

</div>

Thank you, for your anwer. We are now using the operation just to trigger the data transmission on edge and we send the response over the normal REST api.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/flex005/user_avatar/community.cumulocity.com/system/32/31990_2.png) [@system](https://community.cumulocity.com/u/system)\
**Post date:** [February 3, 2025, 7:44am UTC](https://community.cumulocity.com/t/bidirectional-communication-between-c8y-platform-and-edge/1068/4 "2025-02-03T07:44:37Z")

</div>

Closed on February 3, 2025, 7:44am UTC

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