Skip to content

Commit

Permalink
Merge pull request #123 from mcrossley/master
Browse files Browse the repository at this point in the history
v3.13.2 support
  • Loading branch information
mcrossley authored Sep 13, 2021
2 parents b295481 + 6cc5287 commit 4e6c5a5
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 11 deletions.
65 changes: 59 additions & 6 deletions CumulusMX/Cumulus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,10 @@ public Cumulus(int HTTPport, bool DebugEnabled, string startParms)

LogMessage(DateTime.Now.ToString("G"));


// Check if all the folders required by CMX exist, if not create them
CreateRequiredFolders();

// find the data folder
//datapath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + DirectorySeparator + "Cumulus" + DirectorySeparator;

Expand Down Expand Up @@ -7135,6 +7139,11 @@ public void BackupData(bool daily, DateTime timestamp)
if (!Directory.Exists(dirpath))
{
LogMessage("BackupData: *** Error - backup folder does not exist - " + dirpath);
CreateRequiredFolders();
if (!Directory.Exists(dirpath))
{
return;
}
}
else
{
Expand All @@ -7144,16 +7153,28 @@ public void BackupData(bool daily, DateTime timestamp)

while (dirlist.Count > 10)
{
if (Path.GetFileName(dirlist[0]) == "daily")
try
{
LogMessage("BackupData: *** Error - the backup folder has unexpected contents");
break;
if (Path.GetFileName(dirlist[0]) == "daily")
{
LogMessage("BackupData: *** Error - the backup folder has unexpected contents");
break;
}
else
{
Directory.Delete(dirlist[0], true);
dirlist.RemoveAt(0);
}
}
else
catch (UnauthorizedAccessException)
{
Directory.Delete(dirlist[0], true);
dirlist.RemoveAt(0);
LogErrorMessage("BackupData: Error, no permission to read/delete folder: " + dirlist[0]);
}
catch (Exception ex)
{
LogErrorMessage($"BackupData: Error while attempting to read/delete folder: {dirlist[0]}, error message: {ex.Message}");
}

}

string foldername = timestamp.ToString("yyyyMMddHHmmss");
Expand Down Expand Up @@ -10239,6 +10260,38 @@ private void PingCompletedCallback(object sender, PingCompletedEventArgs e)

pingReply = e.Reply;
}

private void CreateRequiredFolders()
{
// The required folders are: /backup, /data, /MXdiags, /Reports
var folders = new string[4] { "backup", "data", "MXdiags", "Reports"};

LogMessage("Checking required folders");

foreach (var folder in folders)
{
try
{
if (!Directory.Exists(folder))
{
LogMessage("Creating required folder: /" + folder);
Directory.CreateDirectory(folder);
}
}
catch (UnauthorizedAccessException)
{
var msg = "Error, no permission to read/create folder: " + folder;
LogConsoleMessage(msg);
LogErrorMessage(msg);
}
catch (Exception ex)
{
var msg = $"Error while attempting to read/create folder: {folder}, error message: {ex.Message}";
LogConsoleMessage(msg);
LogErrorMessage(msg);
}
}
}
}

/*
Expand Down
4 changes: 2 additions & 2 deletions CumulusMX/HttpStationEcowitt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ private void ProcessCo2(NameValueCollection data, WeatherStation station)
}
if (data["pm25_24h_co2"] != null)
{
station.CO2_pm2p5_24h = Convert.ToDouble(data["pm25_24_co2"], CultureInfo.InvariantCulture);
station.CO2_pm2p5_24h = Convert.ToDouble(data["pm25_24h_co2"], CultureInfo.InvariantCulture);
}
if (data["pm10_co2"] != null)
{
Expand All @@ -1090,7 +1090,7 @@ private void ProcessCo2(NameValueCollection data, WeatherStation station)
}
if (data["co2_24h"] != null)
{
station.CO2_24h = Convert.ToInt32(data["co2"], CultureInfo.InvariantCulture);
station.CO2_24h = Convert.ToInt32(data["co2_24h"], CultureInfo.InvariantCulture);
}
}

Expand Down
6 changes: 3 additions & 3 deletions CumulusMX/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Cumulus MX")]
[assembly: AssemblyDescription("Version 3.13.1 - Build 3146")]
[assembly: AssemblyDescription("Version 3.13.2 - Build 3147")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Cumulus MX")]
Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.13.1.3146")]
[assembly: AssemblyFileVersion("3.13.1.3146")]
[assembly: AssemblyVersion("3.13.2.3147")]
[assembly: AssemblyFileVersion("3.13.2.3147")]
8 changes: 8 additions & 0 deletions Updates.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
3.13.2 - b3147
——————————————
- Fix: HTTP Station Ecowitt - not decoding all CO₂ sensor values correctly, again!

- Change: The CumulusMX dustribution zip no longer contains the required empty folders /backup, /data, /MXdiags.
These folders will now be created on start-up if they are missing


3.13.1 - b3146
——————————————
- Fix: HTTP Station Ecowitt - not decoding all CO₂ sensor values correctly
Expand Down

0 comments on commit 4e6c5a5

Please sign in to comment.