Commit graph

922 commits

Author SHA1 Message Date
Anas Nashif 9ab2a56751 cleanup: include/: move misc/printk.h to sys/printk.h
move misc/printk.h to sys/printk.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Anas Nashif e1e05a2eac cleanup: include/: move atomic.h to sys/atomic.h
move atomic.h to sys/atomic.h and
create a shim for backward-compatibility.

No functional changes to the headers.
A warning in the shim can be controlled with CONFIG_COMPAT_INCLUDES.

Related to #16539

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-27 22:55:49 -04:00
Johan Hedberg 46ea1df2ec Bluetooth: Fix not using log_strdup() for bt_uuid_str()
The string returned by bt_uuid_str() is not in ROM so log_strdup()
must be used on it. This also eliminates the following kind of warning
messages: "<err> log: argument 3 in log message "%s: start_handle
0x%04x end_handle 0x%04x type %s" missing log_strdup()."

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-06-26 13:37:44 +02:00
Peter A. Bigot 587c35fa64 Bluetooth: gatt: avoid assumptions about characteristic handles
Although the Characteristic Value descriptor is required to be
immediately after the characteristic descriptor, the specification
allows for gaps in the corresponding Attribute handles.  Use the value
handle from the characteristic descriptor for value reads.

See BLUETOOTH CORE SPECIFICATION Version 5.1 Vol 3, Part G section 2.5.1
(p. 2345), first paragraph.

Signed-off-by: Peter A. Bigot <pab@pabigot.com>
2019-06-25 18:24:32 +02:00
Anas Nashif f2cb20c772 docs: fix misspelling across the tree
Found a few annoying typos and figured I better run script and
fix anything it can find, here are the results...

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2019-06-19 15:34:13 -05:00
Johan Hedberg 17cd196632 Bluetooth: Increase BT_BUF_USER_DATA_MIN to 8
Commit b65fe62719 updated the minimum
required net_buf user data to 8 bytes, so increase this define as
well. It has no other practical purpose except to trigger build
asserts if the user data is for some reason ever decreased below this
minimum.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-06-19 11:07:27 +03:00
Johan Hedberg 4396dc9c71 Bluetooth: Simplify bt_gatt_notify_cb() API
This API had several issues:

 - The parameter types and order were inconsistent with e.g.
   bt_le_adv_start()
 - There were no real users of num_params, which just caused increased
   code size and memory consumption for no good reason.
 - The error handling policy was arbitrary: if one of the
   notifications would fail it would be impossible for the caller to
   know if some notifications succeeded, i.e. at what point the
   failure happened. Some callers might also want to make note of the
   failure but continue trying to notify for the remaining parameters.

The first issue is easily fixable, but because of the other two I
think it's best we don't have this code as part of the stack, rather
require whoever needs it to do the for loop themselves. It's just a
few lines of code, so the benefit of having this in the stack was
anyway quite minimal.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-06-15 10:37:19 +03:00
Tobias Svehagen 1c84d7c5eb Bluetooth: Change from bitfields to normal types
Since the bt_mesh_msg_ctx struct no longer has a size that is a
multiple of 2, the bitfields might as well be made to normal types
as this will minimize the code generated to access them.

Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
2019-06-12 15:51:04 +03:00
Tobias Svehagen 4866fa9e58 Bluetooth: Make RSSI value available to mesh applications
By moving the rssi value from the bt_mesh_net_rx struct to the
bt_mesh_msg_ctx struct, it will be available to applications via
the mesh op callbacks.

Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
2019-06-12 15:51:04 +03:00
Luiz Augusto von Dentz 2699d05e45 Bluetooth: Fix BT_ATT_ENFORCE_FLOW
This moves the processing packets of upper layers from RX thread to the
system workqueue so they have the same priority as the TX callbacks
which has the added benefit of making any protocol on top of L2CAP to
be executed using system wq stack.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-06-05 16:45:57 +03:00
Luiz Augusto von Dentz dcf253a1d2 Bluetooth: GATT: Document the context in which callbacks are run
This documents the context in which callbacks are run, that is now
the System Workqueue.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-06-04 09:52:47 +03:00
Luiz Augusto von Dentz 648a53d50f Bluetooth: GATT: Add support to notify by UUID
This reworks bt_gatt_notify_cb to allow passing an UUID, in addition to
that it can now accept multiple notification at once as there could be
multiple instance of the same UUID the user can set multiple set of
parameters.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-06-04 09:52:47 +03:00
Luiz Augusto von Dentz a5c07aa7fb Bluetooth: GATT: Add bt_gatt_foreach_attr_type
This adds bt_gatt_foreach_attr_type which can match attribute by UUID
and/or attribute user_data, in addition of that the user can also limit
the number of matches.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-06-04 09:52:47 +03:00
Luiz Augusto von Dentz c904a45d8f Bluetooth: L2CAP: Add callback to notify status
This adds a new callback for L2CAP channels which notities whenever
status has changed so the channel user can can for example resume or
suspend sending depending on the status.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-29 16:31:03 +03:00
Luiz Augusto von Dentz d8f20fe1e0 Bluetooth: L2CAP: Add sent callback
This adds a new callback to bt_l2cap_chan_ops which is called whenever a
SDU is completely sent.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-29 16:31:03 +03:00
Luiz Augusto von Dentz b65fe62719 Bluetooth: Add possibility to pass a user_data to conn_tx_cb_t
This allows setting a custom pointer to be passed back to the complete
callback at expense of increasing the buffers in 4 bytes.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-29 16:31:03 +03:00
Kamil Piszczek edea2f0803 Bluetooth: extending API for OOB pairing
This change extends the Bluetooth API to support pairing with the OOB
data that are used in the Authentication Stage of the pairing procedure.
The LE Secure Connections specific API for OOB pairing is also added.
The general OOB API should be able to accomodate the LE legacy pairing
later on.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-05-27 13:50:46 +02:00
Thomas Ebert Hansen 5e1de1a983 Bluetooth: Add support for vendor-specific events
Add an event handler for HCI vendor-specific events with the
event code BT_HCI_EVT_VENDOR.

A vendor defined callback can be registered to be called when
vendor-Specific events are received in the stack. The callback can then
decode and handle the event; if not the stack will decode and handle
the event.

Signed-off-by: Thomas Ebert Hansen <thoh@oticon.com>
2019-05-20 13:33:36 +02:00
Luiz Augusto von Dentz 852b1dca55 Bluetooth: GATT: Fix not parsing result of Read by Type
When using the procedure Read By Type the response may contain multiple
instances so it needs to be parsed properly. When dealing with long
values only the beggining will be read, for the remaining bytes the
application should issue another bt_gatt_read with offset so Read Blob
procedure is used as recommended by the spec:

BLUETOOTH CORE SPECIFICATION Version 5.1 | Vol 3, Part F page 2312:

The Read Blob Request would be used to read the remaining octets of a
long attribute value.

Fixes #16107

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-17 15:29:37 +03:00
Luiz Augusto von Dentz e0f3ab6bf2 Bluetooth: GATT: Add support for static services
This reintroduces support for static service in the form of a new API,
BT_GATT_SERVICE_DEFINE, and changes the internal services (GAP/GATT)
to be defined as const as they are never register/unregistered.

Internal service needed to be renamed in order to keep the same order
as before since the section elements are sorted by name.

The result is the following (make ram_report):

before:
      gatt.c                                    572     0.66%
        cf_cfg                                   32     0.04%
        db                                        8     0.01%
        db_hash                                  16     0.02%
        db_hash_work                             32     0.04%
        gap_attrs				180     0.21%
        gap_svc                                  12     0.01%
        gatt_attrs                              160     0.18%
        gatt_sc                                  80     0.09%
        gatt_svc                                 12     0.01%
        sc_ccc_cfg                               32     0.04%
        subscriptions                             8     0.01%

