Commit Graph

24357 Commits

Author SHA1 Message Date
Luiz Augusto von Dentz
982c73e118 tools/obexctl: Only enable attach input when connected 2018-02-22 11:52:15 +02:00
Luiz Augusto von Dentz
6962320860 tools/bluetooth-player: Only enable attach input when connected 2018-02-22 11:52:15 +02:00
Luiz Augusto von Dentz
0985a5943a shared/shell: Add non-interactive mode
This detects if any command was given as parameter, execute it and
exit disabling all other outputs:

bluetoothctl list
Controller 00:1B:DC:07:31:88 Vudentz's T460s #1 [default]
Controller B8:8A:60:D8:17:D7 BlueZ-1

It is also possible to run interactive command with use of timeout
option:

bluetoothctl --timeout=10 advertise on
Agent registered
[CHG] Controller 00:1B:DC:07:31:88 SupportedInstances: 0x04
[CHG] Controller 00:1B:DC:07:31:88 ActiveInstances: 0x01
Advertising object registered
Tx Power: off
Name: off
Apperance: off
2018-02-22 11:52:15 +02:00
Szymon Janc
c3f7b6733c adapter: Add ConnectDevice method
This allows to connect device without doing general discovery. This is
needed for some of qualification tests where there is no general
discovery upfront and we need to do connection to device with provided
address.

Another usecase is for scenario where scanning happen on one controller
but connection handling on another.

New device object is announced only if physical connection was
successful. On success this method returns path to created device
object. After ConnectProfile return bluetoothd continue with
services discovery and profile connection.

This patch implements bare minimum properties needed for connection -
address and address type. If needed eg. for non-NFC based OOB it could
be extended with more options.
2018-02-21 15:05:52 +01:00
Szymon Janc
19cb7b8c8a shared/shell: Fix history display with no saved prompt
Prompt needs to be restored always since default prompt is provided.
This fix issues with history line being clobbered by offset of prompt
length.

[bluetooth]# connect 9C:5C:F9:AB:C5:82
Attempting to connect to 9C:5C:F9:AB:C5:82
[bluetooth]# disconnect 9C:5C:F9:AB:C5:82
Attempting to disconnect from 9C:5C:F9:AB:C5:82
Failed to connect: org.bluez.Error.Failed
Successful disconnected
[bluetooth]# discoverable on
Changing discoverable on succeeded
[CHG] Controller 5C:E0:C5:34:AE:1C Discoverable: yes
[bluetooth]# disconnect discoverable on

after pressing up-down
[bluetooth]# disconnect dis5C:F9:AB:C5:82
2018-02-21 08:59:52 +01:00
Luiz Augusto von Dentz
8b21a74f2e adapter: Fix crash when discovering
If client exits while start discovery command is pending it may produce
the following crash:

Invalid read of size 8
   at 0x49036E: start_discovery_complete (adapter.c:1428)
   by 0x4D4957: request_complete (mgmt.c:261)
   by 0x4D5BD4: can_read_data (mgmt.c:353)
   by 0x4E717A: watch_callback (io-glib.c:170)
   by 0x50CEB76: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CEF1F: ??? (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x50CF231: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x40CEC0: main (main.c:770)
 Address 0x0 is not stack'd, malloc'd or (recently) free'd
2018-02-20 16:43:07 +02:00
Luiz Augusto von Dentz
1bf0336942 shared/io: Don't process HUP cond before others
When a HUP happens there maybe data left to be processed so the
disconnect handler shall be called last.
2018-02-20 16:43:07 +02:00
Luiz Augusto von Dentz
bc3f2cff83 device: Fix probing service twice
If there is already a service for a given profile there is no point in
probing it again.
2018-02-20 16:43:07 +02:00
Szymon Janc
0d57a236bf adapter: Fix not clearing connectable setting on power off
When kernel control of connectable is used daemon doesn't enable
connectable setting unless discoverable. Both settings are permanent
over power toggle unless discoverable timeout was set. In that case
discoverable flag is cleared by kernel on power off. This leads to
connectable flag being left enabled when toggling power on discoverable
adapter with timeout set.

This has some implications on system behaviour:
 - accepting connection from unknown devices
 - not being able to advertise as broadcaster

Since kernel doens't know the reason for enabling connectable flag (and
thus if disable if on power off) this needs to be handled in bluetoothd.
2018-02-19 19:15:02 +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
ERAMOTO Masaya
0540ff6339 client: Improve help messages for advertise 2018-02-19 12:21:11 +02:00
ERAMOTO Masaya
3df943537a client: Fix data growth if reconfiguring ad service
Since commit 65eff5c2 ("client: Rename set-service to service"), data
are appended in every run of advertise service with data arguments as
below:

  [bluetooth]# service 1 1 2
  [bluetooth]# service
  UUID: SDP(1)
    01 02                                            ..
  [bluetooth]# service 1 1 2 3
  [bluetooth]# service
  UUID: SDP(1)
    01 02 01 02 03                                   .....
