Esempio n. 1
0
            public void OnLeScan(BluetoothDevice device, int rssi, byte[] scanRecord)
            {
                if (device.Name != null && device.Address != null)
                {
                    bool isFound     = _devicesFound.Any(p => string.Equals(p.Address, device.Address, StringComparison.CurrentCulture));
                    bool isPaired    = _pairedDeviceList.Any(p => string.Equals(p, device.Address, StringComparison.CurrentCulture));
                    bool isConnected = _connectedDevicesList.Any(p => string.Equals(p, device.Address, StringComparison.CurrentCulture));

                    // if the device was not already found in this scan, not already connected, or not already in the list of paired devices
                    if ((!isFound) && (!isPaired) && (!isConnected))
                    {
                        // If the device is supported
                        if (AppUtil.isSupported(device))
                        {
                            if (_devicesFound.Count == 0)
                            {
                                clearNewDeviceListViews();
                                setNewDeviceListViewClick(true);
                                string t = "";
                            }

                            newDevicesArrayAdapter.Add(device.Name + "\n" + device.Address);
                            _devicesFound.Add(device);
                        }
                    }
                }
            }
Esempio n. 2
0
        /// <summary>
        /// Add the already paired devices to the paired array adapter
        /// </summary>
        private void addBoundedDevices()
        {
            var deviceList = AppUtil.addPairedDevices(_adpt);

            // Clearing the list
            myAct.RunOnUiThread(delegate
            {
                _pairedDeviceList.Clear();
            });

            // If there are paired devices, add each one to the ArrayAdapter
            if (deviceList.Count > 0)
            {
                //_pairedDeviceListView.ItemClick += deviceClick;
                foreach (BluetoothDevice device in deviceList)
                {
                    bool isPaired    = _pairedDeviceList.Any(p => string.Equals(p, device.Address, StringComparison.CurrentCulture));
                    bool isConnected = _connectedDevicesList.Any(p => string.Equals(p, device.Address, StringComparison.CurrentCulture));

                    // If the device was not already found and is not currently connected
                    if ((!isPaired) && (!isConnected))
                    {
                        // If the device is supported
                        if (AppUtil.isSupported(device))
                        {
                            pairedDevicesArrayAdapter.Add(device.Name + "\n" + device.Address);

                            pairedDevicesArrayAdapter.NotifyDataSetChanged();

                            _pairedDeviceList.Add(device.Address);
                        }
                    }
                }
            }

            boundDeviceScanUI();
        }