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); } }
//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); } }
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"); } }