after:
      gatt.c                                    210     0.24%
        cf_cfg                                   32     0.04%
        db                                        8     0.01%
        db_hash                                  16     0.02%
        db_hash_work                             32     0.04%
        gatt_sc                                  80     0.09%
        last_static_handle                        2     0.00%
        sc_ccc_cfg                               32     0.04%
        subscriptions                             8     0.01%

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-05-02 08:29:23 +03:00
Tedd Ho-Jeong An 100f671bca Bluetooth: GATT: Add support for Read Using Characteristic UUID
This patch adds support for Read Using Characteristic UUID which is one
of the procedure to read the characteristic value especially when the
client only knows the characteristic UUID and does not know the handle
of the characteristic.

Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
2019-04-24 09:39:53 -07:00
Luiz Augusto von Dentz 69b08e6efc Bluetooth: GATT: Update read/write callback documentation
Update read and write callback documentation regarding local access of
the attribute contents.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-04-18 17:50:16 -04:00
Kamil Piszczek da4e3cad7a Bluetooth: hci: adding AD types used for OOB pairing
Added new AD Types that can be used to encode the OOB data.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2019-04-17 09:54:37 +03:00
Johan Hedberg 42d330406e Bluetooth: Mesh: Fix qualification test MESH/SR/HM/CFS/BV-02-C
The commit 8d0ef1eb85 attempted to fix
test case MESH/SR/HM/CFS/BV-02-C, however inadvertently ended up
introducing a hidden bug. This bug was unearthed thanks to commit
686f5c79cf. We have to keep always track
of the FastPeriodDivisor state whether we're using it (faults > 0) or
not (faults == 0). Introduce a boolean field to the model publication
that's used to indicate whether the FastPeriodDivisor should be
applied or not, instead of zeroing the divisor when there are no
faults (this would cause wrong behavior when faults appear again).

Additionally, the PTS seems to require that we wait until the end of
the existing period before sending the next Health Current Status,
rather than sending it immediately when the fault count changes.

Fixes #15365

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-04-11 21:24:55 +03:00
Carles Cufi bae9f1967b samples: Bluetooth: hci_uart: Implement NOP Command Complete
Implement the Controller counterpart to CONFIG_BT_WAIT_NOP so that it
issues a NOP Command Complete event after booting up, to signal to the
Host that it is ready to receive HCI traffic.

Fixes #15333

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2019-04-11 14:54:37 +02:00
Joakim Andersson 710adac50d Bluetooth: host: Add RPA in directed advertisement support
In order to advertise directed to a privacy enabled central the
initiator field of the directed adv packet needs to set to an RPA.
To instruct the controller to use an RPA in the initiator field own
address type should be set to either 0x02 or 0x03.
Since it is not certain that a remote device supports address resolution
of the initiator address we add an option to turn this on and give the
application the responsibility to check if peer supports this.

Fixes #14743

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2019-04-02 13:19:00 +02:00
Luiz Augusto von Dentz bcf3d8e16b Bluetooth: GATT: Add BT_GATT_DISCOVER_ATTRIBUTE type
This adds BT_GATT_DISCOVER_ATTRIBUTE which can be used to discover any
type of attribute in a given range.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-03-13 17:48:37 +02:00
Luiz Augusto von Dentz 0aa10521f4 Bluetooth: GATT: Document discover types
This documents existing types that can be used with bt_gatt_discover.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-03-13 17:48:37 +02:00
Johan Hedberg 1f74e0b1f7 Bluetooth: Clarify bt_conn_create_slave_le documentation
Clarify how the bt_conn_create_slave_le() API can be used to get each
of the two possible advertising packet types.

Fixes #14160

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-03-07 21:02:26 +01:00
Luiz Augusto von Dentz da163794d0 Bluetooth: GATT: Add BT_GATT_CCC_MANAGED
This adds another helper macro called BT_GATT_CCC_MANAGED which can be
used to set 2 new callbacks:

 - cfg_write: Which application can set if it wants to manage writes to
 CCC configuration.
 - cfg_match: Which application can set if it wants to manage matching
 CCC configuration when notifying/indicating.

BT_GATT_CCC_MANAGED retains the ability of saving peer configuration
on storage making it useful for clients which are only interrested in
managing the CCC configuration but not the storage itself.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-02-27 10:30:50 +01:00
David B. Kinder 1de7038f1e doc: fix doxygen API comment misspellings
Fix misspellings in doxygen comments missed during regular reviews

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2019-02-16 09:23:41 -06:00
Luiz Augusto von Dentz f2925e768b Bluetooth: Add definitions for GATT Caching
This adds the definitions for the GATT Caching features.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-02-08 18:07:34 +02:00
Filip Kubicz 1d199181ac Bluetooth: host: Meaningful error codes on advertising start
Translate HCI error codes to POSIX error codes in order to be able to
distinguish reason of connectable advertising start failure.

Signed-off-by: Filip Kubicz <filip.kubicz@nordicsemi.no>
2019-02-07 12:56:26 +02:00
Johan Hedberg 1c171ec283 Bluetooth: Add identifiers for Bluetooth 5.1
The Bluetooth 5.1 specification was recently released, and has a new
version identifier (10) assigned to it in the Bluetooth Assigned
Numbers.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-01-29 16:00:57 +02:00
Johan Hedberg e5b8f60bb6 Bluetooth: Mesh: Add support for suspend/resume
In some cases the Friendship & Low Power Node features aren't
available or feasible, however power saving is nevertheless required.
This patch introduces two new APIs to suspend and resume the Mesh
network. Currently, what this impacts is the LE scanning, the
ability to allocate new outgoing buffers, as well as the model
publishing, beacon and heartbeat timers.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-01-28 14:10:58 +02:00
Johan Hedberg cb2e4b6150 Bluetooth: Fix doxygen parameter reference for bt_le_scan_cb_t
The last parameter is called 'buf' and not 'data'.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-01-27 21:44:33 -05:00
Johan Hedberg a1ee480bdb Bluetooth: Move BT_ID_DEFAULT macro under the right subgroup
The macro should be under GAP instead of being on the top-level
Bluetooth group.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-01-27 21:44:33 -05:00
Vinayak Kariappa Chettimada 254a97af93 Bluetooth: controller: Preliminary work in progress mesh ext.
Preliminary work done towards Mesh extensions on the old LL
architecture implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2019-01-23 09:45:06 +01:00
Luiz Augusto von Dentz a779705f16 Bluetooth: GATT: Add bt_gatt_write_response_cb
This adds bt_gatt_write_response_cb works similarly to
bt_gatt_notify_cb which can take a callback to be called when the PDU
is considered transmitted over the air.

Note: This can also be used to disable the ATT flow control which would
blocks sending multiple commands without wainting their transmissions.

Fixes #11558

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-01-16 21:43:53 -05:00
Luiz Augusto von Dentz c01535c735 Bluetooth: GATT: Fix coding style
Fix lines going over 80 columns.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-01-16 21:43:53 -05:00
Luiz Augusto von Dentz f06a20c25c Bluetooth: GATT: Add groups for server and client APIs
This should make it more clearer what APIs are intended to be used with
server and client instances, in addition to that mention on the function
documentation when operation is valid only for local attributes.

Fixes #12138

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2019-01-03 12:12:10 +01:00
Robert Konc 62c8fee2ec Bluetooth: Mesh: Add header file support for C++
Add preprocessor directive for C++ compatibility.

Signed-off-by: Robert Konc <robert@konc.si>
2018-12-08 14:56:46 +02:00
Theis Blickfeldt bb68ac6c0b bluetooth: Updated comment in conn.h to clarify CB PoV
In conn.h the comments on src/dst in bt_conn_le_info and
bt_conn_br_info does not clearly state the point of view.
src could both be perceived as the connections point of view
(src = local address) or the call-back where the structs are
used point of view (src = remote address).
The comments about src/dst has been made more clear.

Signed-off-by: Theis Blickfeldt <ttjo@oticon.com>
2018-11-29 10:36:11 +02:00
Kim Sekkelund bf11698ed9 bluetooth: host: Rename bt_conn_get_id and make it public.
There is not an easy way to relate an application's user_data to a
connection. One way is to save a pointer to bt_conn in the
application's user_data array upon connection establishment.
Each connection related callback function will have to loop for all
user_data and compare the saved pointer to the passed bt_conn
pointer. This is inefficient if there are many callback activations
during the connection.

