Commit Graph

24096 Commits

Author SHA1 Message Date
ERAMOTO Masaya
4740e022ec toosl/bluetooth-player: Remove extra commands
Removes the output of redundant commands in bluetooth-player since the
previous patch ("shared/shell: Fix hidden default menu if no submenu")
made bluetooth-player output the default menu.
2017-12-11 10:16:04 -02:00
ERAMOTO Masaya
5b3a4b9f56 shared/shell: Fix hidden default menu if no submenu
Also fixes the output of the default menu in the help command of obexctl.
2017-12-11 10:16:04 -02:00
Luiz Augusto von Dentz
e199cd9bca mesh: Fix crash while reading input parameters
read_input_parameters skips the command argument thus arg[0] shall be
considerer the fist argument.
2017-12-11 11:19:16 +02:00
Luiz Augusto von Dentz
d1f9544681 mesh: Remove cmd_scan
cmd_scan is only used internally by discover-unprovisioned.
2017-12-08 13:06:21 +02:00
Luiz Augusto von Dentz
f11a25d42d mesh: Rework set_scan_filter_uuids parameters
set_scan_filter_uuids is not a command handler which means it doesn't
need to take argc and argv instead just pass the filter array.
2017-12-08 13:06:20 +02:00
Luiz Augusto von Dentz
7c16c4044d shell: Add bt_shell_opt
Make use of struct option and getopt_long to parse the options given.
2017-12-08 13:06:19 +02:00
Luiz Augusto von Dentz
ab41d6df80 client: Fix arguments of set-filter-clear
Commands with no arguments shall use NULL not empty string.
2017-12-08 13:06:17 +02:00
Luiz Augusto von Dentz
5f06ec4982 tools/bluetooth-player: Fix arg format for search command
Mandatory command should always be quoted with <>.
2017-12-08 13:06:16 +02:00
Luiz Augusto von Dentz
a469cdb8be tools/bluetooth-player: Use bt_shell helpers
This makes bluetooth-player use bt_shell to manage the menus and
command handling.
2017-12-08 13:06:14 +02:00
Luiz Augusto von Dentz
c235db8066 tools/obexctl: Use bt_shell helpers
This makes obexctl use bt_shell to manage the menus and command
handling.
2017-12-08 13:06:13 +02:00
Luiz Augusto von Dentz
fc53175b8a mesh: Make meshctl use bt_shell helpers
This makes meshctl use bt_shell to manage the menus and command
handling.
2017-12-08 13:06:12 +02:00
Luiz Augusto von Dentz
8edcc31fa2 shared/shell: Don't remove command from arguments
Maintain the original argc and argv so the callback has a chance to
parse the command if it has to.
2017-12-08 13:06:11 +02:00
Luiz Augusto von Dentz
a6ef232a35 shared/shell: Omit menu command if there are no submenus
There is no need to show menu as a command if there are no submenus
to select.
2017-12-08 13:06:09 +02:00
ERAMOTO Masaya
5e7ad41d08 shared/shell: Fix no version output with option
bluetoothctl does output the following error message with the option
-v/--version.

  $ bluetoothctl --version
  Unknown option --version
2017-12-05 16:18:57 -02:00
Steve Brown
cb1c2622fa mesh: meshctl add Node Identity option to connect command
This adds the option to connect via either Node Identity or Network ID
advertisements. Adding the node unicast address selects Node Identity.

See Mesh Profile Specification 7.2.2.2 for further details.
2017-12-04 19:51:26 +02:00
Luiz Augusto von Dentz
109b9fa51b gatt: Add all services as records
This uses services changes to trigger the addition/removal of the SDP
records.
2017-12-04 10:27:50 -02:00
Luiz Augusto von Dentz
c3a336d898 gatt: Use monitor code to decode service name
This makes the daemon reuse the code for decoding service names that
the monitor uses.
2017-12-04 10:27:50 -02:00
Luiz Augusto von Dentz
eb469ed2c8 gatt: Make database_add_record detect the UUID
gatt_db_attribute does carry the UUID so this make database_add_record
add it directly instead of taking as parameter.
2017-12-04 10:27:50 -02:00
ERAMOTO Masaya
c5da066676 tools/obexctl: Fix display of size/time during transfer
When obexctl is run after starting to transfer a file, the transferred
size and the remaining time will be extreme values first as below:

  [NEW] Transfer /org/bluez/obex/server/session8/transfer6
  [CHG] Transfer /org/bluez/obex/server/session8/transfer6 Transferred: 1670741 (@1670KB/s 03:52)
  [CHG] Transfer /org/bluez/obex/server/session8/transfer6 Transferred: 1703502 (@32KB/s 197:14)
  [CHG] Transfer /org/bluez/obex/server/session8/transfer6 Transferred: 1736263 (@32KB/s 197:13)
