ceandre / radonreader

Read current radon level from RadonEye RD200
GNU General Public License v3.0
56 stars 27 forks source link

Script does not connect #9

Open AdminGithubAxiansAT opened 2 years ago

AdminGithubAxiansAT commented 2 years ago

Hi! I found the bluetooth mac with the discovery [NEW] Device 44:17:XX:XX:XX:XX FR:RE22111XXXXXXX

now I'm trying to connect to the radoneye device with python2.7 radon_reader.py -b -v -a 44:17:XX:XX:XX:XX

but I only get following output Connecting... Failed to connect to peripheral 44:17:XX:XX:XX:XX, addr type: random Failed, trying again (1)... Connecting... Failed to connect to peripheral 44:17:XX:XX:XX:XX, addr type: random Failed, trying again (2)... Connecting... Failed to connect to peripheral 44:17:XX:XX:XX:XX, addr type: random Failed, trying again (3)... Connecting... Failed to connect to peripheral 44:17:XX:XX:XX:XX, addr type: random Failed.

what I'm doing wrong?

thanks, kr

zelig2 commented 2 years ago

Did you run trust 44:17:XX.... in the bluetoothctl command?

AdminGithubAxiansAT commented 2 years ago

Hi! Thanks for your answer. I've done it right now. But still the same issue.

bluetoothctl trust 44:17:XX:XX:XX:XX [CHG] Device 44:17:XX:XX:XX:XX Trusted: yes Changing 44:17:XX:XX:XX:XX trust succeeded :~# ls radon_reader.py :~# python radon_reader.py -a 44:17:XX:XX:XX:XX -v Connecting... Failed to connect to peripheral 44:17:XX:XX:XX:XX, addr type: random Failed, trying again (1)... Connecting... Failed to connect to peripheral 44:17:XX:XX:XX:XX, addr type: random Failed, trying again (2)... Connecting...

Loretomes commented 2 years ago

Hi,

I'm facing the same issue on RD200 (Firmware 2.0.2) $ bluetoothctl trust E8:31:XX:XX:XX:XX Changing E8:31:XX:XX:XX:XX trust succeeded

$ bluetoothctl connect E8:31:XX:XX:XX:XX Attempting to connect to E8:31:XX:XX:XX:XX [CHG] Device E8:31:XX:XX:XX:XX Connected: yes Connection successful --> bluetooth symbol on RD200s display is on. So it seems to work.

But when running the script it fails to connect.

dicer commented 2 years ago

What version of python and bluepy are you running the script with?

Loretomes commented 2 years ago

Hi dicer,

It's running on a raspberry pi 3B, if this means something.

EDIT: I've installed additionally python 2.7. Same behaviour:

$ python2.7 radon_reader.py -a E8:31:XX:XX:XX:XX -v Connecting... Failed to connect to peripheral E8:31:XX:XX:XX:XX, addr type: random Failed, trying again (1)... Connecting... Failed to connect to peripheral E8:31:XX:XX:XX:XX, addr type: random Failed, trying again (2)... Connecting...

dicer commented 2 years ago

I just had a look and I'm running the script with python 2.7.18. On x86 hardware, but that should not be the problem. Maybe try with 2.7 just so we know whether it is a python problem or something else?

Loretomes commented 2 years ago

Thanks for taking a look on this. Yesterday I edited my last post. I've tried python 2.7.18 too, sadly with the same result.

Loretomes commented 2 years ago

The smartphone app shows firmware version 2.0.2. Which version do you have?

AdminGithubAxiansAT commented 2 years ago

I also still have the same problem. Also tried with python 2.7 and 3.7. Any ideas?

AdminGithubAxiansAT commented 2 years ago

It seems that something has changed in the device. 1) I removed "random" in the line DevBT = btle.Peripheral(args.address). after that the script connects to the radoneye 2) I changed the uuids to 00001523-0000-1000-8000-00805f9b34fb, 00001524-0000-1000-8000-00805f9b34fb and 00001525-0000-1000-8000-00805f9b34fb. After that the script does something... But the result is always 0 so there needs something to be changed, maybe the \x50 is wrong?

dicer commented 2 years ago

The smartphone app shows firmware version 2.0.2. Which version do you have?

I don't use the app, but 1.2.4 is showing when the device boots up. I guess that fits with what @AdminGithubAxiansAT found out. No idea what needs to be changed though. One of you could dump the BLE traffic the official app generates and have a look there. I guess some other IDs or commands might be needed?

AdminGithubAxiansAT commented 2 years ago

I have the app but can‘t find the version. how can I do the ble traffic dump from the app?

dicer commented 2 years ago

Android can write all bluetooth packets to a file if you have the developer settings enabled. It's called "Enable Bluetooth HCI snoop log" on my device. The resulting file can be analyzed in wireshark afterwards.

Loretomes commented 2 years ago

I have the app but can‘t find the version.

If you connect with the RadonEye App the firmware version is shown at the bottom screen as 'F/W: V2.0.2'.

I'm also able to find out the same UUIDS 00001523-0000-1000-8000-00805f9b34fb, 00001524-0000-1000-8000-00805f9b34fb and 00001525-0000-1000-8000-00805f9b34fb with the help of nRF Connect app.

I've loaded the bluetooth log to wireshark and can see, that there are connections between smartphone and RadonEye (both as source and destination). But I've no idea how to step further. How to read out the lots of information wireshark offers?

AdminGithubAxiansAT commented 2 years ago

I have only ios devices, no android. Seems that there is no app to trace that with ios. Is it possible that you upload the trace?

Loretomes commented 2 years ago

btsnoop_hci_20220816.log