This change makes the internal bt_conn mapping function accessible to
applications in conn.h. The function name is changed to
bt_conn_index() to clearly indicate that the function returns an
index of an array.
Add an ASSERT to catch illegal parameter.

Signed-off-by: Kim Sekkelund <ksek@oticon.com>
2018-11-28 18:20:38 +02:00
Mariusz Skamra 141cf0f2cb Bluetooth: Mention that auto connect do not work along with scan
This has to be stated in API.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-11-21 12:26:27 -05:00
Luiz Augusto von Dentz ae05089946 Bluetooth: GATT: Add flag to indicate write command
Application may need to handle the write differently depending on the
write operation so this adds a flag called BT_GATT_WRITE_FLAG_CMD which
can then be checked by the callback, for instance one can respond with
BT_ATT_ERR_WRITE_REQ_REJECTED when that flag is not set which should
indicate to the client to use write command instead.

Fixes #11206

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-11-20 13:14:58 +02:00
Emanuele Di Santo 7e8b44f774 subsys: bluetooth: services: dev. information service enhancements
This commit moves the BLE GATT Device Information service
from /samples/bluetooth/gatt to /subsys/bluetooth/services and adds
a Kconfig entry to enable and configure the service;
when enabled, it will register itself automatically.

Signed-off-by: Emanuele Di Santo <emdi@nordicsemi.no>
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2018-11-07 18:08:05 +01:00
Johan Hedberg 899d704dee Bluetooth: Add basic documentation for address types
The Bluetooth address types were not documented, causing warnings from
Doxygen.

Fixes #3524

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-11-06 16:58:26 -05:00
Mariusz Skamra 45411bc08d Bluetooth: Update advertising data without advertising restart
This adds new API fuction to update running advertising data.
It will remove the need of advertising restarting.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-10-29 12:30:34 +02:00
Johan Hedberg ab615d305d Bluetooth: Mesh: Add macros to encoded model publication periods
These macros are helpful for using the configuration client API with
periodic model publication.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-10-27 11:16:30 +01:00
Mariusz Skamra 74318e61ca Bluetooth: Change l2cap accept callback return error
This changes EKEYREJECTED to EPERM due to newlib dependencies
errors.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-10-26 16:56:01 +01:00
Mariusz Skamra c04b70469b Bluetooth: shell: Add possibility to reject L2CAP CoC conn request
This adds a possibility to reject incomming LE Connection request
due to insufficient authorization or encryption key size.
This is needed for qualification purposes

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-10-25 08:02:54 +01:00
Mariusz Skamra e82ebb2c84 Bluetooth: L2CAP: Extend available return codes from accept cb
This adds support for returning various return codes from
the channel accept callback.
This is needed for implementation of incoming connection
authorization for certification purposes.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-10-25 08:02:54 +01:00
Johan Hedberg 251d99132d Bluetooth: Remove custom stack macros
Now that log processing happens in a separate thread, the
BT_STACK_EXTRA macro is not needed (since there's no significant
overhead), and therefore the BT_STACK macros become unnecessary as
well.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-10-19 14:50:22 +02:00
Johan Hedberg 343c53e841 Bluetooth: Switch from SYS_LOG to logger-based logging
Initial conversion to use syslog instead of logger.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-10-19 14:50:22 +02:00
Radoslaw Koppel 4db9731451 bluetooth: host: conn: Add const to addr in bt_le_set_auto_conn
This commit adds missed const modifier for addr pointer for
bt_le_set_auto_conn function

Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
2018-10-08 20:31:39 -04:00
Johan Hedberg 559578c09a Bluetooth: Add API to iterate through existing bonds
So far the stack hasn't provided any way for the application to access
the existing bonds. This patch adds such an API.

Fixes #10122

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-09-24 13:27:26 +03:00
Luiz Augusto von Dentz da83616ede Bluetooth: L2CAP: Fix identation of struct members
Align identation of struct members.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-09-24 12:51:11 +03:00
Luiz Augusto von Dentz 3151d26572 Bluetooth: L2CAP: Add return to recv
This adds a int return to recv callback which can be used to notify the
stack about errors when receiving a packet. In addition to that the user
can return -EINPROGRESS to inform the stack the data will be processed
asynchronously which can be complete by calling
bt_l2cap_chan_recv_complete.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-09-24 12:51:11 +03:00
Szymon Janc 6c89c4b5f7 Bluetooth: Controller: Add support for setting public address
This allows to provide public address for controller without using
VS HCI command from host. Useful for controller only builds or
combined builds that are not using VS HCI commands.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
2018-09-21 12:40:10 +02:00
Joakim Andersson 139beac5cf Bluetooth: host: Add set channel map command
Add functionality for setting the host channel classification in
the controller using the HCI command.
This closes issue #9851

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2018-09-19 15:51:57 +03:00
Mariusz Skamra 4f74f69814 Bluetooth: Add run-time option to disable SMP bondable mode
This adds a function that will disable Bonding flag in
Authentication Requirements flag in SMP Pairing Request/Response.
This is needed for qualification purposes.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-09-19 10:48:39 +03:00
Mariusz Skamra 64e608be8b Bluetooth: testing: Exclude Mesh related code if BT_MESH not set
This will exclude testing Mesh related code from build if BT_MESH
option in Kconfig is not set.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-09-19 10:48:39 +03:00
Johan Hedberg 366378f8ac Bluetooth: GATT: Fix const'ness of characteristic descriptor data
None of the data for the CEP, CUD and CPF descriptors needs to be
modified by the stack at runtime. Make it possible to pass constant
data to the descriptor macros, and make sure the descriptor handlers
cast the data back to be a constant.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-09-18 10:19:08 +03:00
Flavio Ceolin 67ca176754 headers: Fix headers across the project
Any word started with underscore followed by and uppercase letter or a
second underscore is a reserved word according with C99.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
2018-09-17 15:49:26 -04:00
Johan Hedberg 6a68a66726 Bluetooth: GATT: Use BT_GATT_DESCRIPTOR() for descriptors
CEP, CUD and CPF are all characteristic descriptors, so use the
approprirate macro for them.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-09-17 22:03:22 +03:00
Kamil Gawor 8853cb3d06 subsys: bluetooth: Add notification TX complete callback
This changed added notification complete callback which
gives information if a given notification has been sent.

Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
2018-09-14 14:39:01 +02:00
Kamil Piszczek 9af28ddc09 Bluetooth: host: directed advertising support
Added implementation to the directed advertising API in the Connection
Management module. Introduced a new connection state for this type of
advertising. The new state is symmetric to the connection state used for
scanning.

Added a new advertising option that can be used to trigger low and high
duty directed advertising. Added macros for default values of
Advertising Parameters, which are used to trigger directed advertising.

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2018-09-13 14:21:21 +02:00
Mariusz Skamra 0312483d12 bluetooth: uuid: Add Central Address Resolution UUID
This adds Central Address Resolution Characteristic UUID.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-09-10 17:47:15 -04:00
David B. Kinder 7b548c42ee doc: fix misspellings in API documentation
Fix misspellings in doxygen API comments missed during regular reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-08-28 13:58:22 -04:00
Vinayak Kariappa Chettimada 76599ec2e8 Bluetooth: Add HCI Error Code definitions required by LE controller
Add missing HCI Error code definitions required by LE
controller implementation.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2018-08-24 16:10:01 +03:00
Johan Hedberg 346f815d9e Bluetooth: Introduce bt_id_delete() API
This API makes it possible to delete an existing identity and to flag
its storage slot as unused.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-08-13 19:53:22 +03:00
Johan Hedberg 7dba2512e3 Bluetooth: Introduce bt_id_reset() API
Add a new API which can be used to reclaim an identity slot for a new
identity. When called, any previous pairings, connections, or other
data will be cleared, and then a new identity will be generated in the
place of the old one.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-08-13 19:53:22 +03:00
Johan Hedberg e70c556dcc Bluetooth: Add full storage support for multiple identities
Update the storage handling to take into account multiple identities.
We can save a bit of code by using the new bt_id_create() API from
within settings.c.

