Skip to contentSkip to conversation

Gatt server with random address does not work (everything is ok with public address)

DISCUSSION Pavel Machek 2 participants 4 messages Apr 16, 2019 – Apr 18, 2019 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Hi!

I adapted example-gatt-server for a project... and it works ok (thanks), as long as public address is used. I could not configure random address in main.conf, so I'm doing it with btmgmt:

#!/bin/bash
(
echo power off
sleep .1
echo le on
sleep .1
echo bredr off
sleep .1
echo static-addr c2:34:56:78:90:ab
#echo public-addr 00:1A:7D:DA:71:11
#echo static-addr c2:34:56:78:90:ab
sleep .1
echo connectable on
sleep .1
echo pairable on
sleep .1
# echo discov on
sleep .1
# echo advertising on
sleep .1
sleep .1
echo power on
) | sudo ../bluez/tools/btmgmt
sleep 2

With random address, it does not work: lescan from other machine detects right address, and I can connect, but that's it, services can't be listed.

I'm using 4.19 kernel on one side and current -next on the other side, with bluez e4cf43fc62b4e4dbabc72d4e44e095d7a9087992, Fri Sep 7 16:25:44 2018.

And it seems I'm not the only one having this problem:
https://stackoverflow.com/questions/50707914/setup-bluez-gatt-server-with-random-address

Any ideas how to debug that? Does configuration with random address work for you? Is there chance update to latest versions helps?

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#1 lore raw

Hi Pavel,

Quoted 6 lines · Pavel Machek

Hi!

I adapted example-gatt-server for a project... and it works ok (thanks), as long as public address is used. I could not configure random address in main.conf, so I'm doing it with btmgmt:

Have you tried setting Privacy = device?
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/main.conf#n71

Quoted 25 lines

#!/bin/bash
(
echo power off
sleep .1
echo le on
sleep .1
echo bredr off
sleep .1
echo static-addr c2:34:56:78:90:ab
#echo public-addr 00:1A:7D:DA:71:11
#echo static-addr c2:34:56:78:90:ab
sleep .1
echo connectable on
sleep .1
echo pairable on
sleep .1
# echo discov on
sleep .1
# echo advertising on
sleep .1
sleep .1
echo power on
) | sudo ../bluez/tools/btmgmt
sleep 2

Quoted 3 lines

With random address, it does not work: lescan from other machine detects right address, and I can connect, but that's it, services can't be listed.

bluetoothd don't really know that you have set a static address like that, anyway I don't know what exactly is not working so it very hard to give any instruction with such vague description of the problem.

Quoted 9 lines

I'm using 4.19 kernel on one side and current -next on the other side, with bluez e4cf43fc62b4e4dbabc72d4e44e095d7a9087992, Fri Sep 7 16:25:44 2018.

And it seems I'm not the only one having this problem:
https://stackoverflow.com/questions/50707914/setup-bluez-gatt-server-with-random-address

Any ideas how to debug that? Does configuration with random address work for you? Is there chance update to latest versions helps?

Look at privacy, if that doesn't work then collect the journal logs and btmon traces, etc.

Signature · 1 line
Luiz Augusto von Dentz
#2 lore raw

Hi!

Quoted 6 lines
Quoted 3 lines

I adapted example-gatt-server for a project... and it works ok (thanks), as long as public address is used. I could not configure random address in main.conf, so I'm doing it with btmgmt:

Have you tried setting Privacy = device?
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/main.conf#n71

I tried playing with privacy, but could not get it to work. But that was some time ago, and I could have messed it up.

Quoted 2 lines
Quoted 2 lines

#!/bin/bash
(

...

Quoted 1 line
Quoted 1 line
    echo static-addr c2:34:56:78:90:ab

...

Quoted 5 lines
Quoted 5 lines

sleep .1
echo power on
) | sudo ../bluez/tools/btmgmt
sleep 2

Quoted 7 lines
Quoted 3 lines

With random address, it does not work: lescan from other machine detects right address, and I can connect, but that's it, services can't be listed.

bluetoothd don't really know that you have set a static address like that, anyway I don't know what exactly is not working so it very hard to give any instruction with such vague description of the problem.

Ok, if bluetoothd does not know I've done this, that would kind of explain the problem.

I'm trying to run gatt-server, so I'll need to get static address to work somehow. What is the correct way to set static address, so that bluetoothd has chance to know about it? Do I need to patch sources for that?

Quoted 4 lines
Quoted 4 lines

I'm using 4.19 kernel on one side and current -next on the other side, with bluez e4cf43fc62b4e4dbabc72d4e44e095d7a9087992, Fri Sep 7 16:25:44 2018.

Quoted 8 lines
Quoted 5 lines

And it seems I'm not the only one having this problem:
https://stackoverflow.com/questions/50707914/setup-bluez-gatt-server-with-random-address

Any ideas how to debug that? Does configuration with random address work for you? Is there chance update to latest versions helps?

Look at privacy, if that doesn't work then collect the journal logs and btmon traces, etc.

Privacy does not do exactly what I need, but I'll try.

Thanks a lot for help,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#3 lore raw

Hi!

Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

I adapted example-gatt-server for a project... and it works ok (thanks), as long as public address is used. I could not configure random address in main.conf, so I'm doing it with btmgmt:

Have you tried setting Privacy = device?
https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/src/main.conf#n71

I tried playing with privacy, but could not get it to work. But that was some time ago, and I could have messed it up.

With privacy = device, bluetoothd does not have enough keys, so it does _not_ turn it on.

Bluetooth daemon 5.50
...
No IRK stored
Failed to open crypto
Failed to set privacy: rejected.

I guess there are instructions somewhere how to set it up, but I'd really like static random address, not this.

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html