Commit graph

22 commits

Author SHA1 Message Date
Trond Einar Snekvik cb7835d18f Bluetooth: Mesh: Wait for proxy on node reset
Adds idle wait callback to proxy by counting the number of pending
notifications.

Ensures that all connected nodes have received messages before resetting
the mesh stack.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-07-09 13:49:26 +02:00
Michał Narajowski 73e1cccdbb mesh: Fix Vendor Model Subscription Get procedure
Invalid argument was passed to bt_mesh_model_tree_walk.

Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl>
2020-07-02 16:30:01 +03:00
Lingao Meng 7239dc1cbd Bluetooth: Mesh: Add key-value concept to store model data
Previous mode store function only can store single data,
change this to store as KV model, let's app-layer to manager
model data, other than by stack when node reset.

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-06-12 11:09:11 +02:00
Kumar Gala a1b77fd589 zephyr: replace zephyr integer types with C99 types
git grep -l 'u\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/u\(8\|16\|32\|64\)_t/uint\1_t/g"
	git grep -l 's\(8\|16\|32\|64\)_t' | \
		xargs sed -i "s/s\(8\|16\|32\|64\)_t/int\1_t/g"

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2020-06-08 08:23:57 -05:00
Trond Einar Snekvik a385873336 Bluetooth: Mesh: Fail init on model init error
Adds propagation of error returns from the model init callbacks in
Access, and removing any other checks for successful init in the
foundation models.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-05-27 18:45:18 +02:00
Joakim Andersson 87d9eadf50 Bluetooth: mesh: Convert bluetooth mesh to using k_timeout struct
Convert bluetooth mesh to using k_timeout struct. Many of the mesh
modules uses timeout calculations, so it is most practical to keep
the s32_t type and only initialize a k_timeout_t struct when
calling the kernel.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-04-30 13:46:48 +03:00
Lingao Meng 49e4f754b4 Bluetooth: Mesh: Fix add model group address to sub list
When low power node reset, should add group address to
friend subscription list.

Fixes: #24311

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2020-04-19 18:36:12 +03:00
Joakim Andersson c97e1aafb1 Bluetooth: Mesh: Fix possible NULL dereference in BT_DBG statement.
Fix possible NULL dereference in BT_DBG statement when
bt_mesh_friend_get is called before a successful cfg_srv init

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-03-06 10:04:46 +02:00
Stephen Pliaskin 84e381e0a7 Bluetooth: Mesh: typo in condition in comp_add_elem of cfg_srv
Vendor model IDs take up four (not two) bytes in the composition

Fixes #22822

Signed-off-by: Stephen Pliaskin <strelok@e-kirov.ru>
2020-02-16 23:28:51 +03:00
Trond Einar Snekvik d55c8ead03 Bluetooth: Mesh: GATT Proxy Spec 1.0.1 changes
Backport of https://github.com/apache/mynewt-nimble/pull/724

Mesh spec 1.0.1 changes proxy disabling behavior to only affect the
relaying from proxy nodes. Previously, disabling proxy would shut down
all proxy and node activity.

Tweaks from the original commit:
- Removed redundant call to bt_mesh_adv_update() in gatt_proxy_set()
- Removed invalid ref to 4.2.11.1 in node_identity_set()

---

According to Mesh Profile Spec 1.0.1, Section 4.2.11:
"If the Proxy feature is disabled, a GATT client device can connect
over GATT to that node for configuration and control. Messages from
the GATT bearer are not relayed to the advertising bearer."

Moreover some notes have been removed from the spec compared to
version 1.0:

Mesh Profile Spec 1.0, Section 4.2.11:

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

"The Configuration Client should turn off the Proxy state as the last
step in the configuration process."

Mesh Profile Spec 1.0, Section 4.2.11.1:

"When the GATT Proxy state is set to 0x00, the Node Identity state
for all subnets shall be set to 0x00 and shall not be changed."

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2020-02-14 14:43:06 +02:00
Joakim Andersson 6426cd58fc Bluetooth: mesh: Use 24-bit functions
Use 24-bit functions for byteorder and net_buf in order to make the
byteorder used more readable.

Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
2020-01-02 19:05:27 +01:00
Lingao Meng a071957746 Bluetooth: Mesh: Fixes wrong return value
Fixes missing return value on `va_del`
Fixes wrong return value on `va_add`

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2019-11-27 11:22:20 +02:00
Trond Einar Snekvik 0151d6dc33 Bluetooth: Mesh: Model extension concept
Adds the model extension concept to the access layer, as described in
the Mesh Profile Specification, Section 2.3.6. Extensions are
implemented as a tree, using two pointers in each model:

The extends pointer points to the first extended model, and the next
pointer points to the next sibling or (if the NEXT_IS_PARENT flag is
set) the parent model in the tree, forming a cyclical "Left-child
right-sibling" (LCRS) tree. The tree root can be obtained by calling
bt_mesh_model_root_get(), and the extended models can be walked by
calling bt_mesh_model_tree_walk().