Also make the treatment of addr & irk parameters to bt_id_create()
consistent, in that NULL is acceptable for both of them.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-08-13 19:53:22 +03:00
Johan Hedberg 1d8dab811e Bluetooth: Add initial APIs for identity manipulation
Add APIs for getting current identities as well as for creating new
ones.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-08-13 19:53:22 +03:00
Johan Hedberg 5708f1e8b1 Bluetooth: Add infrastructure to handle multiple identities
Make it possible to have multiple identity addresses as an LE
peripheral. For central role only the default identity is supported
for now. This also extends the flash storage in a backward compatible
way.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-08-13 19:53:22 +03:00
David B. Kinder 9a3d7a43a0 doc: fix misspellings in API docs
Fix doxygen misspellings affecting API documentation missed during
regular reviews.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-08-08 01:47:51 -05:00
Johan Hedberg c446c8267b Bluetooth: Add support for fixed passkeys
Add a new bt_passkey_set() API that can be used to set a fixed passkey
to be used for pairing. The new API also requires a new Kconfig option
to be enabled first (CONFIG_BT_FIXED_PASSKEY).

Fixes #8350

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-08-01 16:13:21 +03:00
Johan Hedberg 4752788c81 Bluetooth: Fix documentation and other issues with auth callbacks
Provide proper documentation for all of the authentication callbacks,
and clarify the usage of the cancel callback. Previously the cancel
callback was always required, even though that doesn't necessarily
make sense now that the pairing_complete/failed callbacks exist.

Fixes #8385

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-08-01 16:13:21 +03:00
Jun Li 9b6ad4067b bluetooth: add callback to notify pairing is complete
Added two new callbacks for Bluetooth stack to notify
the application that pairing has been completed or failed.

fixes: #8390

Signed-off-by: Jun Li <jun.r.li@intel.com>
2018-07-27 16:16:52 +03:00
Luiz Augusto von Dentz 2e2f122d51 Bluetooth: samples: Make use of BT_LE_ADV_OPT_USE_NAME
Use BT_LE_ADV_OPT_USE_NAME whenver possible since it does properly
track updates.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-07-23 14:45:58 +03:00
Luiz Augusto von Dentz acc3e5129e Bluetooth: Add BT_LE_ADV_OPT_USE_NAME
This introduces a new advertising flag BT_LE_ADV_OPT_USE_NAME which can
be used by applications to make the stack automatically include the
Bluetooth Device Name in the Scan Response.

The name is also updated in case there is already an advertising
instance using it.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-07-23 14:45:58 +03:00
Luiz Augusto von Dentz 2637c978fe Bluetooth: Store device name
This uses bt_dev to store the name and allow changing it at runtime, in
addtion to that if CONFIG_BT_SETTINGS is defined make the name
persistent.

Fixes #8357

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-07-23 14:45:58 +03:00
Kamil Piszczek 85c1522699 Bluetooth: UUID: add UUIDs for missing HIDS characteristics
Adding UUIDs for following characteristics of HID Service:
- Protocol Mode
- Boot Keyboard Input Report
- Boot Keyboard Output Report
- Boot Mouse Input Report

Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
2018-06-26 19:06:30 +02:00
Johan Hedberg 8818244959 Bluetooth: Add helper for parsing advertising data
It is quite easy to implement a buggy or security vulnerable
advertising data parser. Provide a helper for this purpose, which uses
the existing bt_data struct which is used for programming the local
advertising data.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-06-26 19:34:57 +03:00
David B. Kinder ca16b6f8ee doc: fix misspelling in hci API docs
fix misspellings missed during regular reviews

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-06-20 12:37:01 -04:00
Johan Hedberg b1b1017178 Bluetooth: Export HCI command APIs through public hci.h header file
This is the simplest & cleanest way to make these APIs available for
drivers. We already have a public hci.h header file, so using it seems
most natural.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-06-13 21:04:27 +02:00
Luiz Augusto von Dentz c3edc82fe7 Bluetooth: GATT: Allow Characterist to be used with bt_gatt_notify
Since BT_GATT_CHARACTERISTIC now expands to 2 attributes it may be
confusing to use bt_gatt_notify as that expects the Value attribute to
be given which is no longer visible, so this enables the user to use
the Characteristic attribute in addition to its value.

Fixes #8231

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-06-11 14:41:19 -04:00
Johan Hedberg ed5fb3ff37 Bluetooth: Mesh: Fix (re)transmit interval handling
The adv_send() function was incorrectly decoding the 5-bit value (it
was using it directly as milliseconds), which effectively lead to the
code always picking the controller's minimum supported interval.

Fix this issue, but do it by simplifying the (re)transmission state
tracking so that the state is always stored in the original "packed"
8-bit value, where 5 bits are reserved for the interval, and 3 for the
count.

Fixes #7972

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-06-05 19:15:14 +02:00
Asbjørn Sæbø f7a1ffe614 Bluetooth: GATT: Change attribute count from u16_t to size_t
The change changes the type of the attribute count in the
bt_gatt_service struct to size_t.

The background for the change is that with this variable being a
u16_t, we assign something that has been cast to an unsigned long
(from "ARRAY_SIZE") to an u16_t variable, and that Lint complains
about a loss of information (27 bits to 16 bits in the case I found).

(The issue seems to be not only about the cast, but about what is
casted. I suspect that Lint may be confused by the magic of
ZERO_OR_COMPILE_ERROR.)

Signed-off-by: Asbjørn Sæbø <asbjorn.sabo@nordicsemi.no>
2018-05-22 13:33:00 -04:00
Johan Hedberg df4220b213 Bluetooth: L2CAP: Add support for dynamically allocated PSM values
The Bluetooth core specification splits the valid LE L2CAP PSM range
into two subranges:

 - Standard, SIG-assigned fixed PSM values in the range 0x0001-0x007f
 - Dynamic, allocated at runtime in the range 0x0080-0x00ff

Previously the bt_l2cap_server_register() API was assuming that the
app would always decide the PSM, which effectively made it impossible
to have collision-free dynamic PSMs. This patch extends the
implementation so that if server->psm is 0, then the stack will look
for a free PSM from the dynamic range and take it into use.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-05-18 12:39:58 +03:00
Luiz Augusto von Dentz 4b4b6762aa Bluetooth: GATT: Fix documentation of bt_gatt_notify
Document the return value of bt_gatt_notify.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-05-16 18:02:14 +03:00
Johan Hedberg a3c1b3dbcc Bluetooth: Mesh: Expose bt_mesh_is_provisioned() publicly
After introducing persistent storage, it's useful for an app to check
if the node has been provisioned or not.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-05-16 18:00:19 +03:00
Luiz Augusto von Dentz 1b038f2941 Bluetooth: GATT: Make BT_GATT_CHARACTERISTIC declare its value
This ensures the every characteristic has a value attribute declared
with the same UUID since the old macro did not declare the value the
application would normally have to declare one itself using a different
UUID which is not allowed.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-05-14 18:51:22 +03:00
Luiz Augusto von Dentz 318a175867 Bluetooth: GATT: Introduce BT_GATT_ATTRIBUTE
This adds BT_GATT_ATTRIBUTE which replaces BT_GATT_DESCRIPTOR as the
most basic way to declare an attribute since using descriptor may be
confusing when declaring things like a characteristic value since the
Bluetooth has their procedures completely separated.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-05-14 18:51:22 +03:00
Johan Hedberg 88dfd399f4 Bluetooth: Mesh: Remove sequence number from bt_mesh_provision()
The sequence number was acting as a stop-gap for missing persistent
storage. Now that we have the settings support in place it's no longer
needed.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-05-11 16:44:43 +03:00
Johan Hedberg 44bd56877b Bluetooth: Mesh: Support for storing heartbeat publication persistently
Add support for storing the heartbeat publication persistently. The
information is only stored as "publish indefinitely" or as "periodic
publishing disabled" since we can't know for how long the node is
powered off. The information is stored under the settings key
bt/mesh/HBPub.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-05-11 16:44:43 +03:00
Johan Hedberg 8703ffad23 Bluetooth: Mesh: Redesign element and storage info for models
Keeping the model struct same sized, change the element pointer to two
indexes, and add a flags member that will be used to track pending
storage actions.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-05-11 16:44:43 +03:00
Johan Hedberg c1c5f3d9a3 Bluetooth: Mesh: Expose destination address in bt_mesh_msg_ctx
There are valid use cases where the model layer must know the true
destination address. So far only the fact that it was one of the
addresses that the model subscribes to (its element's unicast
included) has been knowable.

