I am trying to implement this same method in C# but can't find an equivalent for the javascript const patch = {..}
I also don't really understand what is going on here - why does the patch have a property 'rundiagnostics' which seems to be the method name, and why are the twin reported properties being updated.
I am wanting to process a long running command and reflect the result in the commands response. It is not entirely clear how IoT Central handles the long running commands so any additional explanation would be welcome. Maybe a sequence diagram or two (??).
Link to docs here
client.onDeviceMethod('rundiagnostics', commandHandler);
// ...
const commandHandler = async (request, response) => {
switch (request.methodName) {
case 'rundiagnostics': {
console.log('Starting long-running diagnostics run ' + request.payload);
await sendCommandResponse(request, response, 202, 'Diagnostics run started');
// Long-running operation here
// ...
const patch = {
rundiagnostics: {
value: 'Diagnostics run complete at ' + new Date().toLocaleString()
}
};
deviceTwin.properties.reported.update(patch, function (err) {
if (err) throw err;
console.log('Properties have been reported for component');
});
break;
}
default:
await sendCommandResponse(request, response, 404, 'unknown method');
break;
}
};