Azure / azure-iot-sdk-csharp

A C# SDK for connecting devices to Microsoft Azure IoT services
Other
468 stars 492 forks source link

addresses supporting byte[] in direct methods and making TwinProperties able to be directly converted to json #3340

Closed patilsnr closed 1 year ago

patilsnr commented 1 year ago

addresses supporting byte[] in direct methods and making TwinProperties able to be directly converted to json

API surface diff:


namespace Microsoft.Azure.Devices.Client {
    public class DirectMethodRequest {
+       public byte[] GetPayload()
-               public byte[] GetPayloadAsBytes()
    }

       public class DirectMethodResponse {
+             public byte[] Payload { get; set; }
-             public object Payload { get; set; }
+             public object PayloadAsObject { get; set; }
       }

       public class EdgeModuleDirectMethodRequest {
+             internal byte[] Payload { get; set; }
-             internal object Payload { get; set; }
+             internal object PayloadAsObject { get; set; }              
       }
}

namespace Microsoft.Azure.Devices {
      public class DirectMethodClientResponse {
+           internal byte[] PayloadAsBytes { get; set; }
      }

      public class DirectMethodServiceRequest {
+          public byte[] Payload { get; set; }     
-           public object Payload { get; set; }
+          public object PayloadAsObject { get; set; }   
    }
}
patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
rido-min commented 1 year ago

@patilsnr can you paste the Json returned by twin.GetSerializedJson? I'd like to check the reported and desired versions are properly formatted.

patilsnr commented 1 year ago

@patilsnr can you paste the Json returned by twin.GetSerializedJson? I'd like to check the reported and desired versions are properly formatted.

image

These are logs from the ThermostatSample that calls the method in question. I'm not sure what it should look like -- what do you think of this?

rido-min commented 1 year ago

I don't see the reported/desired versions

patilsnr commented 1 year ago

I don't see the reported/desired versions

image

How about this?

rido-min commented 1 year ago

Can you paste the text (json) we get from GetTwinAsyc ? we need the $version for reported and desired.

patilsnr commented 1 year ago

Can you paste the text (json) we get from GetTwinAsyc ? we need the $version for reported and desired.

Sure:

image

In this case, a brand new device will return the string expected when we call GetTwinPropertiesAsync (which calls GetTwinAsync internally. Debugging this test shows this for the variable twin that we get back:

image image

Let me know if this is what you're looking for, this should hopefully show that both reported and desired properties are returning the correct version numbers as well as serializing properly

rido-min commented 1 year ago

this should be the same as V1 Twin.ToJson()

{
  "reported" : {
      "$version" : 1
  },
  "desired" : {
     "$version" : 1
  }
}
patilsnr commented 1 year ago

this should be the same as V1 Twin.ToJson()

{
  "reported" : {
      "$version" : 1
  },
  "desired" : {
     "$version" : 1
  }
}
image

Okay, with the exception of the key names being different (reported vs reportedProperties) they seem to be the same

patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago

No commit pushedDate could be found for PR 3340 in repo Azure/azure-iot-sdk-csharp

patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago

No commit pushedDate could be found for PR 3340 in repo Azure/azure-iot-sdk-csharp

patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago

No commit pushedDate could be found for PR 3340 in repo Azure/azure-iot-sdk-csharp

patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago

No commit pushedDate could be found for PR 3340 in repo Azure/azure-iot-sdk-csharp

patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago

No commit pushedDate could be found for PR 3340 in repo Azure/azure-iot-sdk-csharp

patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago

No commit pushedDate could be found for PR 3340 in repo Azure/azure-iot-sdk-csharp

patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).
patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago

No commit pushedDate could be found for PR 3340 in repo Azure/azure-iot-sdk-csharp

patilsnr commented 1 year ago

/azp run

azure-pipelines[bot] commented 1 year ago
Azure Pipelines successfully started running 1 pipeline(s).