Commit Graph

489 Commits

Author SHA1 Message Date
Silviu Florian Barbulescu
1dbd9ba1f1 Rename BAA_SERVICE to BCAA_SERVICE add BAA_SERVICE(0x1851)
Rename BAA_SERVICE to BCAA_SERVICE and added BAA_SERVICE(0x1851)
as UUID for the broadcast sink.
2023-07-31 10:33:25 -07:00
Luiz Augusto von Dentz
82d3d803d4 client: Add bluetoothctl-monitor.1 man page
This adds bluetoothctl-monitor.rst which is then converted to
bluetoothctl-mgmt.1 using rst2man.
2023-07-20 11:14:42 -07:00
Luiz Augusto von Dentz
f0bfd76280 client: Add bluetoothctl-mgmt.1 man page
This adds bluetoothctl-mgmt.rst which is then converted to
bluetooth-mgmt.1 using rst2man.
2023-07-20 11:14:31 -07:00
Luiz Augusto von Dentz
2b063f47ab client: Add support for mgmt submenu
This moves the functionality of btmgmt into client/mgmt.c so its
commands become available on bluetoothctl via mgmt submenu.
2023-07-14 15:14:02 -07:00
Luiz Augusto von Dentz
4578395b53 client/advetising: Allow use of EA data length
The code was supporting a maximum of 25 bytes (31 - 6) to be entered as
advertising data, but in case of EA is used that allows up to 245 bytes
(251 - 6) to be entered.
2023-07-10 12:24:47 -07:00
Luiz Augusto von Dentz
8f525dbccd client/player: Fix transport.acquire for linked transports
Linked (bi-directional) transports can be acquired on single D-Bus
method call which was not being handled properly by the current code
causing unexpected errors.
2023-06-20 12:54:23 -07:00
Luiz Augusto von Dentz
0053bc5472 client/player: Fix auto registration of broadcast endpoint
For broadcast endpoint broadcast must be set properly.
2023-06-20 12:54:23 -07:00
Luiz Augusto von Dentz
2c9ab2d3f4 client: Print integers decimal value
This make the code print D-Bus integer iterators also in decimal format
in addition to hexadecimal.
2023-06-20 12:54:23 -07:00
Silviu Florian Barbulescu
eb821743f9 client/player: Add support for broadcast source
This adds bluetoothctl support for broadcast source.
To test the current implementation use bluetoothctl with the commands:
endpoint.register 00001852-0000-1000-8000-00805f9b34fb 0x06
endpoint.config <created endpoint> <local endpoint> 16_2_1
transport.acquire <created transport>
transport.send <created transport> <file.wav>
2023-06-07 16:03:10 -07:00
Luiz Augusto von Dentz
f3977023f9 client/player: Add codec as parameter to endpoint.presets
This changes endpoint.presets command to take codec as parameter.
2023-05-12 13:31:53 -07:00
Luiz Augusto von Dentz
1707c35771 client/player: Fix not checking for SupportedUUIDs
When registering an endpoint it should always check for SupportedUUIDs.
2023-05-12 13:31:53 -07:00
Luiz Augusto von Dentz
fe16cf2a7e client/player: Add support to Max Transports in endpoint.register
[bluetooth]# endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0x06
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] Max Transports (auto/value): 1
[/local/endpoint/ep0] CIG (auto/value): a
[/local/endpoint/ep0] CIS (auto/value): a
2023-05-12 13:31:53 -07:00
Luiz Augusto von Dentz
67fd8479f1 client/player: Fix crashes accessing metadata
If metadata is not set the respective iovec is left NULL so it needs to
be checked before accessing its fields.
2023-05-12 13:31:53 -07:00
Luiz Augusto von Dentz
416b8375ff client/player: Fix crash when RegisterEndpoint fails
If RegisterEndpoint fails when there are multiple adapters it would
attempt to free the same endpoint multiple times.
2023-05-01 12:27:20 -07:00
Abhay Maheta
f9376b13b3 client/player: Add support for Metadata in BAP Profile
This adds support for Metadata in BAP profile.
In order to register zero Metadata, 0 shall be
entered when prompted.

