Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
MeshModelMulticast Class Reference

Class that: More...

#include <cs_MeshModelMulticast.h>

Collaboration diagram for MeshModelMulticast:

Classes

struct  cs_multicast_queue_item_t
 

Public Types

typedef function< void(MeshMsgEvent &msg)> callback_msg_t
 Callback function definition. More...
 

Public Member Functions

void registerMsgHandler (const callback_msg_t &closure)
 Register a callback function that's called when a message from the mesh is received. More...
 
void init (uint16_t modelId)
 Init the model. More...
 
void configureSelf (dsm_handle_t appkeyHandle)
 Configure the model. More...
 
cs_ret_code_t addToQueue (MeshUtil::cs_mesh_queue_item_t &item)
 Add a msg to an empty spot in the queue (transmissions == 0). More...
 
cs_ret_code_t remFromQueue (cs_mesh_model_msg_type_t type, uint16_t id)
 Remove a msg from the queue. More...
 
void tick (uint32_t tickCount)
 To be called at a regular interval. More...
 
void handleMsg (const access_message_rx_t *accessMsg)
 Internal usage. More...
 

Private Member Functions

void processQueue ()
 Send messages from queue. More...
 
int getNextItemInQueue (bool priority)
 Check if there is a msg in queue with more than 0 transmissions. More...
 
bool sendMsgFromQueue ()
 Get a msg from the queue, and send it. More...
 
cs_ret_code_t sendMsg (const uint8_t *data, uint16_t len)
 Send a message over the mesh via publish, without reply. More...
 

Private Attributes

access_model_handle_t _accessModelHandle = ACCESS_HANDLE_INVALID
 
dsm_handle_t _groupAddressHandle = DSM_HANDLE_INVALID
 
callback_msg_t _msgCallback = nullptr
 
cs_multicast_queue_item_t _queue [_queueSize]
 
uint8_t _queueIndexNext = 0
 Next index in queue to send. More...
 

Static Private Attributes

static const uint8_t _queueSize = 20
 

Detailed Description

Class that:

  • Sends and receives multicast non-segmented messages.
  • Queues messages to be sent.
  • Interleaves sending queued messages.

Member Typedef Documentation

◆ callback_msg_t

typedef function<void(MeshMsgEvent& msg)> MeshModelMulticast::callback_msg_t

Callback function definition.

Member Function Documentation

◆ addToQueue()

cs_ret_code_t MeshModelMulticast::addToQueue ( MeshUtil::cs_mesh_queue_item_t item)

Add a msg to an empty spot in the queue (transmissions == 0).

Start looking at SendIndex, then reverse iterate over the queue. Then set the new SendIndex at the newly added item, so that it will be send first. We do the reverse iterate, so that the old SendIndex should be handled early (for a large enough queue).

◆ configureSelf()

void MeshModelMulticast::configureSelf ( dsm_handle_t  appkeyHandle)

Configure the model.

Subscribes, and sets publish address.

◆ getNextItemInQueue()

int MeshModelMulticast::getNextItemInQueue ( bool  priority)
private

Check if there is a msg in queue with more than 0 transmissions.

If so, return that index. Start looking at index SendIndex as that item should be sent first. Returns -1 if none found.

◆ handleMsg()

void MeshModelMulticast::handleMsg ( const access_message_rx_t *  accessMsg)

Internal usage.

◆ init()

void MeshModelMulticast::init ( uint16_t  modelId)

Init the model.

◆ processQueue()

void MeshModelMulticast::processQueue ( )
private

Send messages from queue.

◆ registerMsgHandler()

void MeshModelMulticast::registerMsgHandler ( const callback_msg_t closure)

Register a callback function that's called when a message from the mesh is received.

◆ remFromQueue()

cs_ret_code_t MeshModelMulticast::remFromQueue ( cs_mesh_model_msg_type_t  type,
uint16_t  id 
)

Remove a msg from the queue.

◆ sendMsg()

cs_ret_code_t MeshModelMulticast::sendMsg ( const uint8_t *  data,
uint16_t  len 
)
private

Send a message over the mesh via publish, without reply.

◆ sendMsgFromQueue()

bool MeshModelMulticast::sendMsgFromQueue ( )
private

Get a msg from the queue, and send it.

Returns true when message was sent, false when no more messages to be sent.

◆ tick()

void MeshModelMulticast::tick ( uint32_t  tickCount)

To be called at a regular interval.

Member Data Documentation

◆ _accessModelHandle

access_model_handle_t MeshModelMulticast::_accessModelHandle = ACCESS_HANDLE_INVALID
private

◆ _groupAddressHandle

dsm_handle_t MeshModelMulticast::_groupAddressHandle = DSM_HANDLE_INVALID
private

◆ _msgCallback

callback_msg_t MeshModelMulticast::_msgCallback = nullptr
private

◆ _queue

cs_multicast_queue_item_t MeshModelMulticast::_queue[_queueSize]
private

◆ _queueIndexNext

uint8_t MeshModelMulticast::_queueIndexNext = 0
private

Next index in queue to send.

◆ _queueSize

const uint8_t MeshModelMulticast::_queueSize = 20
staticprivate

The documentation for this class was generated from the following file: