示例#1
0
 public bool Reset()
 {
     try
     {
         MQTTManager.Publish(new PublishMessage(GetResetTopic(), "true"));
         return(true);
     }
     catch (Exception ex)
     {
         Logger.LogError("An Error Occured: {0} \r\nStack: {1}", ex.Message, ex.StackTrace);
         return(false);
     }
 }
示例#2
0
 //Public
 public bool UpDateConfig(DeviceConfig newConfig)
 {
     try
     {
         var change = DeviceConfig.CreateChangeObject(Config, newConfig);
         var json   = change.ToJSON();
         if (json != "{}")
         {
             MQTTManager.Publish(new PublishMessage(GetConfigTopic() + "/set", json));
         }
         return(true);
     }
     catch (Exception ex)
     {
         Logger.LogError("An Error Occured: {0} \r\nStack: {1}", ex.Message, ex.StackTrace);
         return(false);
     }
 }
示例#3
0
 public (bool sent, string code) SendFirmware(string checksum, string firmware)
 {
     try
     {
         var publishSuccess = MQTTManager.Publish(new PublishMessage(GetFWChecksumTopic(checksum), firmware));
         if (publishSuccess)
         {
             var code = MQTTManager.WaitForMessage(GetFWStatusTopic(), doSee: false, timeout: TimeSpan.FromSeconds(20)).Result;
             return(true, code?.Message ?? "Faild to recive status");
         }
         else
         {
             return(false, "Faild to publish");
         }
     }
     catch (Exception ex)
     {
         Logger.LogError("An Error Occured: {0} \r\nStack: {1}", ex.Message, ex.StackTrace);
         return(false, "An Error Occured");
     }
 }