[bluetooth]# endpoint.register 00002bc9-0000-1000-8000-00805f9b34fb 0x06
[/local/endpoint/ep0] Enter Metadata (value/no): n
[/local/endpoint/ep0] Auto Accept (yes/no): y
[/local/endpoint/ep0] CIG (auto/value): a
[/local/endpoint/ep0] CIS (auto/value): a
Capabilities:
  03 01 ff 00 02 02 03 02 03 03 05 04 1e 00 f0 00  ................
Endpoint /local/endpoint/ep0 registered
2023-04-28 16:07:41 -07:00
Luiz Augusto von Dentz
070c78c426 client/advertising: Add support for advertise.rsi command
This adds support for advertise.rsi command which can be used to request
the generation of RSI and include it as part of advertising data:

[bluetooth]# advertise.rsi --help
Show/Enable/Disable RSI to be advertised
Usage:
	 rsi [on/off]
[bluetooth]# advertise.rsi
RSI: on
[bluetooth]# advertise on
...
Advertising object registered
Tx Power: off
Name: off
Appearance: off
Discoverable: on
RSI: on
[bluetooth]#
2023-04-05 17:00:00 -07:00
Iulia Tanasescu
c4d9b99db5 Split bt_iso_qos into dedicated structures
Split bt_iso_qos into dedicated unicast and broadcast
structures and add additional broadcast parameters.
2023-03-31 14:33:28 -07:00
Luiz Augusto von Dentz
fb1c694100 client: Add samples init scripts
This adds sample init scripts that can be passed to bluetoothctl for
testing.
2023-03-24 16:52:45 -07:00
Luiz Augusto von Dentz
815f779aa8 client: Use AdvertisingFlags when available
This prints devices not discoverable in grey so the user are able to
distict when for example set members are actually visible.
2023-03-10 13:41:06 -08:00
Luiz Augusto von Dentz
373bafc34c client: Add support for DeviceSet proxy 2023-03-10 13:41:06 -08:00
Luiz Augusto von Dentz
31ab084f07 client/player: Update High Reliability presets
This updates High Reliability presets as published in BAP 1.0.1:

https://www.bluetooth.com/specifications/bap-1-0-1/
2023-03-10 13:41:06 -08:00
Luiz Augusto von Dentz
24aeb31961 client: Allow transport.send command to work with multiple transports
This enables transport.send to work with multiple transports instead of
sending one by one which can create synchronization problems.
2023-03-02 12:19:39 -08:00
Luiz Augusto von Dentz
dcbdf5e67f media: Rework support of Vendor to use uint32_t as type
This reworks the handlings of Vendor property to use a single uint32_t.
2023-01-31 17:07:31 -08:00
Abhay Maheta
33d99e12c3 client/player: Add support for Company ID, Vendor ID
This adds support for Company ID and Vendor Codec ID in  BAP profile.
This also adds handling of Vendor Specific Coding format for BAP
Profile.

Now it allows to enter zero codec capabilities for vendor codec.
In order to register zero codec capabilities, 0 shall be
entered when prompted.
2023-01-31 17:07:31 -08:00
Luiz Augusto von Dentz
1270afa5aa client/player: Fix transport.send/receice tab completion
Commands transport.send/receive were not settings any completion
callback so this makes sure it uses transport_generator to generate the
list of transport that could be used to send.
2022-12-15 13:07:41 -08:00
Luiz Augusto von Dentz
318b1a19cb client/player: Print transport progress
This uses bt_shell_echo to print out the transfer progress on the echo
area.
2022-12-15 13:04:45 -08:00
Luiz Augusto von Dentz
e51d6c5f2e client/player: Use bt_shell_echo to print transfer progress
This uses bt_shell_echo to print transfer progress.
2022-12-15 13:04:33 -08:00
Luiz Augusto von Dentz
89b2072b4f client/player: Make transport.send non-blocking
This makes transport.send command non-blocking by using timerfd
callback to initiate the transfers.
2022-12-14 13:26:40 -08:00
Luiz Augusto von Dentz
e07c1e723e client/player: Fix not calculating time to wait
The difference of time start and current time may have advanced just
enough to add a second leaving start nanoseconds to be bigger.
2022-12-09 13:24:16 -08:00
Luiz Augusto von Dentz
9a550d43b8 client: Allow gatt.select-attribute to work with local attributes
This allows gatt.select-attribute local to select from the registered
attributes:

