weliem / bluez_inc

A C library for Bluez (BLE) that hides all DBus communication. It doesn't get easier than this. This library can also be used in C++.
MIT License
82 stars 19 forks source link

Concern about peripheral example. #44

Open guirespi opened 3 months ago

guirespi commented 3 months ago

Hi! First I want to thank you for this porject. I was trying to implement myself the interfaces to build a GATT application and then one post in stackoverflow mentioned your project and I was so relief.

It's not an issue at all, its more a question about how bluez works internally. I compiled the peripheral example to test the application connecting an Android device to the server. I noticed that always a pair request show up and after accept it, the central disconnects. I used wireshark as sniffer to see the packets between my computer and the android device and I notice the localhost asks for a pairing request.

I made some research and I found that linux tries to read the battery characteristic on IOs device and for this operation it is needed the pairing process. I though that maybe in Android devices the same problem exists, so I run bluez without the battery plugin, but the problem is still there.

So, I want to ask you if you ever faced a problem like this and if there is something I am missing in the GATT application or bluez configuration to avoid this pairing. I also noticed that the local host is trying to read some generic characteristics but I don't think that would be the problem. I appreciate if you share with me some knowledge or hints about why is this pairing requested. By the way, I'm using ubuntu.

Thanks again for this project and for taking the time to read this issue!.

weliem commented 3 months ago

That is strange. I just did a test and ran the 'peripheral' example, and then connected with my iPhone. But I didn't get any pairing request....

guirespi commented 3 months ago

Strange indeed haha. Just borrow an IPhone and no pairing request... I guess its an Android problem only now.

marcobergamin-videam commented 3 weeks ago

Hello! I think I had a similar problem with my Samsung S21. I wasn’t able to pair my phone: after confirming the pairing request (on my phone), the phone was immediately disconnected.

I modified the example by adding PIN authentication (copying the necessary code from the README file), and now it works. I’m able to interact with the example application.

guirespi commented 3 weeks ago

@marcobergamin-videam Hi! Thanks for the suggestion. I'll try as soon i get back to that project.