Eryux / miband-heartrate

Enable and monitor heartrate with Mi Band 2, 3 or 4 on Windows 10.
MIT License
57 stars 14 forks source link

Add connection error handling and auto-reconnect mechanism #4

Open YorVeX opened 3 years ago

YorVeX commented 3 years ago

Really nice tool that I replaced my previous node.js based solution with. Thanks for your work and providing it!

Unfortunately one thing is still a lot worse here: there doesn't seem to be any error handling. I have continuous mode running, but sometimes I am out of range for the BT connection for a while.

I would expect the program to detect that it is no longer connected to the Mi Band and try to reconnect regularly. Then when I am back close to the computer it would reconnect and continue measurement.

What happens instead: measurement just stops and keeps on showing the last pulse it could still measure. When I am back nothing about this changes. If I try to press "Auth" again nothing happens either, so also manual reconnection is not possible. If I try to stop and start the sensor the program crashes with an exception.

So every time I move out of range for a short time and come back I have to completely restart the program, with all necessary steps. Since the program doesn't remember its last settings (something I will open a separate issue for) this means: connect again, auth again, tick all check boxes and start sensor - and with the window not remembering it's previous position on a second screen.

It would be great if an auto-reconnect mechanism could be implemented!

YorVeX commented 3 years ago

Note: this was for the previous version. I will do some more tests with 2.0.0 and report my findings here.

YorVeX commented 3 years ago

Just left 2.0.0 running in continuous mode for a while (Mi Band 2) and didn't even move out of range, it still lost connection after 15 minutes. That this can happen is nothing new to me (connection to this device has never been stable with any software, on smartphone or on PC), but that's where the tool then should auto-reconnect.

At the top it now says "No device connected" so the disconnection was detected, but still the "Start" button is deactivated and I can only press "Stop". The good news is that at least I can stop, reconnect manually and start again without the program crashing, so this part has improved compared to the previous version.

Eryux commented 3 years ago

I made some modifications to the code (available in 2.1.0 branch), the application should be able to reconnect to the device if the device get disconnected but you will need to reperform authentication and manually restart heart rate monitoring.

YorVeX commented 3 years ago

Mh, that's progress but kinda misses the original idea being exactly not requiring any manual interaction to restore functionality. I already don't get the part that I have to re-enter the auth key on every program restart, why can't the tool just remember it? Or at least give me a run argument I can start the program with to pass the key.

Kapo2327 commented 3 years ago

I absolutely love this program but doing the same process every time when I went to other room kinda make it harder to use. Wish there was a way for auto reconnection or at least remembering the device,model and auth. key.. I didn't encounter disconnection issue while I'm near to computer with the 2.1.0 update though