Révision 03682d21 SICPA_Connexions/Model/GestionnaireBLE.cs

Voir les différences:

SICPA_Connexions/Model/GestionnaireBLE.cs
20 20
        private List<ICharacteristic> charList;
21 21
        private ICharacteristic characRead;
22 22
        private ICharacteristic characWrite;
23
        private String retourBLE;
24
        public event EventHandler RetourBlEMofifiee;
23 25
        public IDevice DeviceConnected { get; set; }
24 26
        public IService SelectedService { get; set; }
25
        public String RetourBLE { get; set; }
27
        public String RetourBLE
28
        {
29
            get
30
            {
31
                return retourBLE;
32
            }
33
            set
34
            {
35
                if (retourBLE != value)
36
                {
37
                    retourBLE = value;
38
                    OnRetourBLEMofifiee(EventArgs.Empty);
39
                }
40
            }
41
        }
42

  
43
        public void OnRetourBLEMofifiee(EventArgs e)
44
        {
45
            RetourBlEMofifiee?.Invoke(this, e);
46
        }
26 47

  
27 48
        public GestionnaireBLE()
28 49
        {
......
173 194
            //});
174 195
        }
175 196

  
197
        public  async Task LectureTag(IDevice deviceConnected)
198
        {
199
            try
200
            {
201
                String cmd = "READ";
202

  
203
                List<byte> local_frame = new List<byte>();
204
                CRC crcProcess = new CRC();
205
                byte local_crc;
206

  
207
                local_frame.Add(BytesPrtc.STX); //add STX byte
208
                local_frame.Add(BytesPrtc.DST_TX); //add DST byte
209
                local_frame.Add(BytesPrtc.SRC_TX); //add SRC byte
210
                for (int i = 0; i < cmd.Length; i++)
211
                {
212
                    local_frame.Add((byte)cmd[i]); //add cmd string 
213
                }
214
                crcProcess.putBytes(local_frame.ToArray()); //send that buffer (without "the CRC" and ETX bytes !)
215
                local_crc = crcProcess.getCRC(); //calculate CRC with that buffer
216

  
217
                local_frame.Add(local_crc); //add CRC byte
218
                local_frame.Add(BytesPrtc.ETX); //add ETX byte
219

  
220
                /////////////////////////////////////////////
221
                //And now send buffer !
222
                await characWrite.WriteAsync(local_frame.ToArray());
223
                await characRead.StartUpdatesAsync();
224
            }
225
            catch
226
            {
227
                await Application.Current.MainPage.DisplayAlert("Erreur de lecture", "Erreur de lecture du Tag", "OK");
228
            }
229
        }
230

  
176 231
    }
177 232
}

Formats disponibles : Unified diff