BusBricks: MessageService Class Reference
BusBricks  0.1
Customize bus-communication
Loading...
Searching...
No Matches
MessageService Class Reference

Service class for handling messages and acknowledgments. More...

Inheritance diagram for MessageService:
[legend]
Collaboration diagram for MessageService:
[legend]

Public Member Functions

 MessageService (uint8_t instance_id)
 Constructor for MessageService with default Service ID "m".
 
 MessageService (uint8_t instance_id, uint8_t service_id)
 Constructor for MessageService with a custom Service ID.
 
void stackProcessing () override
 Processes all messages from the receive stack.
 
uint8_t get_destinationId ()
 Retrieves the destination instance ID for the current response PDU in the send stack.
 
void sendMessage (char receiverId, String messagetext)
 Sends a new message.
 
- Public Member Functions inherited from Service< Message, STACKSIZE >
 Service (uint8_t serviceID, uint8_t instanceID)
 
uint8_t * get_ServiceID () override
 Get pointer to the 1-byte ServiceID of the Service (unique for each Service-template derived Class)
 
uint8_t * get_InstanceID () override
 Get pointer to the 1-byte InstanceID of the Service-instance (unique for each Instance of Service within the whole communication-network)
 
virtual bool impart_pdu (String *pdu) override
 Add a new Content-Object created from a received payload to the services receive-Stack. The payload is the representation of the Content-Object, during the construction, the Content-object creates it's content from the representation. The Content-object is added to the rec_stack.
 
virtual String get_response () override
 Get the get the response-payload, stored at the response_pdu of the service instance

 
virtual bool responseAvailable () override
 Check, if a response of the service is available (services sendStack not empty)
 
virtual void clearResponse () override
 Clear the response-buffer (delete item, that was returned by get_response from the service-sendStack)
 
- Public Member Functions inherited from ServiceBase
virtual bool impart_pdu (String *pdu)=0
 Add a new Content-Object created from a received payload to the services receive-Stack. The payload is the representation of the Content-Object, during the construction, the Content-object creates it's content from the representation. The Content-object is added to the rec_stack.
 
virtual ~ServiceBase ()
 Destroy the Service Base object.
 

Additional Inherited Members

- Protected Member Functions inherited from Service< Message, STACKSIZE >
void write_response_pdu (Message response_object)
 
- Protected Attributes inherited from Service< Message, STACKSIZE >
uint8_t serviceID
 
uint8_t instanceID
 
Content_stack< Message, stackSize > rec_stack
 
Content_stack< Message, stackSize > send_stack
 
String response_pdu
 

Detailed Description

Service class for handling messages and acknowledgments.

The MessageService class manages messages of type Message, processes incoming messages from the receive stack, and handles sending acknowledgments. It inherits from a Service for conetnt_type 'Message' (Service<Message, STACKSIZE>).

Constructors

Methods

  • void stackProcessing() override: Processes all messages from the receive stack until it is empty. Adds acknowledgments to the send stack and prints received messages.
  • uint8_t get_destinationId(): Retrieves the destination instance ID for the current response PDU.
  • void sendMessage(char receiverId, String messagetext): Sends a new message with the specified receiver ID and message text.
  • void sendAck(Message* message): Adds an acknowledgment for the given message to the send stack.
  • void printMessage(Message* message): Prints the content of the received message.
Note
  • The class handles both the processing of incoming messages and the sending of acknowledgments.
  • The stackProcessing method is responsible for managing the receive and send stacks, ensuring messages are properly handled and acknowledged.

Constructor & Destructor Documentation

◆ MessageService() [1/2]

MessageService::MessageService ( uint8_t instance_id)

Constructor for MessageService with default Service ID "m".

Initializes the service with the given instance ID and a default service ID.

Parameters
instance_idThe instance ID for the service.

◆ MessageService() [2/2]

MessageService::MessageService ( uint8_t instance_id,
uint8_t service_id )

Constructor for MessageService with a custom Service ID.

Initializes the service with the given instance ID and a custom service ID.

Parameters
instance_idThe instance ID for the service.
service_idThe custom service ID.

Member Function Documentation

◆ get_destinationId()

uint8_t MessageService::get_destinationId ( )

Retrieves the destination instance ID for the current response PDU in the send stack.

Returns
uint8_t The destination instance ID extracted from the message in the send stack.
Here is the call graph for this function:

◆ sendMessage()

void MessageService::sendMessage ( char receiverId,
String messagetext )

Sends a new message.

Constructs and sends a message with the specified receiver ID and message text. The message is added to the send stack for transmission.

Parameters
receiverIdchar, The ID of the message receiver.
messagetextString, The text of the message to be sent.
Here is the call graph for this function:

◆ stackProcessing()

void MessageService::stackProcessing ( )
overridevirtual

Processes all messages from the receive stack.

Processes each message in the receive stack until it is empty. For each message, it prints the message content to the serial output, generates and adds an acknowledgment PDU to the send stack, and removes the processed message from the receive stack.

Reimplemented from Service< Message, STACKSIZE >.

Here is the call graph for this function:

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