Esempio n. 1
0
 public ServicesPage(IBLEDevice device)
 {
     InitializeComponent();
     BindingContext = vm = new ServicesViewModel(device)
     {
         Navigation = Navigation
     };
 }
Esempio n. 2
0
        public async Task <IBLEDevice> ConnectAsync()
        {
            var newBle = await ble.ConnectAsync().ConfigureAwait(false);

            if (newBle != null)
            {
                ble = newBle;
            }
            return(newBle);
        }
Esempio n. 3
0
        public async Task <bool> ConnectAsync(string id, IBLEDevice device)
        {
#if UNITY_EDITOR || UNITY_WEBGL
            var success = await webSocketProxy.ConnectAsync(id).ConfigureAwait(false);
#else
            var success = await blePlugin.ConnectTo(id, this, this).ConfigureAwait(false);
#endif
            if (success && !bleConnectionDict.ContainsKey(id))
            {
                bleConnectionDict.Add(id, device);
            }
            return(success);
        }
Esempio n. 4
0
 public void Dispose()
 {
     UnlistenEvent();
     ble?.Disconnect();
     DeviceLostEvent       = null;
     AccelUpdateEvent      = null;
     GyroUpdateEvent       = null;
     CompassUpdateEvent    = null;
     QuaternionUpdateEvent = null;
     IMUSensorUpdateEvent  = null;
     ButtonPushEvent       = null;
     ButtonReleaseEvent    = null;
     ble = null;
 }
Esempio n. 5
0
        public BLEService(BluetoothGattService nativeService, IBLEDevice device)
        {
            _nativeService  = nativeService;
            _device         = device;
            Characteristics = new List <IBLECharacteristic>();

            Guid      = GuidHelper.FromUUID(_nativeService.Uuid);
            IsPrimary = (_nativeService.Type == GattServiceType.Primary);

            foreach (var item in _nativeService.Characteristics)
            {
                var characteristic = new BLECharacteristic(item);
                Characteristics.Add(characteristic);
            }
        }
Esempio n. 6
0
 public Peripheral(IBLEDevice bleDevice)
 {
     ble = bleDevice;
 }
Esempio n. 7
0
 public ServicesViewModel(IBLEDevice device)
 {
     ServicesList = new ObservableCollection <IBLEService>();
     App.Device   = device;
 }
Esempio n. 8
0
 private async Task NavigateToServicesPage(IBLEDevice device)
 {
     await Navigation.PushAsync(new ServicesPage(device));
 }