Command complete event for LE commands are not being handled properly
due blocking calls of LE Set Scan Parameters and LE Set Scan Enable
Commands. Fix wrong Discovering signal emission in the interleaved
discovery mode.
Adapters which are already up when bluetoothd starts will already have
their bdaddr's known and bluetoothd should therefore not wait for a
read_bd_addr_complete event before assuming that they're ready for use.
We might not have the adapter address when we get HCI_DEV_UP so it's not
safe to cache it and let the core daemon know about the adapter being
ready for use. This patch adds tracking of the read_bd_addr command and
only informs the core daemon about the adapter when the command has been
completed. Additional tracking of the UP/DOWN state is also added since
in theory HCI events can come before DEV_UP (since HCI data and stack
internal events are handled using separate kernel threads).
If the state variable is not updated until mce_signal_callback and
SetProperty(Powered) is called two times quickly, then the second
call will not generate a request to change the radio state of the
MCE if its corresponding call to adapter_powered occurs before the
first triggering of mce_signal_callback.
With this patch two calls to the MCE are executed, although there
might still be an unnecessary power cycle in that
mce_signal_callback is also triggered twice.
In the future when the mgmtops code needs to behave in different ways
depending on the kernel side management API version it's convenient to
have the exact version/revision number in easily accessible global
variables inside mgmtops.c.
This patch adds initial mgmtops setup support. The code will fail on
kernels without Bluetooth Management support and cause bluetoothd to
fall back to using hciops.
Newer kernel versions will deal with the automated name request for
connection complete events, so remove it from userspace to avoid
unnecessary traffic and potential interop issues.
This patch changes the adapter_ops registration procedure to simply add
the callback struct into a list. The actual adapter_ops implementation
that gets used gets chosen in the adapter_ops_setup function.
Initializing existing adapters requires calls into adapter.c and a fully
setup adapter_ops so this can only be done after the adapter_ops setup
function (hciops_setup in this case) has returned.
Move the remote name and version requests that are done upon a
connection complete event to hciops. Instead of queuing the version
request after the name just delay it for one second (this simplifies the
logic quite a bit).