2018-02-19 12:21:11 +02:00
ERAMOTO Masaya
7c6d0647ee client: Not output ad service info if no uuid sets 2018-02-19 12:21:11 +02:00
ERAMOTO Masaya
3de5807a53 client: Fix null output for ad service uuid
If getting the advertise service information without setting, outputs
null as UUID as below:

  [bluetooth]# service
  UUID: ((null))
2018-02-19 12:21:11 +02:00
Luiz Augusto von Dentz
3e900572b6 adapter: Fix initializing GATT server for BR/EDR only controllers
Controller that do not support LE bearer shall not use GATT server for
anything.
2018-02-16 20:02:41 +02:00
Steve Brown
287cd9b515 mesh: meshctl: Add subscriptions to node structure and json database
sub-add 0101 c000 1000

              {
                "modelId":"1000",
                "bind":[
                  1
                ],
                "subscribe":[
                  "c000"
                ]
              },
2018-02-16 12:38:20 +02:00
ERAMOTO Masaya
c361096818 obexd: Fix null response name
Prints out "<unknown>" string if there is no response name as below:

  obexd[8117]: obexd/src/obex.c:cmd_connect()
  obexd[8117]: CONNECT(0x0), (null)(0xffffffff)
2018-02-14 12:50:31 +02:00
Matt Schulte
2fa53e0fb6 advertising: only parse adv from adv interfaces
client_proxy_added is called for every interface on an object passed in
to the dbus RegisterAdvertisement method. This can cause a NULL
dereference to occur and a failure status in the reply on dbus
RegisterAdvertisement method calls. The fix is to return early from
client_proxy_added if the proxy interface is not
org.bluez.LEAdvertisement1. If this early return is not there, two
different error paths could occur.

1) client_proxy_added is first called with the
org.bluez.LEAdvertisement1 interface and then with another interface.
The second call will fail the parse_advertisement call and possibly
cause a NULL dereference on the dbus_message_unref if
add_client_complete has already occurred.

2) client_proxy_added is first called with an unknown interface and then
org.bluez.LEAdvertisement1. The first call will cause
parse_advertisement to fail and a failure to be replied to the client
calling RegisterAdvertisement. The advertisement may be successfully
registered on the second client_proxy_added call but a NULL dereference
will occur on the call to dbus_message_new_method_return in
add_client_complete.
2018-02-13 14:21:55 +02:00
Steve Brown
0412f3843b mesh: meshctl: Conform command and function names
Also improve readability of commands descriptions
2018-02-13 14:05:50 +02:00
Steve Brown
7f33e5cc09 mesh: meshctl: Cleanup status messaging
Remove redundant status tests
  mesh_status_str() also decodes MESH_STATUS_SUCCESS
Regularize text in status messages
Add helper function to print model id
2018-02-13 14:05:48 +02:00
Steve Brown
3cb9770549 mesh: meshctl: Add heartbeat get subscribe and publish
[config: Target = 0100]# hb-pub-get

Set heartbeat for node 0100 status: Success
Destination:	c000
Count:		00
Period:		00
TTL:		ff
Features:	0000
Net_Idx:	0000

[config: Target = 0100]# hb-sub-get

Heartbeat subscription status for node 0100 status: Success
Source:		0100
Destination:	0100
Period:		00
Count:		00
Min Hops:	7f
Max Hops:	00
2018-02-13 14:05:43 +02:00
Grzegorz Kolodziejczyk
1b5ece8797 shared/btp: Change struct member order for device found as in btp
This patch changes member order in device found struct definition to be
compatible with btp specification.
2018-02-13 09:12:29 +01:00
Grzegorz Kolodziejczyk
30faa9965a tools/btpclient: Fix ad property manufacturer data name
This patch fixes wrong naming of advertising instance data property.
2018-02-13 09:12:29 +01:00
Konstantin Zhukov
d13f579a36 shared/gatt-db: Fix declaration attributes permission
According to Bluetooth Core specification v4.2 (Vol. 3, part G,
section 3.1), service declararion attributes should have only READ
permission. The same obligation has charateristic declaration and
include service declaration attributes.

