Commit Graph

338 Commits

Author SHA1 Message Date
Gopal Tiwari
b4233bca18 client/gatt: Fix memory leak issues
While performing the static tool analysis using coverity tool
found following reports

Error: RESOURCE_LEAK (CWE-772):
bluez-5.64/client/gatt.c:1531: leaked_storage: Variable "service"
going out of scope leaks the storage it points to.

Error: RESOURCE_LEAK (CWE-772):
bluez-5.64/client/gatt.c:2626: leaked_storage: Variable "chrc"
going out of scope leaks the storage it points to.

Error: RESOURCE_LEAK (CWE-772):
bluez-5.64/client/gatt.c:2906: leaked_storage: Variable "desc"
going out of scope leaks the storage it points to.
2022-05-31 12:48:33 -07:00
Inga Stotland
79fe529d64 client: Fix setting of advertisement interval
This fixes incorrect argument read when using "interval" command
in "advertisement" submenu
2022-05-23 13:47:15 -07:00
Zhengping Jiang
bda2a9e6f9 client: Add filter to devices and show Bonded in info
Use the property name as optional filters to the command "devices" and
show the "Bonded" property for the command "info".

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Reviewed-by: Yun-Hao Chung <howardchung@chromium.org>
2022-05-04 14:56:05 -07:00
Luiz Augusto von Dentz
7a87497da4 client/player: Add transport.receive command
This adds transport.receive command:

Get/Set file to receive
Usage:
	 receive [filename]
2022-04-26 11:03:26 -07:00
Luiz Augusto von Dentz
dd5b66695c client/player: Add transport.volume command
This adds transport.volume command:

Get/Set transport volume
Usage:
	 volume <transport> [value]
2022-04-22 16:01:29 -07:00
Luiz Augusto von Dentz
b2db8f0e3a client/player: Fix use of unsupported config_qos
QoS is not yet supported by bluetoothd so remove them.
2022-04-18 16:57:49 -07:00
Luiz Augusto von Dentz
777bc7c3f5 client/player: Add transport menu
This adds transport menu:

[bluetooth]# menu transport
Menu transport:
Available commands:
-------------------
list                                              List available transports
show <transport>                                  Transport information
acquire <transport>                               Acquire Transport
release <transport>                               Release Transport
send <filename>                                   Send contents of a file
2022-04-14 17:05:25 -07:00
Luiz Augusto von Dentz
46f171a86c client/player: Add endpoint menu
This adds endpoint menu:

[bluetooth]# menu endpoint
Menu endpoint:
Available commands:
-------------------
list [local]                                      List available endpoints
show <endpoint>                                   Endpoint information
register <UUID> <codec> [capabilities...]         Register Endpoint
unregister <UUID/object>                          Register Endpoint
config <endpoint> <local endpoint> [preset]       Configure Endpoint
presets <UUID> [default]                          List available presets
2022-04-14 17:05:24 -07:00
Luiz Augusto von Dentz
d204e84c06 client: Add support for player submenu
This moves adds the functionality of bluetooth-player into
bluetoothctl.
2022-03-30 12:54:29 -07:00
Luiz Augusto von Dentz
18af5f4faf client: Add support for scan <le/bredr>
This adds support for entering the transport directly as an scan
argument rather than having to first set it scan.transport.
2022-03-02 16:30:11 -08:00
Luiz Augusto von Dentz
cfab569484 build: Replace use of g_memdup with util_memdup
This replaces the uses of g_memdup with util_memdup since the former has
been deprecated:

  warning: ‘g_memdup’ is deprecated: Use 'g_memdup2' instead
  [-Wdeprecated-declarations]

