How does one do the following in bluetoothctl from a script and command line that one would do in gatttool as follows:
# gatttool -i hci0 -b $bd_addr -u 2a29 --char-read
handle: 0x0017 value: 54 65 78 61 73 20 49 6e 73 74 72 75 6d 65 6e 74 73
# gatttool -i hci0 -b $bd_addr --char-desc | grep -i aa22
handle = 0x002f, uuid = f000aa22-0451-4000-b000-000000000000
# gatttool -i hci0 -b $bd_addr -a 0x002f --char-write-req -n 01
Characteristic value was written successfully
For instance:
# bluetoothctl connect CC:78:AB:7E:87:07
Attempting to connect to CC:78:AB:7E:87:07
Connection successful
# bluetoothctl gatt.select-attribute 2a29
# bluetoothctl gatt.read
No attribute selected
# bluetoothctl gatt.select-attribute f000aa22-0451-4000-b000-000000000000
# bluetoothctl gatt.acquire-write
No attribute selected
# bluetoothctl gatt.write 0x01
No attribute selected
John Klug
Hi John,
On Tue, Jul 12, 2022 at 11:09 AM John Klug <[email protected]> wrote:
>
> How does one do the following in bluetoothctl from a script and command line that one would do in gatttool as follows:
>
> # gatttool -i hci0 -b $bd_addr -u 2a29 --char-read
> handle: 0x0017 value: 54 65 78 61 73 20 49 6e 73 74 72 75 6d 65 6e 74 73
> # gatttool -i hci0 -b $bd_addr --char-desc | grep -i aa22
> handle = 0x002f, uuid = f000aa22-0451-4000-b000-000000000000
> # gatttool -i hci0 -b $bd_addr -a 0x002f --char-write-req -n 01
> Characteristic value was written successfully
>
>
> For instance:
>
> # bluetoothctl connect CC:78:AB:7E:87:07
> Attempting to connect to CC:78:AB:7E:87:07
> Connection successful
> # bluetoothctl gatt.select-attribute 2a29
> # bluetoothctl gatt.read
> No attribute selected
> # bluetoothctl gatt.select-attribute f000aa22-0451-4000-b000-000000000000
> # bluetoothctl gatt.acquire-write
> No attribute selected
> # bluetoothctl gatt.write 0x01
> No attribute selected
You will probably need to wait for the daemon to resolve the services
which will then export the attributes as D-Bus objects that can be
accessed by bluetoothctl, note that some services are handled
internally by bluetoothd (e.g. GAP and GATT services) which perhaps is
the case of 0x2a29, although we don't currently have any D-Bus
property for Manufacturer like we do for name
(org.bluez.Device1.Name).
--
Luiz Augusto von Dentz
>You will probably need to wait for the daemon to resolve the services
>which will then export the attributes as D-Bus objects that can be
>accessed by bluetoothctl,
How long would one have to wait?? The following was typed manually from the command line:
>> # bluetoothctl gatt.select-attribute f000aa22-0451-4000-b000-000000000000
>> # bluetoothctl gatt.acquire-write
>> No attribute selected
>> # bluetoothctl gatt.write 0x01
>> No attribute selected
I had no idea whether the above is the correct syntax or not. I merely guessed, since the procedure does not appear to be documented.
John Klug
Hi John,
On Tue, Jul 12, 2022 at 11:56 AM John Klug <[email protected]> wrote:
>
> >You will probably need to wait for the daemon to resolve the services
> >which will then export the attributes as D-Bus objects that can be
>
> >accessed by bluetoothctl,
>
> How long would one have to wait? The following was typed manually from the command line:
>
> >> # bluetoothctl gatt.select-attribute f000aa22-0451-4000-b000-000000000000
>
> >> # bluetoothctl gatt.acquire-write
>
> >> No attribute selected
>
> >> # bluetoothctl gatt.write 0x01
>
> >> No attribute selected
>
> I had no idea whether the above is the correct syntax or not. I merely guessed, since the procedure does not appear to be documented.
I think the problem is that you are issuing the select-attribute and
then exiting, instead you will need to enter all the commands at the
same time otherwise the next time you call bluetoothctl it doesn't
have any attribute selected.
>
>
>
>
>
> John Klug
>
>
>
>
--
Luiz Augusto von Dentz
Hi John,
On Thu, Jul 21, 2022 at 8:00 AM John Klug <[email protected]> wrote:
>
> Luiz Augusto von Dentz
> >I think the problem is that you are issuing the select-attribute and
> >then exiting, instead you will need to enter all the commands at the
> >same time otherwise the next time you call bluetoothctl it doesn't
> >have any attribute selected
>
> With gatttool you could issue all the commands non-interactively from the command line.
>
> What you are saying is bluetoothctl has limited command line capability, and cannot replace gatttool as currently written.
Not quite what I said, the difference is that bluetoothctl does
require another command to access so when you are scripting things you
would have to pass the input as a multi line instead of invoking the
binary multiple times with a single line, we could perhaps add support
for a input file where one could enter multiple commands.
>
>
> John Klug
>
--
Luiz Augusto von Dentz