Statistiques
| Branche: | Révision:

teotestbluetooth / TestXamConnections / TestXamConnections.Android / Services / BluetoothService.cs @ 340558f2

Historique | Voir | Annoter | Télécharger (1,144 ko)

1
using Android.Bluetooth;
2
using System.Collections.Generic;
3
using System.Collections.ObjectModel;
4
using TestXamConnections.Device;
5
using TestXamConnections.Services;
6

    
7
namespace TestXamConnections.Droid.Services
8
{
9
    public class BluetoothService : IBluetoothService
10
    {
11
        private readonly BluetoothAdapter bluetoothAdapter;
12

    
13
        public ObservableCollection<InfoAppareil> FoundDevices = new ObservableCollection<InfoAppareil>();
14
        public BluetoothService()
15
        {
16
            FoundDevices = new ObservableCollection<InfoAppareil>();
17
            bluetoothAdapter = BluetoothAdapter.DefaultAdapter;
18
        }
19

    
20
        public ICollection<InfoAppareil> GetBondedDevices()
21
        {
22
            ICollection<InfoAppareil> ret = new ObservableCollection<InfoAppareil>();
23
            foreach (BluetoothDevice bondedDevice in bluetoothAdapter.BondedDevices)
24
            {
25
                InfoAppareil toAddItem = new InfoAppareil
26
                {
27
                    AdresseMAC = bondedDevice.Address,
28
                    Nom = bondedDevice.Name
29
                };
30
                ret.Add(toAddItem);
31
            }
32
            return ret;
33
        }
34
    }
35
}