g_memdup2 requires bumping glib version which would likely have its
own problems thus why util_memdup was introduced.
2022-01-06 12:58:39 -08:00
Ulisses Costa
433f7cce3b client/gatt: Fix property_change in WriteValue for desc
g_dbus_emit_property_changed was not working properly in the WriteValue
for the descriptor because the Characteristic interface was being used.
2021-12-07 18:48:46 -08:00
Tedd Ho-Jeong An
6ea642f6ef client: Fix uninitiailzed scalar variable
This patch fixes the uninitiailzed varialble(CWE-457) reported by
the Coverity scan.
2021-11-15 13:07:08 -08:00
Luiz Augusto von Dentz
8d2b847b00 client/gatt: Fix using atoi
atoi doesn't support values entered in hexadecimal (0x...) which is
likely the prefered format for the likes of handles, etc, so this
replaces the uses of atoi with strtol.
2021-11-09 14:45:23 -08:00
Miao-chen Chou
f4151f35b2 client: Print error code for connect methods
The following steps were performed.
- Issuing repeated commands to connect the same BLE device.
- Verifying the print in bluetoothctl console

Reviewed-by: Alain Michaud <alainm@chromium.org>
Reviewed-by: Howard Chung <howardchung@google.com>
2021-10-04 15:44:56 -07:00
Luiz Augusto von Dentz
1e9ce5ed80 client: Print MTU on attribute-info
This prints the MTU of the characteristic when available.
2021-09-28 16:53:08 -07:00
Archie Pusaka
28a5c47650 client: Inclusive language changes
Use "parent" to describe dbus hierarchy.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2021-09-21 10:51:54 +02:00
Luiz Augusto von Dentz
b84f294cb1 client: Add support for printing ExperimentalFeatures property
Thid adds support to show command to print ExperimentalFeatures property:

[bluetooth]# show
Controller ...
	Experimental: BlueZ Experimental LL p.. (15c0a148-c273-11ea-b3de-0242ac130004)
2021-09-08 14:12:58 -07:00
Yun-Hao Chung
bb0714be21 client: add AffectedByPolicy property
This prints property AffectedByPolicy in device info if
org.bluez.AdminPolicyStatus1 exists.

This also rename find_battery_by_path to find_proxies_by_path to reuse
the function.

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
2021-08-11 11:18:22 -07:00
Yun-Hao Chung
4f3adc7bef client: add admin submenu and allow command
This creates a menu - admin and add a commands to bluetoothctl
- allow [clear/uuid1 uuid2 ...]

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
2021-08-11 11:18:22 -07:00
Luiz Augusto von Dentz
f287a42cd6 client/advertising: Fix not disabling local-name in Includes
When setting a advertising.name other than on/off it shall also disable
local-name flag from Includes as that would cause an error when parsed
by the daemon.
2021-08-10 14:59:12 -07:00
Luiz Augusto von Dentz
c3159848b9 client: Fix advertise broadcast
When advertising with type broadcast it cannot be discoverable as that
would require setting flags which is not allowed by the spec.
2021-05-14 17:25:52 -07:00
Luiz Augusto von Dentz
4e7780d0eb client/advertising: Add support for setting min/max intervals
This adds support for setting MinInterval/MaxInterval.
2021-05-13 13:26:13 -07:00
Daniel Winkler
0b8e166fd8 client: Add adv SupportedFeatures to bluetoothctl
This change adds SupportedFeatures to be shown in "show" option of
bluetoothctl. It was tested with and without kernel support for features
to verify that they are shown or not shown correctly.

Change was tested by verifying SupportedFeatures were populated
correctly in bluetoothctl on hatch and kukui chromebooks

Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
2021-03-17 11:30:27 -07:00
Archie Pusaka
ad02a4eddb bluetoothctl: advmon rssi support for mgmt
Using the new opcode MGMT_OP_ADD_ADV_PATTERNS_MONITOR_RSSI to
monitor advertisement according to some RSSI criteria.
2021-01-15 11:55:06 -08:00
Manish Mandlik
fa53b7018b client: Use correct root path for RegisterMonitor
Bluetoothctl uses "/" as the app root path. So, use the same
app root path while invoking RegisterMonitor method. This will
also ensure that InterfacesAdded/InterfacesRemoved signals are
emitted on the correct app root path.
2020-12-02 21:09:07 -08:00
Inga Stotland
c29a438abe client: Remove reference to g_steal_pointer()
In order to avoid requiring higher version of GLib, replace
g_steal_pointer() with explicitly setting the pointer value
to NULL.
2020-11-09 13:54:06 -08:00
Daniel Winkler
664c55440b client: Add SupportedCapabilities to bluetoothctl
This patch adds the new "SupportedCapabilities" property to the
bluetoothctl "show" view.

