0

I'd like to know how to represent C2D message and External message on IoT Edge module by IoT Plug & Play DTDL definition. I thought that a Command with a value of "asynchronous" in commandType property is used as C2D message. But when I check the behavior in IoT Central, such a command is handled as a direct method invocation. Is it possible to represent C2D message by IoT PnP model? If yes, please let me know how to describe that. regards,

1 Answers1

1

It is a fully managed service which enable secure bidirectional communication between large no of devices and back end.

  • Simulated Device: connects to your IoThub and receive cloud-to-device messages.

  • SendCloudToDevice: app Sends a cloud to device message to device app with the help of IOT hub.

To receive cloud-to-device messages from the IoT hub.

  1. Inside visual studio, in the Simulated Device project add given method to Simulated Device class.

     private static async void ReceiveC2dAsync()
         {
             Console.WriteLine("\nReceiving cloud to device messages from service");
             while (true)
             {
                 Message receivedMessage = await s_deviceClient.ReceiveAsync();
                 if (receivedMessage == null) continue;
        
                 Console.ForegroundColor = ConsoleColor.Yellow;
                 Console.WriteLine("Received message: {0}", 
                 Encoding.ASCII.GetString(receivedMessage.GetBytes()));
                 Console.ResetColor();
        
                 await s_deviceClient.CompleteAsync(receivedMessage);
             }
         }
  1. Add ReceiveC2dAsync() in main method before console.ReadLine().
SaiSakethGuduru
  • 2,218
  • 1
  • 5
  • 15
  • Hey @user18935372, has it solved your problem else you can share more details so I can troubleshoot? – SaiSakethGuduru May 05 '22 at 09:34
  • If the posted answer justifies your requirement, you may [mark it as the answer] by clicking the checkmark beside the answer. Doing so can benefit other community members – SaiSakethGuduru May 06 '22 at 10:35
  • Thank you for your response but... My question is not how to receive C2D messages on IoT Device App with SDK but how to describe C2D message in IoT Plug & Play definition by DTDL. Any idea for this topic? – user18935372 May 07 '22 at 06:23