Commit graph

1085 commits

Author SHA1 Message Date
Mariusz Skamra 0572fe99ec Bluetooth: mesh: Check Heartbeat Pub count prior scheduling delayed work
This check is needed to not schedule the delayed work if current
message to be sent is the last heartbeat message.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-19 14:07:48 +02:00
Mariusz Skamra 37122d7205 Bluetooth: mesh: Reset Heartbeat Pub timer before sending message
The timer should be reset before sending to ensure correct
publication period.

This patch allows to pass MESH/NODE/CFG/HBP/BV-02-C.

This patch is ported from mynewt:
Commit: d4b84638df47e7ea21629e6919f547f5dcd47285

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-19 14:07:48 +02:00
Ioannis Glaropoulos 55d3ce111c Bluetooth: controller: Refactoring nRF5 radio driver
This commit refactors the nRF5 radio driver of Bluetooth controller
to use symbolic names for PPIs. It also revisits the Radio hardware
timing constants to align with experimental measurements.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
2018-01-18 10:58:04 +01:00
Mariusz Skamra 385240ad0c Bluetooth: Fix BT_TESTING option dependency
This removes BT_DEBUG dependency on BT_TESTING flag.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-16 14:40:54 +02:00
Mariusz Skamra 2f81942754 Bluetooth: mesh: Fix model subscription groups cleanup
Virtual address labels array entries were not updated on va deletion,
so that STATUS_INSUFF_RESOURCES error was returned after few
subsequent Config Model Subscription Virtual Address Add, Delete,
Overwrite commands, even if there shall be free space available.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-10 16:38:53 +02:00
Mariusz Skamra 4ba9543bdd Bluetooth: mesh: Fix LPN subsciption groups update on VA deletion
This fixes missing bt_mesh_lpn_group_del call in mod_sub_va_del.
If Config Model Subscription Virtual Address Delete was received
and successfully proceeded, subscription address shall be also
deleted from LPN Subscribe Groups.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-10 16:38:53 +02:00
Anas Nashif 4d2ad0a8a5 Bluetooth: remove unused BT_DEBUG_COLOR
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2018-01-09 10:59:41 -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 fdca8d8f54 Revert "Bluetooth: Mesh: Fix ignoring invalid Transport OpCode as LPN"
This reverts commit ada5771d7c.

MESH/NODE/FRND/LPN/BI-02-C in Mesh Test Specification 1.0.1
has been fixed according to TSE #9774.

IUT shall ignore the message with an RFU Transport Control Opcode
but another Friend Poll message shall be sent with an alternating
FSN value.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-04 15:33:19 +01:00
Mariusz Skamra cc1a960730 Bluetooth: mesh: Fix status returned from mod_unbind
According to Mesh Specification v1.0 4.3.2.48 Config Model App Status:
"The Status Code shall be Success if the received request was redundant
(bind request of existing binding, or unbind of a non-existing binding),
with no further action taken."

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2018-01-04 15:08:43 +01: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
Manivannan Sadhasivam 045d146d9f subsys: bluetooth: host: mesh: shell: Fix IVIndex parsing
Fix the parsing of IVIndex value from shell command line for
cmd_provision

Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
2017-12-30 08:28:00 +01:00
Vinayak Kariappa Chettimada 891ba80087 Bluetooth: controller: Fix S2 coding Rx chain delay timing const
Fix the S2 coding Rx chain delay timing constant based on
manual observations.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-12-29 10:31:44 +01:00
Vinayak Kariappa Chettimada d3585cd1d9 Bluetooth: controller: Add tIFS SW switching for Coded PHY
Add implementation to consider differing Rx chain delays for
S2 and S8 Coded PHY PDU reception. These changes are
required to meet tIFS timings for transmission after a
reception on S8 coding.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-12-29 10:31:44 +01:00
Vinayak Kariappa Chettimada e00282af6e Bluetooth: Fix build failure with -Wshadow CFLAGS
Fixes many instances of errors similar to below:
zephyr/subsys/bluetooth/controller/ll_sw/ctrl.c:5927:22:
    error: declaration of ‘s_link’ shadows a previous
        local [-Werror=shadow]
  static memq_link_t s_link;
                     ^~~~~~
