Add support for: - SAR Configuration Client and Server models - Transport SAR configuration states - Using SAR Transmitter/Receiver states in segmentation and reassembly process. Bsim tests fixes: - Fix failing replay attack test. The replay attack test doesn't consider retransmission attempts at the transport layer. When retransmission happens, SeqNums get increased and the test logic doesn't work anymore. The simplest fix would be to disable retransmissions at the transport layer. - Add device synchronization API to synchronize transport va test. Device configuration may take different time on transmitter and receiver. Add synchronisation barrier between devices. - Fix msg_frnd test. Timing in transport sar behavior has been changed, which affected test_friend_msg test. Now acknowledgments are sent much faster and this needs to be considered in the test. - Fix unicast_low_lat test. Increase number of retransmission attempts when long segmented message is sent. - Reduce timeout in kr_old_key test. - Relax SAR RX state configuration in DFU and BLOB tests. Co-authored-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no> Co-authored-by: Anders Storrø <anders.storro@nordicsemi.no> Co-authored-by: Ingar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no> Signed-off-by: Michał Narajowski <michal.narajowski@codecoup.pl> Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
70 lines
2.1 KiB
C
70 lines
2.1 KiB
C
/*
|
|
* Copyright (c) 2020 Nordic Semiconductor ASA
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
#include <zephyr/net/buf.h>
|
|
#include <zephyr/bluetooth/bluetooth.h>
|
|
#include <zephyr/bluetooth/conn.h>
|
|
#include <zephyr/bluetooth/gatt.h>
|
|
#include <zephyr/bluetooth/mesh.h>
|
|
#include <zephyr/types.h>
|
|
|
|
#include "net.h"
|
|
#include "sar_cfg_internal.h"
|
|
|
|
void bt_mesh_sar_tx_encode(struct net_buf_simple *buf,
|
|
const struct bt_mesh_sar_tx *tx)
|
|
{
|
|
net_buf_simple_add_u8(buf, (tx->seg_int_step & 0xf) |
|
|
(tx->unicast_retrans_count << 4));
|
|
net_buf_simple_add_u8(buf, (tx->unicast_retrans_without_prog_count &
|
|
0xf) | (tx->unicast_retrans_int_step << 4));
|
|
net_buf_simple_add_u8(buf, (tx->unicast_retrans_int_inc & 0xf) |
|
|
(tx->multicast_retrans_count << 4));
|
|
net_buf_simple_add_u8(buf, tx->multicast_retrans_int & 0xf);
|
|
}
|
|
|
|
void bt_mesh_sar_rx_encode(struct net_buf_simple *buf,
|
|
const struct bt_mesh_sar_rx *rx)
|
|
{
|
|
net_buf_simple_add_u8(buf, (rx->seg_thresh & 0x1f) |
|
|
(rx->ack_delay_inc << 5));
|
|
net_buf_simple_add_u8(buf, (rx->discard_timeout & 0xf) |
|
|
((rx->rx_seg_int_step & 0xf) << 4));
|
|
net_buf_simple_add_u8(buf, (rx->ack_retrans_count & 0x3));
|
|
}
|
|
|
|
void bt_mesh_sar_tx_decode(struct net_buf_simple *buf,
|
|
struct bt_mesh_sar_tx *tx)
|
|
{
|
|
uint8_t val;
|
|
|
|
val = net_buf_simple_pull_u8(buf);
|
|
tx->seg_int_step = (val & 0xf);
|
|
tx->unicast_retrans_count = (val >> 4);
|
|
val = net_buf_simple_pull_u8(buf);
|
|
tx->unicast_retrans_without_prog_count = (val & 0xf);
|
|
tx->unicast_retrans_int_step = (val >> 4);
|
|
val = net_buf_simple_pull_u8(buf);
|
|
tx->unicast_retrans_int_inc = (val & 0xf);
|
|
tx->multicast_retrans_count = (val >> 4);
|
|
val = net_buf_simple_pull_u8(buf);
|
|
tx->multicast_retrans_int = (val & 0xf);
|
|
}
|
|
|
|
void bt_mesh_sar_rx_decode(struct net_buf_simple *buf,
|
|
struct bt_mesh_sar_rx *rx)
|
|
{
|
|
uint8_t val;
|
|
|
|
val = net_buf_simple_pull_u8(buf);
|
|
rx->seg_thresh = (val & 0x1f);
|
|
rx->ack_delay_inc = (val >> 5);
|
|
val = net_buf_simple_pull_u8(buf);
|
|
rx->discard_timeout = (val & 0xf);
|
|
rx->rx_seg_int_step = (val >> 4);
|
|
val = net_buf_simple_pull_u8(buf);
|
|
rx->ack_retrans_count = (val & 0x3);
|
|
}
|