예제 #1
0
        private void Receiver_BleReceiveEvent(object sender, BluetoothDeviceReceiver.BleEventArg e)
        {
            switch (e.EventCode)
            {
            case BluetoothDeviceReceiver.BleEventCode.FoundNew:
            {
                if (List_BDevices.Any(x => x.Address == e.FounedDevice.Address))
                {
                    return;
                }
                if (string.IsNullOrEmpty(e.FounedDevice.Name) || !e.FounedDevice.Name.StartsWith("YR"))
                {
                    return;
                }
                List_BDevices.Add(e.FounedDevice);

                ysRecyclerViewAdapter.DataList.Add(new Mod_BlueTooth
                    {
                        BtAdress    = e.FounedDevice.Address,
                        BtName      = e.FounedDevice.Name,
                        BtConnected = e.FounedDevice.BondState != Android.Bluetooth.Bond.None,
                        Rssi        = e.Rssi,
                    });
                ysRecyclerViewAdapter.NotifyDataSetChanged();
            }
            break;
            }
        }
예제 #2
0
        private void Receiver_BleReceiveEvent(object sender, BluetoothDeviceReceiver.BleEventArg e)
        {
            switch (e.EventCode)
            {
            case BluetoothDeviceReceiver.BleEventCode.FoundNew:
            {
                if (ysAdapter.DataList.Any(x => x.BtCode == e.FounedDevice.Address))
                {
                    return;
                }
                ysAdapter.DataList.Add(new MVVM.Core.Models.Mod_BlueTooth
                    {
                        BtCode      = e.FounedDevice.Address,
                        BtName      = e.FounedDevice.Name,
                        BtConnected = e.FounedDevice.BondState != Android.Bluetooth.Bond.None,
                        Rssi        = e.Rssi,
                    });
                ysAdapter.DataList = ysAdapter.DataList.OrderBy(x => x.Rssi).ToList();
                List_MemoryBle.Add(e.FounedDevice);
                ysAdapter.NotifyDataSetChanged();
            }
            break;

            case BluetoothDeviceReceiver.BleEventCode.DiscoveryStart:
                break;

            case BluetoothDeviceReceiver.BleEventCode.DiscoveryFinished:
                break;
            }
        }