Solve the issue by moving the destination address from the internal
net_rx context to the public bt_mesh_msg_ctx struct.

Fixes #7453

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-05-11 13:57:43 +03:00
Johan Hedberg 5b01cb1a46 Bluetooth: Introduce new bt_set_id_addr() API
There are certain use cases where the application needs to be able to
explicitly set a specific identity address. This was previously
possible using the bt_storage API, however now that it's gone another
solution is needed.

This patch adds a ne bt_set_id_addr() API which the application can
use to set a specific identity address before calling bt_enable().

Fixes #7434

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-05-10 22:39:04 +02:00
Johan Hedberg d22b7c9f2d Bluetooth: Remove bt_storage API
The same functionality is now supported by the settings-based
solution, so remove bt_storage out of the way. There were stubs in
bt_storage to handle per-peer information (e.g. pairing keys) but this
was never actually implemented in full. The next step is to add this
support to the settings-based solution.

Leave the code for generating temporary IRK and identity address in
case BT_SETTINGS is not enabled. Also leave the code for using vendor
HCI to read the identity address, in which case the settings
implementation will not touch it.

Introduce a new bt_unpair() API to replace the removed
bt_storage_clear(), since the latter was actually doing more than just
storage management: it was also handling runtime storage of pairing
information. Later, the bt_unpair() implementation will be extended to
clear settings-based pairing storage.

There is one feature that the bt shell module looses: the ability to
give a specific identity address to the "init" command as a parameter.
We might look later in the future if this is really needed, and add a
separate API for this.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-05-04 17:26:05 -04:00
Johan Hedberg 6a71a69f8d Bluetooth: GATT: Fix CCC handling
The 'valid' member of struct bt_gatt_ccc_cfg was redundant, since
setting 'peer' to BT_ADDR_LE_ANY does the same job. What's worse, the
handling of 'valid' was also buggy in that some places looking for
valid CCC structs only matched the address, meaning it might yield a
positive match for invalid entries.

Fix these issues by removing the 'valid' struct member, and solely
using the 'peer' member to identify valid entries. Also simplify the
code by acknowledging that no CCC entry is essentially the same as the
value '0' written to CCC.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-05-03 09:53:16 +01:00
Johan Hedberg 92749e7a92 Bluetooth: Mesh: Remove unnecessary #ifdefs from header file
The #ifdef protections are not needed, and in fact prevent helpers
such as IS_ENABLED() from being used when calling APIs which are
optional.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-05-02 15:45:16 +01:00
Johan Hedberg ac133268a5 Bluetooth: Remove 'own_addr' from advertising parameters
This was originally added as a work-around to avoid the heavy stack
consumption of the TinyCrypt PRNG when generating NRPAs. This is
no-longer an issue, and there are in fact no (in-tree) users of this.
Remove it before it gains any wider users, since it was in many ways a
hack/work-around to begin with.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-03-21 18:11:49 +02:00
Johan Hedberg 7d4514a8b0 Bluetooth: Add option to force using identity address for advertising
In some cases the app may want to force using the identity address
regardless of privacy support or what type of advertising is done.
Provide such an option in bt_le_adv_param.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-03-21 18:11:49 +02:00
Johan Hedberg b9588d8eb6 Bluetooth: Mesh: Switch to using Linux Foundation Company ID
The Linux Foundation now has an assigned Company Identifier, so switch
to using that.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-03-05 19:54:21 -05:00
Johannes Hutter 2c76978ee4 Bluetooth: Add HCI error code definitions
Add HCI error code definitions based on the Bluetooth 5.0 specification.
That allows for example that disconnection reasons can be checked
against the constants.

Signed-off-by: Johannes Hutter <johannes.5494@gmail.com>
2018-03-02 12:27:05 +01:00
Johan Hedberg ac1360f0a7 Bluetooth: Mesh: Convert to new net_buf_simple APIs
Convert the mesh code to use the new net_buf_siple APIs. This has the
benefit of saving 4 bytes off the stack due to the not needed pointer.
Also update the publication context helpers to map to the new
net_buf_simple API in an intuitive way.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-13 14:00:08 +02:00
Luiz Augusto von Dentz 800bfaf9a7 Bluetooth: UUID: Remove macros defining 16 bit values
Application should normally declare a bt_uuid with proper type and then
use bt_uuid_cmp.

Fixes #5162

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2018-02-13 13:33:48 +02:00
Johan Hedberg 2ff98636a5 Bluetooth: Mesh: Add support for OOB info and URI in provisioning data
Until now the OOB info and URI fields in unprovisioned beacons were
generally ignored by the implementation. Add fields for these to
bt_mesh_prov and make sure to take them into account when encoding
advertising data, both for PB-ADV and PB-GATT. For PB-ADV the URI goes
out in a separate beacon, whereas for PB-GATT it is placed in the scan
response data.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2018-02-05 12:46:05 +02:00
David B. Kinder 79e916542a doc: fix misspellings in doxygen API comments
Fix misspellings in API documentation derived from header files.

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-01-30 20:04:21 -05:00
Sebastian Bøe aca1f17dc6 bt: Don't rely on 'enum bt_buf_type' being 1 byte
De-referencing the pointer from net_buf_user_data(buf) as a pointer to
an enum causes issues on qemu_x86 because the true size is 8-bit, but
the enum is 32-bit on qemu_x86. So we put in a temporary cast to 8-bit
to ensure only 8 bits are read from the pointer.

This fixes a regression from d3304dc508
that broke BT on qemu_x86.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-29 06:58:42 -08:00
Sebastian Bøe d3304dc508 bluetooth: Fix cast in bt_buf_get_type
The function returns an enum, not a u8_t, so we should cast
appropriately to avoid an implicit conversion.

This construct was triggering this compilation error when compiling
with CXX:

/home/sebo/zephyr/include/bluetooth/buf.h:85:9: error: invalid
  conversion from ‘u8_t {aka unsigned char}’ to ‘bt_buf_type’
  [-fpermissive] return *(u8_t *)net_buf_user_data(buf);

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-11 16:04:27 -05:00
Sebastian Bøe f61cd12bf8 bluetooth: Fix "struct bt_gatt_read_params" declaration
Compiling this declaration with a CXX compiler triggers the compiler
error:

/home/sebo/zephyr/include/bluetooth/gatt.h:898:10: error: ‘struct
bt_gatt_read_params::<anonymous union>::__single’ invalid; an
anonymous union can only have non-static data members [-fpermissive]

Reading up on the standard, I was unable to find any mention of this
being valid C or CXX code (But reading the standard is not
straightforward). And I was unable to find any mechanism to make the
CXX compiler accept it (e.g. Changing the -std, or adding this as a
language extension e.g. -fms-extensions).

