Commit graph

169 commits

Author SHA1 Message Date
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
Johan Hedberg 966acc1980 Bluetooth: Don't default to continuous scanning with BT_LE_SCAN_ACTIVE
Change-Id: I76d7db24bb9459f1df1d1e9881accc970b60aaf8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:03 -05:00
Johan Hedberg 4087728345 Bluetooth: Provide API to advertise with local NRPA
Applications may want to protect the privacy (identity of the local
device). One way to do this is to generate a Non-resolvable Private
Address and use that when advertising.

Change-Id: Ib852b03c14af062f914aa99a14e50c2e52ac78c2
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg 47044cd677 Bluetooth: Add advertising interval to LE adv params API
Change-Id: Id61589ca723c822ea8eb84c67ac9ed57b00cc305
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg 9533fbcfe1 Bluetooth: Add latency & timeout to LE conn param API
Change-Id: Icd6122b9056dd686d70a2d213a18dcab34f5e80a
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg 1a32d5ed55 Bluetooth: Add support for specifying connection parameters
Applications may want fine-grained control of connection parameters.
The two APIs to provide this through are bt_le_set_auto_conn() as well
as bt_conn_create_le().

Change-Id: If5cddbbf017b868d768d18d2a09daf4af8aa00d8
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:02 -05:00
Johan Hedberg 70669756ff Bluetooth: Add convenience macros for defined GAP timers
Change-Id: I6315c7791249d07fa2df0682decc0049718b5a06
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg 266721018d Bluetooth: Add proper defines for scan enable parameters
Change-Id: I2d915517986007356c14e805eaed60a0f4290109
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg 5a5061ef97 Bluetooth: Convert bt_conn_set_auto_conn to bt_le_set_auto_conn
Once we start persistently storing the addresses of devices we want to
reconnect to we also need a way to reload them to the stack. Since we
don't have a connection object at this point the API cannot take that
as a parameter. Instead rename the function and have it take
bt_addr_le_t as a parameter.

The feature was also lacking proper reference counting for the
connection, which this patch now adds (the flag itself owns a
reference). The function is now also possible to call before bt_init()
so that if we load the stack with multiple devices the HCI doesn't get
bombarded with lots of scan enable/disable commands.

Change-Id: I9072bf061eb64f2ecec96f74fb176be13e5bdaee
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg 3226780a3c Bluetooth: Add LE scan interval & window to bt_le_scan_param
Change-Id: If2ae26625b98485c3495f4f4f48e49600a1ffd14
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg 610d32311e Bluetooth: Add LE scan type to bt_le_scan_param
This way the app can start passive scanning if it wants.

Change-Id: Iab3e60863d5a1a013a5f069a98664628c7b14418
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg dd353487c4 Bluetooth: Create active scanning helper macro
All current user just want basic active scanning so a corresponding
macro makes more sense than something based on duplicate filtering.

Change-Id: I97787be24b89fad66f2a952c5d53ab76f4e062fb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:01 -05:00
Johan Hedberg f5a238b665 Bluetooth: Add ability to specify dedicated LE advertising parameters
We'll need to have a much more flexible LE advertising API. This is a
first step in that direction. A convenience BT_LE_ADV() macro is
provided to ease converting application code.

Change-Id: I74854487bbdfb4b1cf1bee0b6351d1750a56ff86
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg 6f470dcbce Bluetooth: Add ability to specify dedicated LE scan parameters
We'll need to have a much more flexible LE scanning API. This is a
first step towards it. The existing BT_LE_SCAN_FILTER_DUP_* enum
values are converted to macros to avoid having to update application
code at this point.

Change-Id: I0c8d29dc156bad67cddc9401c0d72aee8ec6d8de
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg 52989aeecc Bluetooth: Move bt_le_scan_cb_t definition to better place
Change-Id: I9b17d2237654e651465d054f60f6c4e44576250b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg f1d4b686b6 Bluetooth: Rename bt_bredr_* prefix to bt_br_*
bt_br_* is equally understandable and the same length as the
corresponding bt_le_* prefix on the LE side.

Change-Id: I1820f9b9fab6363b696072f6b70d57c0bc780078
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Johan Hedberg 5619d1114b Bluetooth: Rename LE scan & advertising APIs for consistency
To have a clear split between LE & BR/EDR rename these APIs with the
appropriate prefixes.

Change-Id: I983df2b5880947d96f0ad289d12f3383f44894be
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:25:00 -05:00
Arkadiusz Lichwa 2ebf636fe2 Bluetooth: BR/EDR: Add basic SCAN support
Adds capability to stack to make controller discoverable and
connectable.

Change-Id: Iffe380d2bde0c193f806b76cce3933914c9a4796
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:24:59 -05:00
Szymon Janc 48249bf34a Bluetooth: Add public API for passkey confirmation
This allows to request user to confirm displayed passkey with remote
device. This allows to have authenticated LE SC link resulting in FIPS
security level.

Change-Id: I5b6c1666e3d1687cc04c5d66529372db090dd000
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:51 -05:00
Johan Hedberg 3822aecd24 Bluetooth: Merge buf.[ch] functionality into hci_core.[ch]
There's no need to maintain a separate module for this anymore.
Subsequent patches will have further simplifications thanks to this
being now handled in a single c-file.

Change-Id: I4510c9f72b121e1e5fd19eeb8b5d5ddf2f4bfffe
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:24:39 -05:00
Dan Kalowsky 978851fb6a checkpatch: code_indent failures
Corrects the checkpatch code_indent failures

Change-Id: I2ff93b8907d3eddbaa543ccbd12aecef8af7f698
Signed-off-by: Dan Kalowsky <daniel.kalowsky@intel.com>
2016-02-05 20:24:31 -05:00
Javier B Perez Hernandez f7fffae8aa Change BSD-3 licenses to Apache 2
Change all the Intel and Wind River code license from BSD-3 to Apache 2.

Change-Id: Id8be2c1c161a06ea8a0b9f38e17660e11dbb384b
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
2016-02-05 20:24:29 -05:00
Szymon Janc 68382388ce Bluetooth: Disable parts of public API if not configured
Depending on selected Kconfig options some parts of public API
are disabled with #ifdefs. This should make it easy for user to
figure out which options should be enabled to specific API.

Change-Id: I4ae1bfd7bf535ea45869772c429ccd3d3d4c214e
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:24:24 -05:00
Szymon Janc 01c76d9fa4 Bluetooth: SMP: Add support for passkey entry
This allows to request passkey being entered by user.

Change-Id: I6a56c65ca689473659a13c19f8578058476d2685
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:37 -05:00
Szymon Janc 947f7100c5 Bluetooth: Validate callbacks in bt_auth_cb_register
This adds validation for passed callbacks. Previously registered
callbacks need to be explicitly unregistered by passing NULL.
It is no longer possible to implicitly overwrite callback
structure.

Input Output Capabilities generation is factored out to separate
function. This is in preparation for adding more callbacks.

Change-Id: Ie809ea2daa80f9c54585efb459b49af1107007d3
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:24 -05:00
Szymon Janc 8423871b90 Bluetooth: Add initial support for authenticated pairing
This allows to register agent with display capability resulting
in DisplayOnly InputOuput Capability being used.

Change-Id: I98931af35c51a71882b60303c0f5d4da19eefbc4
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:24 -05:00
Szymon Janc faec70c367 Bluetooth: Move security levels to conn.h
For now this is used only in conn.h. Allows to reduce includes
dependencies.

Change-Id: I60dbe588e711fa0332049cbea43ffb6838a58823
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-02-05 20:15:24 -05:00
Johan Hedberg 79696d3b34 Bluetooth: Redesign Bluetooth init API
We need to be able to perform the init procedure asynchronously
through a callback. The RX fiber is a good candidate to use for the
callback since it's not active in its normal operation before
drv->open has been called. In order to prepare for a future
bt_disable() API the init API is renamed from bt_init() to
bt_enable(). If a NULL pointer is given as the callback the API
behaves synchronously like the old bt_init().

Change-Id: I4e78fa8f32dcf5477ea05a8db75aca5cdce591fd
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:44 -05:00
Mariusz Skamra 6b4f7025f2 Bluetooth: Start using atomic flags to indicate bt_dev state
With this patch advertising state and scanning state are stored as flags.

