Commit Graph

680 Commits

Author SHA1 Message Date
Luiz Augusto von Dentz
16d6fe36f6 policy: Fix removing reconnect flag while still connecting
If a service connects it should stop new attempts but the current ones
should continue so reconnection should not be reset.
2017-03-07 13:06:43 +02:00
Luiz Augusto von Dentz
249d5d4c44 policy: Fix not reseting sink source
policy_connect_sink shall reset the sink_timer not source_timer.
2017-01-24 15:13:23 +02:00
Luiz Augusto von Dentz
cc80afff47 build: Remove gatt-example plugin
This examples can be done over D-Bus already so it makes no sense to have
it as a plugin and in fact it currently it doesn't even work since it was
never ported to the new code under src/shared.
2016-11-08 17:09:49 +02:00
Luiz Augusto von Dentz
0ee2d331d9 policy: Fix not reseting attempts when disconnected
If the link is disconnected before any profile connects it shall still
reset the attempts as the device actually has been connected, otherwise
the number of attempts may not be respected.
2016-10-25 12:43:33 +03:00
Luiz Augusto von Dentz
4ea44dc5cc plugins/policy: Disable other connect policies while reconnect is active
Other policies shall not interfere while reconnect is active.
2016-07-29 14:12:49 +03:00
Luiz Augusto von Dentz
14b6511b35 plugins/policy: Set list separator
Set list separator to ',' as it is used in main.conf.
2016-07-29 14:12:49 +03:00
Luiz Augusto von Dentz
12bd0ffd48 plugins/policy: Revert patch 96db786042
Patch 96db786042 actually breaks
iterating to each attempt since the attempt++ is already done in
reconnect_timeout callback.
2016-07-29 14:12:49 +03:00
Szymon Janc
40bb318d73 policy: Add AutoEnable config option
This option is used to configure policy for auto enabling adapters when
found. This includes adapters found on start as well as adapters that
are plugged in later on.

Some distributions use legacy "hciconfig hci0 up" in boot-scripts to
automatically enable controllers on start. But that is causing SMP
kernel code to not being properly initialized.

This patch allows distributions to automatically enable adapters in
race free manner even if no agent is provided eg. in login screen.
2015-09-28 13:27:43 +02:00
Luiz Augusto von Dentz
96db786042 policy: Fix not incrementing attempts
The number of attempts and intervals maybe different causing the attempts
to not be incremented properly.
2015-05-07 10:43:34 +03:00
Arman Uguray
b57f335c50 plugins/policy: Fix clang compile error
This patch fixes the following error when bluez is compiled with clang:

plugins/policy.c:780:6: error: cast from 'int *' to 'size_t *' (aka 'unsigned long *') increases required alignment from 4 to 8 [-Werror,-Wcast-align]
(size_t *) &reconnect_intervals_len,
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2015-05-05 14:48:04 +03:00
Luiz Augusto von Dentz
3b7ad511ea policy: Add parameters to control reconnection
This adds ReconnectAttempts and ReconnectIntervals so platforms can fine
tune the reconnection strategy.
2015-04-08 10:23:14 +03:00
Luiz Augusto von Dentz
36468cc558 core/device: Convert temporary flag to bool 2015-03-17 17:45:09 +02:00
Marcin Kraglak
d782a659cf plugins/policy: Try reconnect Control/Target services
If state of Control/Remote services changed from CONNECTING to
DISCONNECTED, and error is set to -EAGAIN, set random timer and try
reconnect. This approach is described in AVRCP Spec 1.5 4.1.1:
"If both devices open an AVCTP channel at the same time both channels
shall be closed and each device shall wait a random time
(not more than 1 s and not less than 100ms) and then try to open
the AVCTP channel again."
2015-03-13 13:28:23 +02:00
Marcel Holtmann
3af96d5b0a plugins: Fix local libbluetooth includes order 2015-02-28 23:34:11 -08:00
Marcel Holtmann
91de2012ac plugins: Use local libbluetooth includes 2015-02-28 22:46:52 -08:00
Marcel Holtmann
01b4984652 plugins: Add explicit include for lib/bluetooth.h 2015-02-18 06:23:45 +01:00
Luiz Augusto von Dentz
24c79fd933 policy: Fix not removing timers
If service becomes unavailable, due to e.g. the device being removed,
all the related timers should be removed as well otherwise it may cause
crashes such as the following:

