Commit graph

169 commits

Author SHA1 Message Date
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