Пример #1
0
        private void ProcessFirmwareVersionResponse(byte[] packet)
        {
            string message = new FirmwareVersionResponse(packet).GetFirmwareVersion();

            FirmwareVersionReceived?.Invoke(message);
            analyzerState.FirmwareVersion = message;
        }
Пример #2
0
        public void TestValidFirmwareVersionResponse(string response, double firmwareVersion)
        {
            var sut = new FirmwareVersionResponse {
                DeviceResponse = response
            };

            Assert.That(sut.FirmwareVersion, Is.EqualTo(firmwareVersion));
        }
Пример #3
0
        public async Task CanGetFirmwareInfo()
        {
            FirmwareVersionResponse firmwareResponse = await _Pebble.GetFirmwareVersionAsync();

            AssertSuccessfulResult(firmwareResponse);
            Assert.IsNotNull(firmwareResponse.Firmware);
            Assert.IsNotNull(firmwareResponse.RecoveryFirmware);
        }
Пример #4
0
        public void TestValidFirmwareVersionResponse(string deviceResponse, double version)
        {
            var sut = new FirmwareVersionResponse {
                DeviceResponse = deviceResponse
            };

            Assert.That(sut.FirmwareVersion, Is.EqualTo(version));
            Assert.That(sut.ToString().Contains(deviceResponse), Is.True);
        }
Пример #5
0
        private async Task LoadFirmwareAsync()
        {
            FirmwareVersionResponse firmwareResponse = await Pebble.GetFirmwareVersionAsync();

            if (firmwareResponse.Success)
            {
                Firmware         = firmwareResponse.Firmware;
                RecoveryFirmware = firmwareResponse.RecoveryFirmware;
            }
        }
Пример #6
0
        private async Task LoadFirmwareAsync()
        {
            if (_pebble == null || _pebble.IsAlive == false)
            {
                return;
            }

            FirmwareVersionResponse firmwareResponse = await _pebble.GetFirmwareVersionAsync();

            if (firmwareResponse.Success)
            {
                Firmware         = firmwareResponse.Firmware;
                RecoveryFirmware = firmwareResponse.RecoveryFirmware;
            }
        }
Пример #7
0
        static void Main(string[] args)
        {
            Pebble             pebble;
            SharpMenu <Action> menu;
            SharpMenu <Pebble> pebblemenu;

            Console.WriteLine("Welcome to the Flint test environment.  "
                              + "Please remain seated and press enter to autodetect paired Pebbles.");
            Console.ReadLine();

            try
            {
                List <Pebble> peblist = Pebble.DetectPebbles();
                switch (peblist.Count)
                {
                case 0:
                    Console.WriteLine("No Pebbles found.  Press enter to exit.");
                    Console.ReadLine();
                    return;

                case 1:
                    pebble = peblist[0];
                    break;

                default:
                    pebblemenu = new SharpMenu <Pebble>();
                    foreach (Pebble peb in Pebble.DetectPebbles())
                    {
                        pebblemenu.Add(peb);
                    }
                    pebblemenu.WriteMenu();
                    pebble = pebblemenu.Prompt();
                    break;
                }
            }
            catch (PlatformNotSupportedException e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();
                return;
            }

            try
            {
                pebble.ConnectAsync().Wait();
            }
            catch (System.IO.IOException e)
            {
                Console.Write("Connection failed: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Press enter to exit.");
                Console.ReadLine();
                return;
            }
            Console.WriteLine("Successfully connected!");
            Console.WriteLine(pebble);

            menu = new SharpMenu <Action>();
            menu.Add(() => pebble.PingAsync(235).Wait(), "Send the Pebble a ping");
            menu.Add(() => pebble.NotificationSMSAsync("+3278051200", "It's time.").Wait(), "Send an SMS notification");
            menu.Add(() => pebble.NotificationMailAsync("Your pal", "URGENT NOTICE", "There is a thing you need to do. Urgently.").Wait(),
                     "Send an email notification");
            menu.Add(() => pebble.SetNowPlayingAsync("That dude", "That record", "That track").Wait(), "Send some metadata to the music app");
            menu.Add(() => pebble.BadPingAsync().Wait(), "Send a bad ping to trigger a LOGS response");
            menu.Add(() => Console.WriteLine(pebble.GetTimeAsync().Result.Time), "Get the time from the Pebble");
            menu.Add(() => pebble.SetTimeAsync(DateTime.Now).Wait(), "Sync Pebble time");
            menu.Add(() => Console.WriteLine(pebble.GetAppbankContentsAsync().Result.AppBank), "Get the contents of the app bank");
            menu.Add(() => DeleteApp(pebble), "Delete an app from the Pebble");
            menu.Add(() => pebble.Disconnect(), "Exit");

            // Subscribe to specific events
            pebble.RegisterCallback <MusicControlResponse>(pebble_MediaControlReceived);
            // Subscribe to an event for a particular endpoint
            pebble.RegisterCallback <PingResponse>(pingReceived);

            FirmwareVersionResponse firmwareResponse = pebble.GetFirmwareVersionAsync().Result;

            if (firmwareResponse.Success)
            {
                Console.WriteLine(firmwareResponse.Firmware);
                Console.WriteLine(firmwareResponse.RecoveryFirmware);
            }
            while (pebble.Alive)
            {
                menu.WriteMenu();
                Action act = menu.Prompt();
                // To account for disconnects during the prompt:
                if (pebble.Alive)
                {
                    act();
                }
            }
        }