Commit Graph

132 Commits

Author SHA1 Message Date
Francois Beaufort
1c9bbafd0b client: Show UUIDs when listing attributes
Example output after this patch:

[bluetooth]# connect 7B:3F:2C:2B:D0:06
Attempting to connect to 7B:3F:2C:2B:D0:06
[CHG] Device 7B:3F:2C:2B:D0:06 Connected: yes
Connection successful
[NEW] Primary Service
        /org/bluez/hci0/dev_7B_3F_2C_2B_D0_06/service0001
        00001801-0000-1000-8000-00805f9b34fb
        Generic Attribute Profile
[NEW] Characteristic
        /org/bluez/hci0/dev_7B_3F_2C_2B_D0_06/service0001/char0002
        00002a05-0000-1000-8000-00805f9b34fb
        Service Changed
[NEW] Primary Service
        /org/bluez/hci0/dev_7B_3F_2C_2B_D0_06/service0028
        0000180f-0000-1000-8000-00805f9b34fb
        Battery Service
[NEW] Characteristic
        /org/bluez/hci0/dev_7B_3F_2C_2B_D0_06/service0028/char0029
        00002a19-0000-1000-8000-00805f9b34fb
        Battery Level
[NEW] Descriptor
        /org/bluez/hci0/dev_7B_3F_2C_2B_D0_06/service0028/char0029/desc002b
        00002902-0000-1000-8000-00805f9b34fb
        Client Characteristic Configuration
[CHG] Device 7B:3F:2C:2B:D0:06 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device 7B:3F:2C:2B:D0:06 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device 7B:3F:2C:2B:D0:06 UUIDs: 0000180f-0000-1000-8000-00805f9b34fb
[CHG] Device 7B:3F:2C:2B:D0:06 ServicesResolved: yes
2016-09-20 17:10:06 +03:00
Francois Beaufort
b1d0c3bc51 Add device set-alias bluetoothctl command 2016-09-02 17:09:58 +03:00
Michał Narajowski
0e12a4bbc9 client: Add better support for managing devices of multiple controllers
Previously devices list was cleared when selecting new default
controller. Now devices list is preserverd allowing to list and suggest
devices for default controller even after changing the default
controller.
2016-08-23 17:24:06 +03:00
Luiz Augusto von Dentz
3695bd3106 build: Fix missing file
client/main.c:46:25: fatal error: advertising.h: No such file or directory
2016-08-16 15:30:27 +03:00
Luiz Augusto von Dentz
da3cd9ad24 client: Add set-advertise-tx-power command
This adds set-advertise-tx-power which can be used include TX power
in the advertisement data:

set-advertise-manufacturer <on/off>
[bluetooth]# set-advertise-tx-power on
[bluetooth]# advertise on

@ Advertising Added: 1
< HCI Command: LE Set Aidvertising Data (0x08|0x0008) plen 32
        Length: 6
        Flags: 0x02
          LE General Discoverable Mode
        TX power: 9 dBm
2016-08-16 11:16:03 +03:00
Luiz Augusto von Dentz
c7e97d116a client: Add set-advertise-manufacturer command
This adds set-advertise-manufacturer which can be used set manfacturer
spefic data to be advertised:

