private void HandleConnectedPeripheral(object sender, CBPeripheralEventArgs e)
 {
     System.Threading.Tasks.Task.Run(() =>
     {
         GetPeripheralManager().HandleConnectedPeripheral(e);
     }).FireAndForget();
 }
        private void ConnectedPeripheral(object sender, CBPeripheralEventArgs e)
        {
            var deviceId = Device.DeviceIdentifierToGuid(e.Peripheral.Identifier);
            //var device = _devices.FirstOrDefault (x => x.Id == deviceId);
            var device = new Device(e.Peripheral);

            DeviceConnected(this, new DeviceConnectionEventArgs(device));
        }
Exemple #3
0
		void HandleDeviceConnected (object sender, CBPeripheralEventArgs e)
		{
			connectingDialog.Hide (false);

			detailsScreen = Storyboard.InstantiateViewController ("DeviceDetailsScreen") as DeviceDetailsScreen;
			detailsScreen.ConnectedPeripheral = e.Peripheral;
			NavigationController.PushViewController (detailsScreen, true);
		}
        void HandleDeviceConnected(object sender, CBPeripheralEventArgs e)
        {
            connectingDialog.Hide(false);

            detailsScreen = Storyboard.InstantiateViewController("DeviceDetailsScreen") as DeviceDetailsScreen;
            detailsScreen.ConnectedPeripheral = e.Peripheral;
            NavigationController.PushViewController(detailsScreen, true);
        }
Exemple #5
0
 // This method gets called whenver a device is connected
 public void ConnectedDevice(object sender, CBPeripheralEventArgs args)
 {
     // Invokes the DeviceConnected method in the ViewController.cs page
     if (args.Peripheral.State == CBPeripheralState.Connected)
     {
         Console.WriteLine($"Connected to {args.Peripheral}");
     }
     this.DeviceConnected?.Invoke(sender, args);
 }
Exemple #6
0
        private void OnConnectedPeripheral(object sender, CBPeripheralEventArgs e)
        {
            if (!ReferenceEquals(e.Peripheral, Peripheral))
            {
                return;
            }

            RaiseConnected();
        }
Exemple #7
0
        static void OnManagerConnectedPeripheral(object sender, CBPeripheralEventArgs e)
        {
            Console.WriteLine("Connected peripheral");

            peripheral.DiscoveredService             += OnPeripheralDiscoveredService;
            peripheral.DiscoveredCharacteristic      += OnPeripheralDiscoveredCharacteristic;
            peripheral.UpdatedCharacterteristicValue += OnPeripheralUpdatedCharacteristicValue;
            peripheral.DiscoverServices();
        }
Exemple #8
0
        public void HandleConnectedPeripheral(CBPeripheralEventArgs evnt)
        {
            var descriptor = evnt.Peripheral.ToDeviceDescriptor();

            _manager.HandleDeviceConnected(descriptor, (d) =>
            {
                evnt.Peripheral.Delegate = new PeripheralDelegate(_centralManager, _manager, _tracingInformation);
                evnt.Peripheral.DiscoverServices();
            });
        }
Exemple #9
0
        private void ConnectedPeripheral(object sender, CBPeripheralEventArgs e)
        {
            var deviceId = Device.DeviceIdentifierToGuid(e.Peripheral.Identifier);

            if (ConnectedDevices.All(x => x.Id != deviceId))
            {
                var device = new Device(e.Peripheral);
                ConnectedDevices.Add(device);
                DeviceConnected(this, new DeviceConnectionEventArgs(device));
            }
        }
Exemple #10
0
        void ConnectedPeripheral(object sender, CBPeripheralEventArgs e)
        {
            Console.Error.WriteLine("Connected. Discovering services.");
            central.ConnectedPeripheral -= ConnectedPeripheral;
            central.StopScan();
            connectedCbPeripheral = e.Peripheral;

            connectedCbPeripheral.DiscoveredService             += DiscoveredService;
            connectedCbPeripheral.UpdatedCharacterteristicValue += UpdatedCharacterteristicValue;
            connectedCbPeripheral.WroteCharacteristicValue      += WroteCharacteristicValue;
            connectedCbPeripheral.DiscoverServices();
        }