Invalid read of size 8
   at 0x4A6597: btd_device_get_service (device.c:5335)
   by 0x40F49F: policy_connect_ct (policy.c:112)
   by 0x4E7F552: ??? (in /usr/lib64/libglib-2.0.so.0.4200.1)
   by 0x4E7EAEA: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.4200.1)
   by 0x4E7EE87: ??? (in /usr/lib64/libglib-2.0.so.0.4200.1)
   by 0x4E7F1B1: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.4200.1)
   by 0x40BACF: main (main.c:631)
 Address 0x73b9ba8 is 360 bytes inside a block of size 592 free'd
   at 0x4C2ACE9: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0x4E847FE: g_free (in /usr/lib64/libglib-2.0.so.0.4200.1)
   by 0x49C83F: device_free (device.c:624)
   by 0x4BDB29: remove_interface (object.c:658)
   by 0x4BE701: g_dbus_unregister_interface (object.c:1382)
   by 0x4A49DC: btd_device_unref (device.c:5173)
   by 0x41DC46: avdtp_free (avdtp.c:1138)
   by 0x41EE09: connection_lost (avdtp.c:1164)
   by 0x422EA5: session_cb (avdtp.c:2263)
   by 0x4E7EAEA: g_main_context_dispatch (in /usr/lib64/libglib-2.0.so.0.4200.1)
   by 0x4E7EE87: ??? (in /usr/lib64/libglib-2.0.so.0.4200.1)
   by 0x4E7F1B1: g_main_loop_run (in /usr/lib64/libglib-2.0.so.0.4200.1)
2015-02-02 08:44:15 +02:00
Gowtham Anandha Babu
037ea88d5e plugins/autopair: Provide descriptive error log
Add more description in error logging.
2014-11-25 23:50:08 +02:00
Alex Gal
716edaa412 plugins/sixaxis: Add Sony Navigation Controller 2014-11-07 21:51:00 +01:00
Antonio Ospite
fbe7d5226f plugins/sixaxis: Add a set_leds_sysfs() function
On recent kernels the hid-sony driver exposes leds class entries in
sysfs for setting the Sixaxis LEDs, use this interface and fall back to
hidraw in case using sysfs fails (e.g. on older hid-sony versions).

Setting the LEDs via sysfs is the preferred way on newer kernels, the
rationale behind that is:

  1. the Sixaxis uses the same HID output report for setting both LEDs
     and rumble effects;
  2. hid-sony remembers the state of LEDs in order to preserve them when
     setting rumble effects;
  3. when the LEDs are set via hidraw hid-sony has no way to know the
     new LEDs state and thus can change the LEDs in an inconsistent way
     when setting rumble effects later.

Also require libudev >= 172, this is where
udev_enumerate_add_match_parent() has been first introduced.

NOTE: using udev_enumerate_add_match_parent() results in a memory leak
when enumerating child devices, this has been fixed in udev 207; the
commit which fixes the issue is this one:
http://cgit.freedesktop.org/systemd/systemd/commit/?id=51cc07576e119dea6e65478eeba9472979fd0936
2014-06-08 14:54:41 +02:00
Antonio Ospite
1a124e4acc plugins/sixaxis: Add a get_leds_data() function
Get all the data necessary to set the LEDs in a single function,
returning a leds_data structure to be passed as argument to the
setup_leds() callback.

For now only a 'bitmap' field is used, which is the only thing that
set_leds_hidraw() needs.
2014-06-08 14:54:41 +02:00
Antonio Ospite
fdbe933252 plugins/sixaxis: Fix get_js_number() for devices connected via BT
Match hid devices and input devices using HID_UNIQ and UNIQ when these
are available, this is the correct way to get matching devices when the
controllers are connected via BT (UNIQ refers to the device bdaddr, PHYS
is the adapter bdaddr, so matching against PHYS will result in all
devices with the same LED number).

Fall back to HID_PHYS and PHYS when needed, hid devices do not define
HID_UNIQ when connected via USB.
2014-06-08 14:54:41 +02:00
Antonio Ospite
1783548cf7 plugins/sixaxis: Factor out a calc_leds_bitmap() function
This is also in preparation of set_leds_sysfs().
2014-05-16 14:34:47 +02:00
Antonio Ospite
f6e6850c1e plugins/sixaxis: Factor out a set_leds_hidraw() function
This is in preparation for a set_leds_sysfs() function.

