public string UpdateConfig(IHttpContext context) { var errorMsg = ""; var json = ""; JsonInternetSettingsData settings; context.Response.StatusCode = 200; try { var data = new StreamReader(context.Request.InputStream).ReadToEnd(); // Start at char 5 to skip the "json:" prefix json = WebUtility.UrlDecode(data.Substring(5)); // de-serialize it to the settings structure settings = json.FromJson <JsonInternetSettingsData>(); } catch (Exception ex) { var msg = "Error de-serializing Internet Settings JSON: " + ex.Message; cumulus.LogMessage(msg); cumulus.LogDebugMessage("Internet Data: " + json); context.Response.StatusCode = 500; return(msg); } // process the settings try { cumulus.LogMessage("Updating internet settings"); // website settings try { cumulus.FtpOptions.Enabled = settings.website.enabled; if (cumulus.FtpOptions.Enabled) { cumulus.FtpOptions.Directory = settings.website.directory ?? string.Empty; cumulus.FtpOptions.Port = settings.website.ftpport; cumulus.FtpOptions.Hostname = settings.website.hostname ?? string.Empty; cumulus.FtpOptions.FtpMode = (Cumulus.FtpProtocols)settings.website.sslftp; cumulus.FtpOptions.Password = settings.website.password ?? string.Empty; cumulus.FtpOptions.Username = settings.website.username ?? string.Empty; cumulus.FtpOptions.SshAuthen = settings.website.sshAuth ?? string.Empty; cumulus.FtpOptions.SshPskFile = settings.website.pskFile ?? string.Empty; cumulus.DeleteBeforeUpload = settings.website.general.ftpdelete; cumulus.FTPRename = settings.website.general.ftprename; cumulus.UTF8encode = settings.website.general.utf8encode; if (cumulus.FtpOptions.FtpMode == Cumulus.FtpProtocols.FTP || cumulus.FtpOptions.FtpMode == Cumulus.FtpProtocols.FTPS) { cumulus.FtpOptions.AutoDetect = settings.website.advanced.autodetect; cumulus.FtpOptions.ActiveMode = settings.website.advanced.activeftp; cumulus.FtpOptions.DisableEPSV = settings.website.advanced.disableftpsepsv; } if (cumulus.FtpOptions.FtpMode == Cumulus.FtpProtocols.FTPS) { cumulus.FtpOptions.DisableExplicit = settings.website.advanced.disableftpsexplicit; cumulus.FtpOptions.IgnoreCertErrors = settings.website.advanced.ignorecerts; } } cumulus.FtpOptions.LocalCopyEnabled = settings.website.localcopy; if (cumulus.FtpOptions.LocalCopyEnabled) { cumulus.FtpOptions.LocalCopyFolder = settings.website.localcopyfolder; } } catch (Exception ex) { var msg = "Error processing website settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // web settings try { cumulus.RealtimeIntervalEnabled = settings.websettings.realtime.enabled; if (cumulus.RealtimeIntervalEnabled) { cumulus.FtpOptions.RealtimeEnabled = settings.websettings.realtime.enablerealtimeftp; cumulus.RealtimeInterval = settings.websettings.realtime.realtimeinterval * 1000; if (cumulus.RealtimeTimer.Interval != cumulus.RealtimeInterval) { cumulus.RealtimeTimer.Interval = cumulus.RealtimeInterval; } for (var i = 0; i < cumulus.RealtimeFiles.Length; i++) { cumulus.RealtimeFiles[i].Create = settings.websettings.realtime.files[i].create; cumulus.RealtimeFiles[i].FTP = cumulus.RealtimeFiles[i].Create && settings.websettings.realtime.files[i].ftp; cumulus.RealtimeFiles[i].Copy = cumulus.RealtimeFiles[i].Create && settings.websettings.realtime.files[i].copy; } } cumulus.RealtimeTimer.Enabled = cumulus.RealtimeIntervalEnabled; if (!cumulus.RealtimeTimer.Enabled || !cumulus.FtpOptions.RealtimeEnabled) { cumulus.RealtimeFTPDisconnect(); } cumulus.WebIntervalEnabled = settings.websettings.interval.enabled; if (cumulus.WebIntervalEnabled) { cumulus.FtpOptions.IntervalEnabled = settings.websettings.interval.enableintervalftp; cumulus.UpdateInterval = settings.websettings.interval.ftpinterval; if (cumulus.WebTimer.Interval != cumulus.UpdateInterval * 60 * 1000) { cumulus.WebTimer.Interval = cumulus.UpdateInterval * 60 * 1000; } for (var i = 0; i < cumulus.StdWebFiles.Length; i++) { cumulus.StdWebFiles[i].Create = settings.websettings.interval.stdfiles.files[i].create; cumulus.StdWebFiles[i].FTP = cumulus.StdWebFiles[i].Create && settings.websettings.interval.stdfiles.files[i].ftp; cumulus.StdWebFiles[i].Copy = cumulus.StdWebFiles[i].Create && settings.websettings.interval.stdfiles.files[i].copy; } for (var i = 0; i < cumulus.GraphDataFiles.Length; i++) { cumulus.GraphDataFiles[i].Create = settings.websettings.interval.graphfiles.files[i].create; cumulus.GraphDataFiles[i].FTP = cumulus.GraphDataFiles[i].Create && settings.websettings.interval.graphfiles.files[i].ftp; cumulus.GraphDataFiles[i].Copy = cumulus.GraphDataFiles[i].Create && settings.websettings.interval.graphfiles.files[i].copy; } for (var i = 0; i < cumulus.GraphDataEodFiles.Length; i++) { cumulus.GraphDataEodFiles[i].Create = settings.websettings.interval.graphfileseod.files[i].create; cumulus.GraphDataEodFiles[i].FTP = cumulus.GraphDataEodFiles[i].Create && settings.websettings.interval.graphfileseod.files[i].ftp; cumulus.GraphDataEodFiles[i].Copy = cumulus.GraphDataEodFiles[i].Create && settings.websettings.interval.graphfileseod.files[i].copy; } } } catch (Exception ex) { var msg = "Error processing web settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // external programs try { if (settings.externalprograms != null) { cumulus.DailyProgram = settings.externalprograms.dailyprogram ?? string.Empty; cumulus.DailyParams = settings.externalprograms.dailyprogramparams ?? string.Empty; cumulus.ExternalProgram = settings.externalprograms.program ?? string.Empty; cumulus.ExternalParams = settings.externalprograms.programparams ?? string.Empty; cumulus.RealtimeProgram = settings.externalprograms.realtimeprogram ?? string.Empty; cumulus.RealtimeParams = settings.externalprograms.realtimeprogramparams ?? string.Empty; } } catch (Exception ex) { var msg = "Error processing external programs: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // MQTT try { cumulus.MQTT.Server = settings.mqtt.server ?? string.Empty; cumulus.MQTT.Port = settings.mqtt.port; cumulus.MQTT.UseTLS = settings.mqtt.useTls; cumulus.MQTT.Username = settings.mqtt.username ?? string.Empty; cumulus.MQTT.Password = settings.mqtt.password ?? string.Empty; cumulus.MQTT.EnableDataUpdate = settings.mqtt.dataUpdate.enabled; if (cumulus.MQTT.EnableDataUpdate) { cumulus.MQTT.UpdateTemplate = settings.mqtt.dataUpdate.template ?? string.Empty; } cumulus.MQTT.EnableInterval = settings.mqtt.interval.enabled; if (cumulus.MQTT.EnableInterval) { cumulus.MQTT.IntervalTime = settings.mqtt.interval.time; cumulus.MQTT.IntervalTemplate = settings.mqtt.interval.template ?? string.Empty; cumulus.MQTTTimer.Interval = cumulus.MQTT.IntervalTime * 1000; cumulus.MQTTTimer.Enabled = cumulus.MQTT.EnableInterval && !string.IsNullOrWhiteSpace(cumulus.MQTT.IntervalTemplate); } } catch (Exception ex) { var msg = "Error processing MQTT settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Moon Image try { cumulus.MoonImage.Enabled = settings.moonimage.enabled; if (cumulus.MoonImage.Enabled) { cumulus.MoonImage.Size = settings.moonimage.size; if (cumulus.MoonImage.Size < 10) { cumulus.MoonImage.Size = 10; } cumulus.MoonImage.Ftp = settings.moonimage.includemoonimage; if (cumulus.MoonImage.Ftp) { cumulus.MoonImage.FtpDest = settings.moonimage.ftpdest; } cumulus.MoonImage.Copy = settings.moonimage.copyimage; if (cumulus.MoonImage.Copy) { cumulus.MoonImage.CopyDest = settings.moonimage.copydest; } } } catch (Exception ex) { var msg = "Error processing Moon image settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // HTTP proxy try { cumulus.HTTPProxyPassword = settings.proxies.httpproxy.password ?? string.Empty; cumulus.HTTPProxyPort = settings.proxies.httpproxy.port; cumulus.HTTPProxyName = settings.proxies.httpproxy.proxy ?? string.Empty; cumulus.HTTPProxyUser = settings.proxies.httpproxy.user ?? string.Empty; } catch (Exception ex) { var msg = "Error processing HTTP proxy settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // email settings try { cumulus.SmtpOptions.Enabled = settings.emailsettings.enabled; if (cumulus.SmtpOptions.Enabled) { cumulus.SmtpOptions.Server = settings.emailsettings.server; cumulus.SmtpOptions.Port = settings.emailsettings.port; cumulus.SmtpOptions.SslOption = settings.emailsettings.ssloption; cumulus.SmtpOptions.RequiresAuthentication = settings.emailsettings.authenticate; cumulus.SmtpOptions.User = settings.emailsettings.user; cumulus.SmtpOptions.Password = settings.emailsettings.password; cumulus.SmtpOptions.IgnoreCertErrors = settings.emailsettings.ignorecerterrors; if (cumulus.emailer == null) { cumulus.emailer = new EmailSender(cumulus); } } } catch (Exception ex) { var msg = "Error processing Email settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // misc settings try { cumulus.WebcamURL = settings.misc.webcamurl ?? string.Empty; cumulus.ForumURL = settings.misc.forumurl ?? string.Empty; } catch (Exception ex) { var msg = "Error processing Misc settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Save the settings cumulus.WriteIniFile(); cumulus.SetUpHttpProxy(); //cumulus.SetFtpLogging(cumulus.FTPlogging); // Setup MQTT if (cumulus.MQTT.EnableDataUpdate || cumulus.MQTT.EnableInterval) { if (!MqttPublisher.configured) { MqttPublisher.Setup(cumulus); } if (cumulus.MQTT.EnableInterval) { cumulus.MQTTTimer.Elapsed -= cumulus.MQTTTimerTick; cumulus.MQTTTimer.Elapsed += cumulus.MQTTTimerTick; cumulus.MQTTTimer.Start(); } else { cumulus.MQTTTimer.Stop(); } } else { cumulus.MQTTTimer.Stop(); } } catch (Exception ex) { var msg = "Error processing Internet settings: " + ex.Message; cumulus.LogMessage(msg); cumulus.LogDebugMessage("Internet data: " + json); errorMsg += msg; context.Response.StatusCode = 500; } return(context.Response.StatusCode == 200 ? "success" : errorMsg); }
public string UpdateConfig(IHttpContext context) { var errorMsg = ""; var json = ""; JsonWizard settings; cumulus.LogMessage("Updating settings from the First Time Wizard"); context.Response.StatusCode = 200; try { var data = new StreamReader(context.Request.InputStream).ReadToEnd(); // Start at char 5 to skip the "json:" prefix json = WebUtility.UrlDecode(data.Substring(5)); // de-serialize it to the settings structure settings = json.FromJson <JsonWizard>(); } catch (Exception ex) { var msg = "Error de-serializing Set-up Wizard Settings JSON: " + ex.Message; cumulus.LogMessage(msg); cumulus.LogDebugMessage("Wizard Data: " + json); context.Response.StatusCode = 500; return(msg); } // process the settings try { cumulus.LogMessage("Updating internet settings"); // website settings try { cumulus.FtpOptions.Enabled = settings.internet.ftp.enabled; if (cumulus.FtpOptions.Enabled) { cumulus.FtpOptions.Directory = settings.internet.ftp.directory ?? string.Empty; cumulus.FtpOptions.Port = settings.internet.ftp.ftpport; cumulus.FtpOptions.Hostname = settings.internet.ftp.hostname ?? string.Empty; cumulus.FtpOptions.FtpMode = (Cumulus.FtpProtocols)settings.internet.ftp.sslftp; cumulus.FtpOptions.Password = settings.internet.ftp.password ?? string.Empty; cumulus.FtpOptions.Username = settings.internet.ftp.username ?? string.Empty; cumulus.FtpOptions.SshAuthen = settings.internet.ftp.sshAuth ?? string.Empty; cumulus.FtpOptions.SshPskFile = settings.internet.ftp.pskFile ?? string.Empty; } cumulus.FtpOptions.LocalCopyEnabled = settings.internet.copy.localcopy; if (cumulus.FtpOptions.LocalCopyEnabled) { cumulus.FtpOptions.LocalCopyFolder = settings.internet.copy.localcopyfolder; } // Now flag all the standard files to FTP/Copy or not // do not process last entry = wxnow.txt, it is not used by the standard site for (var i = 0; i < cumulus.StdWebFiles.Length - 1; i++) { cumulus.StdWebFiles[i].Create = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; cumulus.StdWebFiles[i].FTP = cumulus.FtpOptions.Enabled; cumulus.StdWebFiles[i].Copy = cumulus.FtpOptions.LocalCopyEnabled; } // and graph data files for (var i = 0; i < cumulus.GraphDataFiles.Length; i++) { cumulus.GraphDataFiles[i].Create = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; cumulus.GraphDataFiles[i].FTP = cumulus.FtpOptions.Enabled; cumulus.GraphDataFiles[i].Copy = cumulus.FtpOptions.LocalCopyEnabled; } // and EOD data files for (var i = 0; i < cumulus.GraphDataEodFiles.Length; i++) { cumulus.GraphDataEodFiles[i].Create = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; cumulus.GraphDataEodFiles[i].FTP = cumulus.FtpOptions.Enabled; cumulus.GraphDataEodFiles[i].Copy = cumulus.FtpOptions.LocalCopyEnabled; } // and Realtime files // realtime.txt is not used by the standard site //cumulus.RealtimeFiles[0].Create = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; //cumulus.RealtimeFiles[0].FTP = cumulus.FtpOptions.Enabled; //cumulus.RealtimeFiles[0].Copy = cumulus.FtpOptions.LocalCopyEnabled; // realtimegauges.txt IS used by the standard site cumulus.RealtimeFiles[1].Create = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; cumulus.RealtimeFiles[1].FTP = cumulus.FtpOptions.Enabled; cumulus.RealtimeFiles[1].Copy = cumulus.FtpOptions.LocalCopyEnabled; // and Moon image cumulus.MoonImage.Enabled = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; cumulus.MoonImage.Ftp = cumulus.FtpOptions.Enabled; cumulus.MoonImage.Copy = cumulus.FtpOptions.LocalCopyEnabled; if (cumulus.MoonImage.Enabled) { cumulus.MoonImage.CopyDest = cumulus.FtpOptions.LocalCopyFolder + "images" + cumulus.DirectorySeparator + "moon.png"; } // and NOAA reports cumulus.NOAAconf.Create = cumulus.FtpOptions.Enabled || cumulus.FtpOptions.LocalCopyEnabled; cumulus.NOAAconf.AutoFtp = cumulus.FtpOptions.Enabled; cumulus.NOAAconf.AutoCopy = cumulus.FtpOptions.LocalCopyEnabled; if (cumulus.NOAAconf.AutoCopy) { cumulus.NOAAconf.CopyFolder = cumulus.FtpOptions.LocalCopyFolder + "Reports"; } if (cumulus.NOAAconf.AutoFtp) { cumulus.NOAAconf.FtpFolder = cumulus.FtpOptions.Directory + (cumulus.FtpOptions.Directory.EndsWith("/") ? "" : "/") + "Reports"; } } catch (Exception ex) { var msg = "Error processing internet settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // web settings try { cumulus.RealtimeIntervalEnabled = settings.website.realtime.enabled; if (cumulus.RealtimeIntervalEnabled) { cumulus.FtpOptions.RealtimeEnabled = settings.website.realtime.enablerealtimeftp; cumulus.RealtimeInterval = settings.website.realtime.realtimeinterval * 1000; if (cumulus.RealtimeTimer.Interval != cumulus.RealtimeInterval) { cumulus.RealtimeTimer.Interval = cumulus.RealtimeInterval; } } cumulus.RealtimeTimer.Enabled = cumulus.RealtimeIntervalEnabled; if (!cumulus.RealtimeTimer.Enabled || !cumulus.FtpOptions.RealtimeEnabled) { cumulus.RealtimeTimer.Stop(); cumulus.RealtimeFTPDisconnect(); } cumulus.WebIntervalEnabled = settings.website.interval.enabled; if (cumulus.WebIntervalEnabled) { cumulus.FtpOptions.IntervalEnabled = settings.website.interval.enableintervalftp; cumulus.UpdateInterval = settings.website.interval.ftpinterval; if (cumulus.WebTimer.Interval != cumulus.UpdateInterval * 60 * 1000) { cumulus.WebTimer.Interval = cumulus.UpdateInterval * 60 * 1000; } } } catch (Exception ex) { var msg = "Error processing web settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Location try { cumulus.Altitude = settings.location.altitude; cumulus.AltitudeInFeet = (settings.location.altitudeunit == "feet"); cumulus.LocationName = settings.location.sitename ?? string.Empty; cumulus.LocationDesc = settings.location.description ?? string.Empty; cumulus.Latitude = settings.location.latitude; cumulus.LatTxt = degToString(cumulus.Latitude, true); cumulus.Longitude = settings.location.longitude; cumulus.LonTxt = degToString(cumulus.Longitude, false); } catch (Exception ex) { var msg = "Error processing Location settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Units try { if (cumulus.Units.Wind != settings.units.wind) { cumulus.Units.Wind = settings.units.wind; cumulus.ChangeWindUnits(); cumulus.WindDPlaces = cumulus.StationOptions.RoundWindSpeed ? 0 : cumulus.WindDPlaceDefaults[cumulus.Units.Wind]; cumulus.WindAvgDPlaces = cumulus.WindDPlaces; } if (cumulus.Units.Press != settings.units.pressure) { cumulus.Units.Press = settings.units.pressure; cumulus.ChangePressureUnits(); cumulus.PressDPlaces = cumulus.PressDPlaceDefaults[cumulus.Units.Press]; } if (cumulus.Units.Temp != settings.units.temp) { cumulus.Units.Temp = settings.units.temp; cumulus.ChangeTempUnits(); } if (cumulus.Units.Rain != settings.units.rain) { cumulus.Units.Rain = settings.units.rain; cumulus.ChangeRainUnits(); cumulus.RainDPlaces = cumulus.RainDPlaceDefaults[cumulus.Units.Rain]; } } catch (Exception ex) { var msg = "Error processing Units settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // data logging try { cumulus.DataLogInterval = settings.logs.loginterval; cumulus.RolloverHour = settings.logs.logrollover.time == "9am" ? 9 : 0; if (cumulus.RolloverHour == 9) { cumulus.Use10amInSummer = settings.logs.logrollover.summer10am; } } catch (Exception ex) { var msg = "Error processing Logging setting: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Station type try { if (cumulus.StationType != settings.station.stationtype) { cumulus.LogMessage("Station type changed, restart required"); cumulus.LogConsoleMessage("*** Station type changed, restart required ***", ConsoleColor.Yellow); } cumulus.StationType = settings.station.stationtype; cumulus.StationModel = settings.station.stationmodel; } catch (Exception ex) { var msg = "Error processing Station Type setting: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Davis VP/VP2/Vue try { if (settings.station.davisvp2 != null) { cumulus.DavisOptions.ConnectionType = settings.station.davisvp2.conntype; if (settings.station.davisvp2.tcpsettings != null) { cumulus.DavisOptions.IPAddr = settings.station.davisvp2.tcpsettings.ipaddress ?? string.Empty; cumulus.DavisOptions.PeriodicDisconnectInterval = settings.station.davisvp2.tcpsettings.disconperiod; } if (cumulus.DavisOptions.ConnectionType == 0) { cumulus.ComportName = settings.station.davisvp2.comportname; } // set defaults for Davis cumulus.UVdecimals = 1; if (settings.units.rain == 1) { cumulus.RainDPlaces = 2; } } } catch (Exception ex) { var msg = "Error processing Davis VP/VP2/Vue settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // WLL try { if (settings.station.daviswll != null) { cumulus.DavisOptions.ConnectionType = 2; // Always TCP/IP for WLL cumulus.WLLAutoUpdateIpAddress = settings.station.daviswll.network.autoDiscover; cumulus.DavisOptions.IPAddr = settings.station.daviswll.network.ipaddress ?? string.Empty; cumulus.WllApiKey = settings.station.daviswll.api.apiKey; cumulus.WllApiSecret = settings.station.daviswll.api.apiSecret; cumulus.WllStationId = settings.station.daviswll.api.apiStationId; cumulus.WllPrimaryRain = settings.station.daviswll.primary.rain; cumulus.WllPrimarySolar = settings.station.daviswll.primary.solar; cumulus.WllPrimaryTempHum = settings.station.daviswll.primary.temphum; cumulus.WllPrimaryUV = settings.station.daviswll.primary.uv; cumulus.WllPrimaryWind = settings.station.daviswll.primary.wind; } } catch (Exception ex) { var msg = "Error processing WLL settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // GW1000 connection details try { if (settings.station.gw1000 != null) { cumulus.Gw1000IpAddress = settings.station.gw1000.ipaddress; cumulus.Gw1000AutoUpdateIpAddress = settings.station.gw1000.autoDiscover; cumulus.Gw1000MacAddress = settings.station.gw1000.macaddress; } } catch (Exception ex) { var msg = "Error processing GW1000 settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // weatherflow connection details try { if (settings.station.weatherflow != null) { cumulus.WeatherFlowOptions.WFDeviceId = settings.station.weatherflow.deviceid; cumulus.WeatherFlowOptions.WFTcpPort = settings.station.weatherflow.tcpport; cumulus.WeatherFlowOptions.WFToken = settings.station.weatherflow.token; cumulus.WeatherFlowOptions.WFDaysHist = settings.station.weatherflow.dayshistory; } } catch (Exception ex) { var msg = $"Error processing WeatherFlow settings: {ex.Message}"; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // FineOffset try { if (settings.station.fineoffset != null) { cumulus.FineOffsetOptions.SyncReads = settings.station.fineoffset.syncreads; cumulus.FineOffsetOptions.ReadAvoidPeriod = settings.station.fineoffset.readavoid; } } catch (Exception ex) { var msg = "Error processing Fine Offset settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // EasyWeather try { if (settings.station.easyw != null) { cumulus.EwOptions.Interval = settings.station.easyw.interval; cumulus.EwOptions.Filename = settings.station.easyw.filename; } } catch (Exception ex) { var msg = "Error processing EasyWeather settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Instromet try { if (settings.station.imet != null) { cumulus.ComportName = settings.station.imet.comportname ?? cumulus.ComportName; cumulus.ImetOptions.BaudRate = settings.station.imet.baudrate; } } catch (Exception ex) { var msg = "Error processing Instromet settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // WMR928 try { if (settings.station.wmr928 != null) { cumulus.ComportName = settings.station.wmr928.comportname ?? cumulus.ComportName; } } catch (Exception ex) { var msg = "Error processing WMR928 settings: " + ex.Message; cumulus.LogMessage(msg); errorMsg += msg + "\n\n"; context.Response.StatusCode = 500; } // Save the settings cumulus.WriteIniFile(); } catch (Exception ex) { var msg = "Error processing Wizard settings: " + ex.Message; cumulus.LogMessage(msg); cumulus.LogDebugMessage("Station Data: " + json); errorMsg += msg; context.Response.StatusCode = 500; } return(context.Response.StatusCode == 200 ? "success" : errorMsg); }