[bluetooth]# gatt.select-attribute local /org/bluez/app/service0/chrc0
[/org/bluez/app/service0/chrc0]# gatt.write 0x01
[CHG] Attribute /org/bluez/app/service0/chrc0 (%UUID) written
[/org/bluez/app/service0/chrc0]# gatt.read
01                                               .
[/org/bluez/app/service0/chrc0]# gatt.select-attribute local
 /org/bluez/app/service0/chrc1
[/org/bluez/app/service0/chrc1]# gatt.write 0x01
[CHG] Attribute /org/bluez/app/service0/chrc1 (%UUID) written
[/org/bluez/app/service0/chrc1]# gatt.read
01                                               .
[/org/bluez/app/service0/chrc1]#
2022-12-06 13:01:28 -08:00
Luiz Augusto von Dentz
a4bde19d3b client: Move common print_* functions to its own file
This move common print_* functions to its own file so they can be
properly reused instead of duplicating the code.
2022-12-02 11:20:26 -08:00
Luiz Augusto von Dentz
7642669e44 client/player: Add support for custom preset
This adds support for a custom preset which asks the user to enter its
configuration:

[bluetooth]# endpoint.presets 00002bc9-0000-1000-8000-00805f9b34fb custom
[Codec] Enter frequency (Khz): 48
[Codec] Enter frame duration (ms): 10
[Codec] Enter channel allocation: 0x000000003
[Codec] Enter frame length: 100
[QoS] Enter Target Latency (Low, Balance, High): Low
[QoS] Enter SDU Interval (us): 10000
[QoS] Enter Framing (Unframed, Framed): Unframed
[QoS] Enter PHY (1M, 2M): 2M
[QoS] Enter Max SDU: 200
[QoS] Enter RTN: 3
[QoS] Enter Max Transport Latency (ms): 20
[QoS] Enter Presentation Delay (us): 10000
2022-12-02 11:19:53 -08:00
Luiz Augusto von Dentz
5a872af406 client/player: Fix scan-build warning
This fixes the following warning:

client/player.c:1775:25: warning: Dereference of null pointer
[core.NullDereference]
iov_append(&cfg->caps, preset->data.iov_base, preset->data.iov_len);
                        ^~~~~~~~~~~~~~~~~~~~~
2022-11-21 13:03:04 -08:00
Luiz Augusto von Dentz
c8836711ad client: Fix advertise.data command
advertise.data when no parameter is given shall print what is set on
ad.data not the ad.manufacturer which is a different field set by
advertise.manufacturer.
2022-10-20 15:55:55 -07:00
Luiz Augusto von Dentz
25a31f5a93 client/player: Fix attempting to acquire already acquired transport
If the transport has links check if the link is acquiring before
attempting to call Acquire otherwise it may cause an error to be
printed.
2022-09-29 13:58:41 -07:00
Christian Eggers
7b07f1f980 client/player: fix printf format string
Use macros from inttypes.h for correct printf format specifier for
int64_t
2022-09-26 10:57:00 -07:00
Luiz Augusto von Dentz
6c71203056 client/gatt: Fix scan-build warning
This fixes the following warning:

client/gatt.c:2146:2: warning: Null pointer passed to 2nd parameter
expecting 'nonnull' [core.NonNullParamChecker]
        memcpy(*dst_value + offset, src_val, src_len);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-09-23 13:47:10 -07:00
Christian Eggers
ee750bbaf6 client/gatt: proxy_property_changed: check for NULL iterator
The passed iterator can be NULL as in
gdbus/client.c::properties_changed():
...
   proxy->prop_func(..., ..., iter=NULL, ...)
   +--client/gatt.c::proxy_property_changed(..., ..., iter, ...);
      +--dbus_message_iter_get_arg_type(iter);
...
2022-09-23 13:42:49 -07:00
Luiz Augusto von Dentz
c2734c41f7 client/gatt: Fix notification enabled/disabled output
When notifications are enabled/disable the output was not print a new
line.
2022-09-21 14:45:03 -07:00
Bastien Nocera
48992da64f client: Print the PowerState property 2022-09-01 11:43:41 -07:00
Luiz Augusto von Dentz
d8febc76a4 client/player: Fix checkpatch warning
This fixes the following checkpatch warning:

WARNING:LINE_SPACING: Missing a blank line after declarations
216: FILE: client/player.c:625:
+               GDBusProxy *proxy = l->data;
+               print_player(proxy, NULL);
2022-08-30 14:24:08 -07:00
Luiz Augusto von Dentz
d297a5873d client: Add -e/--endpoint option to auto register endpoints
This adds -e/--endpoint option that can be used to auto register
supported endpoints.
2022-08-29 14:36:06 -07:00
Christian Eggers
147cc4cf99 client/advertising: Fix typos: *_exits --> *_exists 2022-08-29 13:06:23 -07:00
Christian Eggers
9b93d95884 client: Add missing return statement in error path
Client will SEGFAULT if default_ctrl==NULL
2022-08-29 13:06:14 -07:00
Luiz Augusto von Dentz
9e298f8402 client/player: Use QoS interval on transport.send
This makes use of QoS interval when sending a file.
2022-08-29 12:43:05 -07:00
Luiz Augusto von Dentz
dc61ec4419 client/player: Add support for PACS endpoints
This adds support for PAC_SINK and PAC_SOURCE endpoints as well as LC3
presets.
2022-08-29 12:43:05 -07:00
Luiz Augusto von Dentz
64abbf7cee client: Move admin submenu
This moves admin submenu to admin.c so it is not mixed up with other
submenus code.
2022-08-15 16:28:14 -07:00
Luiz Augusto von Dentz
6270ad35b2 client: Fix build warning
This fixes the following build warning:

      warning: ‘g_memdup’ is deprecated: Use 'g_memdup2' instead
      [-Wdeprecated-declarations]
2022-07-05 10:31:39 -07:00
Luiz Augusto von Dentz
7f92f75e88 client/advertising: Fixes errors found by scan-build
This fixes the following errors:

client/advertising.c:129:4: warning: Value stored to 'n' is never read
[deadcode.DeadStores]
                        n = sizeof(str) - 1;
                        ^   ~~~~~~~~~~~~~~~