2017-12-04 10:20:34 -02:00
Michal Hobot
5b4be5a091 mesh: Fix parsing composition data for custom models
Custom model ids consist of model id and vendor id. Instead, vendor id
was used twice to build model id.
2017-11-30 23:18:29 +02:00
Bastien Nocera
7bb73f092a plugins/sixaxis: Don't ignore previously setup devices
1. Setup PS3 controller through cable pairing
2. Remove device from BlueZ's database
3. Plug original PS3 controller back

As we don't change the master bdaddr on the device itself, the joypad
will likely be trying to connect to BlueZ, and fail to connect after a
small period of time. But the device will appear connected just long
enough for the cable pairing to say "hey, I already have this setup".

Ideally, we would test for whether the device is temporary, or already
trusted, but testing for whether we've setup its internal services *and*
it's connected, rather than *or*, is sufficient.
2017-11-30 09:53:45 +01:00
Steve Brown
1f17efbac0 mesh: Correct typo in config op defines 2017-11-29 09:34:21 +02:00
ERAMOTO Masaya
d84bd7754b obexd: Fix crash when canceling without agent
When obexd is started with the option auto-accept or the agent is killed
after starting to transfer a file, obexd crashes due to cancellation of
the transfer from a client as below:

  Process terminating with default action of signal 11 (SIGSEGV)
   Access not within mapped region at address 0x0
     at 0x158A40: transfer_cancel (manager.c:272)
     by 0x18A5D2: process_message.isra.4 (object.c:259)
     by 0x18AE44: generic_message (object.c:1079)
     by 0x5290FD2: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.13)
     by 0x5282623: dbus_connection_dispatch (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.13)
     by 0x184DBF: message_dispatch (mainloop.c:72)
     by 0x5505E24: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1)
     by 0x55061EF: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1)
     by 0x5506501: g_main_loop_run (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1)
     by 0x137902: main (main.c:322)
2017-11-28 16:25:18 +02:00
Luiz Augusto von Dentz
5d71be8de9 gdbus: Force service to start if proxy is created while not connected
Because GetAll is no longer send right away the service may never be
started.
2017-11-28 16:22:13 +02:00
Luiz Augusto von Dentz
847337155e shared/shell: Print usage when no argument generator is set
This prints the command and arguments if the command don't provide
a generator so one don't have to always resort to help for checking it.
2017-11-28 13:09:30 +02:00
Luiz Augusto von Dentz
7cf75e0ca6 client: Fix format of arguments of set-service and set-manufacturer
Optional arguments should contain only one set of '[' ']' otherwise
wordexp won't be able to parse it.
2017-11-28 11:02:32 +02:00
Luiz Augusto von Dentz
6962f889bc client: Remove argument checks
This is now done automatically by bt_shell with the use of the
arguments entered in the command table.
2017-11-28 11:02:32 +02:00
Luiz Augusto von Dentz
72a69a0860 shared/shell: Detect if the arguments are properly set
Parse arguments to detect if user has passed a valid number of
arguments.
2017-11-28 11:02:32 +02:00
Michal Hobot
7be84fe316 mesh: onoff-model: Fix msec to sec conversion
There is an error in meshctl while displaying transition time. 1000 ms
is being presented as 16 sec, 40 ms. The reason is incorrect
conversion of milliseconds to seconds.  The fix is pretty trivial.
2017-11-27 10:50:40 +02:00
Luiz Augusto von Dentz
42ffa662d6 avrcp: Fix change-path
AVRCP spec does allow duplicates folder names which would be exposed as
different D-Bus path as their UID is different, the code however would
attempt to set the folder by its name alone which resolve to the first
item on the list rather then the exact UID.
2017-11-26 20:48:43 +02:00
Luiz Augusto von Dentz
fbd0aa83de service: Remove unnecessary btd_assert
btd_service_set_user_data shall be allowed to be called when the state is
unavailable since device_probe is called with that state the callback
attempt to set its user_data.
2017-11-24 17:39:27 +02:00
Luiz Augusto von Dentz
0f6a603184 avrcp: Fix not parsing all items
When using GetFolderItems to list media items it is valid to send
duplicated as they can be repeated in the list.
2017-11-23 23:33:31 +02:00
Luiz Augusto von Dentz
713518331d control: Fix invalid access
When both controller and target roles are supported by a device they
would share the same btd_service user_data pointer which would lead to
use after free once either service is removed.
2017-11-23 15:20:21 +02:00
Luiz Augusto von Dentz
c4f77eb5ac adapter: Cleanup non-connectable temporary devices
These devices cannot be used after the discovery has been terminated so
there is no point in keep them on cache like other temporary devices.
2017-11-23 15:20:20 +02:00
Bastien Nocera
11a57b5c26 audio/control: Fix invalid read on exit
Make control_disconnect() a no-op if control was already
disconnected and freed.

