cardia
cardia copied to clipboard
release for the Bt Smart branch
Any chance you can generate a build for the BT Smart branch? I have a device and would love to test it out. Thanks.
ATM i'm away from home, i can upload the build when i get back home. Anyway, i would be surprised to see that it works on first try.
@uwburn Thanks Michele, I look forward to hear from you once you're back. Even if it doesn't we can try and fix it if it doesn't :)
@uwburn Hi again, any news on this one? Apologies if you are still away, but just wanted to kindly remind you if it's possible
@ariestar I just uploaded a preview release: BT-Smart-pre.1.
You should use a device recognized as a HRM profile and connect it before executing Cardia, otherwise it will not be recognized. In the device menu you should select Bluetooth Smart HRP and then open the Device->Configuration panel where your device should be listed. If it shows up we're half done. Then you should just hit the start button and see if it reads.
In the meantime, i bought a cheap BT Smart HRM on eBay but was crappy... that was not working at all, not even with some fitness apps on the phone, i'm waiting for the substitution, i hope to have more luck with it.
@uwburn thanks for making that available. I have another problem before I can confirm on the status of the ones you mentioned. The sensor is recognised by my Windows 10 tablet, however the app doesn't start. I tried it with admin rights and various compatibility modes, it simply doesn't start.. There are no log files as far as I can see.. I can only test on that tablet as it has BLE and the supported drivers. Please advise if we can do anything about it. Thanks
@ariestar what kind of tablet is that? Is it x86 based? If you try the 1.0 release, does it open up?
@uwburn it's an Intel tablet running win10 x64. The 1.0 release runs fine.
I'm afraid that's caused by how the libraries for accessing the BT Smart are referenced. Unfortunately that's hackish, and probably it's looking for the libraries for my system localization (italian), as on my office PC (that's also italian) it's working ok.
I will try to make it independent, maybe copying the required DLLs in the cardia.exe folder will do the trick.
Can you check out if on your system the folder "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5.1" is present?
If so, are the following files present?
- System.Runtime.dll
- System.Runtime.InteropServices.WindowsRuntime.dll
- System.Runtime.WindowsRuntime.dll
- System.Threading.dll
- System.Threading.Tasks.dll
I have the same problem as ariestar. I got a desktop pc with Windows 10, which runs Cardia just fine, but has no bluetooth. And my Surface Pro 4 which won't even start Cardia. I have no idea of programming, but I have a Polar H7 HRM and a lot of spare time this weekend, but I didn't come far.
I installed Visual Studio and tried to find all prerequisites for compiling Cardia. Took a little (seems that on a surface there are some core components missing), but eventually I got it running. But as soon as I launch it, it throws a "System.InvalidOperationException" at "BtSmartDevices = task.GetResults();" in Cardia.cs If I put a "System.Threading.Thread.Sleep(10000);" right before that, Cardia comes up :) (Yeah, I got some really basic programming skills from way back in time smile) Seems that task.GetResults is called before task is filled by FindAllAsync, but I didn't understand the await / GetAwaiter / async stuff so that was my time to give up finding a fix.
If I connect and pair my Polar H7 before I start Cardia, I get a "System.NullReferenceException" at DeviceInformation backup = Device; at BtHrp.cs
Here are some ressources I found: http://developer.polar.com/wiki/H6_and_H7_Heart_rate_sensors https://code.msdn.microsoft.com/windowsapps/Bluetooth-Generic-5a99ef95
With the sample app, my heart rate monitor worked fine. I tried to implement there a network transmission of the heartrate via UDP sockets (and later add that to Cardia), but my basic programming skills were far from enough for that so I failed there, too.
Thank's for your great piece of software so far and for making it open source. I hope I was able to help a little and I really hope you don't loose interest in that project. Is there any way to donate for it? Maybe an Amazon wishlist with a Polar H7 on it? ;-) If you implement it and are willing to add another small feature for me, I would be glad to donate one for you :)
Thanks for the feedback! Just to be sure: after installing Visual Studio on the Surface, you were able to run Cardia BT-Smart-pre.1 on it?
Moving to the experiments: i would recommend you to stay away from the UDP routing, i mean, it's a nice idea, but it's overcomplicated and once again device specific.
As for the await/async, some of the methods used in there are asynchronous, that means normally, when you invoke them, you have to pass as a parameter a callback method that will deal with their result when they complete their task. As this concept tends to break the "normal" programming style (thing happenings one after another, follwoing the flow of the instructions) you can use the await keyword to "resync" the asynchronous call, making it return the result as a normal method. That's nice, but there's a price to pay: the methods where you use await have to be async as well, so that's basically moving the start of the asynchronous execution up in the stack. That's the basic idea if you wanna try to mess again with it, there are some further details specific to C#/.NET i might not be remembering.
Anyway, i'm wtill waiting for the replacement of my HRM to ship... if it's lost or it doesn't work as the previous one, i will open a wishlist for donations.
No, I just installed Visual Studio to see, why it is failing. It was the "System.InvalidOperationException" at "BtSmartDevices = task.GetResults();" As soon as I delay this line for 10 seconds, it at least starts :)
A friend of mine helped me to get it running. No serious programming, just a quick and dirty solution for my usecase (Polar H7 via Bluetooth). I don't even have to send you the code because it almost just worked. I put here and there a second sleep in to dirty, really dirty, fix some async tasks (like the one mentioned above). And there was a ProcessPackets() missing, I think. And some List casts to Devicelists I didn't understand (I just commented them out and assumed that there is just one device in the system.). Everything else worked out of the box. Thank you again for that. Really great project. I'm not familiar with github, so I don't know how to upload code here (but I think no one should see my bad fixes anyway), but if you want it, just let me know how to send it to you :)
Any posibillity someone can upload this?
How is the program going?
Quick update: thanks to donations, i just bought a Polar H7 and i'm awaiting the shipping. I hope to finally nail the BT Smart support down.
Awesome stuff.
Please check out BT-Smart-pre.2, it should allow BT Smart to work on Windows 8.1 and later.
Please keep in mind that BT Smart devices support on regular Windows Desktop is hacky to say the least (unless something changed with Windows 10, but i have not find anything in that regard). So, be sure of:
- Pair your device before starting Cardia
- Select Bluetooth Smart HRP in Device menu
- Check that in Device -> Configuration your device name appear as selected in the dropdown menu
- If it times out when starting, TRY AGAIN: i don't know why with my Polar H7 sometimes it starts, sometimes it needs several retries
Please note that this version will not start up on Windows 7, and i'm unsure if Windows 7 support has to be dropped in Bluetooth Smart version.
If someone can provide feedback it would be appreciated!
Just downloaded it now and it now runs when you have a device connected although it still refuses to start... Am I that dead inside? haha
By refuse to start you mean that you hit Start button, the chart starts running and you have no reading until it stops, timing out?
Can you please list:
- OS version
- HRM device type
- BT adapter type/manufacturer (also checking if it has a custom BT stack would help, see here: https://bluetoothstackswitcher.com/).
Uploaded BT-Smart-pre.3, i restructured a little Start/Stop logic and added a few options. On Polar H7 i had no more issues starting the devices, yet the reasons behind it are not clear.
I also added two options:
- Characteristic Index: if your devices has several characteristics, changing the index may allow it to work; usually value 0 is fine, if you insert a value not supported by your device it will fail to start immediatly.
- InitDelay: a delay applied before certain start phase instructions, adding a delay seems to help out (as above i don't know why...).
I would push start and it would just hang on starting with no timeout. I just downloaded the BT-Smart-pre 3 and it actually comes up with Bluetooth device is not transmitting this time although, it seems to pick up on my iPhone so i'm not sure what's going off here.
OS - Windows 10 HRM im using is called a CooSpo Adapter type is Microsoft.
Hopefully this information helps.
When you hit start and it hangs, you also cannot move the window and open the menus? Is the UI freezed?
BTW, what is the OS language?
It doesn't freeze I can move everything about but it comes up with "Bluetooth HRP device not transmitting" after about 20-30 secs. The OS language is ENG (United Kingdom)
Sorry, hangs sounded to me like a freeze, "Bluetooth HRP device not transmitting" after 30 seconds is the starting timeout.
If you haven't already tried, you can play with the Characteristic Index and Init Delay. In the next few day i will try to put some logging instruction down the code.
Uploaded BT-Smart-pre.4, including logging to help track down comm issues. When you run it, it will create a log directory with a log file for each day you use it. Please include the logs contents in case of problems reports.
Here is the log from a first time run of the new release: 2017-07-01 23:59:18,459 [1] INFO MGT.Cardia.Program - Starting Cardia 2017-07-01 23:59:27,705 [1] DEBUG MGT.HRM.HRP.BtHrp - Starting HRP 2017-07-01 23:59:27,723 [7] DEBUG MGT.HRM.HRP.BtHrp - Getting GattDeviceService heart rate sensorwith id \?\BTHLEDevice#{0000180d-0000-1000-8000-00805f9b34fb}_f0c77fe841ad#8&16443534&4&0010#{6e3bb679-4372-40c8-9eaa-4509df260cd8} 2017-07-01 23:59:57,846 [6] DEBUG MGT.HRM.HRP.BtHrp - Communication timeout elapsed 2017-07-01 23:59:57,847 [6] DEBUG MGT.HRM.HRP.BtHrp - Stopping HRP 2017-07-01 23:59:57,847 [6] DEBUG MGT.HRM.HRP.BtHrp - Stopping timeout timer 2017-07-01 23:59:57,848 [6] DEBUG MGT.HRM.HRP.BtHrp - Resetting counters
Hope this may help with my issues.
Yeah, apparently it gets stuck on this instruction:
service = await GattDeviceService.FromIdAsync(device.Id);
at HRM/HRP/BtHrp.cs - line 208
That means that there's either a problem with the device (pairing? communication?) or that there's a deadlock (that is likely from the symptoms, but yet it's strange as it never happened to me and looking at the code i could not figure it out).
Please ensure that:
- the device is correctly paired (eventually remove it and pair it again)
- the device is not paired with another device (e.g. phone)
I've tried all of the above and still cannot get it working. I get the feeling it might have something to do with my USB Bluetooth connector or the device i'm using is going crazy. After removing the device it sometimes struggles to find it again/connect to the device after a few attempts... I'm out of ideas and might just purchase the H7.
I got the same problem as Tristay, here is my log. I have a Polar H7 bluetooth smart. 2017-07-04 18:43:30,567 [1] DEBUG MGT.HRM.HRP.BtHrp - Starting HRP 2017-07-04 18:43:30,567 [17] DEBUG MGT.HRM.HRP.BtHrp - Getting GattDeviceService Polar H7 CE85B81Bwith id \?\BTHLEDevice#{0000180d-0000-1000-8000-00805f9b34fb}_Dev_MA&Polar_Electro_Oy_MO&H7_FW&1.4.0_0022d0ce85b8#8&37527f2&1&0010#{6e3bb679-4372-40c8-9eaa-4509df260cd8} 2017-07-04 18:44:00,731 [11] DEBUG MGT.HRM.HRP.BtHrp - Communication timeout elapsed 2017-07-04 18:44:00,731 [11] DEBUG MGT.HRM.HRP.BtHrp - Stopping HRP 2017-07-04 18:44:00,732 [11] DEBUG MGT.HRM.HRP.BtHrp - Stopping timeout timer 2017-07-04 18:44:00,732 [11] DEBUG MGT.HRM.HRP.BtHrp - Resetting counters