Without this permission connected clients could corrupt GATT database
by writing to declaration attributes. After thatm service discovery
fails in other clients.
2018-02-12 13:43:34 +02:00
ERAMOTO Masaya
5d2baeb644 tools/obexctl: Fix display of size on completion
Outputs zero as the transferred size on completion of transfer as below:

  [CHG] Transfer /org/bluez/obex/server/session3/transfer2 Transferred: 5339965 (@32KB/s 00:01)
  [CHG] Transfer /org/bluez/obex/server/session3/transfer2 Transferred: 5372726 (@32KB/s 00:00)
  [CHG] Transfer /org/bluez/obex/server/session3/transfer2 Transferred: 0 (@18446744073704178KB/s 00:00)
  [CHG] Transfer /org/bluez/obex/server/session3/transfer2 Status: complete
2018-02-12 13:36:11 +02:00
ERAMOTO Masaya
3c2d4613be tools/obexctl: Fix retrieving non-existent iterator
If transfer is completed with one time file transfer,
transfer_property_changed() is called with the iter argument, which is
NULL, as below:

  #0  transfer_property_changed (proxy=<optimized out>, name=<optimized out>, iter=0x0, user_data=0x5555557b9060) at tools/obexctl.c:1896
  #1  0x000055555556e3cf in properties_changed (conn=<optimized out>, msg=<optimized out>, user_data=0x5555557c8300) at gdbus/client.c:433
  #2  0x000055555556c830 in signal_filter (connection=0x5555557c65a0, message=0x5555557ccea0, user_data=0x5555557cdbf0) at gdbus/watch.c:407
  #3  0x000055555556c291 in message_filter (connection=0x5555557c65a0, message=0x5555557ccea0, user_data=<optimized out>) at gdbus/watch.c:557
  #4  0x00007ffff7888661 in dbus_connection_dispatch () from /lib/x86_64-linux-gnu/libdbus-1.so.3
  #5  0x000055555556b010 in message_dispatch (data=0x5555557c65a0) at gdbus/mainloop.c:72
  #6  0x00007ffff7b0be25 in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  #7  0x00007ffff7b0c1f0 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  #8  0x00007ffff7b0c502 in g_main_loop_run () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
  #9  0x0000555555577594 in bt_shell_run () at src/shared/shell.c:833
  #10 0x000055555556516d in main (argc=<optimized out>, argv=<optimized out>) at tools/obexctl.c:2116
