Commit graph

41120 commits

Author SHA1 Message Date
Johan Hedberg
3beca82c90 Bluetooth: Add debug config options for all current sub-modules
We want to be able to do fine-grained enabling of debug logs for the
various Bluetooth sub-modules. They all default to 'n' so an app
writer would need to go and enable the specific ones that they're
interested in.

Change-Id: I17105adf133d441dfc811bdd66a00be015813679
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:58 -05:00
Arkadiusz Lichwa
d46de84c03 Bluetooth: Create basic LE scan interface
Adds needed data structures.
Adds basic HCI interface to start/stop LE scan.

Change-Id: I69790b11d191078952ce05da386961c5c55a7172
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:13:58 -05:00
Andrei Emeltchenko
115176e323 Bluetooth: Fix dependency for UART debug option
Move UART debug config option after UART driver configuration and make
it depends on it.

Change-Id: I23dc8a4a43aa6dee0bb5266cd1f84a00e811db1d
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:58 -05:00
Andrei Emeltchenko
5fffe2f225 Bluetooth: Set default toolchain to gcc
Set the toolchain in case the user doesn't have it set in their
environment.

Change-Id: Ia961598bc125ded9326747cc8c5810635a8481d5
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:58 -05:00
Luiz Augusto von Dentz
dd7a73a228 Bluetooth: Rename bt_att_info structs and their defines
This replaces _1 and _2 with the respective UUID size they carry.

Change-Id: I254afe335121aef23ed49a5fe0c49520937cc14f
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:58 -05:00
Luiz Augusto von Dentz
bfcd16be8b Bluetooth: Add ATT server initiated skeletons
This adds the remaining ATT PDU definitions.

Change-Id: Id58116e00ba0d3a0ea4b0f94bd262290342e7e9f
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:58 -05:00
Luiz Augusto von Dentz
ed7b333385 Bluetooth: Add ATT Execute Write Request skeleton
This adds the defines for Execute Write PDUs along with initial code to
parse them.

Change-Id: Ifa8229b9f3bf0a60d9abe553263b32397d1ba881
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:58 -05:00
Luiz Augusto von Dentz
0fe5fa9fcf Bluetooth: Add ATT Prepare Write Request skeleton
This adds the defines for Prepare Write PDUs along with initial code to
parse them.

Change-Id: Ia7210dbe4662afbebe742b5b1a7b8f08999adf2a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:58 -05:00
Luiz Augusto von Dentz
d3acf5f16a Bluetooth: Add ATT Signed Write Command skeleton
This adds the defines for Signed Write Command along with initial code
to parse it.

Change-Id: I2071163c8468a6580d9a9305095187a140c80a43
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:58 -05:00
Luiz Augusto von Dentz
75f56d9e07 Bluetooth: Add ATT Write Command skeleton
This adds the defines for Write Command along with initial code to parse
it.

Change-Id: Ifabcfa8efb54b5135a540718fb60d9a656cd088c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:58 -05:00
Luiz Augusto von Dentz
9e8c1d1326 Bluetooth: Add ATT Write Request skeleton
This adds the defines for Write PDUs along with initial code to parse
them.

Change-Id: I69d2002b3e6da80037c058f42f543a0ab4765958
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:58 -05:00
Luiz Augusto von Dentz
75aab47603 Bluetooth: Add ATT Read by Group Type Request skeleton
This adds the defines for Read by Group Type PDUs along with initial
code to parse them:

> ACL Data RX: Handle 3585 flags 0x02 dlen 11
      ATT: Read By Group Type Request (0x10) len 6
        Handle range: 0x0001-0xffff
        Attribute group type: Primary Service (0x2800)
< ACL Data TX: Handle 3585 flags 0x00 dlen 9
      ATT: Error Response (0x01) len 4
        Read By Group Type Request (0x10)
        Handle: 0x0001
        Error: Attribute Not Found (0x0a)

Change-Id: Iebc84e7a9c405fa58b7984602d2d27f79d6033a7
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:58 -05:00
Luiz Augusto von Dentz
f00308f0eb Bluetooth: Add ATT Read Mutiple Request skeleton
This adds the defines for Read Multiple PDUs along with initial code to
parse them.

