Commit Graph

644 Commits

Author SHA1 Message Date
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
Szymon Janc
f52aa87499 plugins: Add initial code for sixaxis plugin
This plugin will be used to associate PS3 controllers.
2013-11-27 11:29:26 +02:00
Szymon Janc
bc05407e07 Rename adapter_get_address to btd_adapter_get_address
Allow this symbol to be exported and usable from external plugins.
2013-11-27 11:21:42 +02:00
Szymon Janc
e48206fe9b Rename device_device_set_name to btd_device_device_set_name
Allow this symbol to be exported and usable from external plugins.
2013-11-27 11:20:23 +02:00
Szymon Janc
70510e5f11 Rename adapter_get_device to btd_adapter_get_device
Allow this symbol to be exported and usable from external plugins.
2013-11-27 11:19:30 +02:00
Bastien Nocera
ffd321f1e1 autopair: Add special handling for printers
As was done in gnome-bluetooth since 2009:
https://git.gnome.org/browse/gnome-bluetooth/commit/?id=7a472c151d44a3378ecbd3c2a75c763f5c577fe9
2013-11-19 15:35:19 +02:00
David Herrmann
1bbc54e1f3 wiimote: add new documented device IDs
Add some new device IDs for the LEGO wiimote and Wii U Pro Controllers.
Also add comments for each ID so we can track them better.
2013-10-18 17:25:44 +03:00
Szymon Janc
f538355c3f adapter: Handle removing of SDP records
Make adapter in charge of updating SDP database. This allow to decouple
SDP of code used for notifying adapters about SDP database change.
2013-09-23 10:43:01 +03:00
Luiz Augusto von Dentz
92d1321602 neard: Make use of g_dbus_send_message_with_reply
This replaces dbus_connection_send_with_reply with
g_dbus_send_message_with_reply which does not alter message order.
2013-09-09 17:35:30 +03:00
Dirk-Jan C. Binnema
1208266dcc attrib: Rename GATT_OPT_CHR_UUID into GATT_OPT_CHR_UUID16
Rename the option for all in-tree users. This frees up GATT_OPT_CHR_UUID to be used
for UUIDs of type bt_uuid_t* (in a next patch).
2013-07-30 12:59:12 +03:00
Luiz Augusto von Dentz
57ce0cb4c2 plugins/policy: Limit the number of retries to sink profile
The policy should only retry a limit number of times.
2013-07-12 15:05:50 +03:00
Luiz Augusto von Dentz
48e3137565 plugins/policy: Limit the number of retries to source profile
The policy should only retry a limit number of times.
2013-07-12 15:05:50 +03:00
Luiz Augusto von Dentz
f5fc3fffe5 audio/sink: Move stream retry logic to policy plugin
policy plugin is a better place to have such a logic as it is already
handling other connection policies related to such profiles.
2013-07-12 15:05:50 +03:00
Luiz Augusto von Dentz
3c29a14f84 audio/source: Move stream retry logic to policy plugin
policy plugin is a better place to have such a logic as it is already
handling other connection policies related to such profiles.
2013-07-12 15:05:49 +03:00
Luiz Augusto von Dentz
fe4cbedb1e plugins/policy: Reword audio policy code in a simple plugin
This moves audio device policy to a plugin and removes any dependency of
audio plugin to it.
2013-07-12 15:05:49 +03:00
Anderson Lizardo
83ecd743a9 core: Avoid unnecessary gboolean on pincode callback API
Use standard "bool" type instead. Callers in plugins/* are fixed on the
same commit to avoid compilation errors.
2013-06-13 17:24:20 +03:00
Anderson Lizardo
0743aa5a6f plugins: Use open()/read() instead of fopen()/fread() on autopair
open()/read() is more common on BlueZ code. Incidentally, get rid of
this compilation error (using gcc 4.6.3):

plugins/autopair.c: In function ‘autopair_init’:
plugins/autopair.c:154:8: error: ignoring return value of ‘fread’,
declared with attribute warn_unused_result [-Werror=unused-result]
2013-06-13 17:24:20 +03:00
Johan Hedberg
a7171953ac autopair: Clean up coding style 2013-05-10 10:35:54 +03:00
Alex Deymo
dc3a586501 autopair: Try a fixed pincode for keyboards rejecting random codes
This patch makes the autopair plugin try a fixed "0000" pincode for
keyboards that reject the pincode too fast (less than 500ms). This too
short delay rejecting the pincode means that the user didn't have time
to type the random pincode in the bluetooth keyboard and was the
keyboard who actually rejected it.
2013-05-10 10:26:19 +03:00
Alex Deymo
4cf14a98e5 autopair: Add the autopair plugin
The autopair plugin tries standard pincodes for different devices with
dumb pincodes. It also generates a random 6 digit pincode for keyboards
that support any pincode but fallbacks to the agent call in case the
random generated pincode didn't work.
2013-05-10 10:21:39 +03:00
Alex Deymo
fa73398ae6 plugins: Extend the pin code callback with the call number
The plugin's pin code callback doesn't know about the pairing process.
It just provides a pin code based on the information provided to this
function. Although limited state could be added through other new
callbacks, this fix achieves this by providing more information to the
callback itself. The new argument "attempt" states the pin callback
attempt of the particular plugin for the current pairing of the device.
This allows a plugin to try different pincodes for the same device in
the same pairing process.

To signal that the plugin doesn't provide any pin code for the provided
device the current implementation returns 0 (an empty pin code).
Analogously, with this fix, a plugin should return 0 when it doesn't
have any other pin code to provide for the given device.
2013-05-10 10:16:48 +03:00
Szymon Janc
34e99c8328 neard: Fix reading local OOB data when adapter is not powered
Read Local OOB data only if adapter is powered. This fix replying with
error instead of CPS set to inactive when adapter is not powered.
2013-05-08 10:12:23 +03:00
Szymon Janc
88daad9402 neard: Fix checking for unknown carrier power state
Message might not contain State field and CPS needs to be set to
unknown before processing message from neard. This fix processing
RequestOOB called without parameters.
2013-05-08 10:12:08 +03:00
Lucas De Marchi
6f4bdbef1e plugins: Get rid of gint
Use plain int instead of gint. In glib gint is always a typedef to int,
so it's safe to use it even for callbacks with glib.
2013-05-01 09:08:56 +03:00
Johan Hedberg
d56685d057 core: Fix storing info for private addressed devices
Devices with private addresses cannot persistently be identified by
their address. Therefore it doesn't make sense to store any information
about them as the information couldn't be looked up later once the
remote address has changed.

Once the kernel receives support for private address resolution we'll
start getting the public address of such devices to user space. However,
until then we just have to ignore such devices from a storage
perspective.
2013-04-29 14:02:34 +03:00
Johan Hedberg
ab5be5cb35 neard: Use more appropriate log levels than info() 2013-02-15 16:32:38 +02:00
Szymon Janc
cc2a84bf16 neard: Add fallback to legacy register if register failed
This will allow to work with neard 0.9 which doesn't support handover
agent register with carrier type.
2013-02-15 16:30:10 +02:00
Ravi kumar Veeramally
6a3debadb3 neard: Updated neard handover registration agent API calls
neard RegisterHandoverAgent and UnregisterHandoverAgent APIs need an
extra parameter of carrier type(e.g. bluetooth).
2013-02-15 16:29:46 +02:00
Szymon Janc
a629abd62f neard: Update copyright information 2013-02-15 16:29:33 +02:00
Szymon Janc
c7521adc2f neard: Use bool instead of gboolean for agent_register_postpone
There is no need to use gboolean as this flag is not used with any
glib function.
2013-02-15 16:29:19 +02:00
Szymon Janc
46d9e2693d neard: Restrict method calls only to neard process
Disallow methods calls from processes other than registered to as
agent.
2013-02-15 16:28:48 +02:00
Szymon Janc
66d880d232 neard: Use service name and not boolean to track if registered to neard 2013-02-15 16:28:06 +02:00
Szymon Janc
6960cb73b2 hostname: Fallback to static hostname if pretty hostname is not set
If pretty hostname is not set fallback to static hostname (if it is
set). If static or pretty hostname is not set appropriate properties
are empty strings not NULLs. This behaviour is recomended by hostnamed.
2013-02-15 12:50:41 +02:00
Szymon Janc
f0c8fed306 hostname: Fix setting adapter name to empty string
If pretty hostname is not set empty string is received. Don't update
adapters' names is such case.
2013-02-15 12:48:35 +02:00
Szymon Janc
4345fd9154 neard: Add support for setting power state in RequestOOB reply
This allows neard to properly set Bluetooth carrier power state in
handover message.
2013-02-15 10:42:21 +02:00
Szymon Janc
127b948210 neard: Check if adapter is powered in PushOOB
For PushOOB adapter needs to be powered as bluetoothd daemon is
expected to perform action on success.
2013-02-15 10:41:22 +02:00
Szymon Janc
d5672b8869 neard: Move pairable check from check_adapter
If device is already paired there is no need to fail with handover
if adapter is not pairable.
2013-02-15 10:40:23 +02:00