scan_type should be set to BT_LE_SCAN_ACTIVE
Change-Id: I4cb4141919819ce104b002bfc0e89bedbc55e90d
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
When connected, the peripheral/slave can trigger changing connection parameters.
Handle such request on central/master and if needed update controller settings
regarding the relevant connection parameters.
Change-Id: If3c1d91752f8d3875918bd8bfe923330790f530e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This function allows to pick connection destination address.
Change-Id: I3e4959eec00905c64de3d8b9ef810b613c2e9f91
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
Adds user helper functions dealing with formatting bluetooth
address.
Refactors internal helpers using public ones.
Change-Id: If7b9f9a93b2aef3d25df55d6cfae9de05d8830b0
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Enables sending LE discovery results to user app.
Updates central apps to use new scan API.
Change-Id: Id319c96e15554f2eed4cf507cddd114ca74aa8e5
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
hexadecimal is the usual format when defining GATT handles values so
printing in the same format makes it easier to debug.
Change-Id: I6babcadaf5a4cffbac73db29c155343540cee120
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This API is useful for applications wanting to monitor and disconnect
connections.
Change-Id: Ib1a98ece364f137262515fbb1163c6b08ddf792c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
To be able to make these APIs usable for apps where the calls may
happen from preemptible tasks, it's safest to return a dedicated
reference and let the caller do bt_conn_put() once its done with the
object.
Change-Id: If227e088385b8c6f61f4061a54c745c0bff7a6c3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
There's no clear need for this API (at least for now) and supporting
it means we really need to get all state cleanup procedures correct.
Remove it for now.
Change-Id: Ia2c7d51d410117bef12bc08f4f97a4e38ccfb77a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This makes it clearer that this is a specialized API not intended for
general app usage (unlike most other things in bluetooth.h).
Change-Id: I0ce1d5903610a9b3a99cf0be9f0e1462b04bf45a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
To make it clearer that these helpers are intended only for
Bluetooth-subsystem internal code, move them to a separate file.
Change-Id: Iea64780f5c61c1c96e12c9df378676bc49498fe4
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Adds internal HCI interface routine for creation of basic ACL LE link.
Most of the command interface parameters are fixed.
The internal interface is then used directly by simple public interface with
no connection validation.
Change-Id: I8ed72a9d01348e2a05b62facc9e85060e4500631
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Now that we have a publicly exposed connection object it makes sense
to pass that to the connection callbacks rather than an address.
Change-Id: I8e9b17733d1789539a83c3dbc7a778336d2b71ff
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This one should be used for all public connection related APIs. Right
now it includes the reference counting and connection callback APIs.
Change-Id: Ib9b67e6115bb2e51322644757da1170851c3ca17
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We'll have a public conn.h header file soon, so to avoid confusion
rename the existing conn.h to conn_internal.h.
Change-Id: I5e5c89ec184a0a2de63e244b034c55a3d97af9dc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
conn was never set in struct flush_data passed to flush_cb.
Change-Id: I2a16479bf7660a96f705d1194245da02ee6eeff5
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
Add BT_GATT_CEP and BT_GATT_LONG_DESCRIPTOR so which can be used by
a task to declare long attributes.
Change-Id: I37a0bb1851b60f3cdfa7e2f00ade70d5c344abbf
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This introduce a new callback called flush to bt_gatt_attr to indicate
when and attribute can cache data, the data is automatically flushed if
regular write request happens and in case of prepare write it checks if
flush is supported otherwise return an error, then upon receiving an
execute write it perform flush over the entire database and respond
with result:
< ACL Data TX: Handle 42 flags 0x00 dlen 6
ATT: Execute Write Request (0x18) len 1
Flags: Immediately write all pending values (0x01)
> ACL Data RX: Handle 42 flags 0x02 dlen 5
ATT: Execute Write Response (0x19) len 0
Change-Id: I2c47f962858b8a741bf40509a648fe2cd6755691
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
When a connection is made, track its role.
Only peripherial/slave role may trigger update of L2CAP connection
parameters.
Change-Id: I72244581650248c7b020c9e5673b73ce46e7399d
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Call attribute write callback taking into account the signature length
so only the actual data is used.
Note: It still don't support validating the signature because that depend
on storing CRSK key.
Change-Id: I93973e2997f57e5715080ef56ad85e0eaf11d0fe
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This reduces the amount of code necessary to check minimum size and
to generate error responses.
Note that not every response can be generate using this method since in
some cases the handle must be set to indicate what attribute has failed.
Change-Id: I0dde7461d97e451407935d5ec3cbfedf6542d5e6
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
The spec says that CCC shall only be persistent accross connection for
bonded devices:
'The Client Characteristic Configuration descriptor value shall be
persistent across connections for bonded devices. The Client Characteristic
Configuration descriptor value shall be set to the default value at each
connection with non-bonded devices'.
To handle this now each configuration has a valid field indicating if the
configuration is valid.
Change-Id: Id74ac54f5e23a7a0b286f90dbc9af4e9ee966dd4
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This fix following compilation error if CONFIG_BLUETOOTH_DEBUG_SMP
is defined:
In file included from net/bluetooth/smp.c:44:0:
net/bluetooth/smp.c: In function 'bt_smp_irk_matches':
net/bluetooth/smp.c:681:31: error: 'val' undeclared
(first use in this function)
BT_DBG("IRK %s bdaddr %s", h(val, 16), bt_addr_str(addr));
Change-Id: I3350620f1f7dc929b949b4483178df66dde55198
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
This was causing output such as bellow:
bt: bt_gatt_attr_write_ccc: No space to store CCC cfgbt: bt_gatt_attr_write_ccc: No space to store CCC cfgDisconnected
Change-Id: I8aff67b9c4b407e8a2da939c27bea05a597dcf67
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This patch adds callbacks to notify app about connection and disconnection.
Change-Id: If8091254d929fe53d12b153e6f216223a8913f2d
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This checks if connection encrypt flag is set if attribute requires
encryption and in case the connection is already encrypted return
success.
Change-Id: I8af4e9786b63a21f478b3aa9f6df448d7f5760c5
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Respond with an error if attribute read/write return an error.
Change-Id: I9c2f98ac4b73bca5d3714339a47290ca9ae2391b
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
With the introduction of the Number of Completed Packets event
handling this FIFO & fiber aren't anymore strictly HCI command
completion related. Rename them therefore to something that more
appropriately describes their purpose.
Change-Id: Ia53dea8b5ec0098459f23918a5483075757d9202
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The Number of Completed Packets HCI event belongs to the same category
as the Command Complete/Status events in that it is likely to unlock a
waiter in one of the other fibers. Events which may affect waiters in
this way need to be processed without delay and through a separate
FIFO & fiber to avoid deadlocks.
Change-Id: Ibc2ee2b4f72e2534a8579ad1c36591867e19e6df
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The PACK_STRUCT macro will be removed soon and __packed is what all
code should use. Convert all the usages in Bluetooth code.
Change-Id: Id5c724566565f67fa8167b61398c508194ece89b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We need to make sure we have more event buffers than outgoing ACL
buffers. Currently we allocate 7 + 7 ACL in/out buffers leaving only 7
left for commands/events. Increase the buffer count by two to make
sure we've got 8 command/event buffers.
Change-Id: I4c54aa07019ad9ef262aeecabf151edd60f91b9e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When reading a characteristic attribute which contain a 128 bits UUID the
size of the elements were counting only the UUID alone not other fields
that are part of the value causing invalid responses to be sent.
Change-Id: I7474531f586ba19788eb9e0ed59555c5d7672176
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This checks attribute permission returning an error in case they don't
match.
Change-Id: I56a85ad594cb1ac535b03cdbceb43af84dc6604f
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If CONFIG_BLUETOOTH_DEBUG_HCI_CORE is enabled it causes the following
error:
hci_core.c:514:12: error: 'struct bt_hci_evt_encrypt_key_refresh_complete' has no member named 'encrypt'
evt->encrypt);
^
Change-Id: I1983653eba40b9aea6b19572b39a285883f00450
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
We can do centralized PDU length checks and more compact code size
with the help of a handler table where the index maps to the SMP op
code.
Change-Id: Iba69ecc14f452411dfb6b4db7c7a5fd19ba3e51f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixes memory leak when buffer is allocated before CCC check, the best
fix is to move CCC check forward.
Change-Id: Ib0492f629a339b576cf811adce47b2f6ab101c33
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
For now we don't support key shortening, so set the minimum value
appropriately to 16 bytes. Once key shortening is implemented this
value can be lowered again.
Change-Id: I172d0bf6d04ba4c5eaa7bbf8ae2accfa373eebb5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Devices using LE Privacy are identified by their Identity Address
whenever we've paired and received their IRK. We should therefore try
to look up matching IRKs for advertising responses.
Change-Id: I304108da699ff2506e6cc50bd6c5c053a0db024b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Use correct address to string translation.
Change-Id: Ic766147fd6016894c0f60ec57059984887653a15
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This event comes instead of Encrypt Change when we re-encrypt an
already encrypted connection.
Change-Id: I7fe9545e6c58392a34d72f3dd3962c475ebb7871
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
When a connection occurs it may have happened with an RPA. If so,
check if there's a matching IRK available and update the connection
address with the Identity Address (stored together with the IRK).
Change-Id: I3d995a35171b514ec1902fce617e8e7d6770e785
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>