bluetoothd[8436]: profiles/audio/avrcp.c:avrcp_disconnect() path /org/bluez/hci0/dev_38_71_DE_C0_FC_26
==8436== Invalid read of size 8
==8436==    at 0x41FFB9: control_disconnect (control.c:130)
==8436==    by 0x469E0A: service_remove (service.c:177)
==8436==    by 0x475869: device_remove (device.c:4071)
==8436==    by 0x45DEF9: adapter_remove (adapter.c:5485)
==8436==    by 0x466B2A: adapter_cleanup (adapter.c:8679)
==8436==    by 0x40BE16: main (main.c:782)
==8436==  Address 0x84b8ac8 is 8 bytes inside a block of size 48 free'd
==8436==    at 0x4C30D18: free (vg_replace_malloc.c:530)
==8436==    by 0x50D44AD: g_free (in /usr/lib64/libglib-2.0.so.0.5400.2)
==8436==    by 0x488AED: remove_interface (object.c:667)
==8436==    by 0x488FE9: g_dbus_unregister_interface (object.c:1391)
==8436==    by 0x469E20: service_remove (service.c:179)
==8436==    by 0x475869: device_remove (device.c:4071)
==8436==    by 0x45DEF9: adapter_remove (adapter.c:5485)
==8436==    by 0x466B2A: adapter_cleanup (adapter.c:8679)
==8436==    by 0x40BE16: main (main.c:782)
==8436==  Block was alloc'd at
==8436==    at 0x4C31A1E: calloc (vg_replace_malloc.c:711)
==8436==    by 0x50D43F0: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.5400.2)
==8436==    by 0x41FC09: control_init (control.c:320)
==8436==    by 0x42006D: control_init_remote (control.c:361)
==8436==    by 0x469D59: service_probe (service.c:160)
==8436==    by 0x46E464: probe_service (device.c:4207)
==8436==    by 0x46E4C2: dev_probe (device.c:4226)
==8436==    by 0x46989B: btd_profile_foreach (profile.c:708)
==8436==    by 0x47239D: device_probe_profiles (device.c:4285)
==8436==    by 0x50ED51C: g_slist_foreach (in /usr/lib64/libglib-2.0.so.0.5400.2)
==8436==    by 0x50ED54A: g_slist_free_full (in /usr/lib64/libglib-2.0.so.0.5400.2)
==8436==    by 0x45F1EE: load_devices (adapter.c:3864)
==8436==    by 0x465E59: adapter_register (adapter.c:7741)
==8436==    by 0x465E59: read_info_complete (adapter.c:8284)
==8436==    by 0x48D277: request_complete (mgmt.c:261)
==8436==    by 0x48DD44: can_read_data (mgmt.c:353)
==8436==    by 0x4999A2: watch_callback (io-glib.c:170)
==8436==    by 0x50CEBB6: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.5400.2)
==8436==    by 0x50CEF5F: ??? (in /usr/lib64/libglib-2.0.so.0.5400.2)
==8436==    by 0x50CF271: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.5400.2)
==8436==    by 0x40BDE8: main (main.c:770)
2017-11-23 12:20:58 +02:00
Inga Stotland
4d58eb52bc mesh: validate configuration target
Require obtaining node composition prior to sending configuration
commands that assume knowledge about the node's element/model layout.
2017-11-23 12:16:13 +02:00
Luiz Augusto von Dentz
7a177a8f9e adapter: Fix not replying to StopDiscovery
This fixes missing reply to StopDiscovery when a MGMT command needs to
be sent.
2017-11-21 17:23:27 +02:00
Luiz Augusto von Dentz
c70ebf7cb4 avctp: Use different queues for passthrough and vendor PDUs
passthrough commands comes from a different specification which can
have more specific rules regarding timeout, etc, so this moves button
presses to their own queue which should enable them to be send in
parallel to other command on the control channel.
2017-11-21 17:23:26 +02:00
Luiz Augusto von Dentz
60e7ff608c gdbus: Fix not emiting PropertiesChanged
If and interface is removed while properties are pending it would cause
process_properties_from_interface to clear data->pending_prop when it
should only clear the iface->pending_prop.
2017-11-21 17:23:24 +02:00
Luiz Augusto von Dentz
5c1660358f shared/gatt-client: Check if ATT is connected before creating requests
If ATT is not connected there is no point in creating a request since
that will likely fail at bt_att_send.
2017-11-21 17:23:18 +02:00
Luiz Augusto von Dentz
a554a39dda client: Move set-alias back to main menu
set-alias is not GATT related command.
2017-11-21 17:23:12 +02:00
ERAMOTO Masaya
fa6db23fd1 shared/shell: Fix command completion without character
If the command completion without any character is run, then only returns
the commands of default menu since readline increases the variable state
during each matching and tools specific menu is not compared.
2017-11-21 17:15:24 +02:00
ERAMOTO Masaya
251a2b3ca4 obexd: Fix fd which is left even after closing session
A fd is duplicated if dbus type is unix fd, and then it is not closed
even after the file is finished transporting. In the end obexd can not
transport due to the limitation of open-able fd as below.

  Warning: invalid file descriptor 1031 in syscall fcntl(DUPFD_CLOEXEC)()

  FILE DESCRIPTORS: 1021 open at exit.
  Open pf-31 socket 1023:
     at 0x5061F1F: fcntl_common (fcntl.c:46)
     by 0x5061F1F: fcntl (fcntl.c:79)
     by 0x52A1C3D: _dbus_dup (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.13)
     by 0x528C7B8: dbus_message_iter_get_basic (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.13)
     by 0x149E04: profile_new_connection (bluetooth.c:136)
     by 0x18AAF2: process_message.isra.3 (object.c:259)
     by 0x18B364: generic_message (object.c:1079)
     by 0x5290FD2: ??? (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.13)
     by 0x5282623: dbus_connection_dispatch (in /lib/x86_64-linux-gnu/libdbus-1.so.3.14.13)
     by 0x1852FF: message_dispatch (mainloop.c:72)
     by 0x5505E24: g_main_context_dispatch (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1)
     by 0x55061EF: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1)
     by 0x5506501: g_main_loop_run (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.5400.1)
