teotestbluetooth / TestXamConnections / TestXamConnections.Android / Services / BluetoothService.cs @ master
Historique | Voir | Annoter | Télécharger (1,144 ko)
1 | 3fa496d6 | Martin Toutant | using Android.Bluetooth; |
---|---|---|---|
2 | 3c62e059 | Martin Toutant | using System.Collections.Generic; |
3 | using System.Collections.ObjectModel; |
||
4 | 3fa496d6 | Martin Toutant | using TestXamConnections.Device; |
5 | 91ef3e8c | Martin Toutant | using TestXamConnections.Services; |
6 | 3c62e059 | Martin Toutant | |
7 | 91ef3e8c | Martin Toutant | namespace TestXamConnections.Droid.Services |
8 | 3c62e059 | Martin Toutant | { |
9 | public class BluetoothService : IBluetoothService |
||
10 | { |
||
11 | 4ca686e8 | Martin Toutant | private readonly BluetoothAdapter bluetoothAdapter; |
12 | 3c62e059 | Martin Toutant | |
13 | 340558f2 | martin.toutant | public ObservableCollection<InfoAppareil> FoundDevices = new ObservableCollection<InfoAppareil>(); |
14 | 3c62e059 | Martin Toutant | public BluetoothService() |
15 | { |
||
16 | 340558f2 | martin.toutant | FoundDevices = new ObservableCollection<InfoAppareil>(); |
17 | 3c62e059 | Martin Toutant | bluetoothAdapter = BluetoothAdapter.DefaultAdapter; |
18 | } |
||
19 | |||
20 | 340558f2 | martin.toutant | public ICollection<InfoAppareil> GetBondedDevices() |
21 | 3c62e059 | Martin Toutant | { |
22 | 340558f2 | martin.toutant | ICollection<InfoAppareil> ret = new ObservableCollection<InfoAppareil>(); |
23 | 3c62e059 | Martin Toutant | foreach (BluetoothDevice bondedDevice in bluetoothAdapter.BondedDevices) |
24 | { |
||
25 | 340558f2 | martin.toutant | InfoAppareil toAddItem = new InfoAppareil |
26 | 3c62e059 | Martin Toutant | { |
27 | 340558f2 | martin.toutant | AdresseMAC = bondedDevice.Address, |
28 | Nom = bondedDevice.Name |
||
29 | 3c62e059 | Martin Toutant | }; |
30 | ret.Add(toAddItem); |
||
31 | } |
||
32 | return ret; |
||
33 | } |
||
34 | } |
||
35 | } |