teotestbluetooth / TestXamConnections / TestXamConnections.Android / Services / BluetoothService.cs @ 4af7febc
Historique | Voir | Annoter | Télécharger (1,434 ko)
1 | 3c62e059 | Martin Toutant | using Android.App; |
---|---|---|---|
2 | using Android.Bluetooth; |
||
3 | using Android.Content; |
||
4 | using Android.OS; |
||
5 | using Android.Runtime; |
||
6 | using Android.Views; |
||
7 | using Android.Widget; |
||
8 | using Java.IO; |
||
9 | using Java.Util; |
||
10 | using System; |
||
11 | using System.Collections.Generic; |
||
12 | using System.Collections.ObjectModel; |
||
13 | using System.Linq; |
||
14 | using System.Text; |
||
15 | using System.Threading; |
||
16 | using System.Threading.Tasks; |
||
17 | 91ef3e8c | Martin Toutant | using TestXamConnections.Droid.Receivers; |
18 | using TestXamConnections.Droid.Utils; |
||
19 | using TestXamConnections.Models; |
||
20 | using TestXamConnections.Services; |
||
21 | 3c62e059 | Martin Toutant | |
22 | 91ef3e8c | Martin Toutant | namespace TestXamConnections.Droid.Services |
23 | 3c62e059 | Martin Toutant | { |
24 | public class BluetoothService : IBluetoothService |
||
25 | { |
||
26 | 4ca686e8 | Martin Toutant | private readonly BluetoothAdapter bluetoothAdapter; |
27 | 3c62e059 | Martin Toutant | |
28 | 0875d625 | Martin Toutant | public ObservableCollection<Device> FoundDevices = new ObservableCollection<Device>(); |
29 | 3c62e059 | Martin Toutant | public BluetoothService() |
30 | { |
||
31 | 0875d625 | Martin Toutant | FoundDevices = new ObservableCollection<Device>(); |
32 | 3c62e059 | Martin Toutant | bluetoothAdapter = BluetoothAdapter.DefaultAdapter; |
33 | } |
||
34 | |||
35 | 0875d625 | Martin Toutant | public ICollection<Device> GetBondedDevices() |
36 | 3c62e059 | Martin Toutant | { |
37 | 0875d625 | Martin Toutant | ICollection<Device> ret = new ObservableCollection<Device>(); |
38 | 3c62e059 | Martin Toutant | foreach (BluetoothDevice bondedDevice in bluetoothAdapter.BondedDevices) |
39 | { |
||
40 | 0875d625 | Martin Toutant | Device toAddItem = new Device |
41 | 3c62e059 | Martin Toutant | { |
42 | MACAddress = bondedDevice.Address, |
||
43 | Name = bondedDevice.Name |
||
44 | }; |
||
45 | ret.Add(toAddItem); |
||
46 | } |
||
47 | return ret; |
||
48 | } |
||
49 | } |
||
50 | } |