Change-Id: I5d2dc37972620ee89aaf55d45e294e8be82863d3
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:43 -05:00
Johan Hedberg fe41cec885 Bluetooth: Move bt_security to conn.h and rename it appropriately
Change-Id: Ibea6e4ef08c68e9debf0c53036dd2e4f75ea9a72
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg a33047f7a5 Bluetooth: Move bt_connect_le to conn.c and rename it appropriately
This function operates on bt_conn so it should be in conn.c and
exported through conn.h. Rename it with the appropriate bt_conn_*
prefix.

Change-Id: Id17c67f0e95cc1afb10aa7742b2d2ce0110ea616
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Johan Hedberg 824135122f Bluetooth: Move bt_disconnect to conn.[ch] and rename it appropriately
The bt_disconnect deals with the bt_conn object and should therefore
reside in conn.c and be exported through conn.h. It should also have
the appropriate bt_conn_* prefix.

Change-Id: I75eb648fd9aa8ced9a991d472c319d25f4b772af
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:40 -05:00
Mariusz Skamra f45bbec4a1 Bluetooth: hci: Add bt_stop_advertising
This adds above function to stop ongoing advertising.

Change-Id: I16b3913524a61e844a81cbe733f2b8e6072ab442
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:39 -05:00
Johan Hedberg 410a8a8165 Bluetooth: Fix doxygen documentation for bt_connect_le()
Change-Id: Ib40d5a23ee60dad16686f43dee172a31c456e7e1
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:39 -05:00
Mariusz Skamra 296c76c7a8 Bluetooth: Fix status returned by bt_stop_scanning and bt_start_scanning
If the Command Complete status is read, this status shall be returned.

