Esempio n. 1
0
        public App(IBluetooth bluetooth, IAudio audio, IAudioResource audioResource)
        {
            Bluetooth     = bluetooth;
            AudioRenderer = new AudioRenderer(audio, audioResource);

            bluetooth.ConnectedDevices.CollectionChanged += (object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) => {
                if (e.OldItems != null)
                {
                    foreach (BluetoothDevice oldItem in e.OldItems)
                    {
                        oldItem.BeatReceived -= BeatReceived;
                    }
                }

                if (e.NewItems != null)
                {
                    foreach (BluetoothDevice newItem in e.NewItems)
                    {
                        newItem.BeatReceived += BeatReceived;
                    }
                }
            };

            // The root page of your application
            MainPage = new ContentPage();

            OpenScanView();
        }
Esempio n. 2
0
        public DeviceList(IBluetooth bluetooth)
        {
            InitializeComponent();
            _bluetooth = bluetooth;

            pairedDevicesListView.ItemsSource = _bluetooth.PairedDevices;
        }
Esempio n. 3
0
        public ChartElectrocardiograph(IBluetooth bluetooth)
        {
            _bluetooth = bluetooth;

            InitializeComponent();
            series.ItemsSource = _points;
        }
Esempio n. 4
0
 public ResultCasesViewModel(IRestService restService)
 {
     _service         = restService;
     BondedDevices    = new ObservableCollection <BtDevice>();
     _Bluetooth       = DependencyService.Get <IBluetooth>();
     refreshCommand   = new Command(async() => await RefreshAsync());
     SearchCommand    = new Command(async() => await SearchCountry());
     SelectionCommand = new Command(ItemSelected);
     IsVisible        = false;
 }
Esempio n. 5
0
        public Write(string serial, IBluetooth bluetooth)
        {
            this.serial = serial;
            thermostats = Thermostats.Read();
            accessor    = new PeripheralAccessor(bluetooth);

            if (!thermostats.HasSecretAndUuidFor(serial))
            {
                Console.Error.WriteLine($"Has not previously connected to {serial}. Do a read first.");
                Environment.Exit(1);
            }
        }
Esempio n. 6
0
        public ScanViewViewModel(IBluetooth bluetooth)
        {
            _bluetooth  = bluetooth;
            _IsScanning = _bluetooth.IsScanning;
            Devices     = new ObservableCollection <BluetoothDeviceViewModel> ();

            _bluetooth.Devices.CollectionChanged += (object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) => {
                foreach (var device in _bluetooth.Devices.Where(i => !Devices.Any(d => d.Device == i)))
                {
                    Devices.Add(new BluetoothDeviceViewModel(device)
                    {
                        IsConnected = _bluetooth.ConnectedDevices.Contains(device)
                    });
                }
                foreach (var device in Devices.Where(i => !bluetooth.Devices.Contains(i.Device)).ToList())
                {
                    Devices.Remove(device);
                }
            };

            _bluetooth.ConnectedDevices.CollectionChanged += (object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) => {
                foreach (var device in Devices)
                {
                    device.IsConnected = _bluetooth.ConnectedDevices.Contains(device.Device);
                }
            };

            StartScanCommand = new Command(() => {
                IsScanning = true;
                _bluetooth.StartScan();
                (StartScanCommand as Command).ChangeCanExecute();
                (StopScanCommand as Command).ChangeCanExecute();
            }, () => {
                return(!IsScanning);
            });

            StopScanCommand = new Command(() => {
                IsScanning = false;
                _bluetooth.StopScan();
                (StartScanCommand as Command).ChangeCanExecute();
                (StopScanCommand as Command).ChangeCanExecute();
            }, () => {
                return(IsScanning);
            });
        }
Esempio n. 7
0
        public static void Main(string[] args, IBluetooth bluetooth)
        {
            RequireAtLeastOneArgument(args);
            switch (args[0])
            {
            case "scan":
                RequireNumberOfArguments(1, args);
                new Scan(bluetooth).Execute();
                break;

            case "read":
                RequireNumberOfArguments(2, args);
                new Read(args[1], bluetooth).Execute();
                break;

            case "write":
                RequireNumberOfArguments(2, args);
                new Write(args[1], bluetooth).Execute();
                break;

            case "forget":
                RequireNumberOfArguments(2, args);
                new Forget(args[1]).Execute();
                break;

            case "list":
                RequireNumberOfArguments(1, args);
                new ListThermostats().Execute();
                break;

            case "show":
                RequireNumberOfArguments(2, args);
                new Show(args[1]).Execute();
                break;

            case "set":
                new SetValue(args[1], args[2], args.Skip(3).ToArray()).Execute();
                break;

            default:
                QuitWithUsage($"Unknown command: {args[0]}");
                break;
            }
        }
