示例#1
0
        public ObservableCollection <string> PairedDevices()
        {
            //throw new NotImplementedException();

            EAAccessoryManager manager = EAAccessoryManager.SharedAccessoryManager;
            var allaccessorries        = manager.ConnectedAccessories;

            foreach (var accessory in allaccessorries)
            {
                //yourlable.Text = "find accessory";
                Console.WriteLine(accessory.ToString());
                Console.WriteLine(accessory.Name);
                var protocol = "com.Yourprotocol.name";

                if (accessory.ProtocolStrings.Where(s => s == protocol).Any())
                {
                    //yourlable.Text = "Accessory  found";
                    //start session
                    var session = new EASession(accessory, protocol);
                    //var outputStream = session.OutputStream;
                    //outputStream.Delegate = new MyOutputStreamDelegate(yourlable);
                    //outputStream.Schedule(NSRunLoop.Current, "kCFRunLoopDefaultMode");
                    //outputStream.Open();
                }
            }

            return(new ObservableCollection <string>()
            {
                "AAA", "BBB"
            });
        }
示例#2
0
        public List <string> PairedDevices()
        {
            //throw new NotImplementedException();
            var devices = new List <string>();

            EAAccessoryManager manager = EAAccessoryManager.SharedAccessoryManager;
            var allaccessorries        = manager.ConnectedAccessories;

            return(allaccessorries.Select(a => a.Name).ToList());
        }
        partial void DisconnectUpInside(UIButton sender)
        {
            EAAccessoryManager manager = EAAccessoryManager.SharedAccessoryManager;

            //manager.ShowBluetoothAccessoryPicker(null, (obj) => HandleAccessoryPickerResult(obj));//Console.WriteLine($"object is null is {obj == null}"));

            //CBUUID[] x = { };
            //_cbCentralManager.RetrievePeripherals(x);

            //NSUuid[] nsuuids = { };
            //CBUUID[] cbuuids = { };

            //CBCentralManager _cbCentralManager = new CBCentralManager();

            //// get list of peripherals from manager, using the array we just created as a lookup
            //CBPeripheral[] peripherals = _cbCentralManager.RetrievePeripheralsWithIdentifiers(nsuuids);

            //Console.WriteLine($"count is {peripherals.Length}");



            //var allaccessorries = manager.ConnectedAccessories.ToList();

            //StringBuilder sb = new StringBuilder();

            //if (allaccessorries.Count > 0)
            //{
            //	foreach (var accessory in allaccessorries)
            //	{
            //		sb.Append(accessory.Name);
            //	}
            //}
            //else
            //	sb.AppendLine("no accessories found");

            //Console.WriteLine(sb);



            foreach (var sensorMonitor in GetMonitorsForSelectedPeripherals())
            {
                _sensorManager.DisconnectFromSensor(sensorMonitor.ID);
            }


            //GetSelectedPeripherals().ForEach(p => _sensorManager.DisconnectFromSensor(p.Identifier));
            _connectedDevicesCollectionView.ReloadData();
        }
        public async Task OpenOutputStream()
        {
            try
            {
                EAAccessoryManager _manager = EAAccessoryManager.SharedAccessoryManager;
                var _accessories            = _manager.ConnectedAccessories;

                foreach (var _accessory in _accessories)
                {
                    Acr.UserDialogs.UserDialogs.Instance.Toast(_accessory.Connected.ToString());
                }
            }
            catch (System.Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
示例#5
0
        public void Start(string name, int sleepTime, bool readAsCharArray)
        {
            if (Session != null)
            {
                throw new Exception("Session already started");
            }

            // get session with the given device name
            EAAccessoryManager manager = EAAccessoryManager.SharedAccessoryManager;
            var allaccessorries        = manager.ConnectedAccessories;

            foreach (var accessory in allaccessorries)
            {
                if (String.Equals(accessory.Name, name, StringComparison.CurrentCultureIgnoreCase))
                {
                    Session = new EASession(accessory, Protocol);
                    Session.Accessory.Disconnected += Accessory_Disconnected;

                    Session.InputStream.Schedule(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode);
                    Session.InputStream.OnEvent += InputStream_OnEvent;
                    Session.InputStream.Open();
                }
            }
        }
 public HeartRateMonitor_BTClassic()
 {
     _accessoryManager = EAAccessoryManager.SharedAccessoryManager;
 }
 public IOsBluetoothCommunication()
 {
     _manager = EAAccessoryManager.SharedAccessoryManager;
 }