Commit graph

41120 commits

Author SHA1 Message Date
Andrei Emeltchenko
9b7fecc86b Bluetooth: h5: Fix clearing unack packet queue
Using number_removed to find out how many packets from unack queue we
need to clear.

Change-Id: Icad948892f3ab1febc939e9ba6d6b3431973633e
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:09 -05:00
Andrei Emeltchenko
960e1380b2 Bluetooth: h5: Drop out of sync packet
We might get out of sync packet because of race collision, drop it.

Change-Id: Ic84a760199df1520dc7a95383972f9ec428c7fde
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:09 -05:00
Andrei Emeltchenko
cad8ca1025 Bluetooth: Refactoring parsing H5 signalling
Add paring sync_req and conf_req and handling transmit sliding window.

Change-Id: I05827ff81d0bb726e72efec3c7cde161259a10c4
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:09 -05:00
Arkadiusz Lichwa
d34e498d04 Bluetooth: BR/EDR: Extend bt_conn_info type
Enables get basic connection info support for non-LE connections.

Change-Id: If295b552567886256cfc1e215bfe3149d2f1f60c
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:09 -05:00
Arkadiusz Lichwa
1fb522d0ff Bluetooth: BR/EDR: Rename connection req event handler
Shorten conn_req_event handler name to conn_req.

Change-Id: I74e69cc9e105a4b8c35c08dc182b36d15bfcaa41
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:09 -05:00
Arkadiusz Lichwa
19ee83ec19 Bluetooth: BR/EDR: Handle PIN code request
Unmasks pin code request to be able service
pairing request from legacy 2.0 devices.

Change-Id: I5c09232d8e6e2c7673a35205e0bfeb8c8240388e
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:09 -05:00
Arkadiusz Lichwa
c5f22a20b8 Bluetooth: BR/EDR: Add PIN code HCI protocol data
Defines objects mapping of HCI protocol for:
1. PIN code event from controller
2. Link key event from controller
3. PIN code reply to controller
4. PIN code negative reply to controller

Change-Id: Id06c2b74f6e4dadb6d97a95072a7b227bab197b7
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:09 -05:00
Arkadiusz Lichwa
98f1ef7192 Bluetooth: BR/EDR: Add PIN code authentication API
Defines authentication interface for legacy 2.0 devices

Change-Id: I28fe07fa4f5b9f4e0bcb707eab73a0cd5df2b425
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:09 -05:00
Arkadiusz Lichwa
0afdae9677 Bluetooth: SMP: Refactor authentication
Moves object handling user authentication callback interface exposed
in public API to hci core module and exports internally LE SMP
authentication handlers.
The stack authentication API methods call based on connection type
the correct internal methods. Currently only LE SMP backend
is implemented.
Make getting local io capa in runtime.

Change-Id: I17459096616a620467b4fa01c53fd4bc0b59af9b
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:09 -05:00
Arkadiusz Lichwa
bce38d9f9e Bluetooth: BR/EDR: Enable authentication interface
Gets included authentication API in BR/EDR variant

Change-Id: I4fa55bb3baa8db79f6e9f5f1c65c0d93f8f8780a
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:25:09 -05:00
Szymon Janc
aff8c2109c Bluetooth: Fix reading remote features after disconnect
If connection was disconnected from connected callback there is
no point in going with reading remote featurea and updating
connection parameters because.

> HCI Event: Command Status (0x0f) plen 4
      LE Create Connection (0x08|0x000d) ncmd 1
        Status: Success (0x00)
> HCI Event: LE Meta Event (0x3e) plen 19
      LE Connection Complete (0x01)
        Status: Success (0x00)
        Handle: 76
        Role: Master (0x00)
        Peer address type: Public (0x00)
        Peer address: 7C:2F:80:94:97:39 (Gigaset Communications GmbH)
        Connection interval: 50.00 msec (0x0028)
        Connection latency: 0.00 msec (0x0000)
        Supervision timeout: 4000 msec (0x0190)
        Master clock accuracy: 0x00
< HCI Command: Disconnect (0x01|0x0006) plen 3
        Handle: 76
        Reason: Remote User Terminated Connection (0x13)
> HCI Event: Command Status (0x0f) plen 4
      Disconnect (0x01|0x0006) ncmd 1
        Status: Success (0x00)
< HCI Command: LE Read Remote Used Features (0x08|0x0016) plen 2
        Handle: 76
> HCI Event: Command Status (0x0f) plen 4
      LE Read Remote Used Features (0x08|0x0016) ncmd 0
        Status: Success (0x00)
