Commit dd59a45c authored by Michal Narajowski's avatar Michal Narajowski Committed by Carles Cufi
Browse files

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: default avatarPavel Vasilyev <pavel.vasilyev@nordicsemi.no>
Co-authored-by: default avatarAnders Storrø <anders.storro@nordicsemi.no>
Co-authored-by: default avatarIngar Kulbrandstad <ingar.kulbrandstad@nordicsemi.no>
Signed-off-by: default avatarMichał Narajowski <michal.narajowski@codecoup.pl>
Signed-off-by: default avatarPavel Vasilyev <pavel.vasilyev@nordicsemi.no>
parent 2c1abb61
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -34,6 +34,8 @@
#include <zephyr/bluetooth/mesh/cdb.h>
#include <zephyr/bluetooth/mesh/cdb.h>
#include <zephyr/bluetooth/mesh/rpr_cli.h>
#include <zephyr/bluetooth/mesh/rpr_cli.h>
#include <zephyr/bluetooth/mesh/rpr_srv.h>
#include <zephyr/bluetooth/mesh/rpr_srv.h>
#include <zephyr/bluetooth/mesh/sar_cfg_srv.h>
#include <zephyr/bluetooth/mesh/sar_cfg_cli.h>
#include <zephyr/bluetooth/mesh/large_comp_data_srv.h>
#include <zephyr/bluetooth/mesh/large_comp_data_srv.h>
#include <zephyr/bluetooth/mesh/large_comp_data_cli.h>
#include <zephyr/bluetooth/mesh/large_comp_data_cli.h>


+2 −0
Original line number Original line Diff line number Diff line
@@ -128,6 +128,8 @@ struct bt_mesh_elem {
#define BT_MESH_MODEL_ID_HEALTH_CLI                0x0003
#define BT_MESH_MODEL_ID_HEALTH_CLI                0x0003
#define BT_MESH_MODEL_ID_REMOTE_PROV_SRV           0x0004
#define BT_MESH_MODEL_ID_REMOTE_PROV_SRV           0x0004
#define BT_MESH_MODEL_ID_REMOTE_PROV_CLI           0x0005
#define BT_MESH_MODEL_ID_REMOTE_PROV_CLI           0x0005
#define BT_MESH_MODEL_ID_SAR_CFG_SRV               0x000e
#define BT_MESH_MODEL_ID_SAR_CFG_CLI               0x000f
#define BT_MESH_MODEL_ID_LARGE_COMP_DATA_SRV       0x0012
#define BT_MESH_MODEL_ID_LARGE_COMP_DATA_SRV       0x0012
#define BT_MESH_MODEL_ID_LARGE_COMP_DATA_CLI       0x0013
#define BT_MESH_MODEL_ID_LARGE_COMP_DATA_CLI       0x0013


+69 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (c) 2021 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/**
 * @file
 * @defgroup bt_mesh_sar_cfg SAR Configuration common header
 * @{
 * @brief Definitions for the SAR Configuration models.
 */

#ifndef BT_MESH_SAR_CFG_H__
#define BT_MESH_SAR_CFG_H__

#ifdef __cplusplus
extern "C" {
#endif

/** SAR Transmitter Configuration state structure */
struct bt_mesh_sar_tx {
	/** SAR Segment Interval Step state */
	uint8_t seg_int_step;

	/** SAR Unicast Retransmissions Count state */
	uint8_t unicast_retrans_count;

	/** SAR Unicast Retransmissions Without Progress Count state */
	uint8_t unicast_retrans_without_prog_count;

	/* SAR Unicast Retransmissions Interval Step state */
	uint8_t unicast_retrans_int_step;

	/** SAR Unicast Retransmissions Interval Increment state */
	uint8_t unicast_retrans_int_inc;

	/** SAR Multicast Retransmissions Count state */
	uint8_t multicast_retrans_count;

	/** SAR Multicast Retransmissions Interval state */
	uint8_t multicast_retrans_int;
};

/** SAR Receiver Configuration state structure */
struct bt_mesh_sar_rx {
	/** SAR Segments Threshold state */
	uint8_t seg_thresh;

	/** SAR Acknowledgment Delay Increment state */
	uint8_t ack_delay_inc;

	/** SAR Discard Timeout state */
	uint8_t discard_timeout;

	/** SAR Receiver Segment Interval Step state */
	uint8_t rx_seg_int_step;

	/** SAR Acknowledgment Retransmissions Count state */
	uint8_t ack_retrans_count;
};

#ifdef __cplusplus
}
#endif

#endif /* BT_MESH_SAR_CFG_H__ */

/** @} */
+123 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (c) 2021 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/** @file
 *  @brief Bluetooth Mesh SAR Configuration Client Model APIs.
 */
#ifndef BT_MESH_SAR_CFG_CLI_H__
#define BT_MESH_SAR_CFG_CLI_H__

#include <zephyr/bluetooth/mesh/sar_cfg.h>

/**
 * @brief Bluetooth Mesh
 * @defgroup bt_mesh_sar_cfg_cli Bluetooth Mesh SAR Configuration Client Model
 * @ingroup bt_mesh
 * @{
 */

#ifdef __cplusplus
extern "C" {
#endif

/** Mesh SAR Configuration Client Model Context */
struct bt_mesh_sar_cfg_cli {
	/** Access model pointer. */
	struct bt_mesh_model *model;

	/* Publication structure instance */
	struct bt_mesh_model_pub pub;

	/* Synchronous message timeout in milliseconds. */
	int32_t timeout;

	/* Internal parameters for tracking message responses. */
	struct bt_mesh_msg_ack_ctx ack_ctx;
};

/**
 *
 * @brief SAR Configuration Client model composition data entry.
 *
 * @param[in] _cli Pointer to a @ref bt_mesh_sar_cfg_cli instance.
 */
#define BT_MESH_MODEL_SAR_CFG_CLI(_cli)                                  \
	BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_SAR_CFG_CLI,                         \
			 _bt_mesh_sar_cfg_cli_op, _cli.pub, _cli,                  \
			 &_bt_mesh_sar_cfg_cli_cb)

/** @brief Get the SAR Transmitter state of the target node.
 *
 *  @param net_idx Network index to encrypt with.
 *  @param addr    Target node address.
 *  @param rsp     Status response parameter.
 *
 *  @return 0 on success, or (negative) error code on failure.
 */
int bt_mesh_sar_cfg_cli_transmitter_get(uint16_t net_idx, uint16_t addr,
					struct bt_mesh_sar_tx *rsp);

/** @brief Set the SAR Transmitter state of the target node.
 *
 *  @param net_idx Network index to encrypt with.
 *  @param addr    Target node address.
 *  @param set     New SAR Transmitter state to set on the target node.
 *  @param rsp     Status response parameter.
 *
 *  @return 0 on success, or (negative) error code on failure.
 */
int bt_mesh_sar_cfg_cli_transmitter_set(uint16_t net_idx, uint16_t addr,
					const struct bt_mesh_sar_tx *set,
					struct bt_mesh_sar_tx *rsp);

/** @brief Get the SAR Receiver state of the target node.
 *
 *  @param net_idx Network index to encrypt with.
 *  @param addr    Target node address.
 *  @param rsp     Status response parameter.
 *
 *  @return 0 on success, or (negative) error code on failure.
 */
int bt_mesh_sar_cfg_cli_receiver_get(uint16_t net_idx, uint16_t addr,
				     struct bt_mesh_sar_rx *rsp);

/** @brief Set the SAR Receiver state of the target node.
 *
 *  @param net_idx Network index to encrypt with.
 *  @param addr    Target node address.
 *  @param set     New SAR Receiver state to set on the target node.
 *  @param rsp     Status response parameter.
 *
 *  @return 0 on success, or (negative) error code on failure.
 */
int bt_mesh_sar_cfg_cli_receiver_set(uint16_t net_idx, uint16_t addr,
				     const struct bt_mesh_sar_rx *set,
				     struct bt_mesh_sar_rx *rsp);

/** @brief Get the current transmission timeout value.
 *
 *  @return The configured transmission timeout in milliseconds.
 */
int32_t bt_mesh_sar_cfg_cli_timeout_get(void);

/** @brief Set the transmission timeout value.
 *
 *  @param timeout The new transmission timeout.
 */
void bt_mesh_sar_cfg_cli_timeout_set(int32_t timeout);

/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op _bt_mesh_sar_cfg_cli_op[];
extern const struct bt_mesh_model_cb _bt_mesh_sar_cfg_cli_cb;
/** @endcond */

#ifdef __cplusplus
}
#endif

#endif /* BT_MESH_SAR_CFG_CLI_H__ */

/** @} */
+47 −0
Original line number Original line Diff line number Diff line
/*
 * Copyright (c) 2021 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: Apache-2.0
 */

/** @file
 *  @brief Bluetooth Mesh SAR Configuration Server Model APIs.
 */
#ifndef BT_MESH_SAR_CFG_SRV_H__
#define BT_MESH_SAR_CFG_SRV_H__

#include <zephyr/bluetooth/mesh/sar_cfg.h>

/**
 * @brief Bluetooth Mesh
 * @defgroup bt_mesh_sar_cfg_srv Bluetooth Mesh SAR Configuration Server Model
 * @ingroup bt_mesh
 * @{
 */

#ifdef __cplusplus
extern "C" {
#endif

/**
 *
 *  @brief Transport SAR Configuration Server model composition data entry.
 */
#define BT_MESH_MODEL_SAR_CFG_SRV                                              \
	BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_SAR_CFG_SRV, bt_mesh_sar_cfg_srv_op, \
			 NULL, NULL, &bt_mesh_sar_cfg_srv_cb)

/** @cond INTERNAL_HIDDEN */
extern const struct bt_mesh_model_op bt_mesh_sar_cfg_srv_op[];
extern const struct bt_mesh_model_cb bt_mesh_sar_cfg_srv_cb;
/** @endcond */

#ifdef __cplusplus
}
#endif

#endif /* BT_MESH_SAR_CFG_SRV_H__ */

/**
 * @}
 */
Loading