This commit is contained in:
shinichi
2020-09-09 14:49:40 +02:00
parent c5863e9026
commit 650f308cf5
2 changed files with 74 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using Avans.TI.BLE;
using System.Threading;
using System.Security.Cryptography;
namespace Hardware
{
@@ -12,7 +12,7 @@ namespace Hardware
IDataConverter dataConverter;
private BLE bleBike;
private BLE bleHeart;
public bool running { get; }
public bool running { get; set; }
public BLEReciever(IDataConverter dataConverter)
{
@@ -92,14 +92,31 @@ namespace Hardware
disposeBLE();
return;
}
Console.WriteLine("connected to BLE");
this.running = true;
}
private void BleBike_SubscriptionValueChanged(object sender, BLESubscriptionValueChangedEventArgs e)
{
Console.WriteLine("Received from {0}: {1}", e.ServiceName,
BitConverter.ToString(e.Data).Replace("-", " "));
//Console.WriteLine("Received from {0}: {1}", e.ServiceName,
// BitConverter.ToString(e.Data).Replace("-", " "));
//send to dataconverter
if (e.ServiceName == "6e40fec2-b5a3-f393-e0a9-e50e24dcca9e")
{
byte[] payload = new byte[8];
Array.Copy(e.Data, 4, payload, 0, 8);
this.dataConverter.Bike(payload);
}else if(e.ServiceName == "00002a37-0000-1000-8000-00805f9b34fb")
{
this.dataConverter.BPM(e.Data);
}
else
{
Console.WriteLine("received data from unknown source {0}", e.ServiceName);
}
}
private void disposeBLE()