Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
MeshUtil Namespace Reference

Mesh utils without dependencies on mesh SDK. More...

Classes

struct  cs_mesh_queue_item_meta_data_t
 Data needed in each model queue. More...
 
struct  cs_mesh_queue_item_t
 Struct to queue an item. More...
 

Functions

int8_t getRssi (const nrf_mesh_rx_metadata_t *metaData)
 Get the RSSI from meta data. More...
 
uint8_t getChannel (const nrf_mesh_rx_metadata_t *metaData)
 
MeshMsgEvent fromAccessMessageRX (const access_message_rx_t &accessMsg)
 Factory method because a constructor would pollute the struct. More...
 
void printMeshAddress (const char *prefix, const nrf_mesh_address_t *addr)
 Print a mesh address. More...
 
bool isValidMeshMessage (cs_mesh_msg_t *meshMsg)
 
bool isValidMeshMessage (uint8_t *meshMsg, size16_t msgSize)
 
bool isValidMeshPayload (cs_mesh_model_msg_type_t type, uint8_t *payload, size16_t payloadSize)
 
bool testIsValid (const cs_mesh_model_msg_test_t *packet, size16_t size)
 
bool ackIsValid (const uint8_t *packet, size16_t size)
 
bool timeIsValid (const cs_mesh_model_msg_time_t *packet, size16_t size)
 
bool noopIsValid (const uint8_t *packet, size16_t size)
 
bool multiSwitchIsValid (const uint8_t *packet, size16_t size)
 
bool state0IsValid (const cs_mesh_model_msg_state_0_t *packet, size16_t size)
 
bool state1IsValid (const cs_mesh_model_msg_state_1_t *packet, size16_t size)
 
bool profileLocationIsValid (const cs_mesh_model_msg_profile_location_t *packet, size16_t size)
 
bool setBehaviourSettingsIsValid (const behaviour_settings_t *packet, size16_t size)
 
cs_mesh_model_msg_type_t getType (const uint8_t *meshMsg)
 
void getPayload (uint8_t *meshMsg, size16_t meshMsgSize, uint8_t *&payload, size16_t &payloadSize)
 Get payload of a mesh message. More...
 
cs_data_t getPayload (uint8_t *meshMsg, size16_t meshMsgSize)
 Get payload of a mesh message. More...
 
size16_t getMeshMessageSize (size16_t payloadSize)
 
bool setMeshMessage (cs_mesh_model_msg_type_t type, const uint8_t *payload, size16_t payloadSize, uint8_t *meshMsg, size16_t meshMsgSize)
 Create a mesh message. More...
 
bool setMeshPayload (uint8_t *meshMsg, size16_t meshMsgSize, const uint8_t *payload, size16_t payloadSize)
 Set payload of a mesh message. More...
 
bool canShortenStateType (uint16_t type)
 
bool canShortenStateId (uint16_t id)
 
bool canShortenPersistenceMode (uint8_t id)
 
bool canShortenAccessLevel (EncryptionAccessLevel accessLevel)
 
bool canShortenSource (const cmd_source_with_counter_t &source)
 
bool canShortenRetCode (cs_ret_code_t retCode)
 
uint8_t getShortenedRetCode (cs_ret_code_t retCode)
 
cs_ret_code_t getInflatedRetCode (uint8_t retCode)
 
uint8_t getShortenedAccessLevel (EncryptionAccessLevel accessLevel)
 
EncryptionAccessLevel getInflatedAccessLevel (uint8_t accessLevel)
 
uint8_t getShortenedSource (const cmd_source_with_counter_t &source)
 
cmd_source_with_counter_t getInflatedSource (uint8_t sourceId)
 

Detailed Description

Mesh utils without dependencies on mesh SDK.

Author: Crownstone Team Copyright: Crownstone (https://crownstone.rocks) Date: 10 May., 2019 License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)

Mesh utils with dependencies on mesh SDK.

Function Documentation

◆ ackIsValid()

bool MeshUtil::ackIsValid ( const uint8_t *  packet,
size16_t  size 
)

◆ canShortenAccessLevel()

bool MeshUtil::canShortenAccessLevel ( EncryptionAccessLevel  accessLevel)

◆ canShortenPersistenceMode()

bool MeshUtil::canShortenPersistenceMode ( uint8_t  id)

◆ canShortenRetCode()

bool MeshUtil::canShortenRetCode ( cs_ret_code_t  retCode)

◆ canShortenSource()

bool MeshUtil::canShortenSource ( const cmd_source_with_counter_t source)

◆ canShortenStateId()

bool MeshUtil::canShortenStateId ( uint16_t  id)

◆ canShortenStateType()

bool MeshUtil::canShortenStateType ( uint16_t  type)

◆ fromAccessMessageRX()

MeshMsgEvent MeshUtil::fromAccessMessageRX ( const access_message_rx_t &  accessMsg)

Factory method because a constructor would pollute the struct.

◆ getChannel()

uint8_t MeshUtil::getChannel ( const nrf_mesh_rx_metadata_t *  metaData)

◆ getInflatedAccessLevel()

EncryptionAccessLevel MeshUtil::getInflatedAccessLevel ( uint8_t  accessLevel)

◆ getInflatedRetCode()

cs_ret_code_t MeshUtil::getInflatedRetCode ( uint8_t  retCode)

◆ getInflatedSource()

cmd_source_with_counter_t MeshUtil::getInflatedSource ( uint8_t  sourceId)

◆ getMeshMessageSize()

size16_t MeshUtil::getMeshMessageSize ( size16_t  payloadSize)

◆ getPayload() [1/2]

cs_data_t MeshUtil::getPayload ( uint8_t *  meshMsg,
size16_t  meshMsgSize 
)

Get payload of a mesh message.

Assumes message is valid.

Parameters
[in]meshMsgMesh message..
[in]meshMsgSizeSize of the mesh message.

◆ getPayload() [2/2]

void MeshUtil::getPayload ( uint8_t *  meshMsg,
size16_t  meshMsgSize,
uint8_t *&  payload,
size16_t payloadSize 
)

Get payload of a mesh message.

Assumes message is valid.

Parameters
[in]meshMsgMesh message..
[in]meshMsgSizeSize of the mesh message.
[out]payloadSet to payload.
[out]payloadSizeSet to size of the payload.

◆ getRssi()

int8_t MeshUtil::getRssi ( const nrf_mesh_rx_metadata_t *  metaData)

Get the RSSI from meta data.

◆ getShortenedAccessLevel()

uint8_t MeshUtil::getShortenedAccessLevel ( EncryptionAccessLevel  accessLevel)

◆ getShortenedRetCode()

uint8_t MeshUtil::getShortenedRetCode ( cs_ret_code_t  retCode)

◆ getShortenedSource()

uint8_t MeshUtil::getShortenedSource ( const cmd_source_with_counter_t source)

◆ getType()

cs_mesh_model_msg_type_t MeshUtil::getType ( const uint8_t *  meshMsg)

◆ isValidMeshMessage() [1/2]

bool MeshUtil::isValidMeshMessage ( cs_mesh_msg_t meshMsg)

◆ isValidMeshMessage() [2/2]

bool MeshUtil::isValidMeshMessage ( uint8_t *  meshMsg,
size16_t  msgSize 
)

◆ isValidMeshPayload()

bool MeshUtil::isValidMeshPayload ( cs_mesh_model_msg_type_t  type,
uint8_t *  payload,
size16_t  payloadSize 
)

◆ multiSwitchIsValid()

bool MeshUtil::multiSwitchIsValid ( const uint8_t *  packet,
size16_t  size 
)

◆ noopIsValid()

bool MeshUtil::noopIsValid ( const uint8_t *  packet,
size16_t  size 
)

◆ printMeshAddress()

void MeshUtil::printMeshAddress ( const char *  prefix,
const nrf_mesh_address_t *  addr 
)

Print a mesh address.

◆ profileLocationIsValid()

bool MeshUtil::profileLocationIsValid ( const cs_mesh_model_msg_profile_location_t packet,
size16_t  size 
)

◆ setBehaviourSettingsIsValid()

bool MeshUtil::setBehaviourSettingsIsValid ( const behaviour_settings_t packet,
size16_t  size 
)

◆ setMeshMessage()

bool MeshUtil::setMeshMessage ( cs_mesh_model_msg_type_t  type,
const uint8_t *  payload,
size16_t  payloadSize,
uint8_t *  meshMsg,
size16_t  meshMsgSize 
)

Create a mesh message.

Copies the payload into the mesh message. Assumes payload is valid.

Parameters
[in]typePayload type.
[in]payloadPayload packet.
[in]payloadSizeSize of the payload.
[in,out]meshMsgMesh message, must already be allocated.
[in]meshMsgSizeSize of allocated the mesh message.
Return values
Trueon success.

◆ setMeshPayload()

bool MeshUtil::setMeshPayload ( uint8_t *  meshMsg,
size16_t  meshMsgSize,
const uint8_t *  payload,
size16_t  payloadSize 
)

Set payload of a mesh message.

Copies the payload into the mesh message. Assumes payload is valid.

Parameters
[in]payloadPayload packet.
[in]payloadSizeSize of the payload.
[in,out]meshMsgMesh message, must already be allocated.
[in,out]meshMsgSizeSize of allocated the mesh message, set to size of the message on success.
Return values
Trueon success.

◆ state0IsValid()

bool MeshUtil::state0IsValid ( const cs_mesh_model_msg_state_0_t packet,
size16_t  size 
)

◆ state1IsValid()

bool MeshUtil::state1IsValid ( const cs_mesh_model_msg_state_1_t packet,
size16_t  size 
)

◆ testIsValid()

bool MeshUtil::testIsValid ( const cs_mesh_model_msg_test_t packet,
size16_t  size 
)

◆ timeIsValid()

bool MeshUtil::timeIsValid ( const cs_mesh_model_msg_time_t packet,
size16_t  size 
)