userx14 / omblepy

Cli tool to read records from omron blood-pressure bluetooth-low-energy measurement instruments
44 stars 12 forks source link

Using omblepy implementation for supporting OMRON devices in Gadgetbridge #32

Open corrados opened 3 weeks ago

corrados commented 3 weeks ago

I have a HEM-7600T but I am not able to readout data with omblepy. I tried it under Ubuntu, ESP32 and Windows 10. Today, I once could readout data with UBPM under Windows but cannot reproduce it anymore :-/. So, an alternative solution would be great.

As you already tried to get rid of OS restrictions with regard to bluetooth with your ESP32 implementation, another solution would be to integrate your work in Gadgetbridge which runs on Android. There is already an open issue at Gadgetbridge for it: https://codeberg.org/Freeyourgadget/Gadgetbridge/issues/3656

Would that be something you would consider supporting?

userx14 commented 1 week ago

Hi corrados,

Gadgetbridge looks like nice project, but unfortunatelly I'm lacking the java skills and time to work on that. If there are any questions on the protocol or pairing procedure I'm happy to help anyone attempting to implement this.

For win10 you really need to be fast with the pairing dialog confirmation. Unpairing the omron from the list of previously paired devices, also seems to be required.

Do you get any kind of error from omblepy while trying to pair / connect?

Did you already test with the esp32 bridge?

Best, Benjamin

corrados commented 6 days ago

Hi Benjamin,

sorry for my late response but I was not at home for several days and could not access my Omron device.

Gadgetbridge looks like nice project, but unfortunatelly I'm lacking the java skills and time to work on that.

Same with me. I code in C++ but I do not have any java skills too, unfortunately...

For win10 you really need to be fast with the pairing dialog confirmation.

That did the trick! :-) If I very quickly select the device from the list when trying to pair, it works.

Now I am using the -m flag for reading data and it works perfectly.

Thank you for your support.

corrados commented 6 days ago

Did you already test with the esp32 bridge?

Yes I did but that did not work. Do you want me to try it again and give you more info on the error message?

userx14 commented 2 days ago

Nice that you get the windows version working. I also looked into the short timeout issue, but was unable to figure out where this goes wrong.

Did you already test with the esp32 bridge?

Yes I did but that did not work. Do you want me to try it again and give you more info on the error message?

If you find the time for futher testing with esp32, it would be useful to know in which stage the error occurs. You can test the pairing phase with just the arduino IDE and it's serial console, using the commands listed here.

Thanks a lot.

corrados commented 21 hours ago

It's a bit hard for me to find out what goes wrong with the ESP32 connection. When I tried first, I did not see the device in the list:

python3 omblepy_bridge.py -b /dev/ttyUSB0 -p -d HEM-7600T --loggerDebug 2024-10-01 18:31:35,835 - omblepy - INFO - Attempt to import module for device hem-7600t To improve your chance of a successful connection please do the following: -remove previous device pairings in your OS's bluetooth dialog -enable bluetooth on you omron device and use the specified mode (pairing or normal) -do not accept any pairing dialog until you selected your device in the following list

+----+-----+------+------+ | ID | MAC | NAME | RSSI | +----+-----+------+------+ Enter ID or just press Enter to rescan.

After rebooting the ESP32, it then found it:

python3 omblepy_bridge.py -b /dev/ttyUSB0 -p -d HEM-7600T --loggerDebug 2024-10-01 18:33:03,759 - omblepy - INFO - Attempt to import module for device hem-7600t To improve your chance of a successful connection please do the following: -remove previous device pairings in your OS's bluetooth dialog -enable bluetooth on you omron device and use the specified mode (pairing or normal) -do not accept any pairing dialog until you selected your device in the following list

+----+-------------------+-------------------------------+------+ | ID | MAC | NAME | RSSI | +----+-------------------+-------------------------------+------+ | 0 | 00:5f:bf:xx:xx:xx | BLEsmart_0000021F005XXXXXXXXX | -37 | | 1 | 72:fd:85:xx:xx:xx | | -53 | | 2 | 54:3f:bd:xx:xx:xx | | -94 | +----+-------------------+-------------------------------+------+ Enter ID or just press Enter to rescan. 0 2024-10-01 18:33:07,950 - omblepy - INFO - Attempt connecting to 00:5f:bf:xx:xx:xx. 2024-10-01 18:33:17,960 - omblepy - INFO - unpair and disconnect Traceback (most recent call last): File "/home/corrados/TMP/omblepy/omblepy_bridge.py", line 280, in main() File "/home/corrados/TMP/omblepy/omblepy_bridge.py", line 260, in main raise ValueError(f"pairing failed {response}") ValueError: pairing failed b''

Using my known MAC address, it says "communication started" but there is no file with values:

python3 omblepy_bridge.py -b /dev/ttyUSB0 -d HEM-7600T --mac 00:5F:BF:x:x:x --loggerDebug 2024-10-01 18:33:30,625 - omblepy - INFO - Attempt to import module for device hem-7600t 2024-10-01 18:33:30,631 - omblepy - INFO - Attempt connecting to 00:5F:BF:x:x:x. 2024-10-01 18:33:30,631 - omblepy - INFO - communication started 2024-10-01 18:33:40,636 - omblepy - INFO - unpair and disconnect Traceback (most recent call last): File "/home/corrados/TMP/omblepy/omblepy_bridge.py", line 280, in main() File "/home/corrados/TMP/omblepy/omblepy_bridge.py", line 270, in main raise ValueError(f"connection failed {response}") ValueError: connection failed b''

Does this help?

userx14 commented 5 hours ago

Not sure why it needs a restart of the esp32, but I can see that even the pairing process is not working. Could you reupload the arduino esp32 code, with 'Tools->Core Debug Level->Info' set? This will break the communication with the python script, as it generates additional messages which can not be parsed by omblepy.

Enable the pairing mode of the omron device and send the esp32 the letter "S" in the Arduino IDE serial console, to check that it is visible. Then try to pair by sending 'p 00:5F:BF:xx:xx:xx'. This should log some of the communication to the serial console, which could help to pin down the problem.

Thanks.