> HCI Event: Disconnect Complete (0x05) plen 4
        Status: Success (0x00)
        Handle: 76
        Reason: Connection Terminated By Local Host (0x16)
> HCI Event: LE Meta Event (0x3e) plen 12
      LE Read Remote Used Features (0x04)
        Status: Unknown Connection Identifier (0x02)
        Handle: 76
        Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00

Change-Id: I1df211d429383406eda2d23eb1e5fec425ba3427
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:09 -05:00
Szymon Janc
b6221d4a5c Bluetooth: Fix GATT client build without SMP
If GATT client is enabled but SMP is disabled NULL SMP backend
needs to provide bt_smp_sign stub.

  LD      zephyr.elf
net/built-in.o: In function `bt_att_send':
net/bluetooth/att.c:1747: undefined reference to `bt_smp_sign'
Makefile:757: recipe for target 'zephyr' failed
make[2]: *** [zephyr] Error 1

Change-Id: Ia740d6c7ca7d65b78f7ecb781275d1f4d635baf7
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:09 -05:00
Szymon Janc
89a7aa8d72 Bluetooth: SMP: Fix legacy pairing
This fix a regression where incorrect confirm function was used
for legacy pairing.

Change-Id: Ia39aed6b8e9a3cb24b451cdb0219f41ceb5e6c6e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:09 -05:00
Johan Hedberg
8ff6884077 Bluetooth: Fix buffer overflow with ACL fragments
The fragments we create should not be greater than the connection ACL
MTU (which the code already does correctly) but they can also not be
greater than the buffer has room for data. Fix this by taking the
minimum of the connection MTU and the buffer tail room.

Change-Id: I27462d7e8752773c632d212b28e53a8cf6519972
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:09 -05:00
Andrei Emeltchenko
8ded073b6c Bluetooth: Cleanup H5 driver code
Rename functions to indicate static ones

Change-Id: Ie1f58baf9875c0ce606ce2c3cd0704057a7f8223
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:09 -05:00
Andrei Emeltchenko
9a232371ef Bluetooth: Add init_h5 sample app
The main purpose of sample app is testing H5 driver and catching
checkpatch build issues with H5 enabled.

Change-Id: Ia02cdcb38fc8f836de0e5f87b1afe428f7021673
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:09 -05:00
Szymon Janc
a1034a205f Bluetooth: Add DIS peripheral sample application
This adds very simple peripheral application that supports
Device Information Service only and doesn't support pairing.

Change-Id: Iaec1317a8894db11388408d3f65af8a38d1618c3
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:09 -05:00
Szymon Janc
bc18a867b4 Bluetooth: Fix compilation with SMP disabled
This fix SMP dependency checks in connection code.

Change-Id: Ic7e515885381bd243c89f2a6e10c356095e79b55
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Szymon Janc
74333b74af Bluetooth: SMP: Fix NULL backend compilation
This was not building due to bt_l2cap_create_pdu API change.

  CC      net/bluetooth/smp_null.o
net/bluetooth/smp_null.c: In function 'bt_smp_recv':
net/bluetooth/smp_null.c:59:2: warning: passing argument 1 of 'bt_l2cap_create_pdu' from incompatible pointer type [enabled by default]
  buf = bt_l2cap_create_pdu(conn);
  ^
In file included from net/bluetooth/smp_null.c:32:0:
net/bluetooth/l2cap_internal.h:136:17: note: expected 'struct nano_fifo *' but argument is of type 'struct bt_conn *'
 struct net_buf *bt_l2cap_create_pdu(struct nano_fifo *fifo);

Change-Id: I5fd8ce63da09af1c123b1092624d48edc009756b
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Mariusz Skamra
a1e0b4de4e doc: Add bluetooth PTS 6.3 PICS file for GAP
This patch adds document with current supported PICS for PTS 6.3.

Change-Id: Ib87d9432087225612b01d849eced6ad5c2064f0b
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:08 -05:00
Mariusz Skamra
b96f6daeb9 doc: Add bluetooth PTS 6.3 PICS file for SM
This patch adds document with current supported PICS for PTS 6.3.

Change-Id: I1eb62d500fb8b1bb9ec9162f9b0196858fe22b0a
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:08 -05:00
Johan Hedberg
7be985d507 Bluetooth: h5: Fix coding style issues
Change-Id: Ieb25575ed3ef2bb7439531a95e12a7e65eee3d96
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko
841f7c120f Bluetooth: Add stack analysis for H5 UART driver
Analyze stack when sending single ACK packet.

