Commit graph

30 commits

Author SHA1 Message Date
Johan Hedberg e25d925242 Bluetooth: Defer RL update if there's an ongoing connection
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-06 12:50:40 +02:00
Johan Hedberg 56f79f817e Bluetooth: Add support for Link Layer Privacy
Add support for loading IRKs into the controller as well as the LE
Enhanced Connection Complete HCI event. To simplify things, the old LE
Connection Complete handler translates its event into the new enhanced
one which is then the single place of processing new connection
events.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-06 12:50:40 +02:00
Johan Hedberg 7762578de4 Bluetooth: Simplify and clean up LE scan handling
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-06 12:50:40 +02:00
Johan Hedberg aaeff3c165 Bluetooth: Add basic host-side support for HCI vendor extensions
Add skeleton for HCI vendor extenstions and convert the nRF5x-specific
static address setting to use the HCI VS commands instead.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-10-17 15:01:54 +03:00
Johan Hedberg 2975ca0754 Bluetooth: Kconfig: Rename CONFIG_BLUETOOTH_* to CONFIG_BT_*
The API name space for Bluetooth is bt_* and BT_* so it makes sense to
align the Kconfig name space with this. The additional benefit is that
this also makes the names shorter. It is also in line with what Linux
uses for Bluetooth Kconfig entries.

Some Bluetooth-related Networking Kconfig defines are renamed as well
in order to be consistent, such as NET_L2_BLUETOOTH.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-09 11:14:19 +03:00
Carles Cufi 6c9e563c92 Bluetooth: Move common code to common/
Since more and more code is going to be reused by both the Host and the
Controller, this commit introduces a common/ folder that will contain
everything that is not tied to one of the two components but shared by
them.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-05-12 12:56:14 +03:00
Vinayak Kariappa Chettimada 2a40bf6a87 Bluetooth: Add LE Features test macro
Added HCI macros to check LE Features. Also, added test
macros for 2M and Coded PHY support in HCI Controller.

Earlier a common test macro was used between BR/EDR and LE,
but since LE features do not use pages for feature, an
explicit macro for testing LE feature is added now.

Also, features field in LE device structure is now a single
dimension array of 8 octets.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-05-10 07:30:16 +03:00
Johan Hedberg d1bb961bcf Bluetooth: Remove unnecessary bt_dev_esco struct
This information should be part of the main BR/EDR context struct,
rather than there being a separate member in struct bt_dev. If/when
the needed ESCO information grows we can consider having a separate
struct, but even then it should be part of the main BR/EDR struct
instead of sitting directly in bt_dev.

Change-Id: I3edf120606ea6c6974f515bba90de2b25fc6fac6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-04-29 11:39:13 -04:00
Johan Hedberg 97f0241c07 Bluetooth: Fix alignment issues resulting from new integer types
The switch from C99 integer types to u16_t, etc. caused misalignment
in structs and function definitions with multi-line parameter lists.

Change-Id: Ic0e33dc199f834ad7772417bca4c0b2d2f779d15
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-04-29 11:39:13 -04:00
Kumar Gala d0eb235510 Bluetooth: convert to using newly introduced integer sized types
Convert code to use u{8,16,32,64}_t and s{8,16,32,64}_t instead of C99
integer types.

Jira: ZEP-2051

Change-Id: I8f57a17f78e674aca5400f005db8975c9f9e150e
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-04-20 13:25:23 -05:00
Johan Hedberg 4be4c60ab6 Bluetooth: Add support for tracking transmitted packets
Protocols/profiles may want to know when exactly their PDU has been
transmitted over the air. To make this possible, introduce support for
a callback that will get called when the controller reports that a
packet has been transmitted (through the Number of Completed Packets
HCI event).

Change-Id: Ia3a19b93c5b2111f144bfabe5861187c41525f30
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-04-20 09:59:33 +00:00
Johan Hedberg 757fd755a6 Bluetooth: Remove unnecessary controller-side buffers tracking
When there's no support for connections there's also no need to track
the controller side buffers.

