This allows to query information needed for Out Of Band pairing
or connection creation. Currently supports only BT addresses.
Change-Id: I60bf9344baee552e7743fa8fc1b3cfb3a4765334
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This lets the callback take advantage of the powerful net_buf API for
parsing the advertising data content.
Change-Id: Id65e6e83efd60c0f36c47bc5446a2e8ec2833d7c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If privacy is enabled we always use RPA, even for active scan.
This makes single point of controlling current random address
making code simple and not prone to subtle bugs with concurent
advertising, scanning and connecting.
Currently used RPA is rotated to improve privacy. Timeout value is
controlled by Kconfig and by default is 900 seconds (15 minutes).
Change-Id: I27a15666a4f2e2962cf6eb20c7cd06f90b7f2bb1
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This makes bt_gatt_write consistent with the rest of the API where the
parameters are passed back to its callback.
Change-Id: Ie94208aa661d3620d0cbc5be4a4fb5b3c3ef061c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Some non-ASCII characters were used in code comments.
Change-Id: Ie00e0b7d7a42a50503c601225cdd0896c375dee3
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
When each side involved in getting configured L2CAP CoC channel on
BR/EDR transport aggrees on configuration contract regarding in/out MTU,
set proper context flags to start prepare finalize config process.
Change-Id: Ic821ea3b961442be758ad4e2d91b2d812e2a54b5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Adds CoC channel's context to hold channel setup state and SM routine
that evaluates validness of transitions.
At the beginning DISCONNECTED, CONNECT and CONFIG states are added and
used by CoC setup on BR/EDR transport.
Change-Id: I1bbd16ec2f59ea961791786b78f22834d6f4b4d8
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
If active scan was started while advertising random adress was
set to NRPA. This results in device advertising with new adress
instead of RPA making it imposible to resolve its identity by
remote devices.
To fix this NRPA for active scan is set only if advertising is
not enabled. This resulst in RPA being used for scan requests
but this is OK since device is advertising anyway.
Change-Id: I35e98bee72f4abc033f5adc664698c14c5d8a2b0
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Add new bt_dev flag for tracking if performing active scan.
Change-Id: I7eacaa94372bae933f648a49d2f55fc200f9d0bf
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
SMP debugs should be enabled only if CONFIG_BLUETOOTH_DEBUG_SMP is
defined.
Change-Id: I17f8ad5e1a9504dcbd3df545af9205db88ee2849
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This adds reading of included service attribute 128bit UUID.
The limitation of this solution is that if several attr handle-range
pairs will be received, this will read first attribute UUID and then
start discovery from the the succeeding handle.
ZEP-373
Discovery related test results:
2/76 GATT TC_GAD_CL_BV_02_C PASS
3/76 GATT TC_GAD_CL_BV_03_C PASS
4/76 GATT TC_GAD_CL_BV_04_C PASS
5/76 GATT TC_GAD_CL_BV_05_C PASS
6/76 GATT TC_GAD_CL_BV_06_C PASS
Change-Id: I27185b3a3ae96c9c03b0f356492df18ba83b183a
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
If privacy is disabled and static random address is used for identity
we need to restore static address before enabling advertising.
Otherwise NRPA used for any previous active scan could be used instead.
Change-Id: Ifea0d2863d78060c84e61d89ef384a94e86895b6
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Some non-ASCII characters were used in code comments.
Change-Id: I77f13ca1648f34dc5dbd9ea78ccd2964a73a1712
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
If the channel is being destroyed the RTX work should be cancelled as
it may cause destroy to be called again.
Change-Id: I49c10d64a2108719d28e456fb5b4bfb50ef8a140
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The code for adding and removing channels is very similar for LE and
BR/EDR so it can be unified and just leave the CID allocation up for the
bearer implementation.
Change-Id: Icf4c66262c4e973039381ebd1861fad4d46e1535
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This is cleaner and safer as destroy is garanteed to be initialized once
it is added to the list of channels.
Change-Id: Iae674f6e25527d71c03c5903337b0bd18c3dd0be
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This has so far been used in SMP code as the h() function. Now it has
a more generic name and is accessible by all parts of the Bluetooth
subsystem.
Change-Id: Iae4607da9c8b3e6779d9c97f84a4e486d5258ef0
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Now that there's an API always exposed for this the events should
always be enabled whenever the controller supports this feature.
Change-Id: I4965c9463ae7b3f6424784dab2c03403fdf3f179
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
If unexpected PDU is recevied it is better to reply with Pairing
Failed and abort pairing then just silently ingore such PDU as
pairing will most likely fail anyway.
Change-Id: I3c67a6997a5e8d33b1e97cb955981a52baf38d02
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This adds initial timeout handling as described in the spec:
BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part A] page 126:
'The value of this timer is implementation-dependent but the minimum
initial value is 1 second and the maximum initial value is 60
seconds. One RTX timer shall exist for each outstanding signaling
request, including each Echo Request. The timer disappears on the
final expiration, when the response is received, or the physical
link is lost.'
Note: As for the actual interval used they are based on the values used
in Linux but in case of disconnect the minimum of 1 seconds was used
to follow the text above.
Change-Id: Ib98899c3ff07334955aee9c8fb53b1b89ba7bf31
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Accourding to the spec request should have a timeout of 30 seconds:
BLUETOOTH SPECIFICATION Version 4.2 [Vol 3, Part F] page 480:
'A transaction not completed within 30 seconds shall time out. Such a
transaction shall be considered to have failed and the local higher
layers shall be informed of this failure. No more attribute protocol
requests, commands, indications or notifications shall be sent to the
target device on this ATT Bearer.'
Change-Id: I5e5b9fb008d3019831c5f6cc3bd4c2b85dd6b90a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
16 bit handles have to be converted to host order.
Change-Id: Iae5d9d79bacd90cd5b42a98d02165ec75bf1272e
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
If channel has conn set to NULL disconnected shall not be called as
may cause invalid actions as with bt_gatt_disconnected being called
with a NULL conn.
Change-Id: I11bc41a34c2a2a3bc5f8514ec4a948235473cfba
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
LE Rand command crashing the MyNewt HCI firmware issue has been also
observed on Quark SE Devboard. Applying this workaround solves the problem.
Change-Id: I57a533309ced0b2d31517a65ac1899ed55112973
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
We already have host order length in len variable.
Change-Id: I5b4ea652c5709eadd64b66584024501c40fd3abc
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
ATT_CHAN() macro as a wrapper to CONTAINER_OF is been used by ATT
internals API wherein the main parameter is pointer to bt_l2cap_chan
object. The macro returns pointer to bt_att context object but
CONTAINER_OF's third parameter determines what member is taken into
account in getting right address. Luckily here this third parameter
"chan" of type bt_l2cap_le_chan got of its own sub-member the "chan" of
type bt_l2cap_chan on first position in structure order. If such order
would change somehow there could be taken wrong address.
Change-Id: I955c2af11e001dac90a1eacc281ff167ceb34fb9
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
If ACL is disconnected with channels still active the code should call
l2cap_chan_del to clean it up properly.
Change-Id: Iffa9345a9697ac80c1f2295578c7161ffeb44420
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This makes the SMP usage of ECC functionality properly encapsulated
and offers the chance of other protocols to utilize the functionality
in the future.
Change-Id: Iae14beafd5f8f7dbe2c6ffd33700471b8a62b8da
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This makes logs easier to read as those are defined as hex values.
Change-Id: I67f1dc0da9056a69398faf55fd5535a67ec4ebb9
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Replaces all occurences of LE_CHAN() macro with new name
BT_L2CAP_LE_CHAN() and makes it public.
Change-Id: I426b17b0214f7ab4b69e5febbdca1917f22e7487
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Command Status, Command Complete and Number of Complete Packets are
used for driving TX fibers (HCI and connection). Missing any of
those event will lead to HCI traffic stall.
Priority pool will be used when critical HCI event is received
or normal pool runs out of buffers. The difference with priority
pool is that buffer from it must not be passed to RX fiber and
must be freed from bt_recv.
If driver knows HCI event opcode before requesting buffer for event
it may hint HCI core about preferred pool selection.
Change-Id: Iad14724945bb59721c5ffb6b62d5a8a3e3f70be7
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This adds flags parameter to write callback which can be used to indicate
that data only need to be prepared with use of BT_GATT_WRITE_FLAG_PREPARE
fixing qualification tests that needs to check authorization or other
errors that cannot be verified with just the permissions.
Change-Id: I3d662b2027718ffb52a280e3bbc9750be14f89ae
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Applications or higher level profiles that are not part of the core
Bluetooth stack may need an easy way to generate random numbers. Since
we already have an internal helper for this export it for others to
use as well.
Change-Id: I29af7cab30ad8f60d481bc847984e781eaecd6bf
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Adds L2CAP configuration response protocol definitions to be able handle
response from remote in reaction to issued local request to exchange
MTU. Current optimistic path of configuration initiated from local
assumes to set MTU contract in one iteration.
Change-Id: If86d96b37e9cd888ad10a624a79c864a137e027d
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Triggers conditionally outgoing configuration request to start exchange
MTU just after incoming PSM connection request was aknowledged by local
host. If local MTU differs from default (672) add MTU option in request,
otherwise send empty configuration meaning default is wanted.
Change-Id: I4eb382cc496345c051967640422e926f595ce854
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This merges callback checks with permissions checks so there are done in
one place.
Change-Id: Ic51b2be9cda67eac9e5dc1ebcbf6186ad5007bf4
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Enables L2CAP protocol definitions for connection request/response and
use it then to start handle incoming PSM connection request to valid
registered local PSM server. SDP PSM got no security restrictions.
The other PSM connections are validated against link encryption and
availability of SSP feature and if not matched are refused with
security error.
Change-Id: I429cf5dbce92300bd52639d5065e0144f8db4d13
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Instead of having a dedicated branch for the success case jump to the
cleanup label in the inverse condition.
Change-Id: I271ce088a5b469d1fb96af1256fcafa5b1e6e2f7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Introduces HCI protocol defines to be able request and read remote LMP
features and if available extended data from peer when connected.
Change-Id: Ic274737d8b6c896eb9e83e2179829bcbadf6f635
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
The parameter is already inside a struct that's specific to BR/EDR
discovery, so there's no need to repeat "discovery" in its name.
Change-Id: Idb95788bfc9d62ecd52adecc35104e212724cb78
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Since we only have a single user we can enforce length > 0x01. We
should also ensure that the results count is 1-255.
Change-Id: Id5d91acae06c6c6fc66dd59c0e367682a98dc08c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This way we avoid having to explicitly cancel the inquiry when we've
received the maximum amount of results.
Change-Id: I586cdd93f39042ac88384cfe6d2bf963ce8a1d99
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This way the application can control the maximum duration of the
Inquiry. The value 0x00 (which is invalid for HCI) is still accepted
for backwards compatibility and gets mapped to the old hard-coded 0x30
value.
Change-Id: Ibc9eb86bbb6c9e45b7b351278517b4a688015195
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>