Skip to content

Commit

Permalink
ConfigDroneCAN: add manifest dronecan update support
Browse files Browse the repository at this point in the history
  • Loading branch information
meee1 committed Nov 21, 2023
1 parent f2f25e1 commit d5a12c5
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion GCSViews/ConfigurationView/ConfigDroneCAN.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using static DroneCAN.DroneCAN;
using System.ComponentModel;
using System.Drawing;
using MissionPlanner.ArduPilot;

namespace MissionPlanner.GCSViews.ConfigurationView
{
Expand Down Expand Up @@ -495,6 +496,12 @@ private void FirmwareUpdate(byte nodeID, bool beta = false)
{
var url = can.LookForUpdate(devicename, hwversion, beta);

if (url == string.Empty)
url = APFirmware.Manifest.Firmware.Where(a => a.MavFirmwareVersionType == (beta ? APFirmware.RELEASE_TYPES.BETA.ToString() : APFirmware.RELEASE_TYPES.OFFICIAL.ToString()) &&
a.VehicleType == "AP_Periph" && a.Format == "bin" &&
a.MavType == "CAN_PERIPHERAL" &&
devicename.EndsWith(a.Platform)).First()?.Url.ToString();

if (url != string.Empty)
{
try
Expand Down Expand Up @@ -557,7 +564,7 @@ private void FirmwareUpdate(byte nodeID, bool beta = false)
{
FileDialog fd = new OpenFileDialog();
fd.RestoreDirectory = true;
fd.Filter = "*.bin|*.bin|*.*|*.*";
fd.Filter = "*.bin;*.apj|*.bin;*.apj";
var dia = fd.ShowDialog();

if (fd.CheckFileExists && dia == DialogResult.OK)
Expand All @@ -575,6 +582,14 @@ private void FirmwareUpdate(byte nodeID, bool beta = false)

try
{
if (fd.FileName.ToLower().EndsWith(".apj"))
{
var fw = px4uploader.Firmware.ProcessFirmware(fd.FileName);
var tmp = Path.GetTempFileName();
File.WriteAllBytes(tmp, fw.imagebyte);
fd.FileName = tmp;
}

var cancel = new CancellationTokenSource();

prd.DoWork += dialogue =>
Expand Down

0 comments on commit d5a12c5

Please sign in to comment.