2

I m just trying to prepare script which emulate BLE Peripheral Device. I am using bluetoothctl like this:

bluetoothctl -- power on 
bluetoothctl -- advertise on

Above scripts works properly, but I don't know how to call submenu of bluetoothctl advertise(you can see it if you call help) from my script init.sh, something like this

bluetoothctl -- menu advertise, name Rasbperry, name on

Any suggestions are welcome :)

2 Answers 2

4

When using bluetoothctl you don't need to use the menu command, you can specify the command hierachally. For example advertise.name Rasbperry and advertise.name on.

One word of caution about using bluetoothctl in this way; it is not a published API and the commands do change from time to time.

The published BlueZ API is available at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc

There is an example advertisement at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-advertisement

And a peripheral at: https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/test/example-gatt-server

3

You can use :

bluetoothctl << EOF
menu scan
version
quit
EOF

then

bluetoothctl << EOF
menu advertise
name Raspberry
name on
...
quit
EOF

Using variable for the name:

MYNAME="Raspberry"

bluetoothctl << EOF
menu advertise
name ${MYNAME}
name on
...
quit
EOF

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.