Commit graph

10681 commits

Author SHA1 Message Date
David Cermak 55dd3c8b77 ws_client: fix fragmented send setting proper opcodes
Previous implementation violated the RFC by having both the actual opcode and WS_FIN flag set for all fragments of a message.
Fixed by setting the opcode only for the first fragment and WS_FIN for the last one

Closes IDFGH-2938
Closes https://github.com/espressif/esp-idf/issues/4974
2020-05-22 06:11:44 +00:00
David Čermák 7b01509b19 Merge branch 'bugfix/stop_mac_can_be_controlled_by_user_v4.0' into 'release/v4.0'
Bugfix/stop mac can be controlled by user v4.0

See merge request espressif/esp-idf!8762
2020-05-22 14:07:48 +08:00
Island 5897354d7f Merge branch 'bugfix/sync_zephyr_bt_mesh_bugfix_v4.0' into 'release/v4.0'
Bugfix/sync zephyr bt mesh bugfix (v4.0)

See merge request espressif/esp-idf!8853
2020-05-22 10:50:39 +08:00
Island 6c99fdceb2 Merge branch 'bugfix/ble_mesh_node_old_version_to_new_v4.0' into 'release/v4.0'
ble_mesh: Fix mesh node device role restore (v4.0)

See merge request espressif/esp-idf!8854
2020-05-22 10:50:09 +08:00
Island 1340e600c2 Merge branch 'doc/ble_mesh_fix_v4.0' into 'release/v4.0'
ble_mesh: Doc miscellaneous fixes (v4.0)

See merge request espressif/esp-idf!8859
2020-05-22 10:49:39 +08:00
lly cdd35648b7 ble_mesh: Doc miscellaneous fixes
- Update ble mesh architecture
2020-05-21 17:48:21 +08:00
Michael (XIAO Xufeng) 6fe46c1798 Merge branch 'bugfix/timer_group_intr_enable_v4.0' into 'release/v4.0'
Fix timer group intr enable (backport v4.0)

See merge request espressif/esp-idf!8530
2020-05-21 17:42:02 +08:00
lly d2bcb5c7ff ble_mesh: A specific fix for compile warning in idf4.0
Compared with the latest idf, idf4.0 defines BIT(nr) in
the "esp_bit_defs.h" without the pre-condition "#ifndef BIT",
which will cause compile warning when using mesh. So we
include the header file "soc/soc.h" in "mesh_util.h",
which can bypass the definition of "BIT" in "mesh_util.h"
when compiling.
2020-05-21 16:50:09 +08:00
lly 2ea69e6df5 ble_mesh: Fix mesh node device role restore
Old version of BLE Mesh has no device role storage, because
previously we only support storing mesh node info.
If the binary of the node is upgraded from old version to a
new version (support storing provisioner info), the mesh info
of the node will not be restored because mesh role does not
exist in the flash.
2020-05-21 15:26:50 +08:00
lly b5bd1bf67e ble_mesh: Fix not update prov addr in fast prov
When using fast provisioning, the Provisioner functionality
will be enabled. Unicast addresses within the pre-allocated
range will be used for provisioning nodes. And during the
address assignment, the allocated unicast address will be
checked that if it's duplicated with other nodes addresses
and the Provisioner's own addresses.
So before starting using fast provisioning, we need to update
the Provisioner address.
2020-05-21 15:22:21 +08:00
lly 8294055c65 ble_mesh: net_key_status only pull one key idx [Zephyr]
Fixes bug where the config client's net_key_status handler would attempt
to pull two key indexes from a message which only holds one.
2020-05-21 15:22:21 +08:00
lly 11286e35a2 ble_mesh: Update client message timeout calculation
Since the behavior of sending segmented messages has been
changed properly, the calculation of timeout value which
will be used when sending an acknowledged message by a
client model also needs to be updated.
2020-05-21 15:22:20 +08:00
lly 2c5b0a523a ble_mesh: Add lock for segmented msg operations
Add mutex to protect some variables of the mesh segmented
messages.
Currently the timeout handler of mesh will be executed in
the btc task, while the received mesh messages will be
handled in the btu task. In case some variables are set to
NULL when handled in the btu task, meanwhile these variables
are also accessed in the timeout handler, so we add mutex to
protect these variables and related operations.
2020-05-21 15:22:19 +08:00
lly 8c6f6318c0 ble_mesh: Fix dereferencing pointer before checking for NULL [Zephyr]
The publication context is checked for NULL in bt_mesh_model_publish()
however it was dereferenced before that. Move the assignment to
ctx.send_rel to the same place where other ctx members are set.
2020-05-21 15:22:18 +08:00
lly 632d9739b5 ble_mesh: Optimize some mesh log output 2020-05-21 15:22:18 +08:00
lly 34cb56b7aa ble_mesh: Fix restore when revoke keys [Zephyr]
Store keys (NetKey and AppKey) again after revoking.
2020-05-21 15:22:17 +08:00
lly 7c12074801 ble_mesh: Spit mesh_util.h into different header files
Split mesh_util.h into mesh_byteorder.h, mesh_compiler.h,
mesh_ffs.h and mesh_util.h based on the classification of
Zephyr, which will make further porting more clear.
2020-05-21 15:22:16 +08:00
lly 4b21a34675 ble_mesh: Split mesh os related into a separate file 2020-05-21 15:22:13 +08:00
lly ac51ec11ec ble_mesh: Split mesh mutex into a separate file 2020-05-21 15:19:52 +08:00
lly 7db10be193 ble_mesh: Rename mesh_kernel.* to mesh_timer.* 2020-05-21 15:19:51 +08:00
lly fde075aec2 ble_mesh: Add and use transport macro definitions [Zephyr] 2020-05-21 15:19:51 +08:00
lly cbd2bcfbd2 ble_mesh: Friend SeqAuth cleanup [Zephyr]
The Friend queue uses the message SeqAuth to determine whether the
message is already in the queue. To facilitate this, the SeqAuth is
passed around as a pointer throughout the transport modules. In the
bt_mesh_ctl_send functions, this parameter is also exposed in the API,
but the internal usage is inconsistent and buggy. Also, no one actually
uses this parameter.

