-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pairing Request for cpu_temperature.py example despite no secure characteristics #331
Comments
What app are you using for connecting to the Raspberry Pi from your iPhone? Are you using the functionality in settings? As that will probably not work as the iPhone will not know what to do with the custom CPU Temperature Service. I would recommend using a generic Bluetooth Low Energy scanning and exploration tool like nRF Connect to initially connect and prove it works. I have found to get reliable connection to Android phones it is best to put the controller into
The following explanation of this is from
You can also do this from the command line with:
|
Thanks for the quick reply! So I've been testing this via a few apps including nRF Connect and still get a pairing request shortly after connecting to the BLE peripheral running on the Pi. This is also the case if I use non-Apple devices, so it doesn't seem to be client related. What makes me think it is something related to a secure characteristic is that I modified Bluez running on the Pi so that the This is a fine temporary fix, but I thought I'd share this in case it is a bug related to how bluezero is creating characteristics. |
Thanks for the update although I am struggling to understand why you are seeing the issue. Are you using a stock image on the Raspberry Pi? What version of Bluez do you have installed? The code you linked to was changed a couple of years ago to add EATT support. This would seem to link to the 5.54 release: http://www.bluez.org/release-of-bluez-5-54-and-5-53/ I think the stock RPi OS is still shipping with 5.50. I've just done a full upgrade on one of my old RPi 3+ and it has 5.50 and is working fine. |
So it's a stock Raspbian buster image (kernel version: 4.19.97-v71+) (haven't upgraded to RPi OS yet) with Bluez 5.50 running on a Raspberry Pi 4. However, I've also noticed this issue running on a Pi 3+ in the past. |
I just double checked and it is actually an older 3B that I'm running on. There have been some firmware issues on the latest Raspberry Pi's. Have you checked Another thing to help debug is try running I've included the full details of the machine I've run the test on.
|
I just started playing around with BLE, this library and the Raspberry Pi and I find a similar (or the same?) issue:
Both the project
, and then make the PI request authentication (which would fail if not set beforehand, of course) |
I have borrowed an iPhone to do some testing. I ran I am an inexperienced I did see different behaviour when I also had I repeated the example with Android and can confirm that I don't see the issue reported with Android. The next area of investigation is to understand why the iOS devices are asking for battery level information that is not part of the service being connected to. I suspect it is one of the other profiles that are available on the iOS devices |
I'll try to find out, it is puzzling and I raised a ticket to the nFR Connect app as well. Thanks for the quick check, Barry. |
@ukBaz For whatever it is worth, I am trying to use this library for Peripheral purposes and experiencing the same thing when connecting from an iOS device. It is only the following code:
And disabling br/edr, secure-conn, bondable all fail to make a difference. btmon seems to indicate that, as you noted, it requires pairing / authentication regardless:
Do you have any suggestions on how we might be able to workaround this at least in the meantime? In another issue, #291 (which coincidentally I believe was running into this problem as well, but misunderstanding it) you mentioned that the example doesn't handle pairing, which implied that maybe there is a way to handle it via additional python code? Is that the case? We would prefer for our use case to not have to manually intervene and pair via bluetoothctl if possible. Thanks! |
Also, I'm not sure if this might be related or not, but I've also noticed that while the local_name worked / was used the very first time, ever since then I can't get it to work and the device name instead shows up as "raspberrypi". Is this a known issue / is there a way to get the local_name to show instead? If this is unrelated to the other issue let me know and I can open a separate issue if needed. |
I usually set both name and alias. Not sure, but I think the name is
considered ephemeral and doesn’t get linked to the mac addresses by the
scanner (or most probably by the Bluez core).
|
My best guess on why the Battery Service is causing the pairing is one of the other profiles. If I list the default state of the Bluetooth on my RPi I get:
If I do a
Some of the newer versions of audio gateway profiles have added indicator support to report such things as headset battery level. I don't have access to an iOS device currently so if you can test that to see if it makes any difference. With the |
@tnarik thanks for the tip - will try that. One last update on my side for now; I think I was able to (temporarily?) workaround this pairing issue by adding one more btmgmt command to the list:
I say temporarily because I believe this is representing it as "NoInputNoOutput" which I think is basically just a hack workaround for now. Let me know if there is anything else I can help with investigating here. Thanks! |
Thanks @ukBaz - will try that as well and see if it makes a difference. Will keep you all posted. |
I didn’t try any of this yet (
https://stackoverflow.com/questions/59214524/since-bluez-5-48-iphones-require-pairing-when-connecting-on-a-ble-gap-periphera
) but I think the reason is the version of Bluez.
|
Thanks @tnarik . I remember reading about this on the BlueZ mailing list a few years ago. It looks like modifying /lib/systemd/system/bluetooth.service to remove the unwanted plugins is the best way forward. |
Just for a bit of completeness:
So we can see Then, on my RPi (called
The battery plugin is the one trying to get information from a Central (the iPhone), which triggers the reverse pairing (and also explains why my sample agent was prompting for input unexpectedly on the originator). Plugins can be disabled by either recompiling, or via the
In my case, I can now see the You can also add PS: Just run the code on a PiZero and fixed it to run properly. |
I think this has been resolved now so I'm going to go ahead and close it. Happy to re-open if it isn't resolved. |
When running the cpu_temperature.py example, I try to connect to the BLE peripheral from my iPhone and upon connection I receive a pairing request. From looking at the cpu_temperature.py code, I do not see any secure characteristics which is why I'm confused why a pairing request would be generated. Is there something I'm missing here?
I've been running this example on a Raspberry Pi 4 Model B Rev 1.4 4GB. I've tested this on both the onboard Bluetooth module and a Plugable USB bluetooth dongle.
Upon looking at hcidump during this exchange I see the following "Insufficient Authentication" message followed by the pairing request due to the automatic security level upgrade:
The text was updated successfully, but these errors were encountered: