LCOV - code coverage report
Current view: top level - zephyr/bluetooth/mesh - dfu_metadata.h Coverage Total Hit
Test: new.info Lines: 94.7 % 19 18
Test Date: 2025-09-05 20:47:19

            Line data    Source code
       1            0 : /*
       2              :  * Copyright (c) 2021 Nordic Semiconductor ASA
       3              :  *
       4              :  * SPDX-License-Identifier: Apache-2.0
       5              :  */
       6              : 
       7              : /**
       8              :  * @file
       9              :  * @defgroup bt_mesh_dfu_metadata Bluetooth Mesh Device Firmware Update (DFU) metadata
      10              :  * @ingroup bt_mesh_dfu
      11              :  * @{
      12              :  * @brief Common types and functions for the Bluetooth Mesh DFU metadata.
      13              :  */
      14              : 
      15              : #ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_METADATA_H__
      16              : #define ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_METADATA_H__
      17              : 
      18              : #include <stdint.h>
      19              : 
      20              : #include <sys/types.h>
      21              : 
      22              : #include <zephyr/kernel.h>
      23              : 
      24              : #ifdef __cplusplus
      25              : extern "C" {
      26              : #endif
      27              : 
      28              : /** Firmware version. */
      29            1 : struct bt_mesh_dfu_metadata_fw_ver {
      30              :         /** Firmware major version. */
      31            1 :         uint8_t major;
      32              :         /** Firmware minor version. */
      33            1 :         uint8_t minor;
      34              :         /** Firmware revision. */
      35            1 :         uint16_t revision;
      36              :         /** Firmware build number. */
      37            1 :         uint32_t build_num;
      38              : };
      39              : 
      40              : /** Firmware core type. */
      41            1 : enum bt_mesh_dfu_metadata_fw_core_type {
      42              :         /** Application core. */
      43              :         BT_MESH_DFU_FW_CORE_TYPE_APP = BIT(0),
      44              :         /** Network core. */
      45              :         BT_MESH_DFU_FW_CORE_TYPE_NETWORK = BIT(1),
      46              :         /** Application-specific BLOB. */
      47              :         BT_MESH_DFU_FW_CORE_TYPE_APP_SPECIFIC_BLOB = BIT(2),
      48              : };
      49              : 
      50              : /** Firmware metadata. */
      51            1 : struct bt_mesh_dfu_metadata {
      52              :         /** New firmware version. */
      53            1 :         struct bt_mesh_dfu_metadata_fw_ver fw_ver;
      54              :         /** New firmware size. */
      55            1 :         uint32_t fw_size;
      56              :         /** New firmware core type. */
      57            1 :         enum bt_mesh_dfu_metadata_fw_core_type fw_core_type;
      58              :         /** Hash of incoming Composition Data. */
      59            1 :         uint32_t comp_hash;
      60              :         /** New number of node elements. */
      61            1 :         uint16_t elems;
      62              :         /** Application-specific data for new firmware. This field is optional. */
      63            1 :         uint8_t *user_data;
      64              :         /** Length of the application-specific field. */
      65            1 :         uint32_t user_data_len;
      66              : };
      67              : 
      68              : /** @brief Decode a firmware metadata from a network buffer.
      69              :  *
      70              :  *  @param buf Buffer containing a raw metadata to be decoded.
      71              :  *  @param metadata Pointer to a metadata structure to be filled.
      72              :  *
      73              :  *  @return 0 on success, or (negative) error code otherwise.
      74              :  */
      75            1 : int bt_mesh_dfu_metadata_decode(struct net_buf_simple *buf,
      76              :                                 struct bt_mesh_dfu_metadata *metadata);
      77              : 
      78              : /** @brief Encode a firmware metadata into a network buffer.
      79              :  *
      80              :  *  @param metadata Firmware metadata to be encoded.
      81              :  *  @param buf Buffer to store the encoded metadata.
      82              :  *
      83              :  *  @return 0 on success, or (negative) error code otherwise.
      84              :  */
      85            1 : int bt_mesh_dfu_metadata_encode(const struct bt_mesh_dfu_metadata *metadata,
      86              :                                 struct net_buf_simple *buf);
      87              : 
      88              : /** @brief Compute hash of the Composition Data state.
      89              :  *
      90              :  *  The format of the Composition Data is defined in MshPRTv1.1: 4.2.2.1.
      91              :  *
      92              :  *  @param buf Pointer to buffer holding Composition Data.
      93              :  *  @param key 128-bit key to be used in the hash computation.
      94              :  *  @param hash Pointer to a memory location to which the hash will be stored.
      95              :  *
      96              :  *  @return 0 on success, or (negative) error code otherwise.
      97              :  */
      98            1 : int bt_mesh_dfu_metadata_comp_hash_get(struct net_buf_simple *buf, uint8_t *key, uint32_t *hash);
      99              : 
     100              : /** @brief Compute hash of the Composition Data Page 0 of this device.
     101              :  *
     102              :  *  @param key 128-bit key to be used in the hash computation.
     103              :  *  @param hash Pointer to a memory location to which the hash will be stored.
     104              :  *
     105              :  *  @return 0 on success, or (negative) error code otherwise.
     106              :  */
     107            1 : int bt_mesh_dfu_metadata_comp_hash_local_get(uint8_t *key, uint32_t *hash);
     108              : 
     109              : #ifdef __cplusplus
     110              : }
     111              : #endif
     112              : 
     113              : #endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_DFU_METADATA_H__ */
     114              : 
     115              : /** @} */
        

Generated by: LCOV version 2.0-1