Change-Id: Ic3fe102c16da4b01d002a2d39952fd401e9f832d
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:34 -05:00
Anas Nashif 20764a2e8d doxygen: javadoc style
Change all occurances of /*! to /** to match javadoc
style.

Change-Id: I3a759d34e0e928216f61252682266e64c5b875f8
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-02-05 20:14:32 -05:00
Mariusz Skamra 30b50a3227 Bluetooth: Cancel pending connection
Adds HCI routine to cancel creation of outgoing connection.
bt_disconnect is called to cancel connection or disconnect based on current
connection state.

Change-Id: I462a61308a580bb24aa9a6c398eb7e443b995655
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:31 -05:00
Arkadiusz Lichwa b62f778664 Bluetooth: Start outgoing connection with tracking
Enables make outgoing connection with error handling.
Free connection objects maintained in polls are assigned to active
connection by result of lookup on the polls based on input
peer LE address.
Updates shell application to reflect above changes in stack.

Change-Id: Ibc71343c0d122cc78c48bac2ff1e50533369b7d2
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-02-05 20:14:31 -05:00
Szymon Janc a14314e913 Bluetooth: Move security related code to bluetooth.h
Also rename bt_conn_security function to bt_security and
bt_conn_security_t to bt__security_t.

Change-Id: I543c7b97241c4389ef0eb491b6869f93105ae533
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:31 -05:00
Johan Hedberg 32388b9a5f Bluetooth: Clean up doxygen documentation in bluetooth.h
Make the documentation style consistent and add documentation to
functions that were missing it.

Change-Id: I1822480a604bb2efcb0dbfc63ae0675ebf4b5987
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:24 -05:00
Johan Hedberg 55218cd6de Bluetooth: Be consistent with the spelling of 'Bluetooth'
Change-Id: Ic9cbfe792f0b46071e38b52d1e082ce1da83e708
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:24 -05:00
Arkadiusz Lichwa 1d748ba760 Bluetooth: Address conversion user helpers
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>
2016-02-05 20:14:24 -05:00
Arkadiusz Lichwa d81689e915 Bluetooth: Introduce LE scan callback
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>
2016-02-05 20:14:24 -05:00
Johan Hedberg fe669a52e8 Bluetooth: Clean up document style in bluetooth.h
Change-Id: Icd5cbda6ff73b7f4b2d6a4183bb23138fd1ad0be
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:23 -05:00
Johan Hedberg 8c26ce63d1 Bluetooth: Remove bt_hci_reset() API
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>
2016-02-05 20:14:23 -05:00
Johan Hedberg 9bea2c3cfc Bluetooth: Move HCI driver API to dedicated header file
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>
2016-02-05 20:14:23 -05:00
Johan Hedberg 939544b75d Bluetooth: Move logging helpers to a dedicated header file
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>
2016-02-05 20:14:23 -05:00
Szymon Janc 19fe40764c Bluetooth: Make bt_stop_scanning parameters explicit void
Change-Id: I47ece76e00719d2fef702763c061055a1e9c5f76
Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
2016-02-05 20:14:23 -05:00
Mariusz Skamra b2574b645b Bluetooth: Terminate connection
Adds routine for termination of connection.

Change-Id: I444e4cba3297c51fbd9f89bbdba89db45af195c6
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:23 -05:00
Arkadiusz Lichwa f5ae4b70f1 Bluetooth: Add basic interface for LE connection
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>
2016-02-05 20:14:23 -05:00
Johan Hedberg 2b61b44cbc Bluetooth: Add conn.h public header file
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>
2016-02-05 20:14:23 -05:00
Andrei Emeltchenko fab2d401a1 Bluetooth: Document bt_init and bt_start_advertising
Functions bt_init and bt_start_advertising are referenced in the
doxygen documentation. Documenting them gives better overview.

Change-Id: I70cb19a0a3232ce5abfb22c3a352bf3868c6f8fb
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:19 -05:00
Mariusz Skamra 7f1bff8b2d Bluetooth: Add callbacks for connections
This patch adds callbacks to notify app about connection and disconnection.

Change-Id: If8091254d929fe53d12b153e6f216223a8913f2d
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
2016-02-05 20:14:18 -05:00
Johan Hedberg 451b105978 Bluetooth: Use __packed instead of the deprecated PACK_STRUCT
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>
2016-02-05 20:14:18 -05:00
Johan Hedberg 6e20c3b838 Bluetooth: Move all logs behind CONFIG_BLUETOOTH_DEBUG
The BLUETOOTH_DEBUG config option bumps the stack sizes to cope with
printf requirements. Since all the logs use printf now they should
only be available with the bigger stack sizes to avoid surprises.
There are still basically two levels of log enabling where
BLUETOOTH_DEBUG enables the ERR/WARN/INFO everywhere and the
BLUETOOTH_DEBUG_* enables BT_DBG for a specific subset of the stack.

Change-Id: Ie8d64e47f44485efde32b40cd5bb34389c8e39da
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:03 -05:00
Andrei Emeltchenko fa77083bf4 Bluetooth: Fix printf specifier for debug
printf() '%x' expects type 'unsigned int' for 'x', but parameter has
pointer type.

Change-Id: Id2d365a32b2e3e711359bd56741370d8167db868
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:14:02 -05:00
Johan Hedberg d6600e075f Bluetooth: Include context ID in debug logs
Including the context ID in debug logs can help track down various
issues, e.g. stack corruption.

Change-Id: I3cd70edd5bfd1d726f6d35e7331afb313cf3cacb
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:02 -05:00
Johan Hedberg 8930a13b60 Bluetooth: Prefer printf over printk
The printf API has a much richer support for various format
specifiers. Switch the Bluetooth logging macros to use printf instead
of printk and make sure STDOUT_CONSOLE gets selected when
BLUETOOTH_DEBUG is selected (so printf actually works).

Change-Id: I9a9818d51a677c6c79a35fef6daca7979f61c78d
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:14:02 -05:00
Yonattan Louise d133f9661d Fix checkpatch issue - WARNING:SPACING
This commit fixes the issue marked as SPACING by the checkpatch script
deleting the whitespaces between the function name and the open parenthesis.

Change-Id: I972b1646904bf6e1131263f94ab5024a528ae07d
Signed-off-by: Yonattan Louise <yonattan.a.louise.mendoza@intel.com>
2016-02-05 20:13:59 -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
Luiz Augusto von Dentz b3cdfed003 Bluetooth: Extend advertising API
Extend bt_start_advertising to make it possible to add any data type
instead of just the name.

Change-Id: I3f2afe1eb64aec51f321f7fd7439e97b3d67374c
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-02-05 20:13:56 -05:00
Andrei Emeltchenko b3e25209a8 Bluetooth: Add BLUETOOTH_DEBUG configuration option
BLUETOOTH_DEBUG option enables extensive debug output to serial
console. Disabled by default.

Change-Id: I71a6ca4c4f1dfb5bd818e6b8320a07249befadfb
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg 50a25dcfd3 Bluetooth: Add BT_WARN convenience logging macro
Some logs indicate potentially problematic situations but are not
necessarily errors. Since we do want to log these regardless of the
debug setting it's better to have a separate BT_WARN macro for them.

Change-Id: Iad13fc4b58329113458c97b02855033836618f5b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg 429240d376 Bluetooth: Move buffer handling into a dedicated file
The buffer handling code is quite large and will continue to grow. As
it's not strictly HCI core material it's better to just manage it in a
separate file. This patch moves the code to include/bluetooth/buf.h
and net/bluetooth/buf.c.

Change-Id: Ie1ff79ac2cfa132359ce9f7674ff812d34b228aa
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:50 -05:00
Johan Hedberg a6fbfe4bc1 Bluetooth: Add simple advertising enabling API
This patch adds a simple API for enabling advertising and specifying
the friendly name in the advertising data. The API is probably not a
final one but fulfills the initial need to create apps that are able
to act in the LE peripheral role.

Change-Id: I3ff7e72ece377d872ef1b0e4ad44aeb293cc13e5
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:49 -05:00
Johan Hedberg d210d306d7 Bluetooth: Add full HCI initialization routine
This patch adds a full HCI initialization routine to retrieve all
relevant information from the controller.

We also need to introduce a new blocking bt_hci_cmd_send_sync() API
since some commands are conditional to the results of others. The API
is implemented with the help of a semaphore that's part of the
command's bt_buf struct. We wait on the semaphore and get it back once
the command has completed (with the help of the hci_cmd_done
function).

The patch also adds variables for storing various controller specific
parameters which will be needed later during the operation of the
stack. These variables are part of 'struct bt_dev' and get updated
through the respective command complete handlers.

A new bt_hci_reset() API is added which allows an application to reset
the controller state at any time by re-running the HCI init procedure.

Change-Id: I5b1a38e910d79ad5fe806467bc51388eedc9c8f9
Co-authored-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:44 -05:00
Johan Hedberg 23a0df8b9b Bluetooth: Add HCI driver API
This patch adds a basic HCI driver registration API along with a fiber
to process data from the driver. A FIFO is used for receiving data
from the driver and waking up the respective fiber. To open and set up
the HCI transport for operation there's an open() callback passed to
the HCI core. This function will be called as soon as an application
initializes Bluetooth functionality through bt_init().

Change-Id: I780cca517a0dfc714f1ca35527e1c61e307345a0
Co-authored-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:44 -05:00
Johan Hedberg 64b117a9b1 Bluetooth: Add support for HCI data buffers
In order to manage incoming and outgoing HCI data (events, commands &
ACL data packets) we need to have some way of storing this into
buffers. This patch implements a 'pool' of buffers with the help of
the nano_fifo API. The pool is initially populated with all available
buffers. After this code can on demand request buffers from the pool
with the help of bt_buf_get() and return buffers back into the pool
with bt_buf_put().

Since we don't always know the execution context from where the API is
operated on, this patch also adds convenience fifo_get/fifo_put
wrappers that look up the exact context before calling the correct
nano_fifo API.

Change-Id: Ie7f6d450de865273171e21a000d5a14274d27d32
Co-authored-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:44 -05:00
Johan Hedberg ac63429177 Bluetooth: Add skeleton for HCI core
To introduce the Bluetooth stack to the tree we need some additions to
the configuration options, as well as the very basic header files. The
patch also adds a skeleton for a bt_init() function that applications
will need to call to initialize Bluetooth functionality.

Change-Id: Ideb24dfea584b71f514e05eb47654b659776133e
Co-authored-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-02-05 20:13:44 -05:00