Change-Id: I34f597881e3bdb9325ffbf2bda42b7ae6710c3ae
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:58 -05:00
Luiz Augusto von Dentz
eedc01d6d5 Bluetooth: Add ATT Read Blob Request skeleton
This adds the defines for Read Blob PDUs along with initial code to
parse them.

Change-Id: I5a2a2e2e32bf44d98ce928b3d57ad7f05059a927
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:58 -05:00
Luiz Augusto von Dentz
dfdd657b37 Bluetooth: Add ATT Read Request skeleton
This adds the defines for Read PDUs along with initial code to parse
them.

Change-Id: I3ec54a0bf2394b54bd8b08957533f0826bf4a23a
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:58 -05:00
Luiz Augusto von Dentz
0d853d64c2 Bluetooth: Add ATT Read by Type Request skeleton
This adds the defines for Read by Type Value PDUs along with initial
code to parse them:

> ACL Data RX: Handle 3585 flags 0x02 dlen 11
      ATT: Read By Type Request (0x08) len 6
        Handle range: 0x0001-0xffff
        Attribute type: Characteristic (0x2803)
< ACL Data TX: Handle 3585 flags 0x00 dlen 9
      ATT: Error Response (0x01) len 4
        Read By Type Request (0x08)
        Handle: 0x0001
        Error: Attribute Not Found (0x0a)

Change-Id: I0b4371b8decebf33710a949552a11c80c544b5f8
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:58 -05:00
Johan Hedberg
f73b3b954e Bluetooth: Remove unnecessary reinit of buffers
Now that we no-longer need to set an upper limit of outgoing ACL
buffers (thanks to reintroducing the ACL semaphore) we don't need to
perform a second initialization of the buffers.

Change-Id: Ie59bf7cb0e6915f1c67ca3dfb03244f9b4af94d5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:58 -05:00
Johan Hedberg
9b1e7a935b Revert "Bluetooth: Rotate outgoing ACL packets via a pending queue"
This reverts commit ce981a0f51f94a3f23c43b947a2ce62a1ef08623.

Now that we're back to using an ACL buffer semaphore the rotation of
outgoing ACL packets via a pending queue is no-longer necessary.

Change-Id: I0da42992bed2abba1544b1a82c31bc71342ecf70
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:57 -05:00
Johan Hedberg
1f5b1b83e0 Bluetooth: Reintroduce ACL buffers semaphore
Since nano_sema is after all able to handle multiple waiters we can
have a cleaner and more efficient implementation by using a single
semaphore for all of the connection tx fibers.

Change-Id: Iafb595ae556a2dd826502cf282b88548cb34f336
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:57 -05:00
Luiz Augusto von Dentz
d51985e4ce Bluetooth: Add ATT Find Information by Type Value Request skeleton
This adds the defines for Find Information by Type Value PDUs along
with initial code to parse them.

Change-Id: I9eaf2df390ca6f78530df7f1ae606b588d1fcb2e
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:57 -05:00
Luiz Augusto von Dentz
b6d35d8281 Bluetooth: Add ATT Find Information Request skeleton
This adds the defines for Find Information PDUs along with initial code
to parse them.

Change-Id: If34533cca4a1a554ca3f119c7639a1167dae0ff2
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
94fc5b27c5 Bluetooth: Add definitions for LE Encrypt command and reply
Add definitions for implementing HCI controller encryption.

Change-Id: I4e919c8a081c9e61174e6b08f5b2ac088e4b1a4d
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
7a995c0a60 Bluetooth: Export bt_hci_cmd_send_sync() for SMP use
The function bt_hci_cmd_send_sync() would be used in LE SMP code for
using HCI controller for encryption.

Change-Id: I0f8f7963a0bf0597b59f24e6d21b6d1f49072f43
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
82c913d53c Bluetooth: Add SMP encryption key check
Fixes PTS test case TC_EKS_BI_02_C sending correct failed reply to
wrong key size.
...
> ACL Data RX: Handle 64 flags 0x02 dlen 11
      SMP: Pairing Request (0x01) len 6
        IO capability: KeyboardDisplay (0x04)
        OOB data: Authentication data not present (0x00)
        Authentication requirement: No bonding, No MITM, Legacy, No
