Пример #1
0
 public ServicesPage(IBLEDevice device)
 {
     InitializeComponent();
     BindingContext = vm = new ServicesViewModel(device)
     {
         Navigation = Navigation
     };
 }
Пример #2
0
        public async Task <IBLEDevice> ConnectAsync()
        {
            var newBle = await ble.ConnectAsync().ConfigureAwait(false);

            if (newBle != null)
            {
                ble = newBle;
            }
            return(newBle);
        }
Пример #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);
        }
Пример #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;
 }
Пример #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);
            }
        }
Пример #6
0
 public Peripheral(IBLEDevice bleDevice)
 {
     ble = bleDevice;
 }
Пример #7
0
 public ServicesViewModel(IBLEDevice device)
 {
     ServicesList = new ObservableCollection <IBLEService>();
     App.Device   = device;
 }
Пример #8
0
 private async Task NavigateToServicesPage(IBLEDevice device)
 {
     await Navigation.PushAsync(new ServicesPage(device));
 }