diff --git a/ProftaakRH/BLEHandler.cs b/ProftaakRH/BLEHandler.cs index a832567..b25ef03 100644 --- a/ProftaakRH/BLEHandler.cs +++ b/ProftaakRH/BLEHandler.cs @@ -7,6 +7,9 @@ using System.Security.Cryptography; namespace Hardware { + /// + /// BLEHandler class that handles connection and traffic to and from the bike + /// class BLEHandler { IDataConverter dataConverter; @@ -14,12 +17,19 @@ namespace Hardware private BLE bleHeart; public bool Running { get; set; } + /// + /// Makes a new BLEHandler object + /// + /// the dataconverter object public BLEHandler(IDataConverter dataConverter) { this.dataConverter = dataConverter; bool running = false; } + /// + /// Checks for available devices to connect to, and if one is found, it connects to it + /// public void Connect() { BLE bleBike = new BLE(); @@ -40,6 +50,11 @@ namespace Hardware } } } + + /// + /// Connects to the device with the given name + /// + /// The name of the device to connect to public async void Connect(string deviceName) { int errorCode = 0; @@ -95,12 +110,17 @@ namespace Hardware Console.WriteLine("connected to BLE"); this.Running = true; + } + /// + /// Callback for when the subscription value of the ble bike has changed + /// + /// the sender object + /// the value changed event private void BleBike_SubscriptionValueChanged(object sender, BLESubscriptionValueChangedEventArgs e) { - if (e.ServiceName == "6e40fec2-b5a3-f393-e0a9-e50e24dcca9e") { byte[] payload = new byte[8]; @@ -118,6 +138,9 @@ namespace Hardware } + /// + /// Disposes of the current BLE object, if it exists. + /// private void disposeBLE() { this.bleBike?.Dispose(); @@ -125,6 +148,10 @@ namespace Hardware this.Running = false; } + /// + /// Method setResistance converts the input percentage to bytes and sends it to the bike. + /// + /// The precentage of resistance to set public void setResistance(float percentage) { byte[] antMessage = new byte[13];