Skip to contentSkip to conversation

Problem with StopDiscovery() via dbus-send

DISCUSSION Проклов Александр Валерьевич 2 participants 9 messages Aug 24, 2018 – Nov 1, 2018 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hello All,

Thanks for your work. Since version bluez-5.50 start-stop discovery work from command line and scripts:
#bluetoothctl scan on
#bluetoothctl scan off
(see mail-list "Problem with StopDiscovery() via dbus-send")

--------------------------------------------

My next task is to do pair with device from bash script. I tried several ways:
1. #bluetoothctl pair 11:22:33:44:55:66 does not work because the agent is not created.
2. Make agent via Dbus:
#dbus-send --system --print-reply --type=method_call --dest=org.bluez /org/bluez org.bluez.AgentManager1.RegisterAgent objpath:/org/bluez/agent1 string:KeyboardOnly the command works, but I do not see in Dbus /org/bluez/agent1 created.
3. Make agent via bluetoothctl:
[bluetooth]#agent on
the command works, but I do not see in Dbus agent path!.

May be possible to set a default pin code via /etc/bluetooth/main.conf
if it is available, do not make a request for a pin from the command line? I think that then #bluetoothctl pair 11:22:33:44:55:66 will be able to work fine.

---------------------
Best regards,
Aleksandr Proklov

#1 lore raw

Hi,

On Fri, Aug 24, 2018 at 4:58 AM, =D0=9F=D1=80=D0=BE=D0=BA=D0=BB=D0=BE=D0=B2=
=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80 =D0=92=D0=B0=D0=BB=
=D0=B5=D1=80=D1=8C=D0=B5=D0=B2=D0=B8=D1=87

Quoted 8 lines · <[email protected]> wrote:

Hello All,

Thanks for your work. Since version bluez-5.50 start-stop discovery work from command line and scripts:
#bluetoothctl scan on
#bluetoothctl scan off
(see mail-list "Problem with StopDiscovery() via dbus-send")

Quoted 5 lines

--------------------------------------------

My next task is to do pair with device from bash script. I tried several ways:
1. #bluetoothctl pair 11:22:33:44:55:66 does not work because the agent i=

s

Quoted 4 lines

not created.
2. Make agent via Dbus:
#dbus-send --system --print-reply --type=3Dmethod_call --dest=3Dorg.bluez /org/bluez org.bluez.AgentManager1.RegisterAgent objpath:/org/bluez/agent=

1

Quoted 5 lines

string:KeyboardOnly
the command works, but I do not see in Dbus /org/bluez/agent1 created.
3. Make agent via bluetoothctl:
[bluetooth]#agent on
the command works, but I do not see in Dbus agent path!.

Im not sure Im following, you would like to have non-interactive mode working for bluetoothctl pair? The point number 2 don't make much sense since dbus-send normally disconnected after the reply that means the agent would be gone, also regarding 3 if you use a more recent version of bluetootctl it registers and agent automatically nowadays.

Quoted 2 lines

May be possible to set a default pin code via /etc/bluetooth/main.conf if it is available, do not make a request for a pin from the command line=

? I

Quoted 2 lines

think that then #bluetoothctl pair 11:22:33:44:55:66 will be able to work fine.

That is something I had in mind, lets see if I can come up with something.

Quoted 3 lines

---------------------
Best regards,
Aleksandr Proklov

--=20
Luiz Augusto von Dentz

#2 lore raw

Hi,

Quoted 3 lines · Luiz Augusto von Dentz

Hi,

On Fri, Aug 24, 2018 at 4:58 AM, =D0=9F=D1=80=D0=BE=D0=BA=D0=BB=D0=BE=D0=

=B2 =D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80 =D0=92=D0=B0=D0= =BB=D0=B5=D1=80=D1=8C=D0=B5=D0=B2=D0=B8=D1=87

Quoted 9 lines
Quoted 8 lines · <[email protected]> wrote:

Hello All,

Thanks for your work. Since version bluez-5.50 start-stop discovery work from command line and scripts:
#bluetoothctl scan on
#bluetoothctl scan off
(see mail-list "Problem with StopDiscovery() via dbus-send")

Quoted 5 lines
Quoted 5 lines

--------------------------------------------

My next task is to do pair with device from bash script. I tried several ways:
1. #bluetoothctl pair 11:22:33:44:55:66 does not work because the agent =

is

Quoted 3 lines
Quoted 3 lines

not created.
2. Make agent via Dbus:
#dbus-send --system --print-reply --type=3Dmethod_call --dest=3Dorg.blue=

z

Quoted 1 line
Quoted 1 line

/org/bluez org.bluez.AgentManager1.RegisterAgent objpath:/org/bluez/agen=

t1

Quoted 6 lines
Quoted 5 lines

string:KeyboardOnly
the command works, but I do not see in Dbus /org/bluez/agent1 created.
3. Make agent via bluetoothctl:
[bluetooth]#agent on
the command works, but I do not see in Dbus agent path!.

Quoted 8 lines

Im not sure Im following, you would like to have non-interactive mode working for bluetoothctl pair? The point number 2 don't make much sense since dbus-send normally disconnected after the reply that means the agent would be gone, also regarding 3 if you use a more recent version of bluetootctl it registers and agent automatically nowadays.

Quoted 2 lines

May be possible to set a default pin code via /etc/bluetooth/main.conf if it is available, do not make a request for a pin from the command lin=

e? I

Quoted 1 line
Quoted 1 line

think that then #bluetoothctl pair 11:22:33:44:55:66 will be able to wor=

k