Change-Id: I7eac3af486f139f1ab32efda8ccfa188ed8359eb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-04-08 20:11:54 +03:00
Johan Hedberg 5517893543 Bluetooth: Make bt_hci_driver instances link-time constants
Declaring these as const lets the linker generate more optimal code.
Some extra care is needed with hci_ecc.c since it was overwriting the
send callback. Now the choice of send() call is done directly in the
bt_send() function

Change-Id: Iac74f5ee9bee097bbb34c11bd13d1d886700f5cc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-03-21 17:05:42 -07:00
Sathish Narasimman e51a19fdc2 Bluetooth: HFP HF: SCO: Accept eSCO conn request
1. Accept the incoming Synchronous connection request and establish
a new sco connection object.
2. Enable sco conn complete in event_mask

> HCI Event: Connect Request (0x04) plen 10           [hci0] 126.198264
        Address: 48:9D:24:1F:4D:1D (BlackBerry RTS)
        Class: 0x7a020c
          Major class: Phone (cellular, cordless, payphone, modem)
          Minor class: Smart phone
          Networking (LAN, Ad hoc)
          Capturing (Scanner, Microphone)
          Object Transfer (v-Inbox, v-Folder)
          Audio (Speaker, Microphone, Headset)
          Telephony (Cordless telephony, Modem, Headset)
        Link type: eSCO (0x02)
< HCI Command: Accept Synchronous Co.. (0x01|0x0029) plen 21
        Address: 48:9D:24:1F:4D:1D (BlackBerry RTS)
        Transmit bandwidth: 8000
        Receive bandwidth: 8000
        Max latency: 7
        Setting: 0x0060
          Input Coding: Linear
          Input Data Format: 2's complement
          Input Sample Size: 16-bit
          # of bits padding at MSB: 0
          Air Coding Format: CVSD
        Retransmission effort: Optimize for power consumption (0x01)
        Packet type: 0x0006
          HV2 may be used
          HV3 may be used
> HCI Event: Command Status (0x0f) plen 4           [hci0] 126.205171
      Accept Synchronous Connection Request (0x01|0x0029) ncmd 1
        Status: Success (0x00)

Change-Id: I71597aef94e945a9c07be1960994ad20c1b44bb3
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
2017-03-08 15:35:28 +00:00
Sathish Narasimman 5490c80383 Bluetooth: HFP HF: SCO: Add esco supported pkt type
From the response of read_local_supported_feaatures check if local
device supports eSCO packet type and update it to bt_dev.
Also added sco field in bt_dev

Change-Id: If85b3d24d327a6243318fad89a07375a8253f89b
Signed-off-by: Sathish Narasimman <sathish.narasimman@intel.com>
2017-03-08 15:35:06 +00:00
Johan Hedberg dc70415dc4 Bluetooth: Merge HCI command and connection TX threads
We can go further with taking advantage of k_poll and merge the
connection TX thread together with the HCI command thread, thereby
saving even more memory.

Change-Id: I1792056fd4621d62c7cd05929094033acca45c74
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-02-05 22:39:25 +02:00
David B. Kinder ac74d8b652 license: Replace Apache boilerplate with SPDX tag
Replace the existing Apache 2.0 boilerplate header with an SPDX tag
throughout the zephyr code tree. This patch was generated via a
script run over the master branch.

Also updated doc/porting/application.rst that had a dependency on
line numbers in a literal include.

Manually updated subsys/logging/sys_log.c that had a malformed
header in the original file.  Also cleanup several cases that already
had a SPDX tag and we either got a duplicate or missed updating.

Jira: ZEP-1457

Change-Id: I6131a1d4ee0e58f5b938300c2d2fc77d2e69572c
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2017-01-19 03:50:58 +00:00
Johan Hedberg 645f867444 Bluetooth: Take advantage of IS_ENABLED macro for BT_DBG
The new IS_ENABLED macro allows exposing conditionally enabled code
always to the compiler, even though it may not ultimately end up being
built. This is in particular useful for letting the compiler catch any
logging format string errors. Introduce a new BT_DBG_ENABLED macro
that c-files need to define before including <bluetooth/log.h> in
order to choose whether BT_DBG() logs are enabled or not.

