VLCB
Loading...
Searching...
No Matches
VLCB::LongMessageServiceEx Class Reference

a derived class to extend the base long message class to handle multiple concurrent messages, sending and receiving More...

#include <LongMessageService.h>

Inheritance diagram for VLCB::LongMessageServiceEx:
VLCB::LongMessageService VLCB::Service

Public Member Functions

bool allocateContexts (byte num_receive_contexts=NUM_EX_CONTEXTS, unsigned int receive_buffer_len=EX_BUFFER_LEN, byte num_send_contexts=NUM_EX_CONTEXTS)
 allocate memory for receive and send contexts
bool sendLongMessage (const void *msg, const unsigned int msg_len, const byte stream_id)
virtual void process () override
void subscribe (byte *stream_ids, const byte num_stream_ids, void(*messagehandler)(void *msg, unsigned int msg_len, byte stream_id, byte status))
 subscribe to a range of stream IDs
virtual void processReceivedMessageFragment (const VlcbMessage *frame)
 handle an incoming long message Controller message fragment
byte is_sending ()
void use_crc (bool use_crc)
 set whether to calculate and compare a CRC of the message
Public Member Functions inherited from VLCB::LongMessageService
virtual void processAction (const Action &action) override
 Called when there is an action available.
bool sendLongMessage (const void *msg, const unsigned int msg_len, const byte stream_id)
void subscribe (byte *stream_ids, const byte num_stream_ids, void *receive_buffer, const unsigned int receive_buffer_len, void(*messagehandler)(void *fragment, const unsigned int fragment_len, const byte stream_id, const byte status))
 subscribe to a range of stream IDs
bool is_sending ()
void setDelay (byte delay_in_millis)
void setTimeout (unsigned int timeout_in_millis)
virtual VlcbServiceTypes getServiceID () const override
 Return a unique ID for this service.
virtual byte getServiceVersionID () const override
 Return the version of the service specification implemented by this service.
Public Member Functions inherited from VLCB::Service
void setController (Controller *ctrl)
 Set a pointer to the controller object for use in implementing class.
virtual void begin ()
 This optional method is called at the beginning of the Arduino sketch. Define this method for the service to do any setup required at the beginning.
virtual void reportDiagnostics (byte serviceIndex, byte diagnosticsCode)
 Report a given diagnostic value.
virtual int getDiagnosticCount ()
 report how many diagnostics this service supports.
virtual Data getServiceData ()
 Return Data bytes specific for the implementing service. The meaning of each data byte is defined in the service specification.

Additional Inherited Members

Protected Member Functions inherited from VLCB::LongMessageService
void handleMessage (const VlcbMessage *msg)
bool sendMessageFragment (VlcbMessage *frame)
 send next message fragment
Protected Member Functions inherited from VLCB::Service
bool isThisNodeNumber (unsigned int nodeNumber)
 Helper function to decide if a given node number is the same as that assigned to this node.
Protected Attributes inherited from VLCB::LongMessageService
bool _is_receiving = false
byte * _send_buffer
byte * _receive_buffer
byte _send_stream_id = 0
byte _receive_stream_id = 0
byte * _stream_ids = NULL
byte _num_stream_ids = 0
byte _msg_delay = LONG_MESSAGE_DEFAULT_DELAY
unsigned int _send_buffer_len = 0
unsigned int _incoming_message_length = 0
unsigned int _receive_buffer_len = 0
unsigned int _receive_buffer_index = 0
unsigned int _send_buffer_index = 0
unsigned int _incoming_message_crc = 0
unsigned int _incoming_bytes_received = 0
unsigned int _receive_timeout = LONG_MESSAGE_RECEIVE_TIMEOUT
unsigned int _send_sequence_num = 0
unsigned int _expected_next_receive_sequence_num = 0
unsigned long _last_fragment_sent = 0UL
unsigned long _last_fragment_received = 0UL
void(* _messagehandler )(void *fragment, const unsigned int fragment_len, const byte stream_id, const byte status)
Protected Attributes inherited from VLCB::Service
Controllercontroller
 Pointer to the Controller object that can be used by implementing classes.

Detailed Description

a derived class to extend the base long message class to handle multiple concurrent messages, sending and receiving

Member Function Documentation

◆ allocateContexts()

bool VLCB::LongMessageServiceEx::allocateContexts ( byte num_receive_contexts = NUM_EX_CONTEXTS,
unsigned int receive_buffer_len = EX_BUFFER_LEN,
byte num_send_contexts = NUM_EX_CONTEXTS )

allocate memory for receive and send contexts

◆ sendLongMessage()

bool VLCB::LongMessageServiceEx::sendLongMessage ( const void * msg,
const unsigned int msg_len,
const byte stream_id )

initiate sending of a long message this method sends the first message - the header packet the remainder of the message is sent in fragments from the process() method

◆ process()

void VLCB::LongMessageServiceEx::process ( )
overridevirtual

the process method is called regularly from the user's loop function we use this to send the individual fragments of any outgoing messages and check the message receive timeouts

Reimplemented from VLCB::LongMessageService.

◆ subscribe()

void VLCB::LongMessageServiceEx::subscribe ( byte * stream_ids,
const byte num_stream_ids,
void(* messagehandler )(void *msg, unsigned int msg_len, byte stream_id, byte status) )

subscribe to a range of stream IDs

◆ processReceivedMessageFragment()

void VLCB::LongMessageServiceEx::processReceivedMessageFragment ( const VlcbMessage * frame)
virtual

handle an incoming long message Controller message fragment

Reimplemented from VLCB::LongMessageService.

◆ is_sending()

byte VLCB::LongMessageServiceEx::is_sending ( )

report state of long message sending returns number of streams currently in progress

◆ use_crc()

void VLCB::LongMessageServiceEx::use_crc ( bool use_crc)

set whether to calculate and compare a CRC of the message


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