- Removes seq_auth param from bt_mesh_ctl_send, instead passing NULL
  directly to the friend module, to enforce its addition to the queue.
- Makes the seq_auth pointer const throughout the friend module.
2020-05-21 15:19:50 +08:00
lly 5c5621790a ble_mesh: Rework msg_cache [Zephyr]
Changes the behavior of the message cache to optimize for cache
capacity. Previously, the message cache's primary function was to avoid
decrypting messages multiple times, although the cache's main function
in the spec is to avoid message rebroadcasting. Optimizing for minimal
decryption causes us to fill the network cache faster, which in turn
causes more cache misses, potentially outweighing the advantage.

Now stores src + seq in message cache instead of field hash value. This
cuts cache size in two, while including more of the sequence number than
before.

Adds messages to the cache only after the packet is successfully
decrypted. This reduces noise in the cache, and ensures that no
invalid deobfuscations are added.

Additionally, this fixes a bug where multiple calls to net_decrypt with
the same packet failed, as the message cache found its own entry from
the previous call.
2020-05-21 15:19:49 +08:00
lly fbdb7ff665 ble_mesh: Segmented TX to groups [Zephyr]
Implements several changes to the transport layer segmented tx to
improve group message performance:
- Moves retransmit counter to tx context instead of per packet. As every
  unacked packet is sent every retransmit, the retransmit counters would
  be the same in each segment. This makes it easier to control progress.
- Delays the scheduling of the retransmit until the completion of the
  last segment by adding a seg_pending counter. This is essentially the
  same as the old behavior, except that the old behavior might retrigger
  the sending before all segments are finished if the advertising is
  slow.
- Allows the group transmits to stop as soon as all retransmits have
  been exhausted, instead of timing out waiting for acks that won't
  come. This allows group tx to finish without error.
- Fixes a bug where a failed TX would block IV update.
- Cancels any pending transmissions of acked segments.
- Reduces log level for several common group tx scenarios that aren't
  erronous.
2020-05-21 15:19:49 +08:00
lly bbfaaa2044 ble_mesh: Add comment explaining use of byte order [Zephyr]
Add comment that explains why a different byte order is used for the
3-byte opcode on the CID part of the opcode.
2020-05-21 15:19:48 +08:00
lly ad14507e3f ble_mesh: Use 24-bit functions [Zephyr]
Use 24-bit functions for byteorder and net_buf in order to make the
byteorder used more readable.
2020-05-21 15:19:47 +08:00
lly c9d1255ce4 ble_mesh: Optimize net_buf_simple routines [Zephyr]
Use sys_put_xyz() helpers instead of memcpy() whenever possible. This
brings in straight-line inline code for pushes and adds of known,
small sizes.
2020-05-21 15:19:46 +08:00
lly 25569cd9de ble_mesh: Add PRIu64 & PRIx64 in mesh_types.h 2020-05-21 15:19:46 +08:00
lly 416e8958fa ble_mesh: Add push functions for supported bit-variants [Zephyr]
Add push functions for bit-widths supported by add and pull functions.
2020-05-21 15:19:45 +08:00
lly cde1592bf3 ble_mesh: Add support for 64 bit data type [Zephyr]
This enables pulling and pushing values in 64 bit format.
2020-05-21 15:19:44 +08:00
lly 0af05fdee1 ble_mesh: Add support for 48 bit data type [Zephyr]
This enables pulling and pushing values in 48 bit format.
2020-05-21 15:19:44 +08:00
lly 4536a485be ble_mesh: Add 48 bit variants [Zephyr]
This adds sys_*_*48 functions that operation on a 48 bits values.
2020-05-21 15:19:43 +08:00
lly e7d37f2d1a ble_mesh: Add support for 24 bit data type [Zephyr]
This enables pulling and pushing values in 24 bit format.
2020-05-21 15:19:42 +08:00
lly fd17ff2f0b ble_mesh: Add 24 bit variants [Zephyr]
This adds sys_*_*24 functions that operation on a 24 bits values.
2020-05-21 15:19:41 +08:00
lly e322c5950b ble_mesh: Group resends in proxy nodes [Zephyr]
Resend transport segments for groups on the advertiser interface, even
if a connected proxy node holds the group.
2020-05-21 15:19:41 +08:00
lly 1f96a6f35d ble_mesh: Typo in condition in comp_add_elem of cfg_srv [Zephyr]
Vendor model IDs take up four (not two) bytes in the composition
2020-05-21 15:19:40 +08:00
lly 4fddf1156b ble_mesh: GATT Proxy Spec 1.0.1 changes [Zephyr]
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."
2020-05-21 15:19:39 +08:00
lly 833483bb22 ble_mesh: Support reliable sending when publishing [Zephyr]
Until now the choice of reliable sending (segmented messages with
acks) was implicitly dependent on the size of the payload. Add a new
member to the bt_mesh_model_pub to force using segment acks even when
the payload would fit a single unsegmented message.
2020-05-21 15:19:39 +08:00
lly 3d4948664b ble_mesh: Check device uuid when init provisioning 2020-05-21 15:19:38 +08:00
lly 203f871420 ble_mesh: Fix provisioning buffer initialization [Zephyr]
When PB-GATT support has been enabled the provisioning code "borrows"
the buffer from the proxy code. However, the way that initialization
was happening the proxy buffers were initialized only after
provisioning initialization, resulting in a corrupted buffer with
buf->data pointing to NULL. Reorder the initialization calls so that
proxy is done first and provisioning only after it.
2020-05-21 15:19:37 +08:00
lly 2c6a3f9e5b ble_mesh: Skip publish if update fails [Zephyr]
Allow models to skip a periodic publish interval by returning an error
from the publish update callback.

Previously, an error return from publish update would cancel periodic
publishing. This can't be recovered from, and as such, no valid model
implementation could return an error from this callback, and there was
no way to skip a periodic publish.
2020-05-21 15:19:36 +08:00
lly 2b6131b5f4 ble_mesh: Enable Segmented Control Messages [Zephyr]
The function bt_mesh_ctl_send() used to support maximum length of
11 bytes. The segmentation complies with the BLE Mesh Standard.
The ack is disabled in case of non unicast address.
2020-05-21 15:19:36 +08:00
Island 793d2b11f1 Merge branch 'bugfix/ble_mesh_not_ignore_msg_in_fast_prov_v4.0' into 'release/v4.0'
ble_mesh: Not ignore msg when fast prov is enabled (v4.0)

See merge request espressif/esp-idf!8711
2020-05-21 15:16:08 +08:00
Island bbc95d981c Merge branch 'bugfix/ble_mesh_use_sdkconfig_ci_v4.0' into 'release/v4.0'
ble_mesh: Add bluedroid and nimble example configurations (v4.0)

See merge request espressif/esp-idf!8499
2020-05-21 15:14:45 +08:00
Island 471171cb32 Merge branch 'feat/ble_mesh_sensor_model_example_v4.0' into 'release/v4.0'
ble_mesh: Add ble mesh sensor model examples (v4.0)

See merge request espressif/esp-idf!8508
2020-05-21 15:14:22 +08:00
Island 3b4ff12246 Merge branch 'bugfix/ble_mesh_compile_error_o2_v4.0' into 'release/v4.0'
ble_mesh: Fix compile error when -O2 (performance) is chosen (v4.0)

See merge request espressif/esp-idf!8617
2020-05-21 15:13:56 +08:00
Island 351dba9272 Merge branch 'bugfix/ble_mesh_provisioner_check_key_v4.0' into 'release/v4.0'
ble_mesh: Check if appkey exist before deleting it (v4.0)

See merge request espressif/esp-idf!8620
2020-05-21 15:13:31 +08:00
Island 7b6236c2d9 Merge branch 'bugfix/ble_mesh_node_reset_erase_v4.0' into 'release/v4.0'
ble_mesh: Fix node not erase info completely (v4.0)

See merge request espressif/esp-idf!8623
2020-05-21 15:12:21 +08:00
Michael (XIAO Xufeng) 1ce4c20115 Merge branch 'bugfix/fix_gpio_wake_up_disable_invalid_for_rtc_io_v4.0' into 'release/v4.0'
bugfix (GPIO): fixed gpio_wake_up_disable not working for RTC IO (release/4.0)

See merge request espressif/esp-idf!7996
2020-05-21 11:39:39 +08:00
lly 3e885dc73b ble_mesh: Add bluedroid and nimble example configurations 2020-05-20 11:25:07 +00:00