Keypresses (0x00)
        Max encryption key size: 6
        Initiator key distribution: <none> (0x00)
        Responder key distribution: <none> (0x00)
< ACL Data TX: Handle 64 flags 0x00 dlen 6
      SMP: Pairing Failed (0x05) len 1
        Reason: Encryption key size (0x06)
...

Change-Id: I1c02cbc03d1aaf6221d7a6ddfd9bc7ab30ca9586
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
0aadf6ce69 Bluetooth: Add SMP Pairing Confirm skeleton
Change-Id: I484e24f111212acf3e920b4eed56d69e6b94493d
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
b7dddcff00 Bluetooth: Add SMP Pairing Request skeleton
Add handling of SMP Pairing Request for Pairing Feature Exchange. In
the beginning support Just Works pairing method.

Change-Id: I8aab10683e9f26db4e0e9cb1bb9a8dc8940f0ab0
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
d780f70339 Bluetooth: trivial empty space fix
Change-Id: I933dae2543f0f0c722736a3b3be79cf5494e9ff6
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
d135dcf0e5 Bluetooth: Fix using magic number
Instead of magic number use sizeof().

Change-Id: I6c9db3d7a371312d0aab4fd7dc6a9d0c92449afc
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
a9cd5276ec Bluetooth: Enable HCI_CORE debug for samples
Enabling HCI_CORE debug helps to identify possible bugs.

Change-Id: I13df39d63ee9b15f83503d86edc71733c7db94d5
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
fa2473d912 Bluetooth: Allow redefine QEMU_EXTRA_FLAGS
Allowing to redefine QEMU_EXTRA_FLAGS helps to overcome user channel
stuck cases, you still have the possibility to use bluetooth over tcp
by specifying QEMU_EXTRA_FLAGS="-serial tcp:...". Default behavior
remains the same though.

Change-Id: I3a8190a1ca04029e788bfd424f3b3a3be9f2af75
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Johan Hedberg
5cff2d0b78 Bluetooth: Add debug support for buffers
For debugging buffer access related issues it's convenient to be able
to enable logs and extra checks specifically for the buffer related
code.

Change-Id: Ibb87d344809d2bcada10a22b16a23e6556f4ae79
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
f8df842dd5 Bluetooth: Add compile test for nanokernel shell app
Bluetooth regression and system regression would run compile test
for shell app.

Change-Id: I029772483e7aa9ac0717db760d8de1f6be3371b5
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
e15102a206 Bluetooth: Add nanokernel configuration for shell app
Add support for nanokernel build for shell application.

Change-Id: Idf5f3673050c2ac4c941dc9164536fc487e9216b
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
f3794dd657 Bluetooth: Update README with recent changes
Remove old way of starting qemu target and add extra information.

Change-Id: I37c378aa0eb873b3fc16362991eec8a6b661626b
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
3750a7eb36 Bluetooth: Implement SMP error response
Add bt_smp_create_pdu() helper and implement send_err_rsp for an
unknown SMP command.

Change-Id: Iaed0811f3323f62aaa56eb531fb383cf15396ef8
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
69f94f2484 Bluetooth: Add skeleton for SMP handling
Add support for Security Manager Protocol fixed channel. SMP handling
would be done in smp.c.

Change-Id: I26d3d098c6b1c3d03aad958d83dfee09e03add1d
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
0f73da74c5 Bluetooth: Add Bluetooth shell sample application
Bluetooth shell sample application make use of serial console shell
and register Bluetooth commands to it. It shows example how console
shell might be used.

Change-Id: I98340422b90e85dc7a2c44823536121999a08952
Co-authored-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
879541a918 console: Refactor serial console interface
Make serial console interface more robust. Enables interrupts only
when registering input, all memory is managed inside application.
Interface to application is changed to have two fifo queues. One
queue is a free line slots and another queue is keeping entered
lines. This way memory for lines is managed inside application which
provides free lines queue. It is also simpler to manage entered
lines by sleeping on fifo_get on app layer.