Quoted 3 lines
Quoted 1 line

fine.

That is something I had in mind, lets see if I can come up with something=

.

Actually it doesn't seems to be possible with the current IO capabilities even if I set KeyboardOnly the phone end up displaying the passcode on its end, so it seems there is no combination where the acceptor would be asked to enter a passkey and the initiator to enter it. I wonder if that is on purpose though, because right now the only options in case of headless solution would be to use just works and switch Adapter.Pairable on demand.

--=20
Luiz Augusto von Dentz

#3 lore raw
In reply to Luiz Augusto von Dentz

24.08.2018 16:19, Luiz Augusto von Dentz пишет:

Quoted 7 lines
Quoted 4 lines

May be possible to set a default pin code via /etc/bluetooth/main.conf if it is available, do not make a request for a pin from the command line? I think that then #bluetoothctl pair 11:22:33:44:55:66 will be able to work fine.

That is something I had in mind, lets see if I can come up with something.

Yes. Non-interactive mode needed.
But I think in bluez 3 was main.conf parameter to specify the default PIN code.

#4 lore raw

Hi,

On Mon, Aug 27, 2018 at 2:58 AM, =D0=9F=D1=80=D0=BE=D0=BA=D0=BB=D0=BE=D0=B2=
=D0=90=D0=BB=D0=B5=D0=BA=D1=81=D0=B0=D0=BD=D0=B4=D1=80 =D0=92=D0=B0=D0=BB=
=D0=B5=D1=80=D1=8C=D0=B5=D0=B2=D0=B8=D1=87

Quoted 6 lines · <[email protected]> wrote:

24.08.2018 16:19, Luiz Augusto von Dentz =D0=BF=D0=B8=D1=88=D0=B5=D1=82:

Quoted 4 lines
Quoted 4 lines

May be possible to set a default pin code via /etc/bluetooth/main.conf if it is available, do not make a request for a pin from the command line? I
think that then #bluetoothctl pair 11:22:33:44:55:66 will be able to wo=

rk

Quoted 4 lines
Quoted 4 lines
Quoted 1 line

fine.

That is something I had in mind, lets see if I can come up with somethin=

g.

Quoted 5 lines
Quoted 1 line

Yes. Non-interactive mode needed.
But I think in bluez 3 was main.conf parameter to specify the default PIN code.

Afaik that only works for legacy pairing, normally devices without any input/output should rely on just works pairing which is what you would usually see in headset, etc, though that are not always pairable so you have to switch it on with a button or something like it.

--=20
Luiz Augusto von Dentz

#5 lore raw

27.08.2018 15:24, Luiz Augusto von Dentz пишет:

Quoted 4 lines

Afaik that only works for legacy pairing, normally devices without any input/output should rely on just works pairing which is what you would usually see in headset, etc, though that are not always pairable so you have to switch it on with a button or something like it.

Now my pair process with non-android phone:
#bluetoothctl
[bluetooth] pair 11:22:33:44:55:66

I intering pin code in command shell: 1234
Phone shows a window for entering the code.
I intering pin code on phone. Device pair.

Step with the input of the code in the terminal can be skipped if the code is given in main.conf

the reverse process, when the code transmits the phone to the computer, I have not considered so far. I think this through the script will be difficult to implement.

#6 lore raw
In reply to Luiz Augusto von Dentz

24.08.2018 16:19, Luiz Augusto von Dentz пишет:

Quoted 7 lines
Quoted 4 lines

May be possible to set a default pin code via /etc/bluetooth/main.conf if it is available, do not make a request for a pin from the command line? I think that then #bluetoothctl pair 11:22:33:44:55:66 will be able to work fine.

That is something I had in mind, lets see if I can come up with something.

Can be implemented such an option:
#bluetoothctl pair 11:22:33:44:55:66 [pin_code] --timeout 15

bluetoothctl register agent and send pin_code to device. --timeout time for user response, enter pin_code on device.

NOW I use pair my Aftershokz Trekz headphones without request pin_code via Dbus command from script:
#dbus-send --system --type=method_call --dest=org.bluez /org/bluez/55:55:55:55:55:55/dev_11:22:33:44:55:66 org.bluez.Device1.Pair

-----------
Best regards,
Aleksandr Proklov

#7 lore raw

Non intheractive request pin-code

In reply to Luiz Augusto von Dentz

Dear developers, this proposal can be implemented?

24.08.2018 16:19, Luiz Augusto von Dentz пишет:

Quoted 7 lines
Quoted 4 lines

May be possible to set a default pin code via /etc/bluetooth/main.conf if it is available, do not make a request for a pin from the command line? I think that then #bluetoothctl pair 11:22:33:44:55:66 will be able to work fine.

That is something I had in mind, lets see if I can come up with something.

Yes. Non-interactive mode needed.
But I think in bluez 3 was main.conf parameter to specify the default PIN code.

#8 lore raw

Re: Serial communication over BT using the DBus API

In reply to Luiz Augusto von Dentz

Hi Sylvain Leroux,

Some time ago I also asked this question here. I think no one knows how to do it without rfcomm util.

I use dbus-send for read dbus properties and now work non-interactive mode bluetoothctl.

Quoted 11 lines

I tried something like that:

----

busctl call \
    org.bluez /org/bluez org.bluez.ProfileManager1 RegisterProfile \
    'osa{sv}' \
    /bluez \
    "00001101-0000-1000-8000-00805f9b34fb" \
    3 'Role' s server 'Channel' u 1 Name s 'SerialPort'

----

-----------
Best regards,
Aleksandr Proklov