Révision 4ca686e8 TestTeoBluetooth/TestTeoBluetooth.Android/Services/BluetoothService.cs
TestTeoBluetooth/TestTeoBluetooth.Android/Services/BluetoothService.cs | ||
---|---|---|
14 | 14 |
using System.Text; |
15 | 15 |
using System.Threading; |
16 | 16 |
using System.Threading.Tasks; |
17 |
using TestBLE.Droid.Receivers;
|
|
18 |
using TestBLE.Droid.Utils;
|
|
19 |
using TestBLE.Models;
|
|
20 |
using TestBLE.Services;
|
|
17 |
using TeoTestBluetooth.Droid.Receivers;
|
|
18 |
using TeoTestBluetooth.Droid.Utils;
|
|
19 |
using TeoTestBluetooth.Models;
|
|
20 |
using TeoTestBluetooth.Services;
|
|
21 | 21 |
|
22 |
namespace TestBLE.Droid.Services
|
|
22 |
namespace TeoTestBluetooth.Droid.Services
|
|
23 | 23 |
{ |
24 | 24 |
public class BluetoothService : IBluetoothService |
25 | 25 |
{ |
26 | 26 |
|
27 |
private List<BluetoothDevice> discoveredDevices = new List<BluetoothDevice>(); |
|
27 |
private readonly List<BluetoothDevice> discoveredDevices = new List<BluetoothDevice>(); |
|
28 |
private readonly BluetoothAdapter bluetoothAdapter; |
|
29 |
private readonly BluetoothReceiver bluetoothReceiver; |
|
28 | 30 |
private TaskCompletionSource<bool> scanCompletionSource; |
29 |
private BluetoothManager bluetoothManager; |
|
30 |
private BluetoothAdapter bluetoothAdapter; |
|
31 |
private BluetoothReceiver bluetoothReceiver; |
|
32 | 31 |
|
33 | 32 |
private Thread listeningThread; |
34 | 33 |
private BluetoothSocket socket; |
35 | 34 |
private readonly string sppUUID = "00001101-0000-1000-8000-00805f9b34fb"; |
36 |
private string bufferedData; |
|
37 | 35 |
|
38 | 36 |
public ObservableCollection<BTDevice> FoundDevices = new ObservableCollection<BTDevice>(); |
39 | 37 |
public BluetoothService() |
... | ... | |
212 | 210 |
return Task.FromResult(true); |
213 | 211 |
} |
214 | 212 |
|
215 |
private byte[] hexValuesToByteArray(string[] hexValues) |
|
216 |
{ |
|
217 |
byte[] ret = hexValues.Select(value => Convert.ToByte(value, 16)).ToArray(); |
|
218 |
return ret; |
|
219 |
} |
|
220 |
|
|
221 | 213 |
public Task<bool> SendHexValues(byte[] hexValues) |
222 | 214 |
{ |
223 | 215 |
if (socket.IsConnected == false) |
Formats disponibles : Unified diff