The change is tested by verifying bluetoothctl shows the desired
properties.
2020-10-29 17:45:40 -07:00
Tedd Ho-Jeong An
f22f166d6e client: Add SPDX License Identifier
This patch adds SPDX License Identifier and removes the license text.

-------------------------------------
       License            COUNT
-------------------------------------
 GPL-2.0-or-later     :      11

License: GPL-2.0-or-later
   client/adv_monitor.c
   client/adv_monitor.h
   client/advertising.h
   client/display.c
   client/main.c
   client/display.h
   client/agent.h
   client/gatt.c
   client/agent.c
   client/advertising.c
   client/gatt.h
2020-09-21 16:19:33 -07:00
Howard Chung
d465c70f9b client: Expose ADV monitor objects
This adds logic to expose user-defined advertisement monitor to dbus and
also implements methods for exposed objects.
2020-09-16 09:38:14 -07:00
Howard Chung
566db0ed69 client: Implement more interfaces of ADV monitor in bluetoothctl
This patch creates a submenu in bluetoothctl and implements several
commands.

new commands:
[bluetooth]# menu monitor
[bluetooth]# add-or-pattern 1 2 ab0011
Advertisement Monitor 0 added
[bluetooth]# add-or-pattern-rssi -80, ,5 1 2 aa 3 4 ff
Advertisement Monitor 1 added
[bluetooth]# get-pattern all
Advertisement Monitor 0
	path: /org/bluez/adv_monitor_app/0
	type: or_patterns
	pattern 1:
		start position: 1
		AD data type: 2
		content: ab0011
Advertisement Monitor 1
	path: /org/bluez/adv_monitor_app/1
	type: or_patterns
	rssi:
		high threshold: -50
		high threshold timer: 5
		low threshold: -80
		low threshold timer: 5
	pattern 1:
		start position: 1
		AD data type: 2
		content: aa
	pattern 2:
		start position: 3
		AD data type: 4
		content: ff
[bluetooth]# get-supported-info
Supported Features:
Supported Moniter Types: or_patterns
[bluetooth]# remove-pattern 0
Monitor 0 deleted
2020-09-16 09:38:03 -07:00
Howard Chung
664e10ff7e client: Implement basic interface of ADV monitor in bluetoothctl
This patch implements some basic functions for ADV monitor in
bluetoothctl

[bluetooth]# show
...
Advertisement Monitor Features:
	SupportedMonitorTypes: or_patterns
2020-09-16 09:37:42 -07:00
Barry Byford
c24db50c43 client: Fix typo in bluetoothctl 2020-08-31 10:33:48 -07:00
Miao-chen Chou
4d0336ea40 client: Add cancel-pairing command
This adds cancel-pairing command which can be used to cancel the ongoing
pairing.
2020-08-21 10:50:04 -07:00
Alain Michaud
615d82331d client: Add support for the Roles property.
This adds support for reading the Roles property through bluetootctl's
show option.

[bluetooth]# show
...
Roles: central
Roles: peripheral
Roles: central-peripheral
2020-07-07 10:49:34 -07:00
Abhishek Pandit-Subedi
d4c2c8a473 client: Display wake allowed property with info
Display whether the device is configured as wake allowed when queried
with cmd_info.
2020-07-07 10:46:48 -07:00
Sonny Sasaka
841b7ebe0f client: Add battery percentage to info command
This adds the Battery Percentage to the info command based on
org.bluez.Battery1 API. Example usage:

[bluetooth]# info XX:XX:XX:XX:XX:XX
Device XX:XX:XX:XX:XX:XX (random)
        Name: ...
        Alias: ...
        ...
        Modalias: ...
        Battery Percentage: 0x64 (100)
2020-07-02 16:22:10 -07:00
Mariusz Skamra
236fb26ff4 client: Update write callbacks with invalid offset error handlers
This patch adds invalid offset handlers to write callbacks of attributes.
2020-05-11 15:26:55 +02:00
Łukasz Rymanowski
1c2271575d client: Fix possible stack corruption
DBUS_TYPE_BOOLEAN is 'int', which does not have to be the same size as
'bool'.
On architecture where bool is smaller than in, getting prepare-authorize
will corrupt the stack
2020-05-11 15:26:55 +02:00
Luiz Augusto von Dentz
397cbeb864 client: Make advertise instances default to discoverable
The more common case is that advertisements are discoverable not the
other way around.
2020-04-07 12:52:23 -07:00
Luiz Augusto von Dentz
4ec7da4037 client: Add scan.pattern command
This uses the new Pattern filter:

[bluetooth]# scan.pattern Living
[bluetooth]# scan on
SetDiscoveryFilter success
Discovery started
[CHG] Controller XX:XX:XX:XX:XX:XX Discovering: yes
[NEW] Device XX:XX:XX:XX:XX:XX Living Room TV
2020-02-19 16:25:04 -08:00
Syam Sidhardhan
a64d370949 client: Fix memory leak 2019-12-08 06:08:46 +02:00
Ronan Pigott
d45b4ac3ec client/main: add help option for available args
This option exists to facilitate external completion of commands that
have specially defined arguments. It effectively adds two new commands
to bluetoothctl with the following output:

$ bluetoothctl agent help
on
off
DisplayOnly
DisplayYesNo
KeyboardDisplay
KeyboardOnly
NoInputNoOutput

$ bluetoothctl advertise help
on
off
peripheral
broadcast

Shell completion scripts can then parse this output to provide
completions for those commands.
2019-09-06 10:57:10 +03:00
Luiz Augusto von Dentz
19329b3f68 client: Fix not able to select attributes if parent exists
When selecting attributes by UUID the code was not checking attributes
that are not a children of the current selected attribute.
2019-08-20 16:47:29 +03:00
Luiz Augusto von Dentz
31d7430759 client: Allow UUID 16 bits on select-attribute
This allow passing UUIDs on 16 bits format.
2019-08-20 16:47:29 +03:00
Luiz Augusto von Dentz
b723fafbbe client: Fix crash when setting advertising.discoverable on
DBUS_TYPE_BOOLEAN expect a pointer to dbus_bool_t not bool.
2019-05-10 14:58:09 +03:00
Luiz Augusto von Dentz
bbfaae247f client: Fix build with older version on libdbus
This fixes the following error when building with older version of
D-Bus:

client/gatt.c:2973: undefined reference to `dbus_message_iter_get_element_count'
2019-02-26 19:24:40 +02:00
Luiz Augusto von Dentz
d705d726c6 client: Print AdvertisingManager properties on command 'show'
This outputs the AdvertisingManager properties command 'show':

bluetoothctl> show
...
Advertising Features:
	ActiveInstances: 0x00
	SupportedInstances: 0x05
	SupportedIncludes: tx-power
	SupportedIncludes: appearance
	SupportedIncludes: local-name
2019-02-21 14:08:57 +02:00
Luiz Augusto von Dentz
bd0808bf01 client: Add advertise.secondary command
This adds advertose.secondary command which can be used to set a
secondary channel to advertise.
2019-02-21 14:08:52 +02:00
Luiz Augusto von Dentz
64438092cb client: Fix uninitialized error
trusted should be initialized with false since the property may not be
available.
2019-02-13 17:09:13 +02:00