zephyr/subsys/bluetooth/controller/ll_sw/ctrl.c:5905:21:
    note: shadowed declaration is here
  static memq_link_t s_link;
                     ^~~~~~

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-12-20 12:29:52 -05: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
Anas Nashif 429c2a4d9d kconfig: fix help syntax and add spaces
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2017-12-13 17:43:28 -06:00
Mariusz Skamra 700328ac55 Bluetooth: Introduce Bluetooth Testing API
This introduces Bluetooth internal API intended to be used for
qualification purposes. Application may register callbacks to get
data that is not exposed by public API.

Signed-off-by: Mariusz Skamra <mariusz.skamra@codecoup.pl>
2017-12-13 11:26:32 +02:00
Vinayak Kariappa Chettimada ec5a787da2 Bluetooth: controller: Fix multiple master role event scheduling
When the controller is connecting to multiple connectable
advertisers, the events are scheduled consecutively avoiding
overlapping events. Calculation of the window offset did not
consider the preparation time before the event, causing the
new master role connection event to overlap with previous
event. This is now fixed by including the preparation time
in the used window offset from the end of connect_ind PDU
transmitted.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-12-09 09:24:37 +02:00
Michał Narajowski 06facdcad7 Bluetooth: Mesh: Fix typo in Kconfig help message
300 * 100 ms = 30000 ms = 30 s

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2017-12-07 17:15:47 +02:00
Vinayak Kariappa Chettimada ba13c99141 Bluetooth: controller: Fix conn param req initiation check
Fixed the check related to initiating connection parameter
request procedure. This will avoid sending invalid repeated
dispatch of connection parameter request PDU.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-12-06 11:30:42 -06:00
Vinayak Kariappa Chettimada 73a493eae6 Bluetooth: controller: Fix missing CPR procedure reset
When connection parameter request procedure was responded
by master role with Unsupported Link Layer Parameter Value,
a missing reset of the connection parameter request
procedure state caused next connection parameter request to
be incorrectly responded with same procedure collision
extended reject ind PDU. This caused an eventual connection
disconnection with reason LMP response timeout. This is now
fixed by reseting the state correctly.

Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
2017-12-06 10:24:26 -06:00
Johan Hedberg 8b51b60634 Bluetooth: Mesh: Proxy: Don't try to advertise when it's not possible
If we have the maximum number of supported connections, then it
doesn't make sense to try to do connectable advertising.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg e4cac812df Bluetooth: Mesh: Proxy: Fine-tune subnet advertising rotation
Create a slightly smarter algorithm for choosing how long to advertise
each subnet. This is particularly important for the mesh_shell app,
since it uses a 10 second NODE_ID_TIMEOUT, meaning starting Node ID
advertising through user interaction would only succeed in advertising
one subnet (due to this being configured to 10 seconds).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg 6e89138823 Bluetooth: Mesh: Suppport multiple subnets for app-triggered Node ID
Mesh Profile Specification 1.0 section 7.2.2.2.3:

"When the server starts advertising as a result of user interaction,
the server shall interleave the advertising of each subnet it is a
member of"

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg 174facc02a Bluetooth: Mesh: Prioritize subnets with Node ID
Node ID advertising is short lived, so it's important to make sure
that subnets that get it enabled are first in queue to start
advertising.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg 86ac86c6ca Bluetooth: Mesh: Add helpers for starting/stopping Node ID
We'll soon extend the start functionality with a bit more stuff
(prioritizing the started subnet), so in order to avoid excessive code
duplication, create helpers for these actions.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg 62777755f9 Bluetooth: Mesh: Add Proxy advertising support for multiple subnets
Until now the proxy server code would only advertise with the first
subnet. Introduce tracking of what the last advertised subnet was, and
give each subnet 10 seconds of advertising at a time.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02: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 74e1f51350 Bluetooth: Mesh: Coding-style: Remove redundant whitespace
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 20:02:19 +02:00
Johan Hedberg 22f3d36ba7 Bluetooth: Mesh: Fix relaying from GATT to Advertising
The logic for choosing to relay from the GATT bearer to the
advertising bearer was still buggy. This patch refactors the logic to
a separate helper function to make it clearer.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-05 13:52:10 +02:00
Johan Hedberg 7d7121b1ee Bluetooth: Mesh: Fix copy-paste mistake in log message
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-04 13:36:31 +02:00
Johan Hedberg dd839d90ac Bluetooth: Mesh: shell: Fix AppKey Add command handler
The command handler already has support for decoding from hex, however
it was not using the decoded value when calling the client API.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-04 13:36:31 +02:00
Johan Hedberg 39298cf3c5 Bluetooth: Mesh: Fix format specifier for s32_t
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-04 13:36:31 +02:00
Johan Hedberg c0b5a91588 Bluetooth: Mesh: Fix using the correct transmit state
If relaying is not supported, or disabled, the Relay Transmit state
will normally be 0, which is not what we want to use when proxying out
packets from GATT clients. The bt_mesh_net_relay() function is also
used for sending out locally originated packets, in which case the
Relay Retransmit state is also the wrong one to use (the Network
Transmit state should be used instead).

