private void BleBike_SubscriptionValueChanged(object sender, BLESubscriptionValueChangedEventArgs e) { //foreach (byte b in e.Data) //{ // Console.Write(b + " "); //} if (e.ServiceName == "6e40fec2-b5a3-f393-e0a9-e50e24dcca9e") { if (e.Data[4] == 16) { float Speed = (e.Data[9] * 256 + e.Data[8]) / 1000.00f; OnSpeed?.Invoke(this, Speed); //Console.WriteLine("\n\tSpeed: " + Speed + "m/s"); //Console.WriteLine("\telapsed time: " + e.Data[6]/4.0 + " seconds"); //Console.WriteLine("\telapsed distance: " + e.Data[7] + " meters\n"); } } else if (e.ServiceName == "00002a37-0000-1000-8000-00805f9b34fb") { float HeartRate = e.Data[1]; OnHeartRate?.Invoke(this, HeartRate); //Console.WriteLine($"\n\tHeartRate: {HeartRate}bpm"); } //Console.WriteLine("Received from {0}: {1}, {2}", e.ServiceName, // BitConverter.ToString(e.Data).Replace("-", " "), // Encoding.UTF8.GetString(e.Data)); }
private void WorkThreadFunction() { while (true) { OnSpeed?.Invoke(this, Data.GetSpeed()); OnHeartRate?.Invoke(this, Data.GetHeartRate()); OnSend?.Invoke(this, 0); Thread.Sleep(1000); } }