zephyr/subsys/bluetooth/mesh/sar_cfg_internal.h
Michał Narajowski dd59a45c65 Bluetooth: Mesh: Transport SAR Configuration
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>
2023-03-06 13:52:15 +01:00

80 lines
3.8 KiB
C

/*
* Copyright (c) 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief Internal Transport SAR Configuration API
*/
#ifndef ZEPHYR_SUBSYS_BLUETOOTH_MESH_SAR_CFG_INTERNAL_H__
#define ZEPHYR_SUBSYS_BLUETOOTH_MESH_SAR_CFG_INTERNAL_H__
/** SAR Transmitter Configuraion state encoded length */
#define BT_MESH_SAR_TX_LEN 4
/** SAR Receiver Configuraion state encoded length */
#define BT_MESH_SAR_RX_LEN 3
/** SAR Transmitter Configuration state initializer */
#define BT_MESH_SAR_TX_INIT \
{ \
CONFIG_BT_MESH_SAR_TX_SEG_INT_STEP, \
CONFIG_BT_MESH_SAR_TX_UNICAST_RETRANS_COUNT, \
CONFIG_BT_MESH_SAR_TX_UNICAST_RETRANS_WITHOUT_PROG_COUNT, \
CONFIG_BT_MESH_SAR_TX_UNICAST_RETRANS_INT_STEP, \
CONFIG_BT_MESH_SAR_TX_UNICAST_RETRANS_INT_INC, \
CONFIG_BT_MESH_SAR_TX_MULTICAST_RETRANS_COUNT, \
CONFIG_BT_MESH_SAR_TX_MULTICAST_RETRANS_INT, \
}
/** SAR Receiver Configuration state initializer */
#define BT_MESH_SAR_RX_INIT \
{ \
CONFIG_BT_MESH_SAR_RX_SEG_THRESHOLD, \
CONFIG_BT_MESH_SAR_RX_ACK_DELAY_INC, \
CONFIG_BT_MESH_SAR_RX_DISCARD_TIMEOUT, \
CONFIG_BT_MESH_SAR_RX_SEG_INT_STEP, \
CONFIG_BT_MESH_SAR_RX_ACK_RETRANS_COUNT, \
}
#define BT_MESH_SAR_TX_SEG_INT_MS ((bt_mesh.sar_tx.seg_int_step + 1) * 10)
#define BT_MESH_SAR_TX_RETRANS_COUNT(addr) \
(BT_MESH_ADDR_IS_UNICAST(addr) ? \
(bt_mesh.sar_tx.unicast_retrans_count + 1) : \
(bt_mesh.sar_tx.multicast_retrans_count + 1))
#define BT_MESH_SAR_TX_RETRANS_NO_PROGRESS \
(bt_mesh.sar_tx.unicast_retrans_without_prog_count + 1)
#define BT_MESH_SAR_TX_UNICAST_RETRANS_INT_STEP_MS \
((bt_mesh.sar_tx.unicast_retrans_int_step + 1) * 25)
#define BT_MESH_SAR_TX_UNICAST_RETRANS_INT_INC_MS \
((bt_mesh.sar_tx.unicast_retrans_int_inc + 1) * 25)
#define BT_MESH_SAR_TX_UNICAST_RETRANS_TIMEOUT_MS(ttl) \
((ttl > 0) ? (BT_MESH_SAR_TX_UNICAST_RETRANS_INT_STEP_MS + \
BT_MESH_SAR_TX_UNICAST_RETRANS_INT_INC_MS * (ttl - 1)) : \
BT_MESH_SAR_TX_UNICAST_RETRANS_INT_STEP_MS)
#define BT_MESH_SAR_TX_MULTICAST_RETRANS_TIMEOUT_MS \
((bt_mesh.sar_tx.multicast_retrans_int + 1) * 25)
#define BT_MESH_SAR_TX_RETRANS_TIMEOUT_MS(addr, ttl) \
(BT_MESH_ADDR_IS_UNICAST(addr) ? \
BT_MESH_SAR_TX_UNICAST_RETRANS_TIMEOUT_MS(ttl) : \
BT_MESH_SAR_TX_MULTICAST_RETRANS_TIMEOUT_MS)
#define BT_MESH_SAR_RX_SEG_THRESHOLD (bt_mesh.sar_rx.seg_thresh)
#define BT_MESH_SAR_RX_ACK_DELAY_INC_X2 (bt_mesh.sar_rx.ack_delay_inc * 2 + 3)
#define BT_MESH_SAR_RX_ACK_RETRANS_COUNT (bt_mesh.sar_rx.ack_retrans_count + 1)
#define BT_MESH_SAR_RX_SEG_INT_MS ((bt_mesh.sar_rx.rx_seg_int_step + 1) * 10)
#define BT_MESH_SAR_RX_DISCARD_TIMEOUT_MS \
((bt_mesh.sar_rx.discard_timeout + 1) * 5 * MSEC_PER_SEC)
void bt_mesh_sar_tx_encode(struct net_buf_simple *buf,
const struct bt_mesh_sar_tx *tx);
void bt_mesh_sar_rx_encode(struct net_buf_simple *buf,
const struct bt_mesh_sar_rx *rx);
void bt_mesh_sar_tx_decode(struct net_buf_simple *buf,
struct bt_mesh_sar_tx *tx);
void bt_mesh_sar_rx_decode(struct net_buf_simple *buf,
struct bt_mesh_sar_rx *rx);
#endif /* ZEPHYR_SUBSYS_BLUETOOTH_MESH_SAR_CFG_INTERNAL_H__ */