Example #1
0
        async void AlerterClique(object sender, EventArgs args)
        {
            IService service = await _bleService.LoadService(_bleService._findMeConnected.Device, Guid.Parse("00001802-0000-1000-8000-00805f9b34fb"));

            IList <ICharacteristic> characteristics = await _bleService.LoadCharacteristicsFromService(service);

            if (_isAlarmStarted)
            {
                // Change style of button
                BoutonAlerter.BackgroundColor = Color.White;
                BoutonAlerter.BorderWidth     = 0;
                BoutonAlerter.TextColor       = Color.FromHex("#5A5A5A");
                BoutonAlerter.Text            = "Alerter mon Find Me";

                _bleService.WriteValueAsyncInCharacteristic(new byte[] { 0x00 }, characteristics.First());
                _isAlarmStarted = false;

                _myTimerAlarm.Stop();
            }
            else if (!_isAlarmStarted)
            {
                // Change style of button
                BoutonAlerter.BackgroundColor = Color.Transparent;
                BoutonAlerter.BorderColor     = Color.White;
                BoutonAlerter.TextColor       = Color.White;
                BoutonAlerter.BorderWidth     = 1;
                BoutonAlerter.Text            = "Arreter alerte ";

                _bleService.WriteValueAsyncInCharacteristic(new byte[] { 0x01 }, characteristics.First());
                _isAlarmStarted = true;

                _myTimerAlarm = new MyTimer(TimeSpan.FromSeconds(5), ActionTimerAlarm);
                _myTimerAlarm.Start();
            }
        }
        async void OnDeviceConnected()
        {
            _isConnected = true;
            _bleService.StopScan();

            AnimationView.IsVisible         = false;
            successConnectedImage.IsVisible = true;

            labelStatus.Text            = "Connecté";
            labelStatusDescription.Text = "Votre Find Me est maintenant connecté.";
            buttonStart.IsEnabled       = true;

            // Start update notify
            IService service = await _bleService.LoadService(_bleService._findMeConnected.Device, Guid.Parse("a55c5042-90ea-11e9-bc42-526af7764f64"));

            IList <ICharacteristic> characteristics = await _bleService.LoadCharacteristicsFromService(service);

            _bleService.StartUpdatesOnCharacteristic(characteristics.First());
        }