public DeviceCommandResult UpdateLedState(UpdateLedStateCommand command, CancellationToken token) { // validate input parameters if (command.Equipment != LED_CODE) return new DeviceCommandResult("Failed", "Invalid equipment parameter: " + command.Equipment); if (command.State == null || !new[] { 0, 1 }.Contains(command.State.Value)) return new DeviceCommandResult("Failed", "Invalid state parameter: " + command.State); // switch the LED state Console.WriteLine("Received UpdateLedState command, setting LED state to " + command.State); _ledState = command.State.Value; // send the notification about LED state update ServiceChannel.SendEquipmentNotification(command.Equipment, new LedNotification(command.State.Value)); // return the Completed status return new DeviceCommandResult("Completed"); }
public DeviceCommandResult UpdateLedState(UpdateLedStateCommand command, CancellationToken token) { // validate input parameters if (command.Equipment != LED_CODE) { return(new DeviceCommandResult("Failed", "Invalid equipment parameter: " + command.Equipment)); } if (command.State == null || !new[] { 0, 1 }.Contains(command.State.Value)) { return(new DeviceCommandResult("Failed", "Invalid state parameter: " + command.State)); } // switch the LED state Console.WriteLine("Received UpdateLedState command, setting LED state to " + command.State); _ledState = command.State.Value; // send the notification about LED state update ServiceChannel.SendEquipmentNotification(command.Equipment, new LedNotification(command.State.Value)); // return the Completed status return(new DeviceCommandResult("Completed")); }