Hi @PhangGuanRongEE-8742 Have you looked into the Service Client? The class provides an implementation for the method invokeDeviceMethod(string, DeviceMethodParams)
which lets you call the direct method on the device through an SDK.
Here is a sample implementation of the method.
// Invoke the direct method on the device, passing the payload.
private static async Task InvokeMethodAsync(string deviceId, ServiceClient serviceClient)
{
var methodInvocation = new CloudToDeviceMethod("SetTelemetryInterval")
{
ResponseTimeout = TimeSpan.FromSeconds(30),
};
methodInvocation.SetPayloadJson("10");
Console.WriteLine($"Invoking direct method for device: {deviceId}");
// Invoke the direct method asynchronously and get the response from the simulated device.
CloudToDeviceMethodResult response = await serviceClient.InvokeDeviceMethodAsync(deviceId, methodInvocation);
Console.WriteLine($"Response status: {response.Status}, payload:\n\t{response.GetPayloadAsJson()}");
}
You can modify the line of the code SetPayloadJson
and pass each of these options "0xFC 0x74 0x01 0x00 0xFE 0x71"
iteratively by calling this function.
Please refer to the resource Control a device which provides the implementation in C#, Node.js, Python and Java.
Hope this helps! Please let us know if this works for you and feel free to comment below with any follow up questions you may have.