Make set_leds_hidraw() return void, as its return value is never used
by the caller: the setup_leds() callback has to always return FALSE.
2014-05-16 14:34:47 +02:00
Johan Hedberg
986c3d2b1a plugins/policy: Both !uuids and !uuids[0] mean an empty list 2014-05-15 11:46:00 +03:00
Johan Hedberg
de663bfc39 plugins/policy: Remove reconnect timer in reconnect_reset()
In the case that the remote starts connecting to us while we're waiting
for the timeout to discover we shouldn't just reset the basic time
keeping variables but also remove the timer.
2014-05-15 11:46:00 +03:00
Johan Hedberg
f8a0c50bc6 plugins/policy: Add support to retreive ReconnectUUIDs from main.conf 2014-05-15 11:19:32 +03:00
Johan Hedberg
40e77e7b71 plugins/policy: Rename UUIDs list variable to avoid name collisions 2014-05-15 11:16:34 +03:00
Johan Hedberg
42fd4ce72c plugins/policy: Add exponential backoff for reconnection attempts 2014-05-15 11:16:34 +03:00
Johan Hedberg
c3a21d3393 plugins/policy: Continue reconnections after connect attempt failure
This patch adds support for continuing reconnecting for several more
times (up to 3 minutes) even when a connection attempt fails.
2014-05-15 11:16:34 +03:00
Johan Hedberg
e0929a6e88 plugins/policy: Add basic reconnection handling 2014-05-15 11:16:33 +03:00
Claudio Takahasi
6b09f55b09 Remove unneeded headers include 2014-04-04 21:21:42 +03:00
Claudio Takahasi
f1956438cc gatt: Move Characteristic properties to attrib/gatt.h
Properties are defined by GATT specification. This patch moves and
renames the defines related to Characteristic properties bits from
attrib/att.h to attrib/gatt.h
2014-03-25 17:24:01 +02:00
Claudio Takahasi
454a30731b Replace att_put_u16() by put_le16() 2014-03-24 22:11:28 +02:00
Johan Hedberg
c19756d372 core: Update btd_adapter_find_device to also match the address type
This is necessary to do accurate matching for LE devices.
2014-03-22 19:34:32 +02:00
Anderson Lizardo
ef80103f95 autopair: Remove time(NULL) fallback when seeding rand()
If /dev/urandom cannot be opened or read, just fail the plugin
initialization, as it is very unlikely that a fully working Linux system
does not have a working /dev/urandom. This also simplifies the code
logic.
2014-03-05 22:31:16 +02:00
Johan Hedberg
a9f523e0c3 core: Split LE and BR/EDR states for devices
For dual mode devices there are several state variables that are
independent for each bearer. This patch splits these states up into two
separate variable groups in btd_device and tracks the values based on
what kind of connection is in question.

The information is also used to select which bearer to use with
Device1.Connect and Device1.Pair. The basic rule is that the bearer
that's not connected/paired is selected, or then the bearer over which
the device was last seen is selected.
2014-02-21 16:15:56 +02:00
Petri Gynther
0b4da9426f core: Fix device_get_name() to always null-terminate what it returns
Fix device_get_name() to null-terminate the name string it returns.
Modify all callers as needed.
2014-02-19 06:14:17 +02:00
Marcel Holtmann
0b7482398e plugins: Use full include path for header files 2014-01-25 20:09:45 -08:00
Johan Hedberg
57a9c82aca plugins/neard: Use correct service UUID free function 2014-01-21 15:06:16 +02:00
Szymon Janc
6ed9f1552f neard: Refactor request_oob function
This makes function flow easier to follow.
2014-01-18 15:19:37 +02:00
Szymon Janc
d471ce2d77 neard: Set device UUIDs from EIR
Handle UUIDs received in EIR from neard in same way as UUIDs received
on device discovery.
2014-01-18 15:19:33 +02:00
Szymon Janc
231ac1cab9 sixaxis: Don't mark USB plugged device as trusted
There were some valid conserns raised against marking plugged device
as trusted. Mainly due to posibility of crafted USB device. With this
patch user will be asked to confirm service connection and device can
be marked as trusted like any other devices.
2014-01-09 17:54:57 +02:00
Bastien Nocera
7dfdf3f5a0 sixaxis: Fix device detection
After searching past the end of the structure, the loop sometimes
found matches in the daemon's address space...

This fixes the loop to end after the elements have been exhausted.
2013-12-13 11:53:52 +02:00
Szymon Janc
1787252671 sixaxis: Add support for setting LEDs when connected over USB
This allows to setup LEDs when device is connected over USB, not
Bluetooth. This coverts two scenarios:
- user plugged PS3 controller and pressed PS3 button before unplugging,
  in that case LEDs are set
- user plugged already BT connected PS3 controller to USB, this results
  in new /dev/input/jsX device being create but controller is still
  transmitting over BT and old jsX device exists. In that case don't
  set LEDs as they are already set.

This is not directly related to Bluetooth itself but change is really
small and provides much better and consistent user experience.
2013-12-03 09:47:07 +02:00
Szymon Janc
67c269d171 sixaxis: Skip controller setup if already connected over Bluetooth
If controller is already connected over Bluetooth but was then
plugged-in via USB (eg. to charge battery) there is no need to do
any setup.
2013-12-03 09:46:56 +02:00
Szymon Janc
752b6b1cb6 sixaxis: Add support for setting PS3 controller LEDs
This will set controller LEDs according to joystick device number
when controller is connected over Bluetooth. If joystick number is too
big (> 7) or falied to be read, set it to 0 to switch off all LEDs.
This will allow to disable LEDs blinking after connection.

Waiting for events is not really needed when connected over Bluetooth
but this is in preparation for supporting LEDs setup over USB.
2013-12-03 09:44:07 +02:00
Johan Hedberg
ffb0da64dc plugins/sixaxis: Use explicit include paths 2013-11-27 11:32:36 +02:00
Szymon Janc
8b9bd382ec plugins/sixaxis: Add support for configuring new controllers
When new PS3 controller is detected provide it with default adapter
address. Also create new btd_device with proper PNP info if it wasn't
existing yet.
2013-11-27 11:29:30 +02:00
Szymon Janc
663e0b2f0c plugins/sixaxis: Add initial code for udev handling
When new device is added plugin will be notified about it.
2013-11-27 11:29:28 +02:00