2017-11-21 17:15:24 +02:00
Luiz Augusto von Dentz
b04bec273e device: Fix typo 2017-11-20 17:11:51 +02:00
Luiz Augusto von Dentz
83e34edae3 client: Fix crashing on disconnect command
disconnect callback was writing on the argv pointer causing word
wordfree to access invalid memory:

Invalid free() / delete / delete[] / realloc()
  at 0x4C2FD18: free (vg_replace_malloc.c:530)
  by 0x56E8588: wordfree (in /usr/lib64/libc-2.25.so)
  by 0x41D0EB: rl_handler (shell.c:388)
  by 0x53CDB6D: rl_callback_read_char (in /usr/lib64/libreadline.so.7.0)
  by 0x41CA20: input_read (shell.c:661)
  by 0x41D88A: watch_callback (io-glib.c:170)
  by 0x4E85246: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.5200.3)
  by 0x4E855E7: ??? (in /usr/lib64/libglib-2.0.so.0.5200.3)
  by 0x4E85901: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.5200.3)
  by 0x41D77D: bt_shell_run (shell.c:609)
  by 0x4055E4: main (main.c:2502)
Address 0x76afcb4 is 4 bytes inside a block of size 30 alloc'd
  at 0x4C2EB6B: malloc (vg_replace_malloc.c:299)
  by 0x517F803: ??? (in /usr/lib64/libdbus-1.so.3.19.0)
  by 0x516D32A: dbus_message_copy (in /usr/lib64/libdbus-1.so.3.19.0)
  by 0x4195F4: prop_entry_update.isra.1 (client.c:186)
  by 0x4197C4: prop_entry_new (client.c:202)
  by 0x4197C4: add_property (client.c:237)
  by 0x4199A5: update_properties (client.c:277)
  by 0x419E74: parse_properties (client.c:974)
  by 0x419E74: parse_interfaces (client.c:1001)
  by 0x41B412: parse_managed_objects (client.c:1093)
  by 0x41B412: get_managed_objects_reply (client.c:1114)
  by 0x51607A1: ??? (in /usr/lib64/libdbus-1.so.3.19.0)
  by 0x516411E: dbus_connection_dispatch (in /usr/lib64/libdbus-1.so.3.19.0)
  by 0x41261F: message_dispatch (mainloop.c:72)
  by 0x4E81C26: ??? (in /usr/lib64/libglib-2.0.so.0.5200.3)