set-advertise-manufacturer [id][data=[xx xx ...]
[bluetooth]# set-advertise-manufacturer 0xffff 0x00 0x01 0x02 0x03
[bluetooth]# advertise on

@ Advertising Added: 1
< HCI Command: LE Set Advertising Data (0x08|0x0008) plen 32
        Length: 11
        Flags: 0x02
          LE General Discoverable Mode
        Company: internal use (65535)
          Data: 00010203
2016-08-16 11:16:03 +03:00
Luiz Augusto von Dentz
820a6da585 client: Add set-advertise-service command
This adds set-advertise-service which can be used set UUID data to be
advertised:

set-advertise-service [uuid][data=[xx xx ...]
[bluetooth]# set-advertise-service 180D 0xff 0xff
[bluetooth]# advertise on

@ Advertising Added: 1
< HCI Command: LE Set Advertising Data (0x08|0x0008) plen 32
        Length: 9
        Flags: 0x02
          LE General Discoverable Mode
        Service Data (UUID 0x180d): ffff
2016-08-16 11:16:03 +03:00
Luiz Augusto von Dentz
74433d3976 client: Add set-advertise-uuids command
This adds set-advertise-uuids which can be used set UUIDs to be
advertised:

set-advertise-uuids [uuid1 uuid2...]
[bluetooth]# set-advertise-uuids 180D 180F
[bluetooth]# advertise on

@ Advertising Added: 1
< HCI Command: LE Set Advertising Data (0x08|0x0008) plen 32
        Length: 9
        Flags: 0x02
          LE General Discoverable Mode
        16-bit Service UUIDs (complete): 2 entries
          Heart Rate (0x180d)
          Battery Service (0x180f)
2016-08-16 11:16:03 +03:00
Luiz Augusto von Dentz
6c9e45f965 client: Add advertise command
This adds advertise command which uses org.bluez.LEAdvertisingManager1 to
add an advertising instance:

[bluetooth]# advertise
broadcast   off         on          peripheral
[bluetooth]# advertise on
Advertising object registered

@ Advertising Added: 1
< HCI Command: LE Set Advertising Data (0x08|0x0008) plen 32
        Length: 3
        Flags: 0x02
          LE General Discoverable Mode

[bluetooth]# advertise off
Advertising object unregistered

@ Advertising Removed: 1
< HCI Command: LE Set Advertise Enable (0x08|0x000a) plen 1
        Advertising: Disabled (0x00)
2016-08-16 11:16:03 +03:00
Johan Hedberg
5f2c8a1522 client: Don't attach stdin in connect_handler()
connect_handler() gets called when we're connected to D-Bus but before
introspection of the remote service (org.bluez) is complete. The
client_ready() callback otoh waits until the introspection is complete
and is already also taking care of attaching input.
2016-07-24 16:18:37 +03:00
Johan Hedberg
6fd2662dc9 client: Clarify D-Bus disconnected prompt
Make it clear that bluetoothctl is waiting to connect to bluetoothd
instead of showing something that looks like a prompt but which
doesn't accept any input.
2016-07-10 21:40:53 +03:00
Johan Hedberg
aed475dd69 client: Remove input handling if disconnected from D-Bus
When started, bluetoothctl doesn't process input until it has
connected to bluetoothd. To be consistent if the D-Bus connection is
later lost also remove the input processing then.
2016-07-10 21:40:53 +03:00
Luiz Augusto von Dentz
17360a4981 client: Fix filtered scan
Empty list of UUIDs should be allowed to be passed to
set-scan-filter-uuids as bluetoothd accepts it to enable filtering
every UUID.
2016-06-29 13:27:31 +03:00
Luiz Augusto von Dentz
505f2a42f7 client: Update to use new GATT API
This update use of ReadValue and WriteValue to include the options
introduced in the API.
2016-05-18 14:16:29 +03:00
Francois Beaufort
065e286b64 client: Fix select-attribute behaviour 2016-04-26 13:33:53 +03:00
Luiz Augusto von Dentz
08bca88cd6 client: Fix code style problems
Only tabs shall be used for indentation.
2016-04-04 13:12:54 +03:00
Luiz Augusto von Dentz
158248f20a audio/avdtp: Fix code style 2016-04-01 16:44:16 +03:00
Szymon Janc
ac52a82ac0 client: Fix removing all devices
cmd_remove takes address string not device path.
2016-02-12 19:57:08 +01:00
Luiz Augusto von Dentz
8c19cbee79 client: Fix not detecting connections when starting
If a device is connected set it as default so the prompt is updated and
attribute related commands can work.
2016-02-08 11:22:05 +02:00
Francois Beaufort
a6ef3eb009 client: Update remove command to support removing all devices 2016-01-23 12:00:40 +00:00
Johan Hedberg
0e354efc11 client: Fix printing selcted device prompt 2015-11-13 13:15:52 +02:00
Luiz Augusto von Dentz
1e6db1858c client: Fix crash when exiting
When exiting the available proxies are destroy in the same order they are
added causing the following crash when there are attributes whose service
has already been removed:

Invalid read of size 8
   at 0x414AAD: g_dbus_proxy_get_path (client.c:525)
   by 0x40B948: characteristic_is_child (gatt.c:136)
   by 0x40C420: gatt_remove_characteristic (gatt.c:157)
   by 0x4067A7: proxy_removed (main.c:446)
   by 0x414A2E: proxy_free (client.c:439)
   by 0x4E7AF6C: g_list_foreach (in /usr/lib64/libglib-2.0.so.0.4400.1)
   by 0x4E7AF8A: g_list_free_full (in /usr/lib64/libglib-2.0.so.0.4400.1)
   by 0x415D54: g_dbus_client_unref (client.c:1310)
   by 0x40511B: main (main.c:2067)
 Address 0x5eb5450 is 16 bytes inside a block of size 80 free'd
   at 0x4C29D6A: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x4E8479E: g_free (in /usr/lib64/libglib-2.0.so.0.4400.1)
   by 0x4149D6: g_dbus_proxy_unref (client.c:517)
   by 0x414A8D: proxy_free (client.c:451)
   by 0x4E7AF6C: g_list_foreach (in /usr/lib64/libglib-2.0.so.0.4400.1)
   by 0x4E7AF8A: g_list_free_full (in /usr/lib64/libglib-2.0.so.0.4400.1)
   by 0x415D54: g_dbus_client_unref (client.c:1310)
   by 0x40511B: main (main.c:2067)
2015-11-12 16:37:44 +02:00
Johan Hedberg
ed78d12fe9 client: Make GATT listing more readable 2015-11-12 13:21:08 +02:00
Johan Hedberg
4cd67264c3 client: Fix potential array overflow 2015-07-07 22:20:33 +03:00
Mateusz Lemusisk
01e8a8b87a client: Display address if calling 'disconnect' without arguments
Before:

[PHILIPS BTM2180]# disconnect
Attempting to disconnect from
Successful disconnected

After:

[PHILIPS BTM2180]# disconnect
Attempting to disconnect from XX:XX:XX:XX:XX:XX
Successful disconnected
2015-06-23 18:27:34 +03:00
Jakub Pawlowski
d68ff94580 client: main: add support for SetDiscoveryFilter
This patch adds set-scan-filter-* commands to sample DBus client that
might be used to modify discovery filter.

set-scan-filter-uuids - sets filter uuids field
set-scan-filter-rssi - sets filter rssi and clears pathloss
set-scan-filter-pathloss - sets filter pathloss and clears rssi
set-scan-filter-transport - sets filter transport
set-scan-filter-clear - clears filter

Sample output:
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# set-scan-filter-uuids babe
SetDiscoveryFilter success
[bluetooth]# set-scan-filter-transport le
SetDiscoveryFilter success
[bluetooth]# set-scan-filter-rssi -69
SetDiscoveryFilter success
[bluetooth]# scan on
Discovery started
[CHG] Controller 00:1A:7D:DA:71:13 Discovering: yes
[CHG] Device 44:89:1C:C5:67:94 RSSI: -66
[CHG] Device 44:89:1C:C5:67:94 TxPower: -21
[CHG] Device 44:89:1C:C5:67:94 RSSI: -65
[CHG] Device 44:89:1C:C5:67:94 RSSI: -58
[CHG] Device 44:89:1C:C5:67:94 RSSI: -64
[CHG] Device 44:89:1C:C5:67:94 RSSI: -59
[CHG] Device 44:89:1C:C5:67:94 RSSI: -65
[CHG] Device 44:89:1C:C5:67:94 RSSI: -59
[CHG] Device 44:89:1C:C5:67:94 RSSI: -64
[bluetooth]# set-scan-filter-rssi -90
SetDiscoveryFilter success
[CHG] Device 44:89:1C:C5:67:94 RSSI: -76
[CHG] Device 44:89:1C:C5:67:94 RSSI: -82
[CHG] Device 44:89:1C:C5:67:94 RSSI: -75
[CHG] Device 44:89:1C:C5:67:94 RSSI: -81
[CHG] Device 44:89:1C:C5:67:94 RSSI: -76
[CHG] Device 44:89:1C:C5:67:94 RSSI: -76
[CHG] Device 44:89:1C:C5:67:94 RSSI: -81
[CHG] Device 44:89:1C:C5:67:94 RSSI: -75
[CHG] Device 44:89:1C:C5:67:94 RSSI: -82
[CHG] Device 44:89:1C:C5:67:94 RSSI: -82
[bluetooth]# scan off
[CHG] Device 44:89:1C:C5:67:94 TxPower is nil
[CHG] Device 44:89:1C:C5:67:94 RSSI is nil
Discovery stopped
[CHG] Controller 00:1A:7D:DA:71:13 Discovering: no
2015-04-28 10:43:14 +03:00
Jakub Pawlowski
e1bc7c9c4b client: Make command info print TxPower and RSSI
This makes command info to also print TxPower and RSSI if available.
2015-04-23 22:03:18 +02:00
Luiz Augusto von Dentz
09000e29db client: Make command info print ServiceData
This makes command info to also print ServiceData if available.
2015-04-17 14:15:48 +03:00
Luiz Augusto von Dentz
a926593bef client: Make command info print ManufacturerData
This makes command info to also print ManufacturerData if available.
2015-04-17 14:15:47 +03:00
Luiz Augusto von Dentz
9797b12a39 client: Fix no handling dict properly
D-Bus dict may contain keys that are not of string type.
2015-04-17 14:15:47 +03:00
Marcel Holtmann
9fb60a2933 client: Use bool for __terminated variable 2015-04-02 19:27:13 -07:00
Luiz Augusto von Dentz
84cc810f3f client: Add unregister-profile command
This adds support to unregister-profile command which uses
GattManager1.UnregisterProfile.
2015-03-25 12:34:49 +02:00
Luiz Augusto von Dentz
0677f7ac3e client: Add register-profile command
This adds support to register-profile command which uses
GattManager1.RegisterProfile.
2015-03-25 12:34:48 +02:00
Marcel Holtmann
734a1eeeba client: Fix includes for gdbus.h header 2015-02-28 22:21:46 -08:00
Szymon Janc
b99c419fa4 client/display: Fix compilation warning on Android
isprint requires ctype.h include.

target thumb C: btmgmt <= external/bluetooth/bluez/client/display.c
external/bluetooth/bluez/client/display.c: In function 'rl_hexdump':
external/bluetooth/bluez/client/display.c:81:3: warning: implicit
    declaration of function 'isprint' [-Wimplicit-function-declaration]
   str[(i % 16) + 51] = isprint(buf[i]) ? buf[i] : '.';
   ^
2015-02-13 21:58:44 +02:00
Luiz Augusto von Dentz
229e583257 client: Handle attribute notifications
This enable printing properties changes to the current selected
attribute.
2015-02-10 13:15:58 +02:00
Luiz Augusto von Dentz
fcbf38a99c client: Add notify command
This command can be used to start/stop changes on the attribute value,
it only works if an attribute has been selected with select-attribute.
2015-02-10 13:15:58 +02:00
Luiz Augusto von Dentz
52392d8405 client: Add write command
This command can be used to write attributes, it only works if an
attribute has been selected with select-attribute.

The data argument should be passed hexdump format, %02x separated by
spaces, which is the same format used by read command.
2015-02-10 13:15:58 +02:00
Luiz Augusto von Dentz
838bdbce23 client: Add read command
This command can be used to read attributes, it only works if an
attribute has been selected with select-attribute.
2015-02-10 13:15:58 +02:00
Luiz Augusto von Dentz
044ff5e4cd client/display: Add rl_hexdump 2015-02-10 13:15:58 +02:00
Luiz Augusto von Dentz
cfe7f0a613 client: Add attribute-info command
attribute-info can be used to print out attribute information.
2015-02-10 13:15:58 +02:00
Luiz Augusto von Dentz
2eb1f615c4 client: Add command select-attribute
Command select-attribute can be used to select a service attribute.
2015-02-10 13:15:58 +02:00
Luiz Augusto von Dentz
496b6abf74 client: Add command list-attributes
This command can be used to list service attributes of a device.
2015-02-10 13:15:57 +02:00
Luiz Augusto von Dentz
8144c2ff58 client: Make commands relative to device
In case a device is connected make it the default and print to the
prompt, so the user don't have to type in its address.
2015-02-10 13:15:57 +02:00
Luiz Augusto von Dentz
77196fd631 client: Add support for GattDescriptor1
This add support for GattDescriptor1 interface detection and
prints when they are added or removed.
2015-02-10 13:15:57 +02:00
Luiz Augusto von Dentz
c6923a75ae client: Add support for GattCharacteristic1
This add support for GattCharacteristici1 interface detection and
prints when they are added or removed
2015-02-10 13:15:57 +02:00
Luiz Augusto von Dentz
aab6835b0a client: Add support for GattService1
This add support for GattService1 interface detection and prints when
they are added or removed
2015-02-10 13:15:57 +02:00
Luiz Augusto von Dentz
3167c1df57 client: Force redisplay on rl_printf
It seems some in some version of readline rl_redisplay does not update
when rl_printf is called, so this uses rl_forced_update_display which
should force the new lines to be displayed.
2014-09-05 22:53:52 +03:00
Luiz Augusto von Dentz
2fb5a1bccc client: Fix typo 2014-09-05 22:53:52 +03:00
Szymon Janc
36d6740363 client: Allow to terminate if bluetoothd was not started
This allows to terminate bluetoothctl with CTRL-C if daemon didn't
start. Otherwise input is not functional and user must kill
bluetoothctl by sending signal from another terminal.
2014-07-08 21:34:54 +03:00