Hello,
I started a project with Bluetooth, but most of the resources on the
internet use older versions of BlueZ (and often mention using
compatibility mode to hack the legacy code). I think the reason for
the hacking is that there is not any tutorial for BlueZ 5 (or it is in
some very hidden place). I browsed the page
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test for
examples, and I found some interesting codes, but I could not find
what I was searching for.
I would like to see a simple Python code that can register a service
via SDP and receive the incoming RFCOMM connections. Could you provide
an example like that?
Thank you for your help.
Regards,
Kristóf Horváth
Hi,
On Tuesday, 12 November 2019 10:15:38 CET Krist?f Horv?th wrote:
> Hello,
>
> I started a project with Bluetooth, but most of the resources on the
> internet use older versions of BlueZ (and often mention using
> compatibility mode to hack the legacy code). I think the reason for
> the hacking is that there is not any tutorial for BlueZ 5 (or it is in
> some very hidden place). I browsed the page
> https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test for
> examples, and I found some interesting codes, but I could not find
> what I was searching for.
>
> I would like to see a simple Python code that can register a service
> via SDP and receive the incoming RFCOMM connections. Could you provide
> an example like that?
>
> Thank you for your help.
There is test/test-profile and test/test-hfp in BlueZ source code.
--
pozdrawiam
Szymon Janc
Hi,
> There is test/test-profile and test/test-hfp in BlueZ source code.
Thank you very much. Without a table of contents, it's hard to find
the appropriate scripts. (This is also true for the files in folder
doc.)
With the test-profile code, I could register a service, and I could
discover it from another device. However, a connection couldn't build
up. The function NewConnection didn't call at all. (By the way, I
didn't find any line of code to receive the data, how is it possible?)
I monitored the connection-attempt with bluetoothctl (every row starts
with the prefix "[chg] Device {address of the other device}"):
ServiceResolved: yes
Paired: yes
(There was a little pause here.)
ServiceResolved: no
Paired: no
Connected: no
Have you got any idea what the problem is? Thank you for your help.
Regards,
Kristóf Horváth
On Wed, 13 Nov 2019 at 17:29, Kristóf Horváth
<[email protected]> wrote:
>
> Hi,
>
> > There is test/test-profile and test/test-hfp in BlueZ source code.
> With the test-profile code, I could register a service, and I could
> discover it from another device. However, a connection couldn't build
> up. The function NewConnection didn't call at all. (By the way, I
> didn't find any line of code to receive the data, how is it possible?)
Here is an example of receiving data with a Serial Port Profile:
https://gist.github.com/ukBaz/217875c83c2535d22a16ba38fc8f2a91
Going back to your original question, you might find it easier to use
a Python library like Blue Dot on your project as it presents a higher
level interface:
https://bluedot.readthedocs.io/en/latest/btcommapi.html
Regards,
Barry