Esempio n. 8
0
        public MainPage()
        {
            InitializeComponent();

            try
            {
                _speechRecongnitionInstance = DependencyService.Get <ISpeechToText>();
                _bluetoothInstance          = DependencyService.Get <IBluetooth>();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            BindingContext = ViewModel;

            #region gestures
            var tapBluetooth = new TapGestureRecognizer();
            tapBluetooth.Tapped += (s, e) =>
            {
                BluetoothClicked();
            };
            bluetoothText.GestureRecognizers.Add(tapBluetooth);
            bluetoothImage.GestureRecognizers.Add(tapBluetooth);

            var tapMicrophone = new TapGestureRecognizer();
            tapMicrophone.Tapped += (s, e) =>
            {
                RecordAudio();
            };
            microphoneText.GestureRecognizers.Add(tapMicrophone);
            microphoneImage.GestureRecognizers.Add(tapMicrophone);

            var tapCommandList = new TapGestureRecognizer();
            tapCommandList.Tapped += (s, e) =>
            {
                ViewCommandList();
            };
            commandListText.GestureRecognizers.Add(tapCommandList);
            #endregion gestures
        }
        public void setup()
        {
            //Arrange
            _states = Substitute.For <IRaspberryPiStates>();

            _bluetooth = Substitute.For <IBluetooth>();

            _laserBot = Substitute.For <ISensor>();
            _laserTop = Substitute.For <ISensor>();
            _magnet   = Substitute.For <ISensor>();

            _stopWatch = Substitute.For <MyStopWatch>();

            _context = Substitute.For <Context>();
            //_emptyState = new EmptyState();
            _emptyState = Substitute.For <EmptyState>();
            //_fullState = new FullState();
            _fullState = Substitute.For <FullState>();
            //_notDoneState = new NotDoneState();
            _notDoneState = Substitute.For <NotDoneState>();
        }
 /**
  * Constructor with delegate.
  *
  * @param _delegate The delegate implementing platform specific functions.
  */
 public BluetoothBridge(IBluetooth _delegate) : base()
 {
     this._delegate = _delegate;
 }
Esempio n. 11
0
        private readonly IBluetooth _bluetooth; // อ้างถึง Bluetooth ผ่าน Interface ไม่ใช่ Object

        public SmartPhone(IBluetooth bluetooth) // มีการรับ Object ที่มี Interface IBluetooth เป็น Parameter
        {
            _bluetooth = bluetooth;
        }
Esempio n. 12
0
 public static IFrameworkProxy GetInstance_EXPERIMENTAL(IStorage storage, ILogger logger, IBluetooth bluetooth)
 {
     return(new FrameworkProxy(
                new global::Iridium360.Connect.Framework.Implementations.FrameworkInstance__EXPERIMENTAL(bluetooth, storage, logger: logger),
                logger,
                new RealmPacketBuffer(),
                storage));
 }
Esempio n. 13
0
 public static void SetBluetooth(IBluetooth bluetooth)
 {
     _bluetooth = bluetooth;
 }
Esempio n. 14
0
 public Scan(IBluetooth bluetooth)
 {
     this.bluetooth = bluetooth;
 }
Esempio n. 15
0
 public Read(string serial, IBluetooth bluetooth)
 {
     this.serial = serial;
     thermostats = Thermostats.Read();
     accessor    = new PeripheralAccessor(bluetooth);
 }
Esempio n. 16
0
        public PeripheralAccessor(IBluetooth bluetooth)
        {
            this.bluetooth = bluetooth;

            bluetooth.FailureEventHandler += Failure;
        }
 /**
  * Set the delegate implementation.
  *
  * @param _delegate The delegate implementing platform specific functions.
  */
 public void SetDelegate(IBluetooth _delegate)
 {
     this._delegate = _delegate;
 }