Change-Id: Ifd3a54f0d1ad9a644363563fa9b8bea05b895fa9
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko
3a415c6bfb Bluetooth: Add unacked queue re-queueing
Change-Id: I2a12e6db72046d5ebc78c932ab5054eadbb4308c
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko
950078b36d Bluetooth: Improve debug for H5 UART driver
Change-Id: I371717d24ff24ab84871b8f29f365e8a65c74832
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko
3663d11a6d Bluetooth: h5: Add initial retransmission support
Reuse delayed fiber start stack

Change-Id: I739efbeebca15ed27c2874c6f56da99f514bbce9
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko
53543c5f6d Bluetooth: Sending ACK packet using delayed fiber method
If there is no packet to be sent after timeout we have to send ACK for
last received packet.

Change-Id: I30bbc4ae1a257f9a7351dc5a5d2f1269740ce447
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko
379ae2d043 Bluetooth: Add three-wire (H5) uart driver
Add initial code for three-wire (H5) Bluetooth uart driver.
At the moment the driver is EXPERIMENTAL. To test use following
method with qemu:

Run btproxy with three-wire emulation patches:
$ sudo tools/btproxy -d --pty -3
Opening pseudoterminal
New pts created: /dev/pts/21
Opening user channel for hci0

Notice that new device created: /dev/pts/21, use it with qemu -serial
parameter.

Run qemu target with following parameters:
$ make qemu 'QEMU_EXTRA_FLAGS=-serial /dev/pts/21'

Change-Id: I51579ffd8088583df9106689a03b2a0b4aa9e4cb
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko
7160c9c95e Bluetooth: Move BT_STACK definitions to log.h
BT_STACK depends on BT_STACK_DEBUG_EXTRA, therefore moving it there.
It also allows to use BT_STACK in drivers, at the moment only
Bluetooth stack uses it.

Change-Id: I41e0e0d49dae6abef2dc3a8d1d109127787d3db0
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Andrei Emeltchenko
e28c5cecd0 Bluetooth: trivial: Correct style
Remove extra line and correct style according to common style.

Change-Id: I5fc9434edce44e52b51fc40866638c0899985b1b
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:25:08 -05:00
Szymon Janc
349a5af841 Bluetooth: Refactor le_ltk_request function
This is in preparation for LE SC only mode support where slave LTK
support is not compiled in.

Change-Id: Ia30ca08010f8aa42752c4a422fd0ddc1fbdb4f31
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Szymon Janc
f0cc127b5f Bluetooth: SMP: Rename gen_method table to gen_method_legacy
Make sure the name reflects that it is used only for legacy pairing.

Change-Id: I757311991e9f879f377978b8adb02c7f9758b6b2
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Szymon Janc
7e1e124b8c Bluetooth: SMP: Separate legacy pairing code
All legacy pairing code is now separated in dedicated helper functions
(with 'legacy' prefix). Main code flow is LE SC oriented and legacy
pairing is always handled as exception from LE SC code:

if (!atomic_test_bit(&smp->flags, SMP_FLAG_SC)) {
  return legacy_foo(smp);
}

This is in preparation for enabling LE SC only mode.

Change-Id: I89705e6b780014417adaed41bd3beaf4791d8d3f
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Szymon Janc
7f2de1dc7a Bluetooth: SMP: Make bt_smp_create_pdu static
This function is not used outside of smp.c file.

Change-Id: Ib2158330959f2b4b1d63695480e82ac506243ab8
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Szymon Janc
68a4aebde4 Bluetooth: SMP: Move some code up in a file
Those will be used in legacy pairing code.

Change-Id: I311e10254a603c2b4cc46c50f6c3d27593a10bd7
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:25:08 -05:00
Louis Caron
7fdb42a46f Bluetooth: add CPF descriptor support
In order to support more standard descriptors, the PF macro and helper
function are added.

Change-Id: I52db3c32f40f39b9c6bfdb9573d0a614d0f3295e
Signed-off-by: Louis Caron <louis.caron@intel.com>
2016-02-05 20:25:08 -05:00
Louis Caron
d566c3314b Bluetooth: add CUD descriptor support
In order to support more standard descriptors, the UD macro and helper
function are added.

Change-Id: Ic9a82658668107b40abc5c98002fe5091dc10f08
Signed-off-by: Louis Caron <louis.caron@intel.com>
2016-02-05 20:25:08 -05:00
Mariusz Skamra
b90d2c6dbd Bluetooth: GATT: Pass bt_conn to the discovery function callback
This patch replaces bt_gatt_attr_func_t with bt_gatt_discover_func_t
to be used as a type of discovery callback. The reason is
bt_gatt_attr_func_t don't return bt_conn which could be used
later on to issue other commands and to application to know
from which connection this results come.

