in backend/MXApi/Services/IoTHubService.cs [25:41]
public async Task<bool> InvokeDeviceMethod(string deviceId, string message, string methodName)
{
try
{
var methodInvocation = new CloudToDeviceMethod(methodName) { ResponseTimeout = TimeSpan.FromSeconds(30) };
methodInvocation.SetPayloadJson($"'{message.Truncate(Constants.MaxMessageLength)}'");
await _serviceClient.InvokeDeviceMethodAsync(deviceId, methodInvocation);
}
catch (Exception e)
{
Trace.TraceError($"Failed to invoke device method: {e}");
return false;
}
return true;
}