Change-Id: I4776c03eddd1e7d880df3b902bd48f5f2c901cad
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
37d3fae356 Bluetooth: Add standard license header to l2cap.c
Add missing header with license.

Change-Id: I754bc0c3b4fd6b2699930fb9e126e788a438168a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Johan Hedberg
90475d78f2 Bluetooth: Use min() macro where possible
There's no need to have custom minimum value evaluation logic when
there's already a convenience macro available.

Change-Id: I91ad50521deb2575100c3480cad516bbf6f4dc2d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:57 -05:00
Andrei Emeltchenko
2ea4e83446 Bluetooth: Fix ATT code printing
Fix bug printing ATT code in bt_att_recv()

Change-Id: I21fe9cb1272428e618412e98b09e8d786132eef6
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:57 -05:00
Luiz Augusto von Dentz
028edd59ba Bluetooth: Add code to handle BT_ATT_OP_MTU_REQ
Add code to respond to BT_ATT_OP_MTU_REQ with BT_ATT_OP_MTU_RSP
selecting the MTU based on the amount of room bt_buf has:

< ACL Data RX: Handle 39 flags 0x02 dlen 7
      ATT: Exchange MTU Response (0x03) len 2
        Server RX MTU: 65

Change-Id: I47b8179fcee0d6adff5761abc37cfcb1ed636d65
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:56 -05:00
Luiz Augusto von Dentz
7cbb4e6f4b Bluetooth: Add bt_att_create_pdu
Add bt_att_create_pdu which works similarly to bt_l2cap_create_pdu
eliminating some duplicated when generating ATT PDUs.

Change-Id: I30b89effbae887f4032ba1d1e380a763c3556869
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:56 -05:00
Luiz Augusto von Dentz
7ab174d202 Bluetooth: Add len check to bt_l2cap_create_pdu
Check if buffer created is not too short for the len requested and in
case it is print an error and return NULL.

Change-Id: I2361925dfb83fe5e9746445c54e8f39e82b5504d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:56 -05:00
Luiz Augusto von Dentz
4202d9a7bf Bluetooth: Fix missing parentesis to sizeof
Change-Id: I31e7b8fb3e463371950b538a51676baa77b671ba
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:56 -05:00
Luiz Augusto von Dentz
496147e88c Bluetooth: Make ATT opcode define names consistent
This drops L2CAP term and add OP in its place to make it clear what they
are for.

Change-Id: I50de8b505f64d9a468b2a0c96feb037c233ceac5
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:56 -05:00
Luiz Augusto von Dentz
facd477484 Bluetooth: Add error code defines
These are the error codes that can be used in bt_att_error_rsp.

Change-Id: I5fd3a65ed0b35fd8b21644e3d23c58c7bd57cfec
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:56 -05:00
Luiz Augusto von Dentz
7f1119bb2e Bluetooth: Remove unnecessary PRJ_INCPATH
It is not necessary to add any PRJ_INCPATH in order to build Bluetooth
samples.

Change-Id: I3ddb0a645e475d937a7067059e8bf5caa783a04e
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:56 -05:00
Luiz Augusto von Dentz
8fc12c1600 Bluetooth: Add LE beacon sample app
Adds a sample which initializes Bluetooth and enables non-connectable
advertising (i.e. starts acting in the LE broadcaster role).

Change-Id: Ic554b1354464b357b44215af1c0b613f123aeb5d
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:56 -05:00
Johan Hedberg
4dda330440 Bluetooth: Implement ACL fragmentation for outgoing data
If we have a buffer that's larger than the supported ACL MTU we need
to split it into multiple fragments. The first fragment will have
'start' in the flags that are encoded to the connection handle and
subsequent ones will have 'continue' encoded into them.

To not loose track of the original buffer until we have created all of
the fragments we store each buffers in a temporary FIFO and then later
read them back out from there and put them into the tx_queue.

Change-Id: Ice77a79a89286829d624f76df77e0aa719af1490
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:56 -05:00