Skip to content

Commit

Permalink
Auto download latest firmware separate from application.
Browse files Browse the repository at this point in the history
  • Loading branch information
andymanic committed May 3, 2023
1 parent f0486b2 commit b8879ff
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
52 changes: 48 additions & 4 deletions OSRTT Launcher/OSRTT Launcher/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public partial class Main : Form
// CHANGE THESE VALUES WHEN ISSUING A NEW RELEASE
private double boardVersion = 2.6;
private double V1DLFW = 2.8;
private double ProDLFW = 1.2;
private double ProDLFW = 1.5;
public int boardType = -1;
private string softwareVersion = "4.00";
private string softwareVersion = "4.10";

// TODO //
//
Expand Down Expand Up @@ -205,8 +205,9 @@ private void AutoUpdater_ApplicationExitEvent()

private void getODModesJson()
{
/*using (var client = new WebClient())
using (var client = new WebClient())
{
client.Headers.Add("user-agent", "OSRTT");
string jsonPath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
jsonPath = new Uri(System.IO.Path.GetDirectoryName(jsonPath)).LocalPath + @"\lib\odmodes.json";
try
Expand All @@ -217,7 +218,7 @@ private void getODModesJson()
{
Console.WriteLine(ex.Message + ex.StackTrace);
}
}*/
}
}

private void appRunning()
Expand Down Expand Up @@ -323,6 +324,49 @@ private void readAndSaveUserSettings(bool closing)
}
private void getDownloadedFirmwareVersions()
{
string ProFirmwareVersion = "";
using (WebClient wc = new WebClient())
{
wc.Headers.Add("user-agent", "OSRTT");

try
{
string latest = wc.DownloadString("https://api.github.com/repos/andymanic/OSRTT/releases/latest");
//object jsonData = JsonConvert.DeserializeObject(latest);
//Console.WriteLine(jsonData);
string[] splitMessage = latest.Split('}');
foreach (var s in splitMessage)
{
if (s.Contains("browser_download_url"))
{
string[] splitForUrl = s.Split('"');
foreach (var st in splitForUrl)
{
if (st.StartsWith("https://github.com/") && st.Contains(".ino.bin")) // change to .ino.bin for prod
{
ProFirmwareVersion = st;
break;
}
}
if (ProFirmwareVersion != "")
{
break;
}
}
}
if (ProFirmwareVersion != "")
{
string[] fileSplit = ProFirmwareVersion.Split('/');
wc.DownloadFile(ProFirmwareVersion, localPath + @"\\arduinoCLI\\" + fileSplit.Last());
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + ex.StackTrace);
}

}
Console.WriteLine("");
string V1FWPath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
V1FWPath = new Uri(System.IO.Path.GetDirectoryName(V1FWPath)).LocalPath;
string ProFWPath = V1FWPath;
Expand Down
4 changes: 2 additions & 2 deletions OSRTT Launcher/OSRTT Launcher/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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("4.0.0.0")]
[assembly: AssemblyFileVersion("4.0.0.0")]
[assembly: AssemblyVersion("4.1.0.0")]
[assembly: AssemblyFileVersion("4.1.0.0")]

0 comments on commit b8879ff

Please sign in to comment.