本文整理汇总了C#中Power.UpdateFirmware方法的典型用法代码示例。如果您正苦于以下问题:C# Power.UpdateFirmware方法的具体用法?C# Power.UpdateFirmware怎么用?C# Power.UpdateFirmware使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Power
的用法示例。
在下文中一共展示了Power.UpdateFirmware方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
public void Start(Power firmware)
{
var config = new RestApiConfiguration();
config.AddHandler("GET", "/boot/ping", "is server alive")
.ReturnNothing()
.HandledBy(() => {});
config.AddHandler("GET", "/boot/firmware", "get firmware info")
.ReturnJson()
.HandledBy(() => firmware.GetFirmwareInfoAsJson());
config.AddHandler("PUT", "/boot/firmware", "update firmware")
.ReturnJson()
.HandledWithStreamBy((s) => firmware.UpdateFirmware(s));
config.AddHandler("POST", "/boot/sysinfo", "get system state")
.ReturnJson()
.HandledBy(() => HardwareInfo.Instance.GetSystemInfo());
config.AddHandler("POST", "/boot/diskinfo", "list content of filesystem")
.ReturnJson()
.HandledBy(() => HardwareInfo.Instance.GetDiskInfo());
config.AddHandler("GET", "/boot/networks", "list network information")
.ReturnJson()
.HandledBy(() => HardwareInfo.Instance.GetNetworkInterfaceInfo());
config.AddHandler("GET", "/boot/log/full", "get full log")
.ReturnJson()
.HandledBy(() => Logger.Instance.Full.GetLinesAsJson());
config.AddHandler("GET", "/boot/log/errors", "get error log")
.ReturnJson()
.HandledBy(() => Logger.Instance.Errors.GetLinesAsJson());
config.AddHandler("POST", "/boot/ntp/sync", "sync time with NTP")
.ReturnJson()
.HandledBy(() =>
{
RealTimeClock.Instance.UpdateFromNTP();
var status = new JsonObject();
status.Add("time", DateTime.Now);
return status;
});
config.AddHandler("POST", "/boot/reboot", "reboot the device")
.SetNotes("This will reboot the device and not return")
.ReturnNothing()
.HandledBy(() => firmware.Reboot());
var credentials = CredentialValidatorFactory.CreateSimpleValidator("ChickenHouse", "admin", "hnsefyk");
var webService = new WebService(c_servicePort, credentials, config);
string prefix = Name + ": ";
webService.Logging.OnLogInfo += message => Logger.Instance.LogInfo(prefix + message);
webService.Logging.OnLogError += message => Logger.Instance.LogError(prefix + message);
webService.Logging.OnLogException += (message, ex) => Logger.Instance.LogException(prefix + message, ex);
webService.Start();
}