summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
...
* advertising: parse_secondary: fix loop conditionChristian Eggers2022-09-231-1/+1
| | | | | "secondary" isn't an array of pointers, so the iterator can never be NULL.
* shared/vcp: Add bt_vcp_set_debugSathish Narasimman2022-09-212-87/+156
| | | | Add support for bt_vcp_set_debug and replace the exisiting DBG.
* shared/gatt-db: Fix scan-build warningsLuiz Augusto von Dentz2022-09-211-5/+9
| | | | | | | | | | | | | | This fixes the following warnings: src/shared/gatt-db.c:1339:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn] return data.num_of_res; ^~~~~~~~~~~~~~~~~~~~~~ src/shared/gatt-db.c:725:5: warning: Access to field 'handle' results in a dereference of a null pointer service->attributes[0]->handle == handle) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* gatt: Fix scan-build warningsLuiz Augusto von Dentz2022-09-211-2/+2
| | | | | | | | | | | | | This fixes the following warnings: src/gatt-database.c:3541:14: warning: Value stored to 'iface' during its initialization is never read [deadcode.DeadStores] const char *iface = g_dbus_proxy_get_interface(proxy); ^~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ src/gatt-database.c:3542:14: warning: Value stored to 'path' during its initialization is never read [deadcode.DeadStores] const char *path = g_dbus_proxy_get_path(proxy); ^~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* gatt-db: Check if permissions are set when adding CCCLuiz Augusto von Dentz2022-09-211-1/+1
| | | | CCC shall always have some permission set.
* gatt: Fix not setting permissions for CCCLuiz Augusto von Dentz2022-09-211-1/+7
| | | | | | | CCC shall always have both Read and Write permissions set in addition to what application set. Fixes: https://github.com/bluez/bluez/issues/399
* shared/vcp: Add initial code for handling VCPSathish Narasimman2022-09-192-0/+1158
| | | | This adds initial code for Volume Control Profile.
* shared/gatt-client: Make use of gatt_db_attribute_get_cccLuiz Augusto von Dentz2022-09-161-31/+10
| | | | | This makes use of gatt_db_attribute_get_ccc to locate a CCC of a given attribute.
* shared/tester: Remove include to io.hLuiz Augusto von Dentz2022-09-152-1/+2
| | | | | Users of tester.h shall also include io.h, including io.h by default may cause errors if has been previously included.
* shared/bap: Remove include to io.hLuiz Augusto von Dentz2022-09-152-2/+1
| | | | | Users of bap.h shall also include io.h, including io.h by default may cause errors if has been previously included.
* shared/bap: Fix attempting to disable stream when it is idleLuiz Augusto von Dentz2022-09-121-5/+8
| | | | | If the stream is already in idle state do not attempt to disable it again.
* shared/bap: Fix not unregistering disconnect callbackLuiz Augusto von Dentz2022-09-061-3/+24
| | | | | bt_bap_detach shall always unregister the disconnect callback otherwise the session pointer may still be accessible.
* adapter: Fix typo in function nameBastien Nocera2022-09-011-2/+2
|
* adapter: Implement PowerState propertyBastien Nocera2022-09-011-11/+128
| | | | | | | | | | | | | | | | | | | | | This property should allow any program to show whether an adapter is in the process of being turned on. As turning on an adapter isn't instantaneous, it's important that the UI reflects the transitional state of the adapter's power, and doesn't assume the device is already turned on but not yet working, or still off despite having requested for it to be turned on, in both cases making the UI feel unresponsive. This can also not be implemented in front-ends directly as, then, the status of an adapter wouldn't be reflected correctly in the Settings window if it's turned on in the system menu. Implementing it in the front-ends would also preclude from having feedback about the state of the adapter when bluetoothd is the one powering up the adapter after the rfkill was unblocked. See https://gitlab.gnome.org/GNOME/gnome-bluetooth/-/issues/121 and the original https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/5773
* adapter: Keep track of whether the adapter is rfkill'edBastien Nocera2022-09-014-25/+91
| | | | | | Instead of only replying to D-Bus requests with an error saying the adapter is blocked, keep track of the rfkill being enabled or disabled so we know the rfkill state of the adapter at all times.
* shared/shell: Fix scan-build errorLuiz Augusto von Dentz2022-08-301-1/+6
| | | | | | | | | This fixes the following error: src/shared/shell.c:1135:19: warning: Null pointer passed to 1st parameter expecting 'nonnull' data.timeout = atoi(optarg); ^~~~~~~~~~~~
* profiles: Fix function definition styleFrédéric Danis2022-08-301-2/+2
| | | | | | | | | This was found by checkpatch in previous commit: WARNING:SPACING: Unnecessary space before function pointer arguments 124: FILE: src/shared/bap.h:123: + int (*select) (struct bt_bap_pac *lpac, struct bt_bap_pac *rpac, Do the same for (*config) and (*clear) for consistence.
* profiles: Add remote endpoint path to SelectPropertiesFrédéric Danis2022-08-302-3/+16
| | | | | | | This adds the remote endpoint path to the dictionary sent in SelectProperties. It allows audio application to know for which remote endpoint the call is done and so for which it should act as an initiator.
* shell: Set empty argument if optarg is NULLLuiz Augusto von Dentz2022-08-291-1/+1
| | | | | This sets enmpty string ("") when argument don't set any optarg so the application can tell when an option was set or not.
* shared: Add definition for LC3 codecLuiz Augusto von Dentz2022-08-291-0/+112
| | | | This adds the definition for LC3 codec capabilities and configuration.
* shared/bap: Add initial code for handling BAPLuiz Augusto von Dentz2022-08-294-3/+5234
| | | | This adds initial code for Basic Audio Profile.
* adapter: Add btd_adapter_find_device_by_fdLuiz Augusto von Dentz2022-08-292-0/+34
| | | | | This adds btd_adapter_find_device_by_fd that lookup a device by a fd socket destination address.
* gatt: Parse error messageLuiz Augusto von Dentz2022-08-251-12/+28
| | | | | | | Application can now encode an error code into the D-Bus reply error message (0x80-0x9f). Fixes: https://github.com/bluez/bluez/issues/380
* adapter: Reset pending settings when receiving MGMT errorArchie Pusaka2022-08-241-8/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We set the pending settings flag when sending MGMT_SETTING_* commands to the MGMT layer and clear them when receiving a successful reply, but we don't clear them when receiving an error reply. This might cause a setting to be stuck in pending state. Therefore, also clear the pending flag when receiving error. Furthermore, this patch also postpones setting the pending flag until we queue the MGMT command in order to avoid setting it too soon but we return early. This was caught during power off test, where MGMT_OP_SET_POWERED returns Authentication Failed because disconnection takes too long. Future attempts to switch power will then be ignored. < HCI Command: Disconnect (0x01|0x0006) plen 3 #17916 [hci0] 12.502908 Handle: 512 Reason: Remote Device Terminated due to Power Off (0x15) > HCI Event: Command Status (0x0f) plen 4 #17917 [hci0] 12.503185 Disconnect (0x01|0x0006) ncmd 1 Status: Success (0x00) @ MGMT Event: Command Status (0x0002) plen 3 {0x0001} [hci0] 14.519491 Set Powered (0x0005) Status: Authentication Failed (0x05) = bluetoothd: Failed to set mode: Authentication Failed (0x05) 14.520042 = bluetoothd: adapter /org/bluez/hci0 set power to 0 14.813533 > HCI Event: Disconnect Complete (0x05) plen 4 #17918 [hci0] 16.509043 Status: Success (0x00) Handle: 512 Reason: Connection Timeout (0x08) Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
* device: Fix not setting initiatorLuiz Augusto von Dentz2022-08-241-1/+4
| | | | | | This fixes not setting initiator flag properly when MGMT connect event has not been processed yet but ATT is already connected or is in progress.
* shared/util: Correct UUID for Microphone Controldarkhz2022-08-221-1/+1
| | | | | According to the Bluetooth product specification list, the allocated UUID for "Microphone Control" is 0x184D, not 0x184C.
* adapter: Check flags are supportedLuiz Augusto von Dentz2022-08-153-1/+9
| | | | This makes sure the flags are supported before attempting to set it.
* shared/tester: Add tester_setup_ioLuiz Augusto von Dentz2022-08-052-4/+163
| | | | | This adds tester_setup_io which can be used to add a PDU list in the form of iovec.
* sixaxis: Fix fliping device.trusted automaticallyLuiz Augusto von Dentz2022-08-022-0/+7
| | | | | | | | device.trusted is a user preference which controls if the devices needs to be authorized or not so the plugin shall not overwrite it and instead just honor what user has set and skip authorizing if already trusted. Fixes: https://github.com/bluez/bluez/issues/372
* device: Add btd_ prefix to device_is_trustedLuiz Augusto von Dentz2022-08-024-8/+8
| | | | | This adds btd_ prefix to device_is_trusted so it can be used by plugins.
* device: Fix not auto-connecting profileLuiz Augusto von Dentz2022-08-011-1/+2
| | | | | | | If the profile is registered and marked to auto-connect it shall automatically be connected whenever a device is already connected. Fixes: https://github.com/bluez/bluez/issues/370
* adapter: Add support for setting ISO Socket experimental featureLuiz Augusto von Dentz2022-07-224-0/+47
| | | | | This adds support for setting ISO Socket experimental UUID which enables the use of BTPROTO_ISO on the system.
* shared/util: Decode BlueZ Experimental ISO Socket UUIDLuiz Augusto von Dentz2022-07-221-0/+2
| | | | | This adds BlueZ experimental ISO Socket UUID to uuid128_table so it is decoded by the likes of btmon.
* main: Default device_privacy to trueLuiz Augusto von Dentz2022-07-131-0/+2
| | | | | | | | | | | | | | | | If privacy mode is not strictly set to network set it to device otherwise network mode would prevent reconnections if the the identity address is used: BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 6, Part B page 2837-2838 'The Host specifies the privacy mode to be used with each peer identity on the resolving list. If it specifies that device privacy mode is to be used, then the Controller shall accept both the peer's device Identity Address and a resolvable private address generated by the peer device using its distributed IRK. Otherwise, network privacy mode is used: the Controller shall only accept resolvable private addresses generated by the peer device using its distributed IRK.'
* adapter: Fix advertising monitor on Linux 5.12-5.17Andrew Drake2022-07-131-1/+3
| | | | | | | | | | | The existing code assumes that, if a device supports advertising monitor offload, DEVICE_FOUND events can be ignored since the kernel will send ADV_MONITOR_DEVICE_FOUND events instead. Unfortunately, these new events were added in 5.18, but offload was added in 5.12. This patch adds a check on the MGMT API version so we can process the older DEVICE_FOUND events when the new events are not supported. Fixes: https://github.com/bluez/bluez/issues/357
* core: Fix signed vs unsigned compareBrian Gix2022-06-301-2/+2
| | | | | | | | | | | | | | | __time_t is not a portable data type, and can cause sign mismatch on some compares. Fixes: CC src/bluetoothd-device.o src/device.c: In function ‘device_is_name_resolve_allowed’: src/device.c:4092:17: error: comparison of integer expressions of different signedness: ‘__time_t’ {aka ‘long int’} and ‘long unsigned int’ [-Werror=sign-compare] if (now.tv_sec >= device->name_resolve_failed_time + ^~ cc1: all warnings being treated as errors
* core: make bt_uuid_hash() portable across archsBrian Gix2022-06-301-5/+3
| | | | | | | | | | | | | | bt_uuid_t is defined as a byte array, so it can cause alignment errors on some architectures, when the two 64 bit halves are treated as u64s. This patch ensures proper alignment across all architectures. Fixes: src/adapter.c: In function ‘bt_uuid_hash’: src/adapter.c:3617:8: error: cast increases required alignment of target type [-Werror=cast-align] val = (uint64_t *)&uuid_128.value.u128; ^ cc1: all warnings being treated as errors
* device: Fix not removing connected deviceYouwan Wang2022-06-233-4/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | [bluetooth]# connect 40:EF:4C:0C:11:F0 Attempting to connect to 40:EF:4C:0C:11:F0 [CHG] Device 40:EF:4C:0C:11:F0 Connected: yes Connection successful [CHG] Device 40:EF:4C:0C:11:F0 ServicesResolved: yes [UFO]# remove 40:EF:4C:0C:11:F0 [CHG] Device 40:EF:4C:0C:11:F0 ServicesResolved: no Device has been removed [CHG] Device 40:EF:4C:0C:11:F0 Connected: no [bluetooth]# info 40:EF:4C:0C:11:F0 Device 40:EF:4C:0C:11:F0 (public) Name: UFO Alias: UFO Class: 0x00240418 Icon: audio-headphones Paired: yes Trusted: no Blocked: no Connected: no LegacyPairing: no UUID: Headset UUID: Audio Sink UUID: A/V Remote Control Target UUID: A/V Remote Control UUID: Handsfree UUID: Phonebook Access Server
* bluetoothd.rst: Document -K/--kernel optionLuiz Augusto von Dentz2022-06-141-0/+4
| | | | This documents -K/--kernel experimental features options.
* main.conf: Split Kernel Experimental UUIDs from ExperimentalLuiz Augusto von Dentz2022-06-144-37/+61
| | | | | This splits kernel experimental UUIDs from D-Bus Experimental interface so they can be controlled indenpendetly.
* advertising: Fix attempting to set scan_rspLuiz Augusto von Dentz2022-06-141-7/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BLUETOOTH CORE SPECIFICATION Version 5.3 | Vol 4, Part E page 2450 • If extended advertising PDU types are being used (bit 4 = 0) then: The advertisement shall not be both connectable and scannable. So instead this attempts to set name as part of Advertising Data rather then setting it as Scan Response: bluetoothctl> advertise.secondary 2M bluetoothctl> advertise.name Intel-3 bluetoothctl> advertise on < HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen 25 Handle: 0x01 Properties: 0x0001 Connectable Min advertising interval: 1280.000 msec (0x0800) Max advertising interval: 1280.000 msec (0x0800) Channel map: 37, 38, 39 (0x07) Own address type: Public (0x00) Peer address type: Public (0x00) Peer address: 00:00:00:00:00:00 (OUI 00-00-00) Filter policy: Allow Scan Request from Any, Allow Connect Request from Any (0x00) TX power: Host has no preference (0x7f) Primary PHY: LE 1M (0x01) Secondary max skip: 0x00 Secondary PHY: LE 2M (0x02) SID: 0x00 Scan request notifications: Disabled (0x00) > HCI Event: Command Complete (0x0e) plen 5 LE Set Extended Advertising Parameters (0x08|0x0036) ncmd 1 Status: Success (0x00) TX power (selected): 7 dbm (0x07) < HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 4 Handle: 0x01 Operation: Complete extended advertising data (0x03) Fragment preference: Minimize fragmentation (0x01) Data length: 0x00 @ MGMT Event: Command Complete (0x0001) plen 7 Add Extended Advertising Parameters (0x0054) plen 4 Status: Success (0x00) Instance: 1 TX power: 7 dbm (0x07) Available adv data len: 31 Available scan rsp data len: 31 > HCI Event: Command Complete (0x0e) plen 4 LE Set Extended Advertising Data (0x08|0x0037) ncmd 1 Status: Success (0x00) @ MGMT Command: Add Extended Advertising Data (0x0055) plen 23 Instance: 1 Advertising data length: 12 Name (complete): Intel-3 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported Scan response length: 0 < HCI Command: LE Set Extended Advertising Data (0x08|0x0037) plen 16 Handle: 0x01 Operation: Complete extended advertising data (0x03) Fragment preference: Minimize fragmentation (0x01) Data length: 0x0c Name (complete): Intel-3 Flags: 0x06 LE General Discoverable Mode BR/EDR Not Supported > HCI Event: Command Complete (0x0e) plen 4 LE Set Extended Advertising Data (0x08|0x0037) ncmd 1 Status: Success (0x00) < HCI Command: LE Set Extended Scan Response Data (0x08|0x0038) plen 4 Handle: 0x01 Operation: Complete scan response data (0x03) Fragment preference: Minimize fragmentation (0x01) Data length: 0x00 > HCI Event: Command Complete (0x0e) plen 4 LE Set Extended Scan Response Data (0x08|0x0038) ncmd 1 Status: Success (0x00) < HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 6 Extended advertising: Enabled (0x01) Number of sets: 1 (0x01) Entry 0 Handle: 0x01 Duration: 0 ms (0x00) Max ext adv events: 0 > HCI Event: Command Complete (0x0e) plen 4 LE Set Extended Advertising Enable (0x08|0x0039) ncmd 2 Status: Success (0x00) @ MGMT Event: Command Complete (0x0001) plen 4 Add Extended Advertising Data (0x0055) plen 1 Status: Success (0x00) Instance: 1
* device: Add connectable flag to bearer stateLuiz Augusto von Dentz2022-06-133-22/+28
| | | | | This adds connectable flag to state so it can be used to detect which is the last seen connectable bearer.
* device: Fix not deleting the folder after removing the deviceTedd Ho-Jeong An2022-06-091-1/+1
| | | | | This patch fixes the issue not deleting the device folder when the device is removed.
* gatt-server: Fix crash while disconnectingLuiz Augusto von Dentz2022-05-201-5/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If there is a pending notify multiple the code was not removing before freeing the object causing the following crash: Invalid read of size 8 at 0x4A3D10: notify_multiple (gatt-server.c:1703) by 0x4D05F0: timeout_callback (timeout-glib.c:25) by 0x4956900: ??? (in /usr/lib64/libglib-2.0.so.0.7000.5) by 0x49560AE: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.7000.5) by 0x49AB307: ??? (in /usr/lib64/libglib-2.0.so.0.7000.5) by 0x49557C2: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.7000.5) by 0x4D0A34: mainloop_run (mainloop-glib.c:66) by 0x4D0F2B: mainloop_run_with_signal (mainloop-notify.c:188) by 0x2B0CD1: main (main.c:1276) Address 0x6ca35c8 is 136 bytes inside a block of size 144 free'd at 0x48470E4: free (vg_replace_malloc.c:872) by 0x415E73: gatt_server_cleanup (device.c:698) by 0x415E73: attio_cleanup (device.c:715) by 0x47745B: queue_foreach (queue.c:207) by 0x490C54: disconnect_cb (att.c:701) by 0x4CF4AF: watch_callback (io-glib.c:157) by 0x49560AE: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.7000.5) by 0x49AB307: ??? (in /usr/lib64/libglib-2.0.so.0.7000.5) by 0x49557C2: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.7000.5) by 0x4D0A34: mainloop_run (mainloop-glib.c:66) by 0x4D0F2B: mainloop_run_with_signal (mainloop-notify.c:188) by 0x2B0CD1: main (main.c:1276)
* gatt: Store local GATT databaseLuiz Augusto von Dentz2022-05-181-0/+15
| | | | | This enables storing the local (adapter) GATT database which later will be used by btmon to decode GATT handles.
* settings: Add btd_settings_gatt_db_{store,load}Luiz Augusto von Dentz2022-05-183-487/+531
| | | | | This adds helper functions to store and load from/to file so they can get reused by the likes of gatt-database.c and btmon.
* device: Fix enabling wake support without RPA ResolutionLuiz Augusto von Dentz2022-05-124-6/+53
| | | | | | | | If device uses RPA it shall only enable wakeup if RPA Resolution has been enabled otherwise it cannot be programmed in the acceptlist which can cause suspend to fail. Link: https://bugzilla.kernel.org/show_bug.cgi?id=215768
* gatt-db: Allow passing Characteristic Value to gatt_db_attribute_get_char_dataLuiz Augusto von Dentz2022-05-121-3/+13
| | | | | This makes gatt_db_attribute_get_char_data work with Characteristic Value rather than only with Characteristic Declaration.
* service: Add initiator argument to service_acceptLuiz Augusto von Dentz2022-05-123-4/+20
| | | | | | This adds initiator argument to service_accept so profiles accepting the connection can use btd_service_is_initiator to determine if the connection was initiated locally (central) or remotely (peripheral).
* device: Fix pairing has failed due to the error of Already Paired (0x13)wangyouwan2022-05-111-1/+4
| | | | | | | | | | | | After connect the Bluetooth mouse, open two Bluetoothctl at the same time, when remove the mouse, quickly go to power off, try to paired the mouse again when I was power on, found that the error 0x13 was always reported. try to connect directly,can connect successfully. but use the info command to query the information of the mouse and find that the pairing status of the mouse is No. so I try to delete the paired information in the kernel through the "* cancel_pairing()" interface.