From 6e07f3b33a9e2a259def00acbd00032d526be0e8 Mon Sep 17 00:00:00 2001 From: shinichi Date: Fri, 11 Sep 2020 11:50:28 +0200 Subject: [PATCH 1/2] fixed instant power who doesn't love bit flipping --- ProftaakRH/BLEHandler.cs | 2 +- ProftaakRH/DataConverter.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ProftaakRH/BLEHandler.cs b/ProftaakRH/BLEHandler.cs index 85d1072..e32fea5 100644 --- a/ProftaakRH/BLEHandler.cs +++ b/ProftaakRH/BLEHandler.cs @@ -151,7 +151,7 @@ namespace Hardware antMessage[12] = checksum;//reminder that i am dumb :P - bleBike.WriteCharacteristic("6E40FEC3-B5A3-F393-E0A9-E50E24DCCA9E", antMessage); + bleBike.WriteCharacteristic("6e40fec3-b5a3-f393-e0a9-e50e24dcca9e", antMessage); } } } diff --git a/ProftaakRH/DataConverter.cs b/ProftaakRH/DataConverter.cs index 7af4cdd..beb3684 100644 --- a/ProftaakRH/DataConverter.cs +++ b/ProftaakRH/DataConverter.cs @@ -44,16 +44,17 @@ namespace Hardware Console.WriteLine($"Accumulated power: {accumPower} watt (Rollover 65536)"); - int instantPower = (bytes[5]) | (bytes[6]>>4)<<8; + int instantPower = (bytes[5]) | (bytes[6] & 0b00001111)<<8; if (instantPower != 0xFFF) Console.WriteLine($"Instant power: {instantPower} watt (Range 0-4094)"); - int trainerStatus = bytes[6] & 0b00001111; // bit 4-7 + int trainerStatus = bytes[6] & 0b11110000; // bit 4-7 int flags = bytes[7] >> 4; int FEState = bytes[7] & 0b00001111; + break; default: From e77372c91303ab39bca1db242311e36ae42874a0 Mon Sep 17 00:00:00 2001 From: shinichi Date: Fri, 11 Sep 2020 12:39:06 +0200 Subject: [PATCH 2/2] added resistance changing --- ProftaakRH/Main.cs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/ProftaakRH/Main.cs b/ProftaakRH/Main.cs index 4365a26..1bed6eb 100644 --- a/ProftaakRH/Main.cs +++ b/ProftaakRH/Main.cs @@ -23,7 +23,25 @@ namespace ProftaakRH } bLEHandler.setResistance(25); - Console.ReadLine(); + while (true) + { + string input = Console.ReadLine(); + input.ToLower(); + input.Trim(); + if(input == "quit") + { + break; + } + try + { + int resistance = Int32.Parse(input); + bLEHandler.setResistance(resistance); + } + catch + { + //do nothing + } + } } } }