So we rewrite it to not declare the struct with the tag
"__single". There does not seem to be any reason for it to be declared
like this.

Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
2018-01-11 16:04:27 -05:00
Mariusz Skamra 253e40ad0e Bluetooth: mesh: Do not set RFU bits in Heartbeat Publication Features
Features received in Config Heartbeat Publication Set message can have
Feature bits set to RFU values.
This patch fixes setting this RFU bits in Heartbeat Publication
Features, so that those are not indicated in Config Heartbeat
Publication Status message.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-05 09:31:50 +02:00
Mariusz Skamra 813ec50838 Bluetooth: btp: Add event indicating expiration of incomp timer
This event indicates that segmented message incomplete timer
expired.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra 9977caefa1 Bluetooth: testing: Move bt_test_mesh_net_recv to internal API
This function is called only within mesh stack.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra 8274cbabf6 Bluetooth: btp: Add Mesh Clear Replay Protection List Cache command
This command is needed for Bluetooth Mesh testing against PTS.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra a909aa3a0b Bluetooth: btp: Add LPN Subscribe/Unsubscribe commands
This adds commands to manage Friend node Subscription List.
Those will be used to add or remove and group/virtual address
from subscription list.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra 0bd3790d5b Bluetooth: btp: Add event indicating invalid provisioning BearerOpcode
This adds BTP event indicating reception of provisioning message
with invalid (RFU) BearerOpcode.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra 0d71cef1f2 Bluetooth: tester: Add BTP Mesh Model Send command implementation
This command will be used to test if model can properly send
segmented and unsegmented messages to a given destination address.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-03 10:48:13 +01:00
Mariusz Skamra a87840e8e2 Bluetooth: Expose Bluetooth Testing API
This moves Bluetooth testing header file to the include/bluetooth.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2017-12-18 12:43:23 +01:00
Johan Hedberg 364ce8801f Bluetooth: Mesh: Add support for sending NetKey Add message
Add configuration client model support for NetKey Add message, as well
as a mesh shell command for calling the new API.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg aa930f3f94 Bluetooth: Mesh: Improve documentation for model publication
Make it clear that the model publication msg member must not be a
stack variable.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-27 12:10:49 +02:00
Johan Hedberg 48aecd1513 Bluetooth: Mesh: Add IV Update test mode API
This makes it possible to pass all IV Update tests without having to
build a custom configuration for some of the tests. We also disable
the feature in all sample configurations, but leave it on in the
tests.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-27 10:17:54 +02:00
Johan Hedberg 35fd523b03 Bluetooth: Mesh: Add support for manipulating Label UUIDs
Add support for sending messages that add, delete or overwrite Label
UUIDs, and add commands for these to the shell. With the help of these
commands it's possible to pass Transport Layer PTS tests (in
particular TNPT/BV-05-C) by manually adding a Label UUID through
module subscription, since the test case itself does not do this.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-24 17:12:20 +02:00
Johan Hedberg 89030f0906 Bluetooth: Mesh: Introduce public LPN APIs for better control
Many apps, the mesh shell included (due to PTS test requirements)
benefit from exposing LPN state and polling outside of the stack.
Introduce new APIs for these, and add code to the mesh shell module to
take advantage of them.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-24 11:37:09 +02:00
Johan Hedberg d588850c0c Bluetooth: Mesh: Add support for Health Attention messages
Add support for sending Health Attention messages, as well as commands
to use these new APIs from the shell.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-23 14:49:55 +02:00
Johan Hedberg 7e8f9afee5 Bluetooth: Mesh: Add support for Health Period messages
Add support for sending Health Period messages, as well as commands to
use these new APIs from the shell.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-23 14:49:55 +02:00
Johan Hedberg ce10be3a2a Bluetooth: Mesh: Add support for Health Fault Test messages
Add support for sending Test and Test Unacknowledged messages.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-23 14:49:55 +02:00
Johan Hedberg 987c68b7aa Bluetooth: Mesh: Add support for Health Fault Clear messages
Add support for sending Clear and Clear Unacknowledged messages.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-23 14:49:55 +02:00
Johan Hedberg 2eda34cf3f Bluetooth: Mesh: Add support for receiving Health Current Status
Add a callback to the Health Client Model context, so that the
application is able to receive Health Current Status messages that
some Health Server Model publishes.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-23 14:49:55 +02:00
Johan Hedberg b26231d770 Bluetooth: Mesh: Add support for sending Health Fault Get message
Add the needed Health Client API for sending Health Fault Get, and add
a command to the shell to utilize it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-23 14:49:55 +02:00
Johan Hedberg 7ef5e53e28 Bluetooth: Mesh: Add skeleton for Health Client model
Add a skeleton for the Health Client model.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-23 14:49:55 +02:00
Johan Hedberg aaf519e615 Bluetooth: Mesh: Improve model publication documentation
Make it clear which members of bt_mesh_model_pub the documentation is
referencing.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-22 12:53:54 +02:00
Johan Hedberg 15fe221f13 Bluetooth: Mesh: Fix accuracy of Publish Period
After the Publish Retransmit state was introduced the Publish Period
measurement would begin once the previous Publish message has finished
transmitting. This will however cause inaccurate periods, which is
particularly an issue with the PTS that expects accuracy of less than
0.5 seconds (apparently).

Since the publication timer is also used for the retransmissions we
can't simultaneously use if for the period as well. Therefore, we
introduce a new variable called period_start which makes a note of
when the period was supposed to start, and then once all
retransmissoins are done initializes the timer with the send duration
taken into account.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-22 12:53:54 +02:00
Johan Hedberg 491f0c4892 Bluetooth: Mesh: Provide documentation for the publication API
Document all members of the bt_mesh_model_pub struct.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-22 12:53:54 +02:00
Johan Hedberg 8f1541184f Bluetooth: Mesh: Fix non-periodic Model Publication
The only generally available model supporting publication that's
convenient to be used for testing is the Health Server Model.
Unfortunately since this model supports period publication, the
non-periodic side got less attention and had some bugs.

The first thing that needs to be done is to verify that the period
returned by bt_mesh_model_pub_period_get() is positive. If it's zero
then no periodic publication should take place.

Another thing that this patch cleans up is the naming of the callback
used for periodic publishing. There's no need do require the callback
to call bt_mesh_model_publish() since this must happen no matter what,
so instead rename the callback from 'func' to 'update' and have the
access layer call bt_mesh_model_publish() if the callback was
successful.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-22 12:53:54 +02:00
Johan Hedberg 324336167e Bluetooth: Mesh: Add Model Subscription Del & Overwrite support
The Del and Overwrite operations have the exact same parameters and
expected status response as the Add operation, so we can reuse most of
the code.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-20 15:00:29 +02:00
Johan Hedberg e7bb76e2b6 Bluetooth: Mesh: Fix model publication
Model publication was broken in a couple of ways:

 - The Publish Retransmit State was not taken into account at all
 - Health Server used a single publish state for all elements

To implement Publish Retransmit properly, one has to use a callback to
track when the message has been sent. The problem with the transport
layer sending APIs was that giving a callback would cause the
transport layer to assume that segmentation (with acks) is desired,
which is not the case for Model Publication (unless the message itself
is too large, of course). Because of this, the message sending context
receives a new send_rel ("Send Reliable") boolean member that an app
can use to force reliable sending.

Another challenge with the Publish Retransmit state is that a buffer
is needed for storing the AppKey-encrypted SDU once it has been sent
out for the first time.To solve this, a new new net_buf_simple member
is added to the model publication context. The separate 'msg' input
parameter of the bt_mesh_model_publish() API is removed, since the
application is now expected to pre-fill pub->msg instead.

To help with the publishing API change, the Health Server model gets a
new helper macro for initializing the publishing context with a
right-sized publishing message.

The API for creating Health Server instances is also redesigned since
it was so far using a single model publishing state, which would
result in erratic behavior in case of multiple elements with the
Health Server Model. Now, the application needs to provide a unique
publishing context for each Health Server instance.