I've uploaded the trace. I filtered only the traffic between smartphone and RadonEye and could export it without IP or mac addresses. Wireshark shows the smartphone as localhost and the RadonEye as remote. Do you know how to read this log?

grahamck commented 2 years ago

This used to work for me - my pi died about a month ago and i just got around to re-installing it and I have this same issue. Tried it with 2.7 and now with the 3.9 with the one line code fix. bluetooothctl trusts and connects - the only difference i see might be this org.bluez error?

/home/grahamk/radon $ bluetoothctl connect F4:9F:38:88:88:6E Attempting to connect to F4:9F:38:88:88:6E [CHG] Device F4:9F:38:88:88:6E Connected: yes Failed to connect: org.bluez.Error.Failed

Tofnet commented 2 years ago

I have the same problem. When testing with Bluetooth LE Explorer (Windows app) with Firmware 2.0.1 : As AdminGithubAxiansAT says, the UUIDs have changed to 0000152*-0000-1000-8000-00805f9b34fb The value to write to get the measurement seems to be again 0x50. However, the reading gives a result which does not seem to be IEEE 754 anymore. Some correspondences that I do not decode... except 0x50>Request function ; 0x0A>Data length pCi/l | Bytes read 1.30 | 50-0A-30-00-44-00-00-00-04-00-06-00 1.35 | 50-0A-32-00-44-00-00-00-00-00-06-00 1.41 | 50-0A-34-00-44-00-00-00-00-00-0C-00 1.51 | 50-0A-38-00-44-00-00-00-04-00-08-00 1.65 | 50-0A-3D-00-44-00-00-00-02-00-09-00 1.86 | 50-0A-45-00-40-00-00-00-02-00-08-00 2.14 | 50-0A-4F-00-40-00-00-00-05-00-05-00 2.92 | 50-0A-6C-00-40-00-00-00-08-00-09-00
3.24 | 50-0A-78-00-40-00-00-00-04-00-0D-00

dicer commented 2 years ago

Do you have the matching value shown in the display for those (or newer) values? Then maybe we can decode it.

Tofnet commented 2 years ago

Of course, it's in my not very clear table just above. 1.30 pCi/l displayed with trame 50-0A-30-00-44-00-00-00-04-00-06-00 For the test I use the unit pCi/l rather than Bq/m3 to avoid dividing my displayed value by 37. Here 1.30 in IEEE 754 = 0x3FA66666 in big-endian. These bytes aren't in my result.

Tofnet commented 2 years ago

Well it's actually quite simple, the first word in payload (byte 3 and 4) contains the measurement directly in Bq/m3 written in Little-Endian order. 69 | 50-0A-45-00-81-00-00-00-04-00-05-00 72 | 50-0A-48-00-81-00-00-00-01-00-08-00 87 | 50-0A-57-00-81-00-00-00-04-00-0D-00 258 | 50-0A-02-01-81-00-00-00-19-00-1C-00 Now we have to find the firmware version so that the program can work with both.

Loretomes commented 2 years ago

Thanks a lot, Tofnet! With the help of nRF Connect app I can read out the value in Bq/m³. But why radon_reader.py reads zero Bq/m³ at UUID 00001525-0000-1000-8000-00805f9b34fb?

uuidRead  = btle.UUID("00001525-0000-1000-8000-00805f9b34fb")
RadonEyeValue = RadonEyeService.getCharacteristics(uuidRead)[0]
RadonValue = RadonEyeValue.read()
print (RadonValue)

Output: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

AdminGithubAxiansAT commented 2 years ago

Hi! Can someone help me what I have to change now? I changed the uuids but I always get \x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00 as result

AdminGithubAxiansAT commented 2 years ago

When I write the handle I get the current value back [LE]> char-write-req 0x002a 50 Characteristic value was written successfully Notification handle = 0x002c value: 50 0a 7d 00 6e 00 00 00 0b 00 1a 00

and then, if I reade the handle the information is gone [LE]> char-read-hnd 0x002c Characteristic value/descriptor: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

it seems that this is the problem, why the script has no output Maybe the new firmware is using a kind of notification?

Loretomes commented 2 years ago

Yes, I guess the same. So I experiment with this code example: https://ianharvey.github.io/bluepy-doc/notifications.html#notifications

However, I lack the knowledge and experience :-(

Tofnet commented 2 years ago

Hi, I have just successfully tested this fork: EtoTen radonreader

Loretomes commented 2 years ago

Hi Tofnet, glad you found this. Thanks, it works.

AdminGithubAxiansAT commented 2 years ago

Thanks Tofnet for sharing this link! But I get an error --> ModuleNotFoundError: No module named 'radon_reader_by_handle'. Did someone also had this message? Where can I find this module?

AdminGithubAxiansAT commented 2 years ago

sorry my fault. Its in the git... Thanks again for the link!

Ndolam commented 1 year ago

Hi, I have a device which reports FR:GL05RE000997 which is not matched by EtoTen's scanning code.

If I explicitly give the addr with -a, and try -t 0 or -t 1, it doesn't work, with messages as follows:

2023-07-02 10:34:52,380 - root - DEBUG - Re-trying connections attempts: 1'
2023-07-02 10:35:35,388 - root - DEBUG - Re-trying connections attempts: 2'
2023-07-02 10:36:18,396 - root - DEBUG - Re-trying connections attempts: 3'
2023-07-02 10:37:01,406 - root - DEBUG - Re-trying connections attempts: 4'
2023-07-02 10:37:02,408 - root - DEBUG - Sending payload (byte): b'P' To handle (int): 42
Helper not started (did you call connect()?)

Any thoughts? Is this Yet Another hardware version which needs some more code?

Thanks.