// Close the native bootloader object. public void Close() { if (Updater != null) { Updater.Dispose(); Updater = null; IsConnected = false; } }
//internal Boolean Ping() public Boolean Ping() { if (DeviceModel.IsNull) { LastError = "The device does not support a bootloader."; IsConnected = false; return(false); } if (Updater == null) { try { Updater = new blfwkdll.Updater(DeviceModel.PeripheralConfiguration); LastError = "Success."; IsConnected = true; return(true); } catch (Exception e) { LastError = e.Message; IsConnected = false; return(false); } } try { Updater.ping(0, 0, 0); // NOTE: this is where the actual pinging of device takes place! LastError = "Success."; IsConnected = true; return(true); } catch (Exception e) { LastError = e.Message; Close(); return(false); } }
public BootloaderViewModel(DeviceViewModel device) { DeviceModel = device; // Creating a Bootloader object entails Pinging the peripheral. // We don't want to talk to the device until it becomes selected. // That way, we will not try to talk to devices that are not // known to be Kinestis Bootloader devices, and we will not // shut down alternate peripherals on a given Kinetis Bootloader // device. Updater = null; if (DeviceModel != null) { if (DeviceModel.IsSerial) { IsConnectedTimer = new System.Windows.Threading.DispatcherTimer(); IsConnectedTimer.Tick += new EventHandler(IsConnectedTimer_Tick); IsConnectedTimer.Interval = new TimeSpan(0, 0, 1); } } }