The changes are heavily intertwined, so it's not easily possible to
split them into multiple patches, hence the large(ish) patch.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-20 15:00:29 +02:00
Johan Hedberg f9fad553ac Bluetooth: Mesh: Fix encoding/decoding Publish Retransmit value
The Model Publish Retransmit Interval is in units of 50ms and not 10ms
like the other transmit/retransmit states. Create dedicated macros for
the Publish Retransmit State and use them where appropriate.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-20 15:00:29 +02:00
Johan Hedberg 4bf045e282 Bluetooth: Mesh: Use a unified send callback also for public API
There's no need for callback exposed in the public API to be something
different than what's used internally. In fact this would just
complicate things. This patch exposes the internal callback under a
bt_mesh_adv_cb name and uses it throughout the mesh stack.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-20 15:00:29 +02:00
Johan Hedberg 8488d7a9fe Bluetooth: Mesh: Use u8_t instead of bitfields for 8-bit wide values
It's cleaner to use single u8_t variables for values which require
exactly 8 bits.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-17 13:09:45 +02:00
Johan Hedberg bd69b2127e Bluetooth: Mesh: Use dedicated struct for heartbeat subscription
This simplifies the API since there is no-longer a need to pass a huge
number of function arguments around.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-16 15:35:10 +02:00
Johan Hedberg d4365e16f9 Bluetooth: Mesh: Use dedicated struct for heartbeat publication
This simplifies the API since there is no-longer a need to pass a huge
number of function arguments around.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-16 15:35:10 +02:00
Johan Hedberg 05be6b8033 Bluetooth: Mesh: Add support for sending Model Publication messages
Add support for Model Publication Set/Get and their vendor model
variants.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-16 15:35:10 +02:00
Johan Hedberg 2bc2f84a02 Bluetooth: Mesh: Fix documentation of bt_mesh_input_string()
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 08:34:46 -05:00
Johan Hedberg d4be608036 Bluetooth: Mesh: Allow changing cfg client message timeout
10 seconds is quite long for configuration messages, and way too much
currently since we only talk through the local networking interface.
Set the default timeout to 2 seconds, and provide APIs through which
the timeout may be changed at run-time (mainly useful for the shell).

Note: The timeout_set() API is normally assumed to be called just once
for an application, based on the expected size of the network (hops &
latency). Trying to change it e.g. in a multi-threaded environment for
every message may not yield the expected results.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 13:48:29 +02:00
Johan Hedberg 7b27d96f96 Bluetooth: Mesh: Add support for sending Heartbeat Subscription Get
Add support for sending the Heartrate Subscription Get message.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 13:48:29 +02:00
Johan Hedberg 9bf8af8507 Bluetooth: Mesh: Add support for sending Heartbeat Publication Get
Add support for sending the Heartrate Publication Get message.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 13:48:29 +02:00
Johan Hedberg 5e3804b11d Bluetooth: Mesh: Add support for sending Heartbeat Publication Set
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 13:48:29 +02:00
Johan Hedberg 897f32f0d1 Bluetooth: Mesh: Add documentation for public provisioning APIs
Add proper documentation for public provisioning APIs.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 13:48:29 +02:00
Johan Hedberg 255edcfde2 Bluetooth: Mesh: Provisioning: Add NetKeyIndex to complete callback
It may be useful for the app to know what the initial NetKeyIndex that
it was given during provisioning is.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 13:48:29 +02:00
Johan Hedberg 06694787cd Bluetooth: Mesh: Provide documentation for provisioning APIs
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 13:48:29 +02:00
Johan Hedberg 70cbcef576 Bluetooth: Mesh: Rename health server code from health to health_srv
This is in anticipation of soon adding health client support, which
could then cause confusion due to the ambiguous API names.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 13:48:29 +02:00
Johan Hedberg 3b252ca2be Bluetooth: Mesh: Rename configuration server code from cfg to cfg_srv
Now that there's support for configuration client as well, rename cfg
to cfg_srv to avoid any confusion.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 13:48:29 +02:00
Johan Hedberg 0ef7c6e09a Bluetooth: Mesh: Add more flexible APIs for provisioning bearers
Add the ability to track the provisioning bearer through an extra
parameter to link_open/close. Also introduce new public functions to
enable/disable specific provisioning bearers. This also means that one
now needs to explicitly enable provisioning bearers after calling
bt_mesh_init().

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 13:48:29 +02:00
Johan Hedberg a81fa43a59 Bluetooth: Mesh: Use proper _t suffix for typedefs
To be consistent with the coding style, use a _t suffix for typedefs.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-15 13:48:29 +02:00
David B. Kinder 5ab1365cf7 doc: fix doxygen defgroup title error
Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-11-14 18:31:22 -05:00
Johan Hedberg f50b99572f Bluetooth: Mesh: Add support for sending Heartbeat Subscription Set
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-14 16:48:49 +02:00
Johan Hedberg b4688bdc84 Bluetooth: Mesh: Add support for sending Model Subscription Add
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-14 16:48:49 +02:00
Johan Hedberg e4db09e919 Bluetooth: Mesh: Add support for sending Model App Bind message
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-14 16:48:49 +02:00
Johan Hedberg e1bc6a6141 Bluetooth: Mesh: Add support for sending AppKeyAdd message
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-14 16:48:49 +02:00
Johan Hedberg cbfea942f6 Bluetooth: Mesh: Add support for Relay and 1-byte state Get/Set
Add support to the Configuration Client Model for getting and setting
1-byte states (which can be nicely generalized in code) as well as the
2-byte Relay state.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-14 16:48:49 +02:00
Johan Hedberg 07305fd71d Bluetooth: Mesh: Add support for sending Beacon Get & Set
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-14 16:48:49 +02:00
Johan Hedberg 3d1ce43eb0 Bluetooth: Mesh: Add support for sending Get Composition Data
Add Get Composition Data support to the Configuration Client Model.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-14 16:48:49 +02:00
Johan Hedberg 588887c9b7 Bluetooth: Mesh: Add primary address to provisioning complete callback
It may be useful for the app to know that the local node's primary
address is.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-14 16:48:49 +02:00
Johan Hedberg 2a1e16c2a3 Bluetooth: Mesh: Add skeleton for Configuration Client Model
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-14 16:48:49 +02:00
Johan Hedberg 17c9b3a105 Bluetooth: Mesh: Make TRANSMIT_COUNT & TRANSMIT_INT macros public
These are useful for apps who want to implement/use the Configuration
Client Model.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-14 16:48:49 +02:00
Johan Hedberg 52cc3b7d00 Bluetooth: Mesh: Refactor public headers into dedicated subdirectory
As the number of mesh APIs grows it becomes a bit cumbersome to have
everything in a single header file. Split the mesh.h header file into
multiple files in a new mesh subdirectory, and include the new headers
from the old one to retain backwards compatibility and simplicity for
apps (they only need to include <bluetooth/mesh.h>).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-14 16:48:49 +02:00
Johan Hedberg b4700c3f2b Bluetooth: Mesh: Clarify API for empty model arrays
Avoid applications defining empty model arrays by themselves by
documenting the BT_MESH_MODEL_NONE helper macro (renamed to be more
intuitive) and using it in the mesh sample app.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-13 14:38:04 +02:00
Johan Hedberg 092a28541a Bluetooth: Mesh: Provisioning: Introduce link open/close callbacks
It may be useful for the app to know when the provisioning link is
active and when it has been closed. This can be used e.g. to signal
the user the state of the device. Some PTS tests also require
verifying the link state.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-13 13:15:07 +02:00
Johan Hedberg 1311676645 Bluetooth: Mesh: Provisioning: Make static OOB value const
This makes it possible for the actual value to reside in ROM.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-13 13:15:07 +02:00
Johan Hedberg eb23d688f2 Bluetooth: Mesh: Fix network credential selection
The only messages that should be encrypted using the friendship
credentials are those coming through the Friend Queue on the Friend
node, most request-response pairs between LPN & Friend (exceptions are
Friend Request - Friend Offer, and Friend Clear - Friend Clear
Confirm), as well as Model Publication messages when the Friendship
Credentials Flag has been enabled in the model publication.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-10 22:17:43 +03: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 a74feaaf55 Bluetooth: Add missing HCI defines for LL privacy
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-06 12:50:40 +02:00
Johan Hedberg b452d6f348 Bluetooth: Add support for decoding new address types
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-10-05 13:14:08 +03:00
Johan Hedberg 8d0ef1eb85 Bluetooth: Mesh: Fix setting health period divider
A previous patch which moved dispatching the health publish callback
to a later moment introduced a regression where the period divider
does not get updated when it should. In fact, having the divider as
part of the Health Server context is redundant, since the same
information is already stored generically in the model publication
context. Switching to using the model publication context makes things
simpler and ensures that the value is always up-to-date.