When no Bluetooth logs are enabled the patch also modifies the log
macros to have the format strings checked with the help of the
__printf_like annotation and empty static inline functions.

Change-Id: Ie6bc8e10727b5b306f3ed0f94089a07a22583d9b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-18 08:28:06 +02:00
Johan Hedberg e564de0deb Bluetooth: Prefer struct bt_le_conn_param over individual values
This reduces stack pressure a little bit, and also paves the way for
introducing an application callback for accepting an incoming
connection parameter update request.

Change-Id: Ib02c14e27cbe34f85d663f36abd0597683ae1dc1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-17 08:44:21 +02:00
Johan Hedberg 0a3a108762 Bluetooth: Introduce support for HCI driver-side RX thread
Add support for using the context bt_recv() is called in as the RX
thread, rather than having a separate host-side RX thread.

Change-Id: I256bfe5dece5272c816f2292e58747553189963d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-01-05 08:49:16 +02:00
Johan Hedberg 758e220cdc Bluetooth: Remove inline declaration from bt_le_conn_params_valid
The function is not particularly small, and is used from several
places, so remove the inline declaration. This also prepares the way
for the possibility of having an application callback for letting the
application choose whether it's fine with the proposed parameters, and
thereby influence the response we send to the remote device.

Change-Id: I5848b179318b6fb6ee37fcbd479a919204f559f1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-16 10:27:48 +02:00
Johan Hedberg d883fcf814 Bluetooth: Make LE random address helpers public
Expose helpers in hci.h for setting and getting the LE random address
type.

Change-Id: I7c6437051f0b2d1f5f79e19b2616bb643ae6300b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-09 08:18:24 +02:00
Johan Hedberg cb84ad1ad6 Bluetooth: Fix coding style issues in LE address helper functions
Even one-line branches should have {}, and the last two return
statements can be simplified into a single one.

Change-Id: I0f65aeaba867240255eae8e1c461386700444ae6
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-12-03 17:09:38 +00:00
Szymon Janc 70417f1fce Bluetooth: Simplify ncmd handling
With k_sem API it is possible to specify maximum sempahore value
so we no longer need to track semaphore count.

Change-Id: I86744ba63bd3207051ca3466d4f81b816d24f5ad
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-12-03 17:09:38 +00:00
Johan Hedberg 81975637dc Bluetooth: Rename left-over mentions of "fiber" to "thread"
Rename left-over mentions in code comments of "fiber" to "thread".

Change-Id: I1af1baf99652434e90eb491c10238b94d26d341d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-11-11 10:06:05 +02:00
Luiz Augusto von Dentz 203897d04e Bluetooth: HCI: Fix using nano_delayed_work API
This fixes warnings related to the use of nano_work and
nano_delayed_work in HCI layer.

Note that k_delayed_work takes a timeout in miliseconds rather than in
ticks thus the timeout values have been changed.

Change-Id: I953a82a6aa613bb1072a8ad4b01e0f94e5cd64bd
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-11-11 07:59:15 +02:00
Szymon Janc 47eaaf9f96 Bluetooth: Use unified k_fifo API for FIFOs
Change-Id: I6ddc24575e4bf3c3040945a2bdb62f153b15cdb3
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-11-11 07:59:15 +02:00
Szymon Janc 8f800a8bfe Bluetooth: Use unified k_sem API for semaphores
Change-Id: I0099c837cc8ad67b8f927b2debd771acfe626eea
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-11-09 08:57:52 +02:00
Johan Hedberg f26007d212 Bluetooth: Print full controller info upon init
Provide more detailed information about the controller address and
version upon init when debug is enabled.

Change-Id: I5fe9c7c91f95928cb3cc64b801137bb1466e4115
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-11-04 22:06:31 +02:00
Johan Hedberg 6bc645962a Bluetooth: Move Bluetooth host stack to subsys
Move the Bluetooth host stack from net/bluetooth to
subsys/bluetooth/host. This is preparation for having both host and
controller under the same root, i.e. subsys/bluetooth/.

Change-Id: I3bc796f7e331fca0c485f3890d62b9c03e027b96
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-11-04 22:05:05 +02:00
Renamed from net/bluetooth/hci_core.h (Browse further)