Beispiel #1
0
        public static void Main()
        {
            bool switchToBootLoader = false;

            var mode = SystemUpdate.GetMode();

            if (mode == SystemUpdate.SystemUpdateMode.NonFormatted)
            {
                // This erases the application!
                Debug.Print("SystemUpdate.EnableBootLoader - formatting !!!!!!");
                SystemUpdate.EnableBootloader();
            }

            if (mode == SystemUpdate.SystemUpdateMode.Bootloader)
            {
                // Switch to application mode.
                Debug.Print("SystemUpdate.AccessApplication");
                SystemUpdate.AccessApplication();
            }

            if (mode == SystemUpdate.SystemUpdateMode.Application)
            {
                // Developer use only: Switch to BootLoader
                if (switchToBootLoader)
                {
                    SystemUpdate.AccessBootloader();
                }
            }

            // LED - Flashing for 5 seconds.
            LED.State = LED.LedState.FlashingData;
            Thread.Sleep(5000);

            // LED - switch on.
            LED.State = LED.LedState.On;

            // Start PDA comms thread.
            PDA.Start();

            // Start meter comms thread.
            EMR3.Start();

            while (true)
            {
                // Sleep a second
                Thread.Sleep(1000);
            }
        }
Beispiel #2
0
 private static void InitializeWatchdog()
 {
     _watchdog = new Timer(s =>
     {
         if (_bootloader.Started)
         {
             Debug.Print(_bootloader.CurrentProgress + "%");
             _watchdog.Change(5000, -1);
         }
         else
         {
             Debug.Print("Exiting bootloader");
             _watchdog.Dispose();
             _radio.Disable();
             _bootloader.Stop();
             _led.BlinkOff();
             _led.Off();
             SystemUpdate.AccessApplication();
         }
     },
                           null, 5000, -1);
 }
Beispiel #3
0
 private static void InitializeLoaderButton()
 {
     Debug.Print("Initializing loader button...");
     _ldrButton              = new InterruptPort(LdrPin, true, Port.ResistorMode.PullUp, Port.InterruptMode.InterruptEdgeLow);
     _ldrButton.OnInterrupt += (d1, d2, t) => SystemUpdate.AccessApplication();
 }