With this patch it is possible to pass MESH/SR/HM/CFS/BV-02-C.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-09-29 13:21:40 +03:00
Carles Cufi b77b8e615b Bluetooth: controller: Issue Data Buffer Overflow event
Whenever the HCI ACL flow control is violated by the Host, a Data Buffer
Overflow event is now issued by the Controller (if enabled) to notify
the Host of the buffer overrun.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-09-13 14:17:32 +02:00
Carles Cufi f597c8120e Bluetooth: controller: Add LE Read Chan Map command
Implement the LE Read Channel Map HCI command, along with making the
reading of the multi-byte channel map value from the connection pointer
thread-safe in case the ISR triggers while we are reading the value.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-08-25 11:27:22 +02:00
Carles Cufi a5fcafa155 Bluetooth: controller: Add Read TX Power commands
Although the current BLE controller only supports a single TX power (0
dBm), the qualification tests require the 2 Read TX Power to be
present and supported in the controller, so implement them while
returning always 0 dBm.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-08-25 11:27:22 +02:00
Carles Cufi 7bfa0ef47b Bluetooth: controller: Implement Read RSSI command
When the CONFIG_BT_CTLR_CONN_RSSI option is set, the connection RSSI is
available in the controller, and can be reported to the Host via the
Read RSSI command. Implement the command, which is required for
qualification.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-08-25 11:27:22 +02:00
Carles Cufi 9d63dda43a Bluetooth: VS: Replace IRK with IR
The values returned by the controller are Identity Roots and not
Identity Resolving Key. To avoid confusion, and since IRK is commonly
associated with the latter, use "ir" instead.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-08-17 12:36:51 +02:00
Carles Cufi 16a28bf106 Bluetooth: VS: Add RSSI to Scan Req Received Event
In order to allow for the controller to report the RSSI of a received
Scan Request, include the field inside the Scan Request Received
Vendor-Specific Event.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-08-17 12:36:51 +02:00
Carles Cufi 01338fd3ed Bluetooth: VS: Fill the Vendor-Specific header with the spec
The Vendor-Specific header file defines the commands and events used to
communicate with a Zephyr Vendor-Specific capable controller from a
Host. Translate the existing specification fully into the header file.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-08-17 08:30:32 +03:00
David B. Kinder 2c850d7547 doc: fix misspellings in include (API docs)
Fix misspellings in .h files missed during code reviews
and affecting generated API documentation

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2017-08-10 12:22:19 -04:00
Carles Cufi 868aeeb126 Bluetooth: controller: LE Directed Advertising Report
Implement the 4.2 event LE Directed Advertising Report, used for
scanners in a privacy-enabled controller to report directed advertising
events whose TargetA cannot be resolved by the local controller.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-08-10 12:33:36 +03:00
Johan Hedberg 505c45a7ad Bluetooth: Clean up address related definitions
Fix white-space usage and use a shorter parameter name to avoid line
splits.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-09 12:51:39 -04:00
Johan Hedberg f4673fa8b6 Bluetooth: Mesh: Fix alignment issue resulting from Kconfig change
The alignment of these defines went a bit off with the shortened
Kconfig variable names.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-08-09 12:49:10 +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
Luiz Augusto von Dentz cf913738c5 Bluetooth: GATT: Indicate service changes when reconnecting
If peer has previously configure to received service changes indications
any changes to the database during the time it has been disconnected
shall be indicated once it reconnects:

[bt] [DBG] sc_process: (0x004065b4) start 0x000a end 0x0014
[bt] [DBG] sc_save: (0x004065b4) peer b8:8a:60:d8:17:d7 (public)
 start 0x000a end 0x0014
[bt] [DBG] bt_gatt_connected: (0x00405240) conn 0x00405aa0
[bt] [DBG] gatt_ccc_changed: (0x00405240) ccc 0x00400b30 value 0x0002
[bt] [DBG] sc_ccc_cfg_changed: (0x00405240) value 0x0002
[bt] [DBG] sc_restore: (0x00405240) peer b8:8a:60:d8:17:d7 (public)
 start 0x000a end 0x0014
[bt] [DBG] sc_process: (0x004065b4) start 0x000a end 0x0014
[bt] [DBG] gatt_indicate: (0x004065b4) conn 0x00405aa0 handle 0x0008
[bt] [DBG] sc_indicate_rsp: (0x00405240) err 0x00

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2017-07-31 13:52:08 +03:00
Vinayak Kariappa Chettimada 255e5cc344 Bluetooth: controller: Implement Read/Write Auth Payload timeout
Added implementation to support HCI Read Authenticated
Payload Timeout Command and HCI Write Authenticated Payload
Timeout Command.

This fixes:
TP/SEC/SLA/BV-08-C [No response to LL_PING_REQ]
TP/SEC/SLA/BV-09-C [Modified Authentication Payload Timeout]
TP/SEC/MAS/BV-08-C [No response to LL_PING_REQ]
TP/SEC/MAS/BV-09-C [Modified Authentication Payload Timeout]
conformance tests in LL.TS.5.0.0.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-07-22 11:55:35 +03:00
Johan Hedberg 0ec2630882 Bluetooth: Mesh: Add initial implementation
Add an initial implementation for the Bluetooth Mesh Profile
Specification. The main code resides in subsys/bluetooth/host/mesh and
the public API can be found in include/bluetooth/mesh.h. There are a
couple of samples provided as well under samples/bluetooth and
tests/bluetooth.

The implementation covers all layers of the Bluetooth Mesh stack and
most optional features as well. The following is a list of some of
these features and the c-files where the implementation can be found:

 - GATT & Advertising bearers (proxy.c & adv.c)
 - Network Layer (net.c)
 - Lower and Upper Transport Layers (transport.c)
 - Access Layer (access.c)
 - Foundation Models, Server role (health.c & cfg.c)
 - Both PB-ADV and PB-GATT based provisioning (prov.c)
 - Low Power Node support (lpn.c)
 - Relay support (net.c)
 - GATT Proxy (proxy.c)

Notable features that are *not* part of the implementation:

 - Friend support (initial bits are in place in friend.c)
 - Provisioner support (low-value for typical Zephyr devices)
 - GATT Client (low-value for typical Zephyr devices)

Jira: ZEP-2360

Change-Id: Ic773113dbfd84878ff8cee7fe2bb948f0ace19ed
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-07-20 09:30:44 +03:00
Marcel Holtmann aefcf547ad Bluetooth: controller: Add skeleton for vendor HCI commands
Signed-off-by: Marcel Holtmann <marcel.holtmann@intel.com>
2017-07-14 14:54:52 +03:00
Johan Hedberg 30beef9419 Bluetooth: GATT Introduce BT_GATT_CCC_MAX helper define
The worst-case maximum number of CCC entries we need is actually
MAX_CONN + MAX_PAIRED. Provide a helper define for it and use it
whenever appropriate.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-07-04 17:30:40 +03:00
Johan Hedberg dd542e14f6 Bluetooth: GATT: Reorder bt_gatt_ccc_cfg to eliminate padding
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-07-04 17:30:40 +03:00
Carles Cufi d990079f15 Bluetooth: controller: Fix HCI remote version structure
The HCI Read Remote Version Information Complete event structure was
incorrect, leading to qualification test failures. This patch fixes the
structure and also the storing of the data in an endianness-agnostic
manner.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-07-04 13:43:48 +03:00
Carles Cufi fc14bfbe2f Bluetooth: controller: Filter Auth Payload timeout exp
Correctly filter out the Authenticated Payload Timeout Expired event
based on the bit present on page 2 of the Event Mask.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-07-03 15:43:00 +02:00
Carles Cufi 73378e1cad Bluetooth: controller: Add support for Event Mask Page 2
In order to be able to filter events present in Page 2 of the Event
Mask, this command allows the Host to set the Page 2 of the bitmask
through the corresponding command.

Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2017-07-03 15:43:00 +02:00
Johan Hedberg a5ae267e92 Bluetooth: Introduce new BT_LE_ADV_OPT_ONE_TIME advertising option
In some cases applications may want better control of advertising
instead of the stack doing automated re-enablement. Introduce a new
option that can be used to do more "manual" advertising control.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-06-29 15:08:00 +03:00