client/advertising.c:1012:25: warning: Dereference of null pointer
(loaded from variable 'min') [core.NullDereference]
        if (ad.min_interval != *min) {
                               ^~~~
2022-06-22 11:16:18 -07:00
Luiz Augusto von Dentz
33c96ca658 client/player: Fixes errors found by scan-build
This fixes the following errors:

client/player.c:1406:44: warning: Dereference of null pointer
[core.NullDereference]
        reply = endpoint_select_config_reply(msg, p->data.iov_base,
                                                  ^~~~~~~~~~~~~~~~
client/player.c:1866:2: warning: 3rd function call argument is an
uninitialized value [core.CallAndMessage]
        iov_append(&cfg->caps, data, len);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2022-06-22 11:09:04 -07:00
Luiz Augusto von Dentz
e4fd2dc5aa client/player: Enable acquiring multiple transports
This enables acquiring multiple transports simultaneously.
2022-06-22 11:00:55 -07:00
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
Luiz Augusto von Dentz
15cbd14aaa client: Improve logging of GATT operations
This prints the UUID along with attribute path and also print the
hexdump when payload is available.
2019-02-13 17:09:13 +02:00
Luiz Augusto von Dentz
f12dc48511 client: Forward notifications from cloned attributes
Notifications come in a form of 'Value' property changes thus this
copies the values to the local attribute so they are in sync.
2019-02-13 17:09:13 +02:00
Luiz Augusto von Dentz
40ebc70dae client: Remove cloned services if the proxy is removed
This unregister the cloned services if the proxy is removed since they
would no longer be accessible.
2019-02-13 17:09:13 +02:00
Luiz Augusto von Dentz
8ba5b4fb21 client: Proxy calls to StartNotify/StopNotify
This uses the proxies created by clone command to forward the
subscriptions to the cloned services.
2019-02-13 17:09:13 +02:00
Luiz Augusto von Dentz
32232aba53 client: Proxy calls to ReadValue and WriteValue
This uses the proxies created by clone command to forward the requests
to the cloned services.
2019-02-13 17:09:13 +02:00
Luiz Augusto von Dentz
183d47c176 client: Add gatt.clone command
This adds clone command to gatt submenu which can be use to clone
services as follow:

Clone all services from the connected device:
> gatt.clone

Clone a given service
> gatt.select-attribute <attribute/uuid>
> gatt.clone

In either case there is a prompt to confirm since this may add a lot of
service the user must confim before proceding.

Then finally:

> gatt.register-application
2019-02-13 17:09:13 +02:00
Luiz Augusto von Dentz
db15160d5c client: Add type to write command
This enables setting the write type as optional third parameter:

write <data=xx xx ...> [offset] [type]

The type can be used to force a specific procedure to be used, for
example to force reliable writes one can enter:

> write 00 0 reliable
2019-02-11 11:29:21 +02:00
Luiz Augusto von Dentz
b52543ae3d client: Don't expose pointer value in attribute path
Instead use the position in the list to create a unique path:

[bluetooth]# register-service 0x1820
[NEW] Primary Service (Handle 0x0000)
	/org/bluez/app/service0
	0x1820
	Internet Protocol Support
2019-01-31 14:10:56 +02:00
Luiz Augusto von Dentz
d5cb29ce5a client: Enable list-attributes to print local attributes
This enable passing "local" to list-attributes to print the attributes
registered locally:

> list-attributes local
Primary Service (Handle 0x0400)
	/org/bluez/app/service0x74ccb0
	0x1820
	Internet Protocol Support
2019-01-31 14:10:54 +02:00
Luiz Augusto von Dentz
918f6f932b client: Enable setting attribute handles
This emulates application setting their attribute handles.
2019-01-31 14:10:51 +02:00
Luiz Augusto von Dentz
ae63206ff8 client: Enable Handle property for GATT attributes
This enable bluetoothd to write back the actual value of attribute
handles.
2019-01-31 14:10:50 +02:00
Marcel Holtmann
261948090e build: Move declaration of _GNU_SOURCE back into individual source files 2018-12-06 21:28:18 +01:00
Luiz Augusto von Dentz
91df85690c client: Switch from write to sendmsg for Acquire*
Use sendmsg with MSG_NOSIGNAL to prevent crashes involving SIGPIPE.
2018-11-20 11:28:29 +02:00
Luiz Augusto von Dentz
847dcb2a6c client: Fix not resetting filters on scan.clear
If call to SetDiscoveryFilter comes with any value set the daemon will
not attempt to clear the filters, instead the client is suppose to send
an empty dict.
2018-08-01 14:55:40 +03:00
Luiz Augusto von Dentz
151a80b6ac client: Commit changes to scan filter if active
This detects if the command scan has been triggered and if so commit
changes to filter immediately so they take effect in the current
session.
2018-08-01 14:55:40 +03:00
Luiz Augusto von Dentz
9a57d90628 client: Add scan.clear discoverable
This implements scan.clear for discoverable filter.
2018-08-01 14:55:39 +03:00
Luiz Augusto von Dentz
170ff3b81f client: Add scan.discoverable command
This adds discoverable command to scan menu which can be used to set
if adapter should become discoverable while scanning:

[bluetooth]# scan.discoverable on
[bluetooth]# scan on
SetDiscoveryFilter success
[CHG] Controller XX:XX:XX:XX:XX:XX Discoverable: yes
Discovery started
[CHG] Controller XX:XX:XX:XX:XX:XX Discovering: yes
[bluetooth]# scan off
Discovery stopped
[CHG] Controller XX:XX:XX:XX:XX:XX Discoverable: no
2018-08-01 14:55:39 +03:00
Luiz Augusto von Dentz
ee863d9d5d client: Make show command print DiscoverableTimeout
Controller XX:XX:XX:XX:XX:XX (public)
	Name: Vudentz's T460s
	Alias: Intel-1
	Class: 0x004c010c
	Powered: yes
	Discoverable: no
	DiscoverableTimeout: 0x00000000
	Pairable: yes
	UUID: Headset AG                (00001112-0000-1000-8000-00805f9b34fb)
	UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
	UUID: SIM Access                (0000112d-0000-1000-8000-00805f9b34fb)
	UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
	UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
	UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
	UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
	UUID: Headset                   (00001108-0000-1000-8000-00805f9b34fb)
	Modalias: usb:v1D6Bp0246d0532
	Discovering: no
2018-07-30 09:36:27 +03:00
Luiz Augusto von Dentz
2796d545e8 client: Add discoverable-timeout command
This adds discoverable-timeout command which can be used to get/set
DiscoverableTimeout property:

[bluetooth]# discoverable-timeout 180
Changing discoverable-timeout 180 succeeded
2018-07-30 09:36:23 +03:00
Grzegorz Kolodziejczyk
1e32752f38 client: Don't require authorization for trusted devices
This patch adds possibility to ommit authorization request from trusted
devices.
2018-05-29 14:06:34 +03:00
Grzegorz Kolodziejczyk
822f082063 client: Add authorized property handling to characteristic attribute
This patch adds handling of characteristic prepare write authorized
property to bluetoothctl.
2018-05-28 16:29:11 +03:00
Luiz Augusto von Dentz
806276fe54 client: Add advertise.discoverable-timeout command
This adds advertise.discoverable-timeout command which can be used to
limit the amount of time the advertisement is discoverable:

[bluetooth]# advertise.discoverable on
[bluetooth]# advertise.discoverable-timeout 10
[bluetooth]# advertise on

@ MGMT Command: Add Advertising (0x003e) plen 14
        Instance: 1
        Flags: 0x00000001
          Switch into Connectable mode
        Duration: 0
        Timeout: 0
        Advertising data length: 3
        Flags: 0x02
          LE General Discoverable Mode
        Scan response length: 0
@ MGMT Event: Advertising Added (0x0023) plen 1
        Instance: 1
@ MGMT Event: Command Complete (0x0001) plen 4
      Add Advertising (0x003e) plen 1
        Status: Success (0x00)
        Instance: 1
@ MGMT Command: Add Advertising (0x003e) plen 14
        Instance: 1
        Flags: 0x00000001
          Switch into Connectable mode
        Duration: 0
        Timeout: 0
        Advertising data length: 3
        Flags: 0x00
        Scan response length: 0
2018-05-24 11:09:31 +03:00
Luiz Augusto von Dentz
e8f51b980c client: Print AD Data and Discoverable once registered
This prints both Data and Discoverable if advertise command succeeds:

[bluetooth]# advertise.data 0x26 0x01 0x00
[bluetooth]# advertise.discoverable on
[bluetooth]# advertise on
Advertising object registered
Data Type: 0x26
  01 00                                            ..
Tx Power: off
Name: off
Apperance: off
Discoverable: on
2018-05-24 11:09:30 +03:00
Luiz Augusto von Dentz
4f68e5f1fe client: Add advertise.discoverable command
This adds advertise.discoverable command which can be used to set it
own instance:

[bluetooth]# advertise.discoverable on
[bluetooth]# advertise on

@ MGMT Command: Add Advertising (0x003e) plen 14
        Instance: 1
        Flags: 0x00000001
          Switch into Connectable mode
        Duration: 0
        Timeout: 0
        Advertising data length: 3
        Flags: 0x02
          LE General Discoverable Mode
        Scan response length: 0
< HCI Command: LE Set Advertising Data (0x08|0x0008) plen 32
        Length: 3
        Flags: 0x02
          LE General Discoverable Mode
2018-05-24 11:09:30 +03:00
Luiz Augusto von Dentz
8cfef5aa0c client: Fix use of g_free
g_free shall only be used with pointer allocated with g_* functions.
2018-05-21 11:35:06 +03:00
Avichal Agarwal
8f970c44e6 client/gatt : Add support for Included Service
included service support implemented at service registration
2018-05-21 11:30:05 +03:00
Nagaraj D R
454fdfb541 Fix possible invalid memory access
Uninitialized data is read from local variable 'addr'
2018-05-21 11:28:43 +03:00
Grzegorz Kolodziejczyk
d2277dfa5f client: Define maximum attribute value length as initial value
Initial registered attribute value is set as maximal attribute length.
2018-05-21 11:09:30 +03:00
Grzegorz Kolodziejczyk
48dd3a49fb client: Add missing duplicated string free
This patch free duplicated strings in read, write attribute callbacks.
2018-05-21 11:09:29 +03:00
Luiz Augusto von Dentz
884fe6c82c client: Make info command print Advertising{Flags,Data} 2018-05-02 12:01:50 +03:00
Luiz Augusto von Dentz
72c9b97f5e client: Add support for setting advertising Data property
This adds data command to advertise menu which can be used to set
an arbitrary/profile specific advertising type and data:

[bluetooth]# data 0x26 0x01 0x01 0x00
2018-05-02 12:01:41 +03:00
Grzegorz Kolodziejczyk
7f9dcb3c45 client: Add support for optional gatt write offset parameter
This patch extends missing optional gatt write offset parameter.
2018-04-26 15:53:38 +03:00
Grzegorz Kolodziejczyk
5d50dc020b client: Add support for optional gatt read offset parameter
This patch extends missing optional gatt read offset parameter.
2018-04-26 15:53:37 +03:00
Grzegorz Kolodziejczyk
1dd33d584c client: Fix writing attribute values
Attribute values is not copied with dbus_message_iter_get_fixed_array,
so gatt write callback needs to replace old value with reallocation and
copy.
2018-04-26 15:53:37 +03:00
Luiz Augusto von Dentz
9f1388f2cf client: Attempt to convert the device path to address
Printing the object path is not only long but it also may change.
2018-03-29 14:10:25 +03:00
Luiz Augusto von Dentz
650a0d814a client: Add envs for proxies
This adds envs for device and adapter proxies found so other files are
able to access them.
2018-03-29 14:10:25 +03:00
ERAMOTO Masaya
14388c1d94 client: Return exit status for non-interactive 2018-03-27 13:58:17 +03:00
Luiz Augusto von Dentz
db663b1d57 client: Parse all options passed for GATT attribute
This parses the options given to Acquire*, WriteValue and ReadValue.
2018-03-26 16:19:29 +03:00
ERAMOTO Masaya
76d29b9bad client: Fix stay on error handling in non-interactive
Returns the FAILURE status since there is no meaning of stay in
non-interactive mode when executing some commands with an invalid
argument or with no controller. Also returns with the SUCCESS status
when getting a scan filtering value or disconnecting a non-default
device.
2018-03-23 13:19:04 +02:00
Grzegorz Kolodziejczyk
d3f155e458 client: Add authorization request handling for attribute operations
This patch adds optional authorization request for reading, writing of
gatt database attributes.
2018-03-21 11:25:52 +01:00
Grzegorz Kolodziejczyk
bc6facb0cf client: Update read callbacks with invalid offset error handlers
This patch adds invalid offset handlers to read callbacks of attributes.
2018-03-21 10:47:07 +01:00
Grzegorz Kolodziejczyk
1abee58711 client: Fix reading long values
While value has more than single MTU can carry long read procedure will
be triggered. In such cases offset need to bo considered while getting
value from storage.
2018-03-21 10:47:07 +01:00
Luiz Augusto von Dentz
41465ce57c client: Fix lines going beyond 80 columns 2018-03-01 11:23:09 +02:00
ERAMOTO Masaya
237365998f client: Use g_dbus_dict_append_*() 2018-03-01 10:49:05 +02:00
Luiz Augusto von Dentz
936ad5ef7b client: Quit when done with command
This ensures that the commands don't stay hanging since bt_shell no
longer quits immediatelly after executing a command.
2018-02-28 16:17:13 +02:00
Luiz Augusto von Dentz
fd656b1ce3 client: Don't auto register agent on non-interactive mode
There is no use to register an agent when on non-interactive mode.
2018-02-22 11:52:16 +02:00
ERAMOTO Masaya
9c90fc508d client: Add clear command for advertise
Adds the clear command to advertise-related commands to clear individual
fields or whole of advertise configuration.
2018-02-19 12:21:11 +02:00
ERAMOTO Masaya
4d04b9f573 client: Introduce ad_disable_{uuids,service,manufacturer} 2018-02-19 12:21:11 +02:00
ERAMOTO Masaya
f0fccd6f4d client: Introduce data_clear() calling ->clear() 2018-02-19 12:21:11 +02:00