This patch makes sure we only use the Relay Retransmit state for
packets originating from the advertising bearer, and for all other
packets use the Network Transmit state.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-04 11:13:31 +02:00
Johan Hedberg 4871d8567b Bluetooth: Mesh: Fix relaying conditions for Adv & GATT bearers
The bt_mesh_net_relay() function was missing several important checks
for whether a PDU should be relayed or not. In particular, it would
relay a packet from adv to adv even if the Relay state was set to
disabled, as long as GATT Proxy was set to enabled. The code would
also relay packets to the GATT Proxy bearer if the Relay state was set
to enabled but GATT Proxy was set to disabled. This patch addresses
both of these issues.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-04 11:13:31 +02:00
Johan Hedberg ad6f9b15e6 Bluetooth: Mesh: Fix changing Relay state from Not Supported (0x02)
If the Relay state is set to Not Supported (0x02) the Config Relay Set
message should not change the state, rather just return its current
value.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-04 11:13:31 +02:00
Johan Hedberg 967d8b5b59 Bluetooth: Mesh: Fix beacon cache handling
The beacon cache handling was severely broken in the way that the
cache_add() function was incorrectly mapping net_idx to array index,
which could have lead to array overflows.

To fix this, while also cleaning things up, move the cache to the
actual bt_mesh_subnet struct. This e.g. lets us avoid having to track
the net_idx twice.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-01 12:28:56 +02:00
Johan Hedberg a3448aba9f Bluetooth: Mesh: Fix setting an upper limit on beacon interval
https://www.bluetooth.org/errata/errata_view.cfm?errata_id=9807

"If the computed Beacon Interval is less than 10 seconds, it should be
set to 10 seconds. If the computed Beacon Interval is greater than 600
seconds, it should be set to 600 seconds."

The lower limit is already covered by how frequently the delayed work
callback gets called, so we just need enforce the 600 second maximum.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-12-01 12:28:56 +02:00
Johan Hedberg 77ca943fd5 Bluetooth: Mesh: Fix sending beacons to Friend Queue & GATT clients
Whenever there's a security change (Key Refresh or IV Update) we
should immediately send beacons to any Friend Queues or connected GATT
clients. Introduce a helper function to do this, and make sure it's
called from all places that change the Key Refresh or IV Update
states.

This fixes test case MESH/SR/PROX/PB-12-C.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-30 19:29:15 +02:00
Johan Hedberg 8f2a7f2d46 Bluetooth: Mesh: Fix logging mesh addresses
Addresses are 16-bit and not 8-bit.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-30 19:29:15 +02:00
Johan Hedberg 1210258603 Bluetooth: Mesh: Clearly document the magic 18 byte minimum length
This makes it clear why 18 is a valid minimum network PDU length to
enforce. This is particularly important since as of writing this patch
there's at least one PTS test case which sends too small PDUs, which
could potentially lead to people thinking the implementation is at
fault (it's not).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-30 14:58:09 +02:00
Johan Hedberg 6078f8acc2 Bluetooth: Mesh: Introduce API for clearing the RPL
Some Transport Layer tests (MESH/NODE/TNPT/BV-13-C in particular)
require manual clearing of the RPL. Introduce an API for it as well as
a command to the mesh shell to call the API.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-29 13:49:45 +02:00
Johan Hedberg 3222662553 Bluetooth: Mesh: Fix Replay Protection List checking
If we the stored RPL entry was for an old IV Index, and the received
PDU is for a new IV Index we should not be comparing the sequence
number (as it's by definition always greater than the old one).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-29 13:49:45 +02:00
Johan Hedberg 859afbf39b Bluetooth: Mesh: Fix disconnecting clients when disabling GATT Proxy
Section 4.2.11 of the Mesh Profile Specification 1.0 states:

"Upon transition from GATT Proxy state 0x01 to GATT Proxy state 0x00
the GATT Bearer Server shall disconnect all GATT Bearer Clients."

This also makes test case MESH/SR/MPXS/BV-08-C pass.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2017-11-29 13:05:34 +02:00