2017-11-20 17:11:50 +02:00
Luiz Augusto von Dentz
728d50c204 device: Don't disable auto-connect for trusted devices
Trusted shall indicate if the device is allowed connect in any
circumstance, even if the user has called device.Disconnect.
2017-11-20 17:11:49 +02:00
Luiz Augusto von Dentz
f2ec4f54bf doc/device-api: Document behavior of Disconnect method with LE
If and LE device is disconnected using device.Device method it won't
be able to reconnect by itself.
2017-11-20 17:11:44 +02:00
Luiz Augusto von Dentz
bee3796113 build: Move shell.{c,h} to libshared
bt_shell instance should be available to any code linked with
libshared.
2017-11-20 11:34:15 +02:00
Steve Brown
65aaf36f2a mesh: Correct length test in agent.c:request_ascii 2017-11-19 10:16:33 +02:00
Bastien Nocera
ce57fdeb2f device: Fix possible runtime warning
This g_source_remove() doesn't have its argument check for validity
which can lead to a runtime warning.

bluetoothd[14785]: GLib: g_source_remove: assertion 'tag > 0' failed
bluetoothd[14785]: ++++++++ backtrace ++++++++
bluetoothd[14785]: #1  g_logv+0x25d (/usr/lib64/libglib-2.0.so.0.5400.1) [0x50d5a7d]
bluetoothd[14785]: #2  g_log+0x8f (/usr/lib64/libglib-2.0.so.0.5400.1) [0x50d5bef]
bluetoothd[14785]: #3  g_source_remove+0x24 (/usr/lib64/libglib-2.0.so.0.5400.1) [0x50cd884]
bluetoothd[14785]: #4  device_remove+0xfb (src/device.c:4054) [0x4756cb]
bluetoothd[14785]: #5  adapter_remove+0x4a (src/adapter.c:5485) [0x45e0ea]
bluetoothd[14785]: #6  adapter_cleanup+0x2b (src/adapter.c:8681) [0x466abb]
bluetoothd[14785]: #7  main+0x867 (src/main.c:784) [0x40bdc7]
bluetoothd[14785]: #8  __libc_start_main+0xe7 (../csu/libc-start.c:340) [0x5d12187]
bluetoothd[14785]: #9  _start+0x2a (/home/hadess/Projects/jhbuild/bluez/src/bluetoothd) [0x40c5ca]
bluetoothd[14785]: +++++++++++++++++++++++++++
2017-11-17 16:08:35 +02:00