Révision 340558f2 TestXamConnections/TestXamConnections.Android/Connection/BluetoothConnectionService.cs

Voir les différences:

TestXamConnections/TestXamConnections.Android/Connection/BluetoothConnectionService.cs
15 15
    /* Classe permettant d'établir une connection Bluetooth
16 16
     * Avec socket RFCOMM connecté au SPP
17 17
     */
18
    public class BluetoothConnectionService : IConnectionService
18
    public class BluetoothConnexionService : IConnexionService
19 19
    {
20 20
        private readonly BluetoothAdapter bluetoothAdapter;
21 21
        private Thread listeningThread;
22 22
        private BluetoothSocket socket;
23 23
        private readonly string sppUUID = "00001101-0000-1000-8000-00805f9b34fb";
24 24

  
25
        public BluetoothConnectionService()
25
        public BluetoothConnexionService()
26 26
        {
27 27
            bluetoothAdapter = BluetoothAdapter.DefaultAdapter;
28 28
        }
29 29

  
30 30
        // Pour le bluetooth, le paramètre de connection est l'addresse MAC
31
        public async Task<bool> Connect(Dictionary<string, string> param)
31
        public async Task<bool> Connexion(Dictionary<string, string> param)
32 32
        {
33 33
            try
34 34
            {
......
39 39
                    _ = bluetoothAdapter.CancelDiscovery();
40 40
                }
41 41

  
42
                if (param.ContainsKey(ConnectionConstants.MAC_ADDR_KEY))
42
                if (param.ContainsKey(ConnexionConstantes.MAC_ADDR_KEY))
43 43
                {
44
                    BluetoothDevice droidBtDevice = bluetoothAdapter.GetRemoteDevice(param[ConnectionConstants.MAC_ADDR_KEY]);
44
                    BluetoothDevice droidBtDevice = bluetoothAdapter.GetRemoteDevice(param[ConnexionConstantes.MAC_ADDR_KEY]);
45 45
                    if (droidBtDevice != null)
46 46
                    {
47 47
                        // Si le socket est occupé pour une autre connexion
......
80 80
            return true;
81 81
        }
82 82

  
83
        public EventHandler<byte[]> DataReceivedEvent { get; set; }
83
        public EventHandler<byte[]> DonneesRecuesEvent { get; set; }
84 84

  
85 85
        // Fonction d'écoute pour le Thread d'écoute
86 86
        private async Task ListeningAsync()
......
94 94
                    // Resize the byte array 
95 95
                    byte[] filledBuffer = buffer.Take(byteAvailable).ToArray();
96 96
                    // Trigger DataReceivedEvent
97
                    Application.SynchronizationContext.Post(_ => { DataReceivedEvent.Invoke(this, filledBuffer); }, null);
97
                    Application.SynchronizationContext.Post(_ => { DonneesRecuesEvent.Invoke(this, filledBuffer); }, null);
98 98
                }
99 99
            }
100 100
            catch (IOException ex)
......
118 118
            return Task.FromResult(true);
119 119
        }
120 120

  
121
        public Task<bool> SendCommand(byte[] command)
121
        public Task<bool> EnvoiCommande(byte[] command)
122 122
        {
123 123

  
124 124
            if (socket.IsConnected == false)

Formats disponibles : Unified diff