예제 #1
0
파일: Sensors.cs 프로젝트: MoonJM98/BLINK
        public Sensors(Bluetooth bluetooth) : base()
        {
            if (Singleton != null)
            {
                Singleton.Dispose();
            }

            thread = new Thread(TickChecker);
            Accelerometer.ReadingChanged += AcceleroChanged;
            Bluetooth = bluetooth;
        }
예제 #2
0
        public bool Start()
        {
            try
            {
                if (BlinkDevices.Any())
                {
                    BluetoothDevice device = BlinkDevices.First();
                    if (!Connect(adapter.GetRemoteDevice(device.Address)))
                    {
                        return(false);
                    }

                    try
                    {
                        Sensors.Start();
                    } catch (System.Exception e)
                    {
                        Functions.ShowToast($"센서를 불러오는 도중 오류가 발생했습니다.");
                        Log.Debug(Name, "Sensor Failed {0}", e);
                        return(false);
                    }

                    return(true);
                }
                else
                {
                    Functions.ShowToast($"BLINK 기기를 찾을 수 없습니다.\n기기를 켜고 페어링 한 후 앱을 다시 켜주세요.");
                    Sensors.Dispose();
                    Sensors = null;
                }
            }
            catch (System.Exception e)
            {
                Log.Error("BLINK", "Bluetooth Error!", e);
            }
            return(false);
        }