Change-Id: I1f26c72ad5c8a0b97485a337c7005d34281586d7
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:08 -05:00
Mariusz Skamra
5ac044431e Bluetooth: tester: Handle Read Multiple Characteristic Values command
This patch adds Read Multiple Characteristic Values command handler
to the tester. It allows to test if GATT Client can read multiple
values from a GATT Server.

Change-Id: I994ffac73eb8e6c0a7696dc41304efd9f01c35a4
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:08 -05:00
Mariusz Skamra
c3ee5fbcdd Bluetooth: tester: Handle Write Long Characteristic/Descriptor command
This patch adds Long Write Characteristic Value/Descriptor command handler
to the tester. It allows to test if GATT Client writes long values properly.

Change-Id: I788707b0a043ecad6be32d9e1f8d536765ebf41a
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:08 -05:00
Mariusz Skamra
2f1e4e92e9 Bluetooth: tester: Handle Write Characteristic Value/Descriptor command
This patch adds Write Characteristic Value/Descriptor command handler
to the tester. It allows to test if GATT Client performs write
operation properly.

Change-Id: I3afe167c7ca2789df7d288bbc06ffc8479240da8
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:08 -05:00
Mariusz Skamra
b1c8d269ec Bluetooth: tester: Handle Read Long Characteristic/Descriptor command
This patch adds Read Long Characteristic Value/Descriptor command handler
to the tester. It allows to test if GATT Client can read long value from
a GATT Server.

Change-Id: I1c2060f7ecd45ca18ed5f9e0747121236b283631
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:08 -05:00
Mariusz Skamra
4e04f912f1 Bluetooth: tester: Handle Read Characteristic Value/Descriptor command
This patch adds Read Characteristic Value/Descriptor command handler
to the tester. It allows to test if GATT Client can perform read
attribute value from a GATT Server.

Change-Id: If95b8d2d3a5a62048bb6371ae80b2834c20d88e1
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:08 -05:00
Mariusz Skamra
0e774613a4 Bluetooth: tester: Handle Signed Write Without Response command
This patch adds Signed Write Without Response command handler to the tester.
It allows to test if GATT Client can perform signed write operation without
acknowledgement form Server.

Change-Id: I14757e6a52abf87bed68103b2e6fbff200fb6bb8
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:08 -05:00
Mariusz Skamra
51de714eef Bluetooth: tester: Handle Write Without Response command
This patch adds Write Without Response command handler to the tester.
It allows to test if GATT Client can perform write operation without
acknowledgement form Server.

Change-Id: I3663e2e01c0fabfd75e4bedab0955700e3003522
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:08 -05:00
Mariusz Skamra
66cc8faf7a Bluetooth: tester: Handle Discover All Characteristic Descriptors command
This patch adds Discover All Characteristic Descriptors command handler
to the tester. It allows to test if GATT Client can perform discovery of
characteristic descriptors within specified range.

Change-Id: Ieb04b47168249d8d76eab840b4f54b8b6b450792
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:07 -05:00
Mariusz Skamra
2d1b3b5a62 Bluetooth: tester: Handle Discover Characteristics by UUID command
This patch adds Discover Characteristics by UUID command handler
to the tester. It allows to test if GATT Client can perform discovery
of characteristics based on known UUID.

Change-Id: Iab78ea7e5bc85e1fadc46b7e8f5b28ee4b9db16d
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:07 -05:00
Mariusz Skamra
b01cc79923 Bluetooth: tester: Handle Discover All Characteristics command
This patch adds Discover All Characteristics command handler to the tester.
It allows to test if GATT Client can perform discovery of all
characteristics contained within specified range.

Change-Id: Ib70abaf1365fe4a73757507148723e66881b01de
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:07 -05:00
Mariusz Skamra
469ea4ee10 Bluetooth: tester: Handle Find Included Services command
This patch adds Find Included Services command handler to the tester.
It allows to test if GATT Client can perform relationship discovery.

Change-Id: I76c12fcd5e79d906b4e29b926a82a2022e505c40
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:07 -05:00
Mariusz Skamra
ee178fe665 Bluetooth: tester: Handle Discover primary services by UUID command
This patch adds Discover Primary Services by UUID command handler
to the tester. It allows to test if GATT Client can perform discovery
of primary services based on known service UUID.

Change-Id: If5788c6f23481c7b4af85834bf8b113a97a4b66d
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:25:07 -05:00