According to the Mesh Profile Specification Section 4.2.3, all models in
the same extension tree share one subscription list per element. This is
implemented by walking the model's extension tree, and pooling the
subscription lists of all models in the same element into one. If the
config server adds a subscription to a model, it may be stored in any of
the model tree's models' subscription lists. No two models in the same
extension tree and element will have duplicate groups listed. This
allows us to increase extended models' capacity for subscriptions
significantly.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2019-11-07 18:57:32 +02:00
Trond Einar Snekvik 2cc0263a53 Bluetooth: Reduce severity of unavoidable warnings
Reduces the severity of warnings that happen from normal behavior, or
can't be prevented by the user:
- "No ID address" in hci_core.c: Reduced to an informational warning, as
  this will always output with the expected usage. This isn't useful
  information for 99.9% of users, and pollutes the output of all samples
  using the module.
- "Composition page %u not available" in cfg_srv.c: According to the
  Mesh Profile Specification section 4.4.2.2.2, the client is expected
  to send page=0xff. Reduced to a debug message.
- "Connectable advertising deferred" in proxy.c: Gets logged every 10
  seconds when in a Mesh Proxy connection. This is not useful
  information unless the user is debugging the proxy module. Reduced to
  a debug message.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2019-11-06 19:24:32 +02:00
Tobias Svehagen 80669decce Bluetooth: Mesh: Add support for provisioner role over PB-ADV
Make it possible to provision devices over advertising bearer (PB-ADV).
Many messages in the provisioning protocol are the same for provisioner
and device so much of the code could be reused by only changing when
they are expected to arrive.

This introduces to concept of local and remote device keys. The models
for cfg_cli and cfg_srv have been updated to reflect this concept. Both
the send and receive path in the transport layer have been updated to
support encrypting/decrypting with local and remote device keys.

When a node has been provisioned it is stored in bt_mesh_net.nodes. If
CONFIG_BT_SETTINGS is enabled, they are also saved to settings. If the
callback node_added in bt_mesh_prov has been set, it will be called for
every node that gets provisioned. This includes when they are retrieved
from settings.

The configuration CONFIG_BT_MESH_NODE_COUNT controls how many nodes that
can be provisioned.

Signed-off-by: Tobias Svehagen <tobias.svehagen@gmail.com>
2019-10-30 13:08:09 +01:00
Lingao Meng 101ad56d43 Bluetooth: Mesh: Persistent storage of Virtual Addresses
The 16-bit format group addresses will be stored,
but we don't store (or restore) the virtual label UUIDs,
i.e. after a power cycle the 16-bit group addresses
would be meaningless.

Fixes #19342

Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
2019-10-17 12:24:13 +03:00
Trond Einar Snekvik 5aee3ee995 Bluetooth: Mesh: Model message macros
Creates macros for determining model message lengths based on opcode,
payload length and MIC size. Also adds macro wrapping
NET_BUF_SIMPLE_DEFINE to serve the most common use case.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2019-10-08 18:38:43 +03:00
Trond Einar Snekvik b7d05fbf13 Bluetooth: Mesh: Add model reset callback
Adds additional model callback that gets called on node_reset. Will also
erase any user data when this happens.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2019-09-16 22:56:22 +03:00
Trond Einar Snekvik c2c05c916a Bluetooth: Mesh: Add model callback structure
Adds a structure of callbacks for each model instance. This allows for
more flexible model implementations, that can interact with the Mesh
stack without going through the application.

For now, only an init callback is added, replacing the init mechanism in
the foundation models. The init callback does not provide the primary
flag that used to be in the foundation model callbacks, but replaces
this with an inline function in access.h.

Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
2019-09-16 22:56:22 +03:00
Johan Hedberg 39edab1013 Bluetooth: Mesh: Fix checking for active heartbeat publication
When sending heartbeat messages triggered by feature changes the code
was trying to look up the configured publication subnet, in an
apparent attempt to figure out if publication is enabled or not. A
more appropriate way is to check for the heartbeat publication
destination address, and since we have a helper function this can be
done in a single place.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-14 14:48:37 +02:00
Johan Hedberg ed71fc9a9e Bluetooth: Mesh: Move heartbeat sending to transport layer
The heartbeat is a transport layer feature, so move it to transport.c.
This also opens the way to properly fix Friendship-established/lost
triggering for LPN role.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-08-14 14:48:37 +02:00
Johan Hedberg 408703e8dd Bluetooth: Mesh: Move under subsys/bluetooth/mesh
We've already got GATT services in subsys/bluetooth/services so
subsys/bluetooth/mesh is a more natural place. Aditionally this aims
to fix the Kconfig dependencies to be able to use mesh together with
BT_CUSTOM (i.e. a custom, potentially non-HCI, host stack).

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2019-07-10 09:41:57 +03:00
Renamed from subsys/bluetooth/host/mesh/cfg_srv.c (Browse further)