Exemple #11
0
        void ConnectedPeripheral(object sender, CBPeripheralEventArgs e)
        {
            var peripheral     = e.Peripheral;
            var ble_peripheral = devices [peripheral.Identifier.ToString()];

            ble_peripheral.State = "Connected";

            Console.WriteLine("ConnectedPeripheral: {0}", peripheral.Name);

            peripheral.DiscoveredService        += Peripheral_DiscoveredServices;
            peripheral.DiscoveredCharacteristic += Peripheral_DiscoveredCharacteristic;
            peripheral.DiscoverServices();

            OnSomethingHappened();
        }
Exemple #12
0
        private void DeviceConnected(object sender, CBPeripheralEventArgs args)
        {
            // This isn't working, but also not a focus so haven't fixed yet
            for (int i = 0; i < View.Subviews.Length; i++)
            {
                View.Subviews[i].Dispose();
                View.Subviews[i] = null;
            }

            Console.WriteLine("Peripheral State: " + args.Peripheral.State);

            var disconnectBtn = UIButton.FromType(UIButtonType.System);

            disconnectBtn.Frame = new CGRect(10, (View.Bounds.Height / 2) - 50, View.Bounds.Width - 10, 40);
            disconnectBtn.SetTitle("Disconnect", UIControlState.Normal);

            disconnectBtn.TouchUpInside += async(sendoo, e) =>
            {
                await this.bluetoothService.Disconnect(args.Peripheral, 2000);
            };

            View.AddSubview(disconnectBtn);
        }
Exemple #13
0
        void OnConnectedPeripheral(object sender, CBPeripheralEventArgs e)
        {
            BLEPeripheral peripheral = null;

            foreach (BLEPeripheral blep in discoveredPeripherals)
            {
                if (blep.UUID.StringValue == e.Peripheral.ToString())
                {
                    peripheral = blep;

                    break;
                }
            }

            EventHandler <BLEPeripheralEventArgs> handler = ConnectedToPeripheral;

            if (handler != null)
            {
                BLEPeripheralEventArgs args = new BLEPeripheralEventArgs();
                args.Peripheral = peripheral;

                handler(this, args);
            }
        }
 private void OnConnectedPeripheral(object sender, CBPeripheralEventArgs e)
 => _wes.RaiseEvent(nameof(ConnectedPeripheral), sender, e);
Exemple #15
0
 private void _centralManager_ConnectedPeripheral(object sender, CBPeripheralEventArgs e)
 {
     Debug.WriteLine("Peripheral Connected");
     _devices.Single(x => ((CBPeripheral)x.NativeDevice).Identifier == e.Peripheral.Identifier).Connected = true;
     _deviceConnected.Set();
 }
		private void ConnectedPeripheral(object sender, CBPeripheralEventArgs e)
		{
			var deviceId = Device.DeviceIdentifierToGuid(e.Peripheral.Identifier);
			if (ConnectedDevices.All(x => x.Id != deviceId))
			{
				var device = new Device(e.Peripheral);
				ConnectedDevices.Add(device);
				DeviceConnected(this, new DeviceConnectionEventArgs(device));
			}
		}
Exemple #17
0
 private void ManagerOnConnectedPeripheral(object sender, CBPeripheralEventArgs e)
 {
     _peripheral = e.Peripheral;
 }
 private void OnConnectedPeripheral(object sender, CBPeripheralEventArgs args)
 {
     Debug.WriteLine("Successfully connected peripheral: " + args.Peripheral.Name);
     _connectedPeripheralTaskSource.TrySetResult(args.Peripheral);
 }