2018-02-12 13:36:10 +02:00
ERAMOTO Masaya
bb16051518 obexd: Emit Size property of transfer after open()
Emits the Size property of transfer after calling ->open() because it
may update the size information.
2018-02-12 13:36:09 +02:00
ERAMOTO Masaya
3e9617fcd8 obexd: Use emitting function wrapped for transfer
Also replaces emit_transfer_progress() with the new wrapper function
because the total/transferred arguments have not been used since commit
a5c2b6e8 ("obexd: Align client and server spec of org.bluez.obex.Transfer1")
and g_dbus_emit_property_changed_full() checks if the path argument is
NULL.
2018-02-12 13:35:33 +02:00
Luiz Augusto von Dentz
6811debb9d unit/test-ecc: Fix uninitialised values
Conditional jump or move depends on uninitialised value(s)
   at 0x40208C: test_sample (test-ecc.c:106)
   by 0x4022AB: test_invalid_pub (test-ecc.c:272)
   by 0x406DA2: run_callback (tester.c:415)
   by 0x4E83576: ??? (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x4E86B76: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x4E86F1F: ??? (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x4E87231: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x408245: tester_run (tester.c:830)
   by 0x401CC3: main (test-ecc.c:291)

Conditional jump or move depends on uninitialised value(s)
   at 0x4020D6: test_sample (test-ecc.c:113)
   by 0x4022AB: test_invalid_pub (test-ecc.c:272)
   by 0x406DA2: run_callback (tester.c:415)
   by 0x4E83576: ??? (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x4E86B76: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x4E86F1F: ??? (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x4E87231: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.5400.3)
   by 0x408245: tester_run (tester.c:830)
   by 0x401CC3: main (test-ecc.c:291)
2018-02-12 13:26:39 +02:00
Luiz Augusto von Dentz
b22a259643 shared/gatt-client: Reset callbacks when unregistering
If user application is unregistering a notification handler its
callbacks shall not be called even CCC write is still holding a
reference to notify_data.
2018-02-12 13:26:39 +02:00
Łukasz Rymanowski
1d4d0d8127 mgmt-tester: Add testcases for advertising while connected
This patch adds testcases which verifies if Linux Kernel properly
enables advertising while is connected (LE) based on supported LE states
in the controller
2018-02-12 10:41:15 +01:00
Łukasz Rymanowski
de9a43dc91 mgmt-tester: Add test_le_full 2018-02-12 10:06:37 +01:00
Łukasz Rymanowski
b54111d2a4 emulator: Add initial LE states to btdev and API to set new one 2018-02-12 10:06:37 +01:00
Szymon Janc
b83b171cad adapter: Remove spurious propery changed signal
There is no "Connectable" property on Adapter1 interface.
2018-02-09 15:37:42 +01:00
Szymon Janc
91d4b17160 advertising: Configure discoverable flag based on adapter settings
Until now advertising as peripheral was always setting General Discoverable
flag set. With this patch this is set based on adapter discoverable setting.
2018-02-09 15:12:30 +01:00
Luiz Augusto von Dentz
1873096352 core: Fixes order InterfaceAdded
Registering on the callback of MGMT_OP_READ_ADV_FEATURES causes
InterfacesAdded to be reschedule after the device objects which causes
tools such as PulseAudio to consider it invalid.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1534857
2018-02-07 15:54:23 +02:00
Tedd Ho Jeong An
243f974115 tester: Enable LE Generate DHKey Complete event
This patch adds LE Generate DHKey Complete event for
LE Event Mask list for 'LE Generate DHKey'.
2018-02-07 09:37:42 +01:00
Tedd Ho Jeong An
6990e417c4 tester: Set event mask for LE Read Local P-256 PK Complete event
LE Read Local P-256 PK command fails because LE Read Local P-256 PK
Complete event and LE Meta event are disabled by default.
This patch sets event masks for LE Read Local P-256 PK Complete and
LE Meta Event to receive the events for 'LE Read Local PK' test and
'LE Generate DHKey' test.
2018-02-07 09:37:42 +01:00
ERAMOTO Masaya
a62f013cd0 shared/shell: Print out help if using invalid command
Because Vincent Petry kindly reported that it is hard to use a command
in a submenu, clients are changed to print out help messages as below
when an invalid command is used.

  [bluetooth]# list-attributes
  Invalid command in menu main: list-attributes

  Use "help" for a list of available commands in a menu.
  Use "menu <submenu>" if you want to enter any submenu.
  Use "back" if you want to return to menu main.
2018-02-06 10:00:05 -02:00
Luiz Augusto von Dentz
17c8980ad3 client: Fix not cleaning up notify pipe
If remote unsubscribe, disconnects or the daemon closes the socket the
io shall be destroyed properly otherwise it will prevent new
subscriptions.
2018-02-06 09:54:13 -02:00
Luiz Augusto von Dentz
0e260e458c gatt: Fix memory leak
If bt_gatt_client_register_notify fails the client shall be freed.
2018-02-06 09:54:13 -02:00
Luiz Augusto von Dentz
dfb579e509 shared/shell: Fix not checking mandatory arguments
Even if mandatory argument takes is of variable size it should still be
checked if at least one argument has been provided.
2018-02-06 09:54:13 -02:00
Luiz Augusto von Dentz
36e0a8f817 client: Don't set generators for modes
Commands that already have all values set on the argument string don't
need to add a generator since bt_shell can now auto complete them.
2018-02-06 09:54:13 -02:00
Luiz Augusto von Dentz
4175508e8b shared/shell: Add tab completion for argument values
In case a command don't have a generator parse its argument string and
generate a list of possible values.
2018-02-06 09:54:13 -02:00
Luiz Augusto von Dentz
8595ae20f2 shared/shell: Make bt_shell_hexdump use util_hexdump 2018-02-06 09:54:13 -02:00
Luiz Augusto von Dentz
90e6b7234d shared/shell: Introduce bt_shell_{get,set}_env
These function can be used to share environment variable accross
different files.
2018-02-06 09:54:13 -02:00
Szymon Janc
6832af9f7c build: Bump ELL dependency to 0.3
This is first version that supports D-Bus proxy API used by btpclient.
2018-02-02 11:29:56 +01:00
Luiz Augusto von Dentz
a7d4f3f8b8 adapter: Use g_dbus_send_reply whenever possible
This convert calls of g_dbus_create_reply + g_dbus_send_message to just
g_dbus_send_reply as that is simpler to maintain and saver as that always
check if the reply could be constructed properly.
2018-01-31 09:07:06 -02:00