Bluetooth Mesh message decoder component header file.

License#

Copyright 2025 Silicon Laboratories Inc. www.silabs.com

SPDX-License-Identifier: Zlib

The licensor of this software is Silicon Laboratories Inc.

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

  3. This notice may not be removed or altered from any source distribution.

/***************************************************************************/
#ifndef SL_BTMESH_DECODER_H
#define SL_BTMESH_DECODER_H

// -----------------------------------------------------------------------------
// Includes
#include <stdint.h>
#include <sl_status.h>
#include "sl_bt_api.h"
#include "sl_btmesh_sensor_model_capi_types.h"

#include "config/sl_btmesh_decoder_config.h"

#ifdef __cplusplus
extern "C"
{
#endif

// -----------------------------------------------------------------------------
// Macros

#define SL_MESH_KEY_HANDLE_INVALID  ~0
#define SL_MESH_MAX_NET_PDU_LEN     29
#define SL_MESH_MAX_CONTROL_PDU_LEN 256
#define SL_MESH_MAX_ACCESS_PDU_LEN  384
#define SL_MESH_PROPERTY_ID_LEN     2

// Scannable and connectable
#define ADV_IND         0x00
// Directed connectable
#define ADV_DIRECT_IND  0x01
// Non-connectable and non-scannable
#define ADV_NONCONN_IND 0x02
// Non-connectable and scannable
#define ADV_SCAN_IND    0x06

// -----------------------------------------------------------------------------
// Enums, structs, typedefs

enum sl_mesh_beacon {
  sl_mesh_beacon_unprovisioned = 0x00, //< Unprovisioned device beacon
  sl_mesh_beacon_secure = 0x01,        //< Secure network beacon
  sl_mesh_beacon_private = 0x02,       //< Mesh private beacon
};

enum sl_mesh_control_opcode {
  sl_mesh_control_opcode_segack = 0x00,                      //< Segment acknowledgement
  sl_mesh_control_opcode_friend_poll = 0x01,                 //< Friend Poll message
  sl_mesh_control_opcode_friend_update = 0x02,               //< Friend Update message
  sl_mesh_control_opcode_friend_request = 0x03,              //< Friend Request message
  sl_mesh_control_opcode_friend_offer = 0x04,                //< Friend Offer message
  sl_mesh_control_opcode_friend_clear = 0x05,                //< Friend Clear message
  sl_mesh_control_opcode_friend_clear_confirm = 0x06,        //< Friend Clear Confirm message
  sl_mesh_control_opcode_friend_subscription_add = 0x07,     //< Friend Subscription List Add message
  sl_mesh_control_opcode_friend_subscription_remove = 0x08,  //< Friend Subscription List Remove message
  sl_mesh_control_opcode_friend_subscription_confirm = 0x09, //< Friend Subscription List Confirm message
  sl_mesh_control_opcode_heartbeat = 0x0a,                   //< Heartbeat message
  sl_mesh_control_opcode_path_request = 0x0b,                //< Path Request message
  sl_mesh_control_opcode_path_reply = 0x0c,                  //< Path Reply message
  sl_mesh_control_opcode_path_confirmation = 0x0d,           //< Path Confirmation message
  sl_mesh_control_opcode_path_echo_request = 0x0e,           //< Path Echo Request message
  sl_mesh_control_opcode_path_echo_reply = 0x0f,             //< Path Echo Reply message
  sl_mesh_control_opcode_dependent_node_update = 0x10,       //< Dependent Node Update message
  sl_mesh_control_opcode_path_request_solicitation = 0x11    //< Path Request Solicitation message
};

typedef struct {
  uint8_t ad_len;        
  uint8_t ad_type;       
  uint8_t *data;         
} advertisement_data_t;

typedef struct {
  uint8_t pdu_type;      
  uint8_t tx_addr_type;  
  bd_addr tx_addr;       
  uint8_t rx_addr_type;  
  uint8_t data_num;      
  advertisement_data_t adv_data[MAX_ADV_DATA_NUM]; 
} advertisement_header_t;

typedef struct {
  uint8_t ivi;                   
  uint8_t nid;                   
  uint8_t ctl;                   
  uint8_t ttl;                   
  uint32_t seq;                  
  uint16_t src;                  
  uint16_t dst;                  
  size_t trans_pdu_len;          
  const uint8_t *transport_pdu;  
  size_t net_mic_len;            
  const uint8_t *net_mic;        
} net_pdu_t;

typedef struct {
  uint8_t seg;           
  uint8_t opcode;        
  uint8_t rfu;           
  uint8_t akf;           
  uint8_t aid;           
  uint8_t szmic;         
  uint16_t seq_0;        
  uint8_t seg_o;         
  uint8_t seg_n;         
  size_t segment_len;    
  const uint8_t *segment;
} trans_pdu_t;

struct sl_mesh_decoder;

struct sl_mesh_friendship {
  uint16_t lpn_addr;       //< LPN address
  uint16_t lpn_counter;    //< LPN counter
  uint16_t friend_addr;    //< Friend address
  uint16_t friend_counter; //< Friend counter
};

typedef struct {
  uint8_t obo;             
  uint16_t seq_zero;       
  uint8_t rfu;             
  uint32_t block_ack;      
} segack_t;

typedef struct {
  uint8_t padding;         
  uint8_t fsn;             
} friend_poll_t;

typedef struct {
  uint8_t rfu;             
  uint8_t ivu;             
  uint8_t kr;              
  uint32_t ivi;            
  uint8_t md;              
} friend_update_t;

typedef struct {
  uint8_t rfu;           
  uint8_t rssi_factor;   
  uint8_t window_factor; 
  uint8_t min_queue;     
  uint8_t receive_delay; 
  uint32_t poll_timeout; 
  uint16_t prev_addr;    
  uint8_t num_elements;  
  uint16_t lpn_counter;  
} friend_request_t;

typedef struct {
  uint8_t receive_window;  
  uint8_t queue_size;      
  uint8_t subs_list;       
  uint8_t rssi;            
  uint16_t friend_counter; 
} friend_offer_t;

typedef struct {
  uint16_t lpn_address; 
  uint16_t lpn_counter; 
} friend_clear_t;

typedef struct {
  uint16_t tid;         
  const uint16_t *addr; 
} friend_subscription_t;

typedef struct {
  uint8_t rfu;       
  uint8_t ttl;       
  uint16_t features; 
} heartbeat_t;

typedef struct {
  uint8_t obo_dep;    
  uint8_t ptype;      
  uint8_t plife;      
  uint8_t pdisc;      
  uint8_t prohib;     
  uint8_t fwdnum;     
  uint8_t metric;     
  uint16_t pdst;      
  size_t prange_len;  
  uint32_t prange;    
  size_t drange_len;  
  uint32_t drange;    
} path_request_t;

typedef struct {
  uint8_t uni_dst;      
  uint8_t obo_dep;      
  uint8_t confirm;      
  uint8_t prohib;       
  uint16_t path_origin; 
  uint8_t fwdnum;       
  size_t prange_len;    
  uint32_t prange;      
  size_t drange_len;    
  uint32_t drange;      
} path_reply_t;

typedef struct {
  uint16_t path_origin; 
  uint16_t path_target; 
} path_confirmation_t;

typedef struct {
  uint8_t type;           
  uint8_t prohib;         
  uint16_t path_endpoint; 
  size_t drange_len;      
  uint32_t drange;        
} dependent_node_update_t;

typedef struct {
  const uint16_t *addr; 
} path_request_solicitation_t;

struct sl_mesh_net_pdu {
  uint8_t pdu_len; //< PDU length
  uint8_t pdu_data[SL_MESH_MAX_NET_PDU_LEN]; //< PDU data
};

struct sl_mesh_access_pdu {
  uint8_t pdu_len; //< Access message data
  uint8_t pdu_data[SL_MESH_MAX_ACCESS_PDU_LEN]; //< Access message length
};

typedef void* sl_mesh_key_handle;

typedef struct {
  uint8_t format;                   //< Marshalled property format
  uint8_t length;                   //< Data length
  sensor_property_id_t property_id; //< Sensor Property ID
} marshalled_property;

typedef struct {
  marshalled_property marshalled_property_id; //< Sensor Property ID
  uint16_t raw_value_length;                  //< Data length
  uint8_t *raw_value;                         //< Raw value
} sensor_status_msg_t;

typedef struct {
  sensor_property_id_t property_id; //< Sensor Property ID
  uint16_t raw_value_length;        //< Data length/
  uint8_t *raw_value;               //< Raw setting value
} sensor_get_column_msg_t;

typedef struct {
  sensor_property_id_t property_id; //< Sensor Property ID
  uint16_t raw_value_length;        //< Data length
  uint8_t *raw_value_x;             //< Raw value X
  uint8_t *column_width;            //< Column Width
  uint8_t *raw_value_y;             //< Raw value Y
} sensor_column_status_msg_t;

typedef struct {
  sensor_property_id_t property_id; //< Sensor Property ID
  uint16_t raw_value_length;        //< Data length
  uint8_t *raw_value_x1;            //< Raw value X1
  uint8_t *raw_value_x2;            //< Raw value X2
} sensor_get_series_msg_t;

typedef struct {
  sensor_property_id_t property_id; //< Sensor Property ID
  uint16_t raw_value_length;        //< Data length
  uint8_t *raw_value_x;             //< Raw value X
  uint8_t *column_width;            //< Column Width
  uint8_t *raw_value_y;             //< Raw value Y
} sensor_series_status_msg_t;

// -----------------------------------------------------------------------------
// Function declarations

// -------------------------------
// Library initialization / deinitialization

sl_status_t sl_mesh_decoder_create(struct sl_mesh_decoder **context);

sl_status_t sl_mesh_decoder_delete(struct sl_mesh_decoder *context);

// -------------------------------
// Crypto key management

sl_status_t sl_mesh_decoder_add_network_key(struct sl_mesh_decoder *context,
                                            const uint8_t *key_value,
                                            sl_mesh_key_handle *handle);

sl_status_t sl_mesh_decoder_add_application_key(struct sl_mesh_decoder *context,
                                                const uint8_t *key_value,
                                                sl_mesh_key_handle *handle);

sl_status_t sl_mesh_decoder_add_device_key(struct sl_mesh_decoder *context,
                                           const uint8_t *key_value,
                                           uint16_t device_addr,
                                           sl_mesh_key_handle *handle);

sl_status_t sl_mesh_decoder_remove_key(struct sl_mesh_decoder *context,
                                       sl_mesh_key_handle handle);

sl_status_t sl_mesh_decoder_get_friendship_key_context(struct sl_mesh_decoder *context,
                                                       sl_mesh_key_handle handle,
                                                       struct sl_mesh_friendship *friendship);

sl_status_t sl_mesh_decoder_get_friendship_key(struct sl_mesh_decoder *context,
                                               uint16_t lpn_addr,
                                               uint16_t lpn_counter,
                                               sl_mesh_key_handle *handle);

sl_status_t sl_mesh_decoder_remove_friendship_key(struct sl_mesh_decoder *context,
                                                  uint16_t lpn_addr,
                                                  sl_mesh_key_handle net_key_handle);

// -------------------------------
// Network layer decoding

sl_status_t sl_mesh_decoder_decrypt_net_pdu(struct sl_mesh_decoder *context,
                                            uint32_t current_ivindex,
                                            const uint8_t *net_pdu_ptr,
                                            size_t net_pdu_len,
                                            struct sl_mesh_net_pdu *pdu,
                                            sl_mesh_key_handle *matching_net_key,
                                            sl_mesh_key_handle *matching_friend_key);

bool sl_mesh_net_pdu_is_valid(const struct sl_mesh_net_pdu *pdu);

uint32_t sl_mesh_net_pdu_ivi(const struct sl_mesh_net_pdu *pdu);

uint8_t sl_mesh_net_pdu_nid(const struct sl_mesh_net_pdu *pdu);

uint8_t sl_mesh_net_pdu_ctl(const struct sl_mesh_net_pdu *pdu);

uint8_t sl_mesh_net_pdu_ttl(const struct sl_mesh_net_pdu *pdu);

uint32_t sl_mesh_net_pdu_seq(const struct sl_mesh_net_pdu *pdu);

uint16_t sl_mesh_net_pdu_src(const struct sl_mesh_net_pdu *pdu);

uint16_t sl_mesh_net_pdu_dst(const struct sl_mesh_net_pdu *pdu);

const uint8_t *sl_mesh_net_pdu_data_ptr(const struct sl_mesh_net_pdu *pdu);

size_t sl_mesh_net_pdu_data_len(const struct sl_mesh_net_pdu *pdu);

const uint8_t *sl_mesh_net_pdu_mic_ptr(const struct sl_mesh_net_pdu *pdu);

size_t sl_mesh_net_pdu_mic_len(const struct sl_mesh_net_pdu *pdu);

void sl_mesh_net_pdu_data(const struct sl_mesh_net_pdu *pdu, net_pdu_t *net_pdu);

void sl_mesh_trans_pdu_data(const struct sl_mesh_net_pdu *pdu,
                            trans_pdu_t *trans_pdu_access,
                            uint8_t ctl);

void sl_mesh_advertisement_header_from_buf(sl_bt_msg_t *evt, advertisement_header_t *adv_header);

void sl_mesh_segack_from_buf(const uint8_t *ptr, segack_t *segack);

void sl_mesh_friend_poll_from_buf(const uint8_t *ptr, friend_poll_t *friend_poll);

void sl_mesh_friend_update_from_buf(const uint8_t *ptr, friend_update_t *friend_update);

void sl_mesh_friend_request_from_buf(const uint8_t *ptr, friend_request_t *friend_request);

void sl_mesh_friend_offer_from_buf(const uint8_t *ptr, friend_offer_t *friend_offer);

void sl_mesh_friend_clear_from_buf(const uint8_t *ptr, friend_clear_t *friend_clear);

void sl_mesh_friend_subscription_from_buf(const uint8_t *ptr, friend_subscription_t *friend_subscription);

void sl_mesh_heartbeat_from_buf(const uint8_t *ptr, heartbeat_t *heartbeat);

void sl_mesh_path_request_from_buf(const uint8_t *ptr, path_request_t *path_request);

void sl_mesh_path_reply_from_buf(const uint8_t *ptr, path_reply_t *path_reply);

void sl_mesh_path_confirmation_from_buf(const uint8_t *ptr, path_confirmation_t *path_confirmation);

void sl_mesh_dependent_node_update_from_buf(const uint8_t *ptr, dependent_node_update_t *dependent_node_update);

void sl_mesh_path_request_solicitation_from_buf(const uint8_t *ptr,
                                                path_request_solicitation_t *path_request_solicitation);
//
// Lower transport layer decoding

bool sl_mesh_net_pdu_contains_valid_trans_pdu(const struct sl_mesh_net_pdu *pdu);

uint8_t sl_mesh_trans_pdu_seg(const struct sl_mesh_net_pdu *pdu);

uint16_t sl_mesh_trans_pdu_seg_seq0(const struct sl_mesh_net_pdu *pdu);

uint8_t sl_mesh_trans_pdu_seg_o(const struct sl_mesh_net_pdu *pdu);

uint8_t sl_mesh_trans_pdu_seg_n(const struct sl_mesh_net_pdu *pdu);

uint8_t sl_mesh_trans_pdu_access_akf(const struct sl_mesh_net_pdu *pdu);

uint8_t sl_mesh_trans_pdu_access_aid(const struct sl_mesh_net_pdu *pdu);

uint8_t sl_mesh_trans_pdu_access_szmic(const struct sl_mesh_net_pdu *pdu);

uint8_t sl_mesh_trans_pdu_control_opcode(const struct sl_mesh_net_pdu *pdu);

const uint8_t *sl_mesh_trans_pdu_data_ptr(const struct sl_mesh_net_pdu *pdu);

size_t sl_mesh_trans_pdu_data_len(const struct sl_mesh_net_pdu *pdu);

// -------------------------------
// Transport layer reassembly

sl_status_t sl_mesh_reassembler_add_segment(struct sl_mesh_decoder *context,
                                            sl_mesh_key_handle net_key,
                                            net_pdu_t net_pdu,
                                            trans_pdu_t trans_pdu,
                                            bool *now_completed);

sl_status_t sl_mesh_reassembler_get_data(struct sl_mesh_decoder *context,
                                         uint16_t src,
                                         uint16_t dst,
                                         uint16_t seq_0,
                                         const uint8_t **ptr,
                                         size_t *len,
                                         uint32_t *seq_auth);

// -------------------------------
// Transport control

bool sl_mesh_pointer_contains_valid_control_message(uint8_t opcode,
                                                    const uint8_t *param_ptr,
                                                    size_t param_len);

bool sl_mesh_pointer_contains_valid_access_pdu(uint8_t szmic,
                                               const uint8_t *pdu_ptr,
                                               size_t pdu_len);

// -------------------------------
// Friendship

sl_status_t sl_mesh_friendship_add_friend_request(struct sl_mesh_decoder *context,
                                                  sl_mesh_key_handle net_key,
                                                  uint16_t lpn_addr,
                                                  uint16_t lpn_counter);

sl_status_t sl_mesh_friendship_add_friend_offer(struct sl_mesh_decoder *context,
                                                sl_mesh_key_handle net_key,
                                                uint16_t lpn_addr,
                                                uint16_t friend_addr,
                                                uint16_t friend_counter);

// -------------------------------
// Access layer decoding

sl_status_t sl_mesh_decoder_add_virtual_label_uuid(struct sl_mesh_decoder *context,
                                                   const uint8_t *label_uuid);

sl_status_t sl_mesh_decoder_remove_virtual_label_uuid(struct sl_mesh_decoder *context,
                                                      const uint8_t *label_uuid);

sl_status_t sl_mesh_decoder_decrypt_access_pdu(struct sl_mesh_decoder *context,
                                               uint32_t current_ivindex,
                                               struct sl_mesh_access_pdu *pdu,
                                               sl_mesh_key_handle *matching_app_key,
                                               const uint8_t **matching_label_uuid,
                                               net_pdu_t net_pdu,
                                               trans_pdu_t trans_pdu);

bool sl_mesh_access_pdu_contains_valid_access_message(const struct sl_mesh_access_pdu *pdu);

const uint8_t *sl_mesh_access_pdu_opcode_ptr(const struct sl_mesh_access_pdu *pdu);

size_t sl_mesh_access_pdu_opcode_len(const struct sl_mesh_access_pdu *pdu);

const uint8_t *sl_mesh_access_pdu_data_ptr(const struct sl_mesh_access_pdu *pdu);

size_t sl_mesh_access_pdu_data_len(const struct sl_mesh_access_pdu *pdu);

// -------------------------------
// Beacon decoding

sl_status_t sl_mesh_decoder_authenticate_network_beacon(struct sl_mesh_decoder *context,
                                                        const uint8_t *beacon_ptr,
                                                        size_t beacon_len,
                                                        enum sl_mesh_beacon *type,
                                                        uint8_t *flags,
                                                        uint32_t *iv_index,
                                                        sl_mesh_key_handle *matching_net_key);

// -------------------------------
// Sensor model decoding

float sl_mesh_decoder_time_to_sec(uint32_t interval);

float sl_mesh_decoder_tolerance_to_error_percentage(uint16_t tolerance);

sl_status_t sl_mesh_sensor_descriptors_from_buf(sensor_descriptor_t *descriptor,
                                                const uint8_t *pdu_data,
                                                const size_t pdu_data_len);

sl_status_t sl_mesh_sensor_cadence_from_buf(struct sensort_cadence_state *cadence,
                                            uint8_t *pdu_data,
                                            const size_t pdu_data_len);

sl_status_t sl_mesh_sensor_setting_set_from_buf(sensor_set_setting_msg_t *set_setting,
                                                uint8_t *pdu_data,
                                                const size_t pdu_data_len);

sl_status_t sl_mesh_sensor_setting_get_from_buf(sensor_get_setting_msg_t *get_setting,
                                                uint8_t *pdu_data,
                                                const size_t pdu_data_len);

sl_status_t sl_mesh_sensor_setting_status_from_buf(struct sensor_setting_status *setting_status,
                                                   uint8_t *pdu_data,
                                                   const size_t pdu_data_len);

sl_status_t sl_mesh_sensor_status_from_buf(sensor_status_msg_t *sensor_status,
                                           uint8_t *pdu_data,
                                           const size_t pdu_data_len);

sl_status_t sl_mesh_sensor_settings_status_from_buf(sensor_settings_status_t *settings_status,
                                                    uint8_t *pdu_data,
                                                    const size_t pdu_data_len);

sl_status_t sl_mesh_sensor_column_get_from_buf(sensor_get_column_msg_t *column_get,
                                               uint8_t *pdu_data,
                                               const size_t pdu_data_len);

sl_status_t sl_mesh_sensor_series_get_from_buf(sensor_get_series_msg_t *series_get,
                                               uint8_t *pdu_data,
                                               const size_t pdu_data_len);

sl_status_t sl_mesh_sensor_series_status_from_buf(sensor_series_status_msg_t *series_status,
                                                  uint8_t *pdu_data,
                                                  const size_t pdu_data_len);
sl_status_t sl_mesh_sensor_column_status_from_buf(sensor_column_status_msg_t *column_status,
                                                  uint8_t *pdu_data,
                                                  const size_t pdu_data_len);

#ifdef __cplusplus
}
#endif

#endif // SL_BTMESH_DECODER_H

Modules#

advertisement_data_t

advertisement_header_t

net_pdu_t

trans_pdu_t

sl_mesh_friendship

segack_t

friend_poll_t

friend_update_t

friend_request_t

friend_offer_t

friend_clear_t

friend_subscription_t

heartbeat_t

path_request_t

path_reply_t

path_confirmation_t

dependent_node_update_t

path_request_solicitation_t

sl_mesh_net_pdu

sl_mesh_access_pdu

marshalled_property

sensor_status_msg_t

sensor_get_column_msg_t

sensor_column_status_msg_t

sensor_get_series_msg_t

sensor_series_status_msg_t

Macros#

#define
SL_MESH_KEY_HANDLE_INVALID ~0

Invalid cryptographic key.

#define
SL_MESH_MAX_NET_PDU_LEN 29

Maximum network PDU length.

#define
SL_MESH_MAX_CONTROL_PDU_LEN 256

Maximum transport PDU length.

#define
SL_MESH_MAX_ACCESS_PDU_LEN 384

Maximum access message length.

#define
SL_MESH_PROPERTY_ID_LEN 2

Property ID length.

#define
ADV_IND 0x00
#define
ADV_DIRECT_IND 0x01
#define
ADV_NONCONN_IND 0x02
#define
ADV_SCAN_IND 0x06

Enumerations#

enum
sl_mesh_beacon_unprovisioned = 0x00
sl_mesh_beacon_secure = 0x01
sl_mesh_beacon_private = 0x02
}

Mesh beacon type enumeration.

enum
sl_mesh_control_opcode_segack = 0x00
sl_mesh_control_opcode_friend_poll = 0x01
sl_mesh_control_opcode_friend_update = 0x02
sl_mesh_control_opcode_friend_request = 0x03
sl_mesh_control_opcode_friend_offer = 0x04
sl_mesh_control_opcode_friend_clear = 0x05
sl_mesh_control_opcode_friend_clear_confirm = 0x06
sl_mesh_control_opcode_friend_subscription_add = 0x07
sl_mesh_control_opcode_friend_subscription_remove = 0x08
sl_mesh_control_opcode_friend_subscription_confirm = 0x09
sl_mesh_control_opcode_heartbeat = 0x0a
sl_mesh_control_opcode_path_request = 0x0b
sl_mesh_control_opcode_path_reply = 0x0c
sl_mesh_control_opcode_path_confirmation = 0x0d
sl_mesh_control_opcode_path_echo_request = 0x0e
sl_mesh_control_opcode_path_echo_reply = 0x0f
sl_mesh_control_opcode_dependent_node_update = 0x10
sl_mesh_control_opcode_path_request_solicitation = 0x11
}

Transport control message opcode enumeration.

Typedefs#

typedef void *

Cryptographic key abstraction.

Functions#

sl_status_t
sl_mesh_decoder_create(struct sl_mesh_decoder **context)

Create a decoder context.

sl_status_t
sl_mesh_decoder_delete(struct sl_mesh_decoder *context)

Delete a decoder context.

sl_status_t
sl_mesh_decoder_add_network_key(struct sl_mesh_decoder *context, const uint8_t *key_value, sl_mesh_key_handle *handle)

Add a network key.

sl_status_t
sl_mesh_decoder_add_application_key(struct sl_mesh_decoder *context, const uint8_t *key_value, sl_mesh_key_handle *handle)

Add an application key.

sl_status_t
sl_mesh_decoder_add_device_key(struct sl_mesh_decoder *context, const uint8_t *key_value, uint16_t device_addr, sl_mesh_key_handle *handle)

Add a device key.

sl_status_t
sl_mesh_decoder_remove_key(struct sl_mesh_decoder *context, sl_mesh_key_handle handle)

Remove a key by reference.

sl_status_t
sl_mesh_decoder_get_friendship_key_context(struct sl_mesh_decoder *context, sl_mesh_key_handle handle, struct sl_mesh_friendship *friendship)

Get friendship context for a key.

sl_status_t
sl_mesh_decoder_get_friendship_key(struct sl_mesh_decoder *context, uint16_t lpn_addr, uint16_t lpn_counter, sl_mesh_key_handle *handle)

Get a friendship key by LPN friendship parameters.

sl_status_t
sl_mesh_decoder_remove_friendship_key(struct sl_mesh_decoder *context, uint16_t lpn_addr, sl_mesh_key_handle net_key_handle)

Remove a friendship key by LPN address and network key.

sl_status_t
sl_mesh_decoder_decrypt_net_pdu(struct sl_mesh_decoder *context, uint32_t current_ivindex, const uint8_t *net_pdu_ptr, size_t net_pdu_len, struct sl_mesh_net_pdu *pdu, sl_mesh_key_handle *matching_net_key, sl_mesh_key_handle *matching_friend_key)

Decrypt a network PDU.

bool
sl_mesh_net_pdu_is_valid(const struct sl_mesh_net_pdu *pdu)

Verify NetPDU length.

uint32_t
sl_mesh_net_pdu_ivi(const struct sl_mesh_net_pdu *pdu)

Get Network PDU IVI header.

uint8_t
sl_mesh_net_pdu_nid(const struct sl_mesh_net_pdu *pdu)

Get Network PDU NID header.

uint8_t
sl_mesh_net_pdu_ctl(const struct sl_mesh_net_pdu *pdu)

Get Network PDU CTL header.

uint8_t
sl_mesh_net_pdu_ttl(const struct sl_mesh_net_pdu *pdu)

Get Network PDU TTL header.

uint32_t
sl_mesh_net_pdu_seq(const struct sl_mesh_net_pdu *pdu)

Get Network PDU sequence number.

uint16_t
sl_mesh_net_pdu_src(const struct sl_mesh_net_pdu *pdu)

Get Network PDU source address.

uint16_t
sl_mesh_net_pdu_dst(const struct sl_mesh_net_pdu *pdu)

Get Network PDU destination address.

const uint8_t *
sl_mesh_net_pdu_data_ptr(const struct sl_mesh_net_pdu *pdu)

Get Network PDU TransportPDU data.

size_t
sl_mesh_net_pdu_data_len(const struct sl_mesh_net_pdu *pdu)

Get Network PDU TransportPDU length.

const uint8_t *
sl_mesh_net_pdu_mic_ptr(const struct sl_mesh_net_pdu *pdu)

Get Network PDU NetMIC data.

size_t
sl_mesh_net_pdu_mic_len(const struct sl_mesh_net_pdu *pdu)

Get Network PDU NetMIC length.

void
sl_mesh_net_pdu_data(const struct sl_mesh_net_pdu *pdu, net_pdu_t *net_pdu)

Extracts all relevant fields from a decoded network PDU.

void
sl_mesh_trans_pdu_data(const struct sl_mesh_net_pdu *pdu, trans_pdu_t *trans_pdu_access, uint8_t ctl)

Extracts the lower transport PDU from a network PDU.

void
sl_mesh_advertisement_header_from_buf(sl_bt_msg_t *evt, advertisement_header_t *adv_header)

Decodes an advertisement header from a Bluetooth event buffer.

void
sl_mesh_segack_from_buf(const uint8_t *ptr, segack_t *segack)

Decodes a Segment Acknowledgement message from a buffer.

void
sl_mesh_friend_poll_from_buf(const uint8_t *ptr, friend_poll_t *friend_poll)

Decodes a Friend Poll message from a buffer.

void
sl_mesh_friend_update_from_buf(const uint8_t *ptr, friend_update_t *friend_update)

Decodes a Friend Update message from a buffer.

void
sl_mesh_friend_request_from_buf(const uint8_t *ptr, friend_request_t *friend_request)

Decodes a Friend Request message from a buffer.

void
sl_mesh_friend_offer_from_buf(const uint8_t *ptr, friend_offer_t *friend_offer)

Decodes a Friend Offer message from a buffer.

void
sl_mesh_friend_clear_from_buf(const uint8_t *ptr, friend_clear_t *friend_clear)

Decodes a Friend Clear message from a buffer.

void
sl_mesh_friend_subscription_from_buf(const uint8_t *ptr, friend_subscription_t *friend_subscription)

Decodes a Friend Subscription message from a buffer.

void
sl_mesh_heartbeat_from_buf(const uint8_t *ptr, heartbeat_t *heartbeat)

Decodes a Heartbeat message from a buffer.

void
sl_mesh_path_request_from_buf(const uint8_t *ptr, path_request_t *path_request)

Decodes a Path Request message from a buffer.

void
sl_mesh_path_reply_from_buf(const uint8_t *ptr, path_reply_t *path_reply)

Decodes a Path Reply message from a buffer.

void
sl_mesh_path_confirmation_from_buf(const uint8_t *ptr, path_confirmation_t *path_confirmation)

Decodes a Path Confirmation message from a buffer.

void
sl_mesh_dependent_node_update_from_buf(const uint8_t *ptr, dependent_node_update_t *dependent_node_update)

Decodes a Dependent Node Update message from a buffer.

void
sl_mesh_path_request_solicitation_from_buf(const uint8_t *ptr, path_request_solicitation_t *path_request_solicitation)

Decodes a Path Request Solicitation message from a buffer.

bool
sl_mesh_net_pdu_contains_valid_trans_pdu(const struct sl_mesh_net_pdu *pdu)

Verify TransportPDU length.

uint8_t
sl_mesh_trans_pdu_seg(const struct sl_mesh_net_pdu *pdu)

Get Lower Transport PDU SEG header.

uint16_t
sl_mesh_trans_pdu_seg_seq0(const struct sl_mesh_net_pdu *pdu)

Get Lower Transport PDU SeqZero header.

uint8_t
sl_mesh_trans_pdu_seg_o(const struct sl_mesh_net_pdu *pdu)

Get Lower Transport PDU SegO header.

uint8_t
sl_mesh_trans_pdu_seg_n(const struct sl_mesh_net_pdu *pdu)

Get Lower Transport PDU SegN header.

uint8_t
sl_mesh_trans_pdu_access_akf(const struct sl_mesh_net_pdu *pdu)

Get Lower Transport PDU AKF header.

uint8_t
sl_mesh_trans_pdu_access_aid(const struct sl_mesh_net_pdu *pdu)

Get Lower Transport PDU AID header.

uint8_t
sl_mesh_trans_pdu_access_szmic(const struct sl_mesh_net_pdu *pdu)

Get Lower Transport PDU SZMIC header.

uint8_t
sl_mesh_trans_pdu_control_opcode(const struct sl_mesh_net_pdu *pdu)

Get Lower Transport PDU Opcode header.

const uint8_t *
sl_mesh_trans_pdu_data_ptr(const struct sl_mesh_net_pdu *pdu)

Get Lower Transport PDU payload data.

size_t
sl_mesh_trans_pdu_data_len(const struct sl_mesh_net_pdu *pdu)

Get Lower Transport PDU payload length.

sl_status_t
sl_mesh_reassembler_add_segment(struct sl_mesh_decoder *context, sl_mesh_key_handle net_key, net_pdu_t net_pdu, trans_pdu_t trans_pdu, bool *now_completed)

Add segment data to SAR reassembly.

sl_status_t
sl_mesh_reassembler_get_data(struct sl_mesh_decoder *context, uint16_t src, uint16_t dst, uint16_t seq_0, const uint8_t **ptr, size_t *len, uint32_t *seq_auth)

Get reassembled data.

bool
sl_mesh_pointer_contains_valid_control_message(uint8_t opcode, const uint8_t *param_ptr, size_t param_len)

Verify upper transport control message length.

bool
sl_mesh_pointer_contains_valid_access_pdu(uint8_t szmic, const uint8_t *pdu_ptr, size_t pdu_len)

Verify upper transport access PDU length.

sl_status_t
sl_mesh_friendship_add_friend_request(struct sl_mesh_decoder *context, sl_mesh_key_handle net_key, uint16_t lpn_addr, uint16_t lpn_counter)

Add a Friend Request for pending friendship tracking.

sl_status_t
sl_mesh_friendship_add_friend_offer(struct sl_mesh_decoder *context, sl_mesh_key_handle net_key, uint16_t lpn_addr, uint16_t friend_addr, uint16_t friend_counter)

Add a Friend Offer for pending friendship tracking.

sl_status_t
sl_mesh_decoder_add_virtual_label_uuid(struct sl_mesh_decoder *context, const uint8_t *label_uuid)

Add a virtual address label UUID.

sl_status_t
sl_mesh_decoder_remove_virtual_label_uuid(struct sl_mesh_decoder *context, const uint8_t *label_uuid)

Remove a virtual address label UUID.

sl_status_t
sl_mesh_decoder_decrypt_access_pdu(struct sl_mesh_decoder *context, uint32_t current_ivindex, struct sl_mesh_access_pdu *pdu, sl_mesh_key_handle *matching_app_key, const uint8_t **matching_label_uuid, net_pdu_t net_pdu, trans_pdu_t trans_pdu)

Decrypt an access message.

bool
sl_mesh_access_pdu_contains_valid_access_message(const struct sl_mesh_access_pdu *pdu)

Verify access message length.

const uint8_t *
sl_mesh_access_pdu_opcode_ptr(const struct sl_mesh_access_pdu *pdu)

Get a pointer to the access message payload.

size_t
sl_mesh_access_pdu_opcode_len(const struct sl_mesh_access_pdu *pdu)

Get access message payload length.

const uint8_t *
sl_mesh_access_pdu_data_ptr(const struct sl_mesh_access_pdu *pdu)

Get a pointer to the access message parameters.

size_t
sl_mesh_access_pdu_data_len(const struct sl_mesh_access_pdu *pdu)

Get access message parameter length.

sl_status_t
sl_mesh_decoder_authenticate_network_beacon(struct sl_mesh_decoder *context, const uint8_t *beacon_ptr, size_t beacon_len, enum sl_mesh_beacon *type, uint8_t *flags, uint32_t *iv_index, sl_mesh_key_handle *matching_net_key)

Authenticate beacon and get beacon contents.

float
sl_mesh_decoder_time_to_sec(uint32_t interval)

Converts a time interval in milliseconds to seconds.

float

Converts a tolerance value to an error percentage.

sl_status_t
sl_mesh_sensor_descriptors_from_buf(sensor_descriptor_t *descriptor, const uint8_t *pdu_data, const size_t pdu_data_len)

Parses sensor descriptors from a buffer.

sl_status_t
sl_mesh_sensor_cadence_from_buf(struct sensort_cadence_state *cadence, uint8_t *pdu_data, const size_t pdu_data_len)

Decodes sensor cadence state from a buffer.

sl_status_t
sl_mesh_sensor_setting_set_from_buf(sensor_set_setting_msg_t *set_setting, uint8_t *pdu_data, const size_t pdu_data_len)

Parses the sensor setting from a buffer.

sl_status_t
sl_mesh_sensor_setting_get_from_buf(sensor_get_setting_msg_t *get_setting, uint8_t *pdu_data, const size_t pdu_data_len)

Extracts sensor setting information from a buffer.

sl_status_t
sl_mesh_sensor_setting_status_from_buf(struct sensor_setting_status *setting_status, uint8_t *pdu_data, const size_t pdu_data_len)

Parses a sensor setting status message from a buffer.

sl_status_t
sl_mesh_sensor_status_from_buf(sensor_status_msg_t *sensor_status, uint8_t *pdu_data, const size_t pdu_data_len)

Decodes a sensor status message from a buffer.

sl_status_t
sl_mesh_sensor_settings_status_from_buf(sensor_settings_status_t *settings_status, uint8_t *pdu_data, const size_t pdu_data_len)

Extracts sensor settings status message from a buffer.

sl_status_t
sl_mesh_sensor_column_get_from_buf(sensor_get_column_msg_t *column_get, uint8_t *pdu_data, const size_t pdu_data_len)

Extracts sensor column data from a buffer.

sl_status_t
sl_mesh_sensor_series_get_from_buf(sensor_get_series_msg_t *series_get, uint8_t *pdu_data, const size_t pdu_data_len)

Extracts sensor series data from a buffer.

sl_status_t
sl_mesh_sensor_series_status_from_buf(sensor_series_status_msg_t *series_status, uint8_t *pdu_data, const size_t pdu_data_len)

Decodes a sensor series status message from a buffer.

sl_status_t
sl_mesh_sensor_column_status_from_buf(sensor_column_status_msg_t *column_status, uint8_t *pdu_data, const size_t pdu_data_len)

Decodes a sensor column status message from a buffer.

 

Enumeration Documentation#

sl_mesh_beacon#

sl_mesh_beacon

Mesh beacon type enumeration.

Enumerator
sl_mesh_beacon_unprovisioned
sl_mesh_beacon_secure
sl_mesh_beacon_private

sl_mesh_control_opcode#

sl_mesh_control_opcode

Transport control message opcode enumeration.

Enumerator
sl_mesh_control_opcode_segack
sl_mesh_control_opcode_friend_poll
sl_mesh_control_opcode_friend_update
sl_mesh_control_opcode_friend_request
sl_mesh_control_opcode_friend_offer
sl_mesh_control_opcode_friend_clear
sl_mesh_control_opcode_friend_clear_confirm
sl_mesh_control_opcode_friend_subscription_add
sl_mesh_control_opcode_friend_subscription_remove
sl_mesh_control_opcode_friend_subscription_confirm
sl_mesh_control_opcode_heartbeat
sl_mesh_control_opcode_path_request
sl_mesh_control_opcode_path_reply
sl_mesh_control_opcode_path_confirmation
sl_mesh_control_opcode_path_echo_request
sl_mesh_control_opcode_path_echo_reply
sl_mesh_control_opcode_dependent_node_update
sl_mesh_control_opcode_path_request_solicitation

Typedef Documentation#

sl_mesh_key_handle#

typedef void* sl_mesh_key_handle

Cryptographic key abstraction.


Function Documentation#

sl_mesh_decoder_create#

sl_status_t sl_mesh_decoder_create (struct sl_mesh_decoder ** context)

Create a decoder context.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder **N/Acontext

Pointer to an allocated context is returned here on success

Returns

  • SL_STATUS_OK if a context has been allocated and is ready to use


sl_mesh_decoder_delete#

sl_status_t sl_mesh_decoder_delete (struct sl_mesh_decoder * context)

Delete a decoder context.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

Context to delete

Returns

  • SL_STATUS_OK if the given context was deleted


sl_mesh_decoder_add_network_key#

sl_status_t sl_mesh_decoder_add_network_key (struct sl_mesh_decoder * context, const uint8_t * key_value, sl_mesh_key_handle * handle)

Add a network key.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

Context to use

const uint8_t *N/Akey_value

Exactly 16 octets of AES key material

sl_mesh_key_handle *N/Ahandle

A reference to the key is returned here on success

Add a known network key to a decoder. The decoder will internally construct the various derivations Mesh Protocol uses, and use those to decrypt and authenticate Mesh network PDUs.

Returns

  • SL_STATUS_OK if the key has been added


sl_mesh_decoder_add_application_key#

sl_status_t sl_mesh_decoder_add_application_key (struct sl_mesh_decoder * context, const uint8_t * key_value, sl_mesh_key_handle * handle)

Add an application key.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

Context to use

const uint8_t *N/Akey_value

Exactly 16 octets of AES key material

sl_mesh_key_handle *N/Ahandle

A reference to the key is returned here on success

Add a known application key to a decoder. The decoder will use the key to decrypt and authenticate Mesh access messages.

Returns

  • SL_STATUS_OK if the key has been added


sl_mesh_decoder_add_device_key#

sl_status_t sl_mesh_decoder_add_device_key (struct sl_mesh_decoder * context, const uint8_t * key_value, uint16_t device_addr, sl_mesh_key_handle * handle)

Add a device key.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

Context to use

const uint8_t *N/Akey_value

Exactly 16 octets of AES key material

uint16_tN/Adevice_addr

Primary address of the device; used to match keys to messages

sl_mesh_key_handle *N/Ahandle

A reference to the key is returned here on success

Add a known device key to a decoder. The decoder will use the key to decrypt and authenticate Mesh access messages.

Returns

  • SL_STATUS_OK if the key has been added


sl_mesh_decoder_remove_key#

sl_status_t sl_mesh_decoder_remove_key (struct sl_mesh_decoder * context, sl_mesh_key_handle handle)

Remove a key by reference.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

Context to use

sl_mesh_key_handleN/Ahandle

Reference to the key to remove

Returns

  • SL_STATUS_OK if the key has been removed


sl_mesh_decoder_get_friendship_key_context#

sl_status_t sl_mesh_decoder_get_friendship_key_context (struct sl_mesh_decoder * context, sl_mesh_key_handle handle, struct sl_mesh_friendship * friendship)

Get friendship context for a key.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

Context to use

sl_mesh_key_handleN/Ahandle

Reference to the friendship key to query

struct sl_mesh_friendship *N/Afriendship

The friendship context will be returned here

If a network PDU is encrypted using friendship key material, sl_mesh_decoder_decrypt_pdu() will return a reference to the friendship key that decrypted the PDU successfully. The friendship context can be extracted by this API call.

Returns

  • SL_STATUS_OK if the key was a friendship key and the context was read; SL_STATUS_NOT_SUPPORTED if library was compiled without friendship support.


sl_mesh_decoder_get_friendship_key#

sl_status_t sl_mesh_decoder_get_friendship_key (struct sl_mesh_decoder * context, uint16_t lpn_addr, uint16_t lpn_counter, sl_mesh_key_handle * handle)

Get a friendship key by LPN friendship parameters.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

Context to use

uint16_tN/Alpn_addr

LPN address for the friendship

uint16_tN/Alpn_counter

LPN counter for the friendship

sl_mesh_key_handle *N/Ahandle

The friendship key handle is returned here

Returns

  • SL_STATUS_OK if the friendship key was returned; SL_STATUS_NOT_SUPPORTED if library was compiled without friendship support.


sl_mesh_decoder_remove_friendship_key#

sl_status_t sl_mesh_decoder_remove_friendship_key (struct sl_mesh_decoder * context, uint16_t lpn_addr, sl_mesh_key_handle net_key_handle)

Remove a friendship key by LPN address and network key.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

Context to use

uint16_tN/Alpn_addr

LPN address for the friendship

sl_mesh_key_handleN/Anet_key_handle

Network key from which friendship credentials were derived

Returns

  • SL_STATUS_OK if the friendship key was removed; SL_STATUS_NOT_SUPPORTED if library was compiled without friendship support.


sl_mesh_decoder_decrypt_net_pdu#

sl_status_t sl_mesh_decoder_decrypt_net_pdu (struct sl_mesh_decoder * context, uint32_t current_ivindex, const uint8_t * net_pdu_ptr, size_t net_pdu_len, struct sl_mesh_net_pdu * pdu, sl_mesh_key_handle * matching_net_key, sl_mesh_key_handle * matching_friend_key)

Decrypt a network PDU.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

Context to use

uint32_tN/Acurrent_ivindex

Network IV Index value

const uint8_t *N/Anet_pdu_ptr

Encrypted network PDU data

size_tN/Anet_pdu_len

Encrypted network PDU length

struct sl_mesh_net_pdu *N/Apdu

The decrypted PDU is returned here

sl_mesh_key_handle *N/Amatching_net_key

A reference to the matching network key is returned here

sl_mesh_key_handle *N/Amatching_friend_key

A reference to the matching friendship is returned here, if the PDU was encrypted with friendship key material; otherwise, SL_MESH_KEY_HANDLE_INVALID is returned.

Decrypt a network PDU. The decoder will try to decrypt and authenticate the given encrypted network PDU with the encryption keys it has; and if successful, it will return the decrypted PDU contents as well as a reference to the matching network key, and a reference to the matching friendship key derivation in case the PDU was encrypted using friendship key material that could be decoded.

On successful decryption the pdu structure will contain the plaintext IVI and NID values; the deobfuscated CTL, TTL, sequence number, and source address values; the decrypted and authenticated destination address and payload; and the plaintext NetMIC at the end for reference.

Returns

  • SL_STATUS_OK if the PDU is successfully decrypted and authenticated


sl_mesh_net_pdu_is_valid#

bool sl_mesh_net_pdu_is_valid (const struct sl_mesh_net_pdu * pdu)

Verify NetPDU length.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Verify that a decrypted NetPDU is long enough to parse. Note that this only verifies that there is enough data to read all network PDU headers, that there is some payload, and that there is MIC data; it does not check the header field values or the higher layer PDU structure.

This API must be called before calling any of the network PDU parsing functions, if the PDU structure is not created by sl_mesh_decoder_decrypt_net_pdu().

Returns

  • true if the Network PDU contains enough data to be parsed


sl_mesh_net_pdu_ivi#

uint32_t sl_mesh_net_pdu_ivi (const struct sl_mesh_net_pdu * pdu)

Get Network PDU IVI header.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Returns

  • Low bit of the IV index used to send the PDU


sl_mesh_net_pdu_nid#

uint8_t sl_mesh_net_pdu_nid (const struct sl_mesh_net_pdu * pdu)

Get Network PDU NID header.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Returns

  • NID header value


sl_mesh_net_pdu_ctl#

uint8_t sl_mesh_net_pdu_ctl (const struct sl_mesh_net_pdu * pdu)

Get Network PDU CTL header.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Get the CTL header value of a networkPDU. This indicates whether the lower transport PDU contained in the network PDU is a control message or an access message.

Returns

  • CTL header value


sl_mesh_net_pdu_ttl#

uint8_t sl_mesh_net_pdu_ttl (const struct sl_mesh_net_pdu * pdu)

Get Network PDU TTL header.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Returns

  • TTL header value


sl_mesh_net_pdu_seq#

uint32_t sl_mesh_net_pdu_seq (const struct sl_mesh_net_pdu * pdu)

Get Network PDU sequence number.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Returns

  • Sequence number value


sl_mesh_net_pdu_src#

uint16_t sl_mesh_net_pdu_src (const struct sl_mesh_net_pdu * pdu)

Get Network PDU source address.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Returns

  • Source address value


sl_mesh_net_pdu_dst#

uint16_t sl_mesh_net_pdu_dst (const struct sl_mesh_net_pdu * pdu)

Get Network PDU destination address.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Returns

  • Destination address value


sl_mesh_net_pdu_data_ptr#

const uint8_t * sl_mesh_net_pdu_data_ptr (const struct sl_mesh_net_pdu * pdu)

Get Network PDU TransportPDU data.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Returns

  • Pointer to the beginning of the TransportPDU


sl_mesh_net_pdu_data_len#

size_t sl_mesh_net_pdu_data_len (const struct sl_mesh_net_pdu * pdu)

Get Network PDU TransportPDU length.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Returns

  • TransportPDU length


sl_mesh_net_pdu_mic_ptr#

const uint8_t * sl_mesh_net_pdu_mic_ptr (const struct sl_mesh_net_pdu * pdu)

Get Network PDU NetMIC data.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Returns

  • Pointer to the beginning of NetMIC


sl_mesh_net_pdu_mic_len#

size_t sl_mesh_net_pdu_mic_len (const struct sl_mesh_net_pdu * pdu)

Get Network PDU NetMIC length.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Returns

  • NetMIC length


sl_mesh_net_pdu_data#

void sl_mesh_net_pdu_data (const struct sl_mesh_net_pdu * pdu, net_pdu_t * net_pdu)

Extracts all relevant fields from a decoded network PDU.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *[in]pdu

Pointer to the decoded network PDU structure.

net_pdu_t *[out]net_pdu

Pointer to the net_pdu_t structure where the extracted fields will be stored.


sl_mesh_trans_pdu_data#

void sl_mesh_trans_pdu_data (const struct sl_mesh_net_pdu * pdu, trans_pdu_t * trans_pdu_access, uint8_t ctl)

Extracts the lower transport PDU from a network PDU.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *[in]pdu

Pointer to the decoded network PDU structure.

trans_pdu_t *[out]trans_pdu_access

Pointer to the structure where the extracted transport PDU information will be stored.

uint8_t[in]ctl

Control flag (0 for access message, 1 for control message).


sl_mesh_advertisement_header_from_buf#

void sl_mesh_advertisement_header_from_buf (sl_bt_msg_t * evt, advertisement_header_t * adv_header)

Decodes an advertisement header from a Bluetooth event buffer.

Parameters
TypeDirectionArgument NameDescription
sl_bt_msg_t *[in]evt

Pointer to the Bluetooth scanner event structure containing the raw advertisement data.

advertisement_header_t *[out]adv_header

Pointer to the advertisement header structure where the decoded information will be stored.


sl_mesh_segack_from_buf#

void sl_mesh_segack_from_buf (const uint8_t * ptr, segack_t * segack)

Decodes a Segment Acknowledgement message from a buffer.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]ptr

Pointer to the buffer containing the message data.

segack_t *[out]segack

Pointer to the structure where the decoded information will be stored.


sl_mesh_friend_poll_from_buf#

void sl_mesh_friend_poll_from_buf (const uint8_t * ptr, friend_poll_t * friend_poll)

Decodes a Friend Poll message from a buffer.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]ptr

Pointer to the buffer containing the message data.

friend_poll_t *[out]friend_poll

Pointer to the structure where the decoded information will be stored.


sl_mesh_friend_update_from_buf#

void sl_mesh_friend_update_from_buf (const uint8_t * ptr, friend_update_t * friend_update)

Decodes a Friend Update message from a buffer.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]ptr

Pointer to the buffer containing the message data.

friend_update_t *[out]friend_update

Pointer to the structure where the decoded information will be stored.


sl_mesh_friend_request_from_buf#

void sl_mesh_friend_request_from_buf (const uint8_t * ptr, friend_request_t * friend_request)

Decodes a Friend Request message from a buffer.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]ptr

Pointer to the buffer containing the message data.

friend_request_t *[out]friend_request

Pointer to the structure where the decoded information will be stored.


sl_mesh_friend_offer_from_buf#

void sl_mesh_friend_offer_from_buf (const uint8_t * ptr, friend_offer_t * friend_offer)

Decodes a Friend Offer message from a buffer.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]ptr

Pointer to the buffer containing the message data.

friend_offer_t *[out]friend_offer

Pointer to the structure where the decoded information will be stored.


sl_mesh_friend_clear_from_buf#

void sl_mesh_friend_clear_from_buf (const uint8_t * ptr, friend_clear_t * friend_clear)

Decodes a Friend Clear message from a buffer.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]ptr

Pointer to the buffer containing the message data.

friend_clear_t *[out]friend_clear

Pointer to the structure where the decoded information will be stored.


sl_mesh_friend_subscription_from_buf#

void sl_mesh_friend_subscription_from_buf (const uint8_t * ptr, friend_subscription_t * friend_subscription)

Decodes a Friend Subscription message from a buffer.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]ptr

Pointer to the buffer containing the message data.

friend_subscription_t *[out]friend_subscription

Pointer to the structure where the decoded information will be stored.


sl_mesh_heartbeat_from_buf#

void sl_mesh_heartbeat_from_buf (const uint8_t * ptr, heartbeat_t * heartbeat)

Decodes a Heartbeat message from a buffer.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]ptr

Pointer to the buffer containing the message data.

heartbeat_t *[out]heartbeat

Pointer to the structure where the decoded information will be stored.


sl_mesh_path_request_from_buf#

void sl_mesh_path_request_from_buf (const uint8_t * ptr, path_request_t * path_request)

Decodes a Path Request message from a buffer.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]ptr

Pointer to the buffer containing the message data.

path_request_t *[out]path_request

Pointer to the structure where the decoded information will be stored.


sl_mesh_path_reply_from_buf#

void sl_mesh_path_reply_from_buf (const uint8_t * ptr, path_reply_t * path_reply)

Decodes a Path Reply message from a buffer.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]ptr

Pointer to the buffer containing the message data.

path_reply_t *[out]path_reply

Pointer to the structure where the decoded information will be stored.


sl_mesh_path_confirmation_from_buf#

void sl_mesh_path_confirmation_from_buf (const uint8_t * ptr, path_confirmation_t * path_confirmation)

Decodes a Path Confirmation message from a buffer.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]ptr

Pointer to the buffer containing the message data.

path_confirmation_t *[out]path_confirmation

Pointer to the structure where the decoded information will be stored.


sl_mesh_dependent_node_update_from_buf#

void sl_mesh_dependent_node_update_from_buf (const uint8_t * ptr, dependent_node_update_t * dependent_node_update)

Decodes a Dependent Node Update message from a buffer.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]ptr

Pointer to the buffer containing the message data.

dependent_node_update_t *[out]dependent_node_update

Pointer to the structure where the decoded information will be stored.


sl_mesh_path_request_solicitation_from_buf#

void sl_mesh_path_request_solicitation_from_buf (const uint8_t * ptr, path_request_solicitation_t * path_request_solicitation)

Decodes a Path Request Solicitation message from a buffer.

Parameters
TypeDirectionArgument NameDescription
const uint8_t *[in]ptr

Pointer to the buffer containing the message data.

path_request_solicitation_t *[out]path_request_solicitation

Pointer to the structure where the decoded information will be stored.


sl_mesh_net_pdu_contains_valid_trans_pdu#

bool sl_mesh_net_pdu_contains_valid_trans_pdu (const struct sl_mesh_net_pdu * pdu)

Verify TransportPDU length.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Verify that the TransportPDU field in a decrypted PDU is long enough to parse. Note that this only verifies that there is enough data to read all lower transport layer headers and that there is some payload; it does not check the header field values or the higher layer PDU structure.

This API must be called before calling any of the lower transport PDU parsing functions.

Returns

  • true if the TransportPDU field contains enough data to be parsed


sl_mesh_trans_pdu_seg#

uint8_t sl_mesh_trans_pdu_seg (const struct sl_mesh_net_pdu * pdu)

Get Lower Transport PDU SEG header.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Get the SEG header value of a lower transport PDU. This indicates whether the lower transport PDU is segmented or not.

Returns

  • Value of the SEG header


sl_mesh_trans_pdu_seg_seq0#

uint16_t sl_mesh_trans_pdu_seg_seq0 (const struct sl_mesh_net_pdu * pdu)

Get Lower Transport PDU SeqZero header.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Get the SeqZero header value of a segmented lower transport PDU. This function should only be called for PDUs that are segmented.

Returns

  • Value of the SeqZero header


sl_mesh_trans_pdu_seg_o#

uint8_t sl_mesh_trans_pdu_seg_o (const struct sl_mesh_net_pdu * pdu)

Get Lower Transport PDU SegO header.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Get the SegO header value of a segmented lower transport PDU. This function should only be called for PDUs that are segmented.

Returns

  • Value of the SegO header


sl_mesh_trans_pdu_seg_n#

uint8_t sl_mesh_trans_pdu_seg_n (const struct sl_mesh_net_pdu * pdu)

Get Lower Transport PDU SegN header.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Get the SegN header value of a segmented lower transport PDU. This function should only be called for PDUs that are segmented.

Returns

  • Value of the SegN header


sl_mesh_trans_pdu_access_akf#

uint8_t sl_mesh_trans_pdu_access_akf (const struct sl_mesh_net_pdu * pdu)

Get Lower Transport PDU AKF header.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Get the AKF header value of a lower transport access message. This function should only be called for PDUs that contain access messages.

Returns

  • Value of the AKF header


sl_mesh_trans_pdu_access_aid#

uint8_t sl_mesh_trans_pdu_access_aid (const struct sl_mesh_net_pdu * pdu)

Get Lower Transport PDU AID header.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Get the AID header value of a lower transport access message. This function should only be called for PDUs that contain access messages.

Returns

  • Value of the AID header


sl_mesh_trans_pdu_access_szmic#

uint8_t sl_mesh_trans_pdu_access_szmic (const struct sl_mesh_net_pdu * pdu)

Get Lower Transport PDU SZMIC header.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Get the SZMIC header value of a lower transport access message. This function should only be called for PDUs that contain access messages. For non-segmented access messages this function will always return 0.

Returns

  • Value of the SZMIC header


sl_mesh_trans_pdu_control_opcode#

uint8_t sl_mesh_trans_pdu_control_opcode (const struct sl_mesh_net_pdu * pdu)

Get Lower Transport PDU Opcode header.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Get the Opcode header value of a lower transport control message. This function should only be called for PDUs that contain control messages.

Returns

  • Value of the Opcode header


sl_mesh_trans_pdu_data_ptr#

const uint8_t * sl_mesh_trans_pdu_data_ptr (const struct sl_mesh_net_pdu * pdu)

Get Lower Transport PDU payload data.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Get a pointer to the beginning of lower transport layer PDU payload. This returns a pointer to the beginning of upper transport access PDU for unsegmented access messages; a pointer to the beginning of an access message segment for segmented access messages; a pointer to the beginning of control message parameters for unsegmented control messages; and a pointer to the beginning of a control message segment for segmented control messages.

Returns

  • Pointer to lower transport PDU payload


sl_mesh_trans_pdu_data_len#

size_t sl_mesh_trans_pdu_data_len (const struct sl_mesh_net_pdu * pdu)

Get Lower Transport PDU payload length.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_net_pdu *N/Apdu

Decrypted Network PDU

Returns

  • Lower transport PDU payload length


sl_mesh_reassembler_add_segment#

sl_status_t sl_mesh_reassembler_add_segment (struct sl_mesh_decoder * context, sl_mesh_key_handle net_key, net_pdu_t net_pdu, trans_pdu_t trans_pdu, bool * now_completed)

Add segment data to SAR reassembly.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

Context to use

sl_mesh_key_handleN/Anet_key

Reference to the network key the data was encrypted with

net_pdu_tN/Anet_pdu

Decoded network PDU structure

trans_pdu_tN/Atrans_pdu

Decoded transport PDU structure

bool *N/Anow_completed

Set to true on first reception of a segment that completes the reassembly; the caller can make a decision on when to process the full message data based on this value, if it wants to process the data only once

Segmented access and control message data can be reassembled by the decoder as long as all segment data is received at least once. This function should be called when segmented data is received. The decoder will make the full message available to the application when all segment data is at hand.

The decoder will do a consistency check on incoming segments and will not consider badly formatted segments or segments with conflicting parameters for reassembly.

The caller does not need to filter for retransmitted segments as the decoder will take care of that.

Reassembler structures are internally allocated and deallocated by the decoder. The maximum number of parallel reassemblies that can be attempted is defined by the #MAX_REASSEMBLER_COUNT macro.

Returns

  • SL_STATUS_OK if segment data has been successfully processed for reassembly.


sl_mesh_reassembler_get_data#

sl_status_t sl_mesh_reassembler_get_data (struct sl_mesh_decoder * context, uint16_t src, uint16_t dst, uint16_t seq_0, const uint8_t ** ptr, size_t * len, uint32_t * seq_auth)

Get reassembled data.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

Context to use

uint16_tN/Asrc

Source address for the network PDU the data was received in

uint16_tN/Adst

Destination address for the network PDU the data was received in

uint16_tN/Aseq_0

SeqZero for the lower transport PDU the data was received in

const uint8_t **N/Aptr

Pointer to the beginning of reassembled data is returned here

size_t *N/Alen

Length of the reassembled data is returned here

uint32_t *N/Aseq_auth

The SeqAuth value for the reassembled message, used in access message decryption and authentication.

Get the reassembled access or control message data, if possible.

Returns

  • SL_STATUS_OK if reassembled data is available and could be returned


sl_mesh_pointer_contains_valid_control_message#

bool sl_mesh_pointer_contains_valid_control_message (uint8_t opcode, const uint8_t * param_ptr, size_t param_len)

Verify upper transport control message length.

Parameters
TypeDirectionArgument NameDescription
uint8_tN/Aopcode

Transport control opcode

const uint8_t *N/Aparam_ptr

Parameters array data

size_tN/Aparam_len

Parameters array length

Verify that the upper transport control message is long enough to parse. Note that this only verifies that there is enough data to read all parameters for the given opcode; it does not check parameter value validity.

This API must be called before starting to interpret the data.

Returns

  • true if the parameters array contains enough data to be parsed


sl_mesh_pointer_contains_valid_access_pdu#

bool sl_mesh_pointer_contains_valid_access_pdu (uint8_t szmic, const uint8_t * pdu_ptr, size_t pdu_len)

Verify upper transport access PDU length.

Parameters
TypeDirectionArgument NameDescription
uint8_tN/Aszmic

The SZMIC value for the PDU

const uint8_t *N/Apdu_ptr

PDU data array

size_tN/Apdu_len

PDU data length

Verify that the upper transport access PDU is long enough to parse. Note that this only verifies that there is enough data to read all fields; it does not check field value validity.

This API must be called before starting to interpret the data.

Returns

  • true if PDU data array contains enough data to be parsed


sl_mesh_friendship_add_friend_request#

sl_status_t sl_mesh_friendship_add_friend_request (struct sl_mesh_decoder * context, sl_mesh_key_handle net_key, uint16_t lpn_addr, uint16_t lpn_counter)

Add a Friend Request for pending friendship tracking.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

The context to use

sl_mesh_key_handleN/Anet_key

Reference to the network key from which friendship key material is derived

uint16_tN/Alpn_addr

Address of the LPN making the Friend Request

uint16_tN/Alpn_counter

LPN's friendship counter

The decoder must be made aware of the friendships it should keep track of as friendship negotiation is taking place. When a Friend Request PDU that is sent by an LPN that is of interest is seen, the application should call this API to add the pending friendship into the list of friendships to follow.

Once decoder is aware of both a Friend Request and the matching Friend Offer – see sl_mesh_friendship_add_friend_offer() – it can track a friendship that is established by being able to decode a PDU (such as a Friend Poll) that is encrypted with friendship key material derived from the parameters carried in these PDUs. It will do this automatically, provided that it is able to store the derived key material for use.

The decoder will internally manage the resources for friendship tracking. The macro #MAX_INCOMPLETE_FRIENDSHIP_COUNT defines how many pending friendships can be tracked in parallel; and the macro #MAX_KEYS affects how many friendship key derivations can be stored in addition to the other cryptographic keys.

The application should call sl_mesh_decoder_remove_key() to drop friendship key material for any friendships that are no longer of interest, such as terminated ones, so that it can derive keys for new friendships as needed.

Returns

  • SL_STATUS_OK if the pending friendship is being monitored; SL_STATUS_NOT_SUPPORTED if library was compiled without friendship support.


sl_mesh_friendship_add_friend_offer#

sl_status_t sl_mesh_friendship_add_friend_offer (struct sl_mesh_decoder * context, sl_mesh_key_handle net_key, uint16_t lpn_addr, uint16_t friend_addr, uint16_t friend_counter)

Add a Friend Offer for pending friendship tracking.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

The context to use

sl_mesh_key_handleN/Anet_key

Reference to the network key from which friendship key material is derived

uint16_tN/Alpn_addr

Address of the LPN that made a Friend Request

uint16_tN/Afriend_addr

Address of the Friend that made a Friend Offer

uint16_tN/Afriend_counter

Friend's friendship counter

This is the Friend Offer control message counterpart for sl_mesh_friendship_add_friend_request().

Returns

  • SL_STATUS_OK if the pending friendship is being monitored; SL_STATUS_NOT_SUPPORTED if library was compiled without friendship support.


sl_mesh_decoder_add_virtual_label_uuid#

sl_status_t sl_mesh_decoder_add_virtual_label_uuid (struct sl_mesh_decoder * context, const uint8_t * label_uuid)

Add a virtual address label UUID.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

The context to use

const uint8_t *N/Alabel_uuid

The label UUID to add

Virtual address label UUIDs need to be known by the decoder in order to be able to decrypt and authenticate access messages that are sent to virtual address destinations.

Returns

  • SL_STATUS_OK if the label UUID was successfully added


sl_mesh_decoder_remove_virtual_label_uuid#

sl_status_t sl_mesh_decoder_remove_virtual_label_uuid (struct sl_mesh_decoder * context, const uint8_t * label_uuid)

Remove a virtual address label UUID.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

The context to use

const uint8_t *N/Alabel_uuid

The label UUID to remove

Returns

  • SL_STATUS_OK if the label UUID was successfully removed


sl_mesh_decoder_decrypt_access_pdu#

sl_status_t sl_mesh_decoder_decrypt_access_pdu (struct sl_mesh_decoder * context, uint32_t current_ivindex, struct sl_mesh_access_pdu * pdu, sl_mesh_key_handle * matching_app_key, const uint8_t ** matching_label_uuid, net_pdu_t net_pdu, trans_pdu_t trans_pdu)

Decrypt an access message.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

Context to use

uint32_tN/Acurrent_ivindex

Network IV Index value

struct sl_mesh_access_pdu *N/Apdu

The decrypted message is returned here

sl_mesh_key_handle *N/Amatching_app_key

A reference to the matching application or device key is returned here

const uint8_t **N/Amatching_label_uuid

Pointer to the matching label UUID for virtual destination addresses, or NULL for non-virtual destination addresses, is returned here

net_pdu_tN/Anet_pdu

Transport protocol data unit

trans_pdu_tN/Atrans_pdu

Network protocol data unit

Decrypt an access message. The decoder will try to decrypt and authenticate the given encrypted access message with the encryption keys it has; and if successful, it will return the decrypted PDU contents as well as a reference to the matching application or device key, and a reference to the matching label UUID if the destination address is a virtual address or the NULL pointer.

On successful decryption the message structure will contain the decrypted and authenticated access message; and the plaintext TransMIC at the end for reference.

Returns

  • SL_STATUS_OK if the message is successfully decrypted and authenticated


sl_mesh_access_pdu_contains_valid_access_message#

bool sl_mesh_access_pdu_contains_valid_access_message (const struct sl_mesh_access_pdu * pdu)

Verify access message length.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_access_pdu *N/Apdu

Decrypted access message

Verify that the access message is long enough to parse. Note that this only verifies that there is enough data to read the access message opcode; it does not check parameter value validity for the particular message.

This API must be called before starting to interpret the data.

Returns

  • true if the access message contains enough data so that opcode can be parsed


sl_mesh_access_pdu_opcode_ptr#

const uint8_t * sl_mesh_access_pdu_opcode_ptr (const struct sl_mesh_access_pdu * pdu)

Get a pointer to the access message payload.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_access_pdu *N/Apdu

Decrypted access message

Returns

  • a pointer to the payload


sl_mesh_access_pdu_opcode_len#

size_t sl_mesh_access_pdu_opcode_len (const struct sl_mesh_access_pdu * pdu)

Get access message payload length.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_access_pdu *N/Apdu

Decrypted access message

Returns

  • length of the payload


sl_mesh_access_pdu_data_ptr#

const uint8_t * sl_mesh_access_pdu_data_ptr (const struct sl_mesh_access_pdu * pdu)

Get a pointer to the access message parameters.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_access_pdu *N/Apdu

Decrypted access message

Returns

  • a pointer to the beginning of parameters


sl_mesh_access_pdu_data_len#

size_t sl_mesh_access_pdu_data_len (const struct sl_mesh_access_pdu * pdu)

Get access message parameter length.

Parameters
TypeDirectionArgument NameDescription
const struct sl_mesh_access_pdu *N/Apdu

Decrypted access message

Returns

  • length of the parameters


sl_mesh_decoder_authenticate_network_beacon#

sl_status_t sl_mesh_decoder_authenticate_network_beacon (struct sl_mesh_decoder * context, const uint8_t * beacon_ptr, size_t beacon_len, enum sl_mesh_beacon * type, uint8_t * flags, uint32_t * iv_index, sl_mesh_key_handle * matching_net_key)

Authenticate beacon and get beacon contents.

Parameters
TypeDirectionArgument NameDescription
struct sl_mesh_decoder *N/Acontext

The context to use

const uint8_t *N/Abeacon_ptr

Beacon data pointer

size_tN/Abeacon_len

Beacon data length

enum sl_mesh_beacon *N/Atype

Beacon type will be returned here

uint8_t *N/Aflags

Beacon flags will be returned here

uint32_t *N/Aiv_index

Beacon IV index value will be returned here

sl_mesh_key_handle *N/Amatching_net_key

The network key with which the beacon authenticates will be returned here

Returns

  • SL_STATUS_OK if beacon was authenticated successfully


sl_mesh_decoder_time_to_sec#

float sl_mesh_decoder_time_to_sec (uint32_t interval)

Converts a time interval in milliseconds to seconds.

Parameters
TypeDirectionArgument NameDescription
uint32_t[in]interval

The time interval in milliseconds.

This function takes a time interval in milliseconds and converts it to seconds.

Returns

  • The time interval in seconds as a float.


sl_mesh_decoder_tolerance_to_error_percentage#

float sl_mesh_decoder_tolerance_to_error_percentage (uint16_t tolerance)

Converts a tolerance value to an error percentage.

Parameters
TypeDirectionArgument NameDescription
uint16_t[in]tolerance

The tolerance value.

This function takes a tolerance value and converts it to an error percentage.

Returns

  • The error percentage as a float.


sl_mesh_sensor_descriptors_from_buf#

sl_status_t sl_mesh_sensor_descriptors_from_buf (sensor_descriptor_t * descriptor, const uint8_t * pdu_data, const size_t pdu_data_len)

Parses sensor descriptors from a buffer.

Parameters
TypeDirectionArgument NameDescription
sensor_descriptor_t *[out]descriptor

Pointer to the structure where the parsed sensor descriptor information will be stored.

const uint8_t *[in]pdu_data

Pointer to the buffer containing the sensor descriptor data.

const size_t[in]pdu_data_len

Length of the buffer in bytes.

This function extracts sensor descriptor information from the provided buffer and populates the given sensor_descriptor_t structure.

Returns

  • sl_status_t Status code indicating the success or failure of the operation.

    • SL_STATUS_OK: The operation was successful.

    • Error code: An error occurred during parsing.


sl_mesh_sensor_cadence_from_buf#

sl_status_t sl_mesh_sensor_cadence_from_buf (struct sensort_cadence_state * cadence, uint8_t * pdu_data, const size_t pdu_data_len)

Decodes sensor cadence state from a buffer.

Parameters
TypeDirectionArgument NameDescription
struct sensort_cadence_state *[out]cadence

Pointer to the structure where the decoded sensor cadence state will be stored.

uint8_t *[in]pdu_data

Pointer to the buffer containing the encoded sensor cadence data.

const size_t[in]pdu_data_len

Length of the buffer containing the encoded data.

This function parses the provided buffer to extract the sensor cadence state and populates the given sensort_cadence_state structure with the decoded data.

Returns

  • sl_status_t Status code indicating the success or failure of the operation.

    • SL_STATUS_OK: The operation was successful.

    • Error code: An error occurred during parsing.


sl_mesh_sensor_setting_set_from_buf#

sl_status_t sl_mesh_sensor_setting_set_from_buf (sensor_set_setting_msg_t * set_setting, uint8_t * pdu_data, const size_t pdu_data_len)

Parses the sensor setting from a buffer.

Parameters
TypeDirectionArgument NameDescription
sensor_set_setting_msg_t *[out]set_setting

Pointer to the structure where the parsed sensor setting information will be stored.

uint8_t *[in]pdu_data

Pointer to the buffer containing the sensor setting data.

const size_t[in]pdu_data_len

Length of the buffer in bytes.

This function parses the provided buffer and populates the sensor setting structure with the extracted data.

Returns

  • sl_status_t Status code indicating the success or failure of the operation.

    • SL_STATUS_OK: The operation was successful.

    • Error code: An error occurred during parsing.


sl_mesh_sensor_setting_get_from_buf#

sl_status_t sl_mesh_sensor_setting_get_from_buf (sensor_get_setting_msg_t * get_setting, uint8_t * pdu_data, const size_t pdu_data_len)

Extracts sensor setting information from a buffer.

Parameters
TypeDirectionArgument NameDescription
sensor_get_setting_msg_t *[out]get_setting

Pointer to the structure where the sensor setting information will be stored.

uint8_t *[in]pdu_data

Pointer to the buffer containing the sensor setting data.

const size_t[in]pdu_data_len

Length of the buffer in bytes.

This function parses the provided buffer to populate the sensor_get_setting_msg_t structure with sensor setting data.

Returns

  • sl_status_t Status code indicating the success or failure of the operation.

    • SL_STATUS_OK: The operation was successful.

    • Error code: An error occurred during parsing.


sl_mesh_sensor_setting_status_from_buf#

sl_status_t sl_mesh_sensor_setting_status_from_buf (struct sensor_setting_status * setting_status, uint8_t * pdu_data, const size_t pdu_data_len)

Parses a sensor setting status message from a buffer.

Parameters
TypeDirectionArgument NameDescription
struct sensor_setting_status *[out]setting_status

Pointer to a sensor_setting_status structure where the parsed data will be stored.

uint8_t *[in]pdu_data

Pointer to the buffer containing the PDU data.

const size_t[in]pdu_data_len

Length of the PDU data buffer.

This function extracts the sensor setting status information from the provided data buffer and populates the given sensor_setting_status structure with the parsed data.

Returns

  • sl_status_t Returns SL_STATUS_OK if the parsing is successful, or an appropriate error code otherwise.


sl_mesh_sensor_status_from_buf#

sl_status_t sl_mesh_sensor_status_from_buf (sensor_status_msg_t * sensor_status, uint8_t * pdu_data, const size_t pdu_data_len)

Decodes a sensor status message from a buffer.

Parameters
TypeDirectionArgument NameDescription
sensor_status_msg_t *[out]sensor_status

Pointer to the structure where the decoded sensor status message will be stored.

uint8_t *[in]pdu_data

Pointer to the buffer containing the sensor status message data.

const size_t[in]pdu_data_len

Length of the buffer containing the sensor status message data.

This function parses the provided buffer containing sensor status data and populates the given sensor_status_msg_t structure with the decoded information.

Returns

  • sl_status_t Status code indicating the success or failure of the operation.

    • SL_STATUS_OK: The operation was successful.

    • Error code: An error occurred during parsing.


sl_mesh_sensor_settings_status_from_buf#

sl_status_t sl_mesh_sensor_settings_status_from_buf (sensor_settings_status_t * settings_status, uint8_t * pdu_data, const size_t pdu_data_len)

Extracts sensor settings status message from a buffer.

Parameters
TypeDirectionArgument NameDescription
sensor_settings_status_t *[out]settings_status

Pointer to the structure where the decoded sensor settings status will be stored.

uint8_t *[in]pdu_data

Pointer to the buffer containing the encoded sensor settings status message.

const size_t[in]pdu_data_len

Length of the buffer in bytes.

This function parses the provided buffer to extract the sensor settings status information and populates the given sensor_settings_status_t structure.

Returns

  • sl_status_t Status code indicating the success or failure of the operation.

    • SL_STATUS_OK: The operation was successful.

    • Error code: An error occurred during parsing.


sl_mesh_sensor_column_get_from_buf#

sl_status_t sl_mesh_sensor_column_get_from_buf (sensor_get_column_msg_t * column_get, uint8_t * pdu_data, const size_t pdu_data_len)

Extracts sensor column data from a buffer.

Parameters
TypeDirectionArgument NameDescription
sensor_get_column_msg_t *[out]column_get

Pointer to the structure where the extracted sensor column data will be stored.

uint8_t *[in]pdu_data

Pointer to the buffer containing the sensor column data.

const size_t[in]pdu_data_len

Length of the buffer in bytes.

This function parses the provided buffer to populate the sensor_get_column_msg_t structure with sensor column data.

Returns

  • sl_status_t Status code indicating the success or failure of the operation.

    • SL_STATUS_OK: The operation was successful.

    • Error code: An error occurred during parsing.


sl_mesh_sensor_series_get_from_buf#

sl_status_t sl_mesh_sensor_series_get_from_buf (sensor_get_series_msg_t * series_get, uint8_t * pdu_data, const size_t pdu_data_len)

Extracts sensor series data from a buffer.

Parameters
TypeDirectionArgument NameDescription
sensor_get_series_msg_t *[out]series_get

Pointer to the structure where the extracted sensor series data will be stored.

uint8_t *[in]pdu_data

Pointer to the buffer containing the PDU data.

const size_t[in]pdu_data_len

Length of the PDU data buffer.

This function parses the provided PDU data buffer to extract sensor series information and populates the given sensor_get_series_msg_t structure.

Returns

  • sl_status_t Status code indicating the success or failure of the operation.

    • SL_STATUS_OK: The operation was successful.

    • Error code: An error occurred during parsing.


sl_mesh_sensor_series_status_from_buf#

sl_status_t sl_mesh_sensor_series_status_from_buf (sensor_series_status_msg_t * series_status, uint8_t * pdu_data, const size_t pdu_data_len)

Decodes a sensor series status message from a buffer.

Parameters
TypeDirectionArgument NameDescription
sensor_series_status_msg_t *[out]series_status

Pointer to the structure where the decoded sensor series status will be stored.

uint8_t *[in]pdu_data

Pointer to the buffer containing the PDU data.

const size_t[in]pdu_data_len

Length of the PDU data buffer.

This function parses the provided PDU data and populates the sensor_series_status_msg_t structure with the decoded information.

Returns

  • sl_status_t Status code indicating the success or failure of the operation.

    • SL_STATUS_OK: The operation was successful.

    • Error code: An error occurred during parsing.


sl_mesh_sensor_column_status_from_buf#

sl_status_t sl_mesh_sensor_column_status_from_buf (sensor_column_status_msg_t * column_status, uint8_t * pdu_data, const size_t pdu_data_len)

Decodes a sensor column status message from a buffer.

Parameters
TypeDirectionArgument NameDescription
sensor_column_status_msg_t *[out]column_status

Pointer to the structure where the decoded sensor column status will be stored.

uint8_t *[in]pdu_data

Pointer to the buffer containing the encoded sensor column status message.

const size_t[in]pdu_data_len

Length of the buffer containing the encoded message.

This function extracts the sensor column status information from the provided buffer and populates the given sensor_column_status_msg_t structure.

Returns

  • sl_status_t Status code indicating the success or failure of the operation.

    • SL_STATUS_OK: The operation was successful.

    • Error code: An error occurred during parsing.