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

Service for producing events. More...

#include <EventProducerService.h>

Inheritance diagram for VLCB::EventProducerService:
VLCB::Service VLCB::EventProducerServiceWithDiagnostics

Public Member Functions

void setRequestEventHandler (void(*fptr)(byte index, const VlcbMessage *msg))
 register the user handler for learned events
virtual void processAction (const Action &action) override
 Called when there is an action available.
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.
void sendShortEvent (bool state, int eventNumber)
 Send a short event.
void sendLongEvent (bool state, int eventNumber)
 Send a long event.
void sendLongEventWithSpoofedNodeNumber (bool state, int nodeNumber, int eventNumber)
 Send a long event with a spoofed node number.
void sendEventAtIndex (bool state, byte evIndex)
 Send an event from the taught events table.
void sendEventAtIndex (bool state, byte evIndex, byte data1)
 Send an event from the taught events table with data.
void sendEventAtIndex (bool state, byte evIndex, byte data1, byte data2)
 Send an event from the taught events table with data.
void sendEventAtIndex (bool state, byte evIndex, byte data1, byte data2, byte data3)
 Send an event from the taught events table with data.
void sendEventResponse (bool state, byte index)
void sendEventResponse (bool state, byte index, byte data1)
void sendEventResponse (bool state, byte index, byte data1, byte data2)
void sendEventResponse (bool state, byte index, byte data1, byte data2, byte data3)
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 process ()
 This method that be called regularly from the VLCB core to let the service perform regular tasks.
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.

Protected Attributes

unsigned int diagEventsProduced = 0
Protected Attributes inherited from VLCB::Service
Controllercontroller
 Pointer to the Controller object that can be used by implementing classes.

Additional Inherited Members

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.

Detailed Description

Service for producing events.

This service provides a means of generating VLCB events and interrogating their status. A full description of events can be found in the document VLCB Event Model.

The events that a module can produce are either taught events which are stored in the events table or direct events.

Member Function Documentation

◆ setRequestEventHandler()

void VLCB::EventProducerService::setRequestEventHandler ( void(* fptr )(byte index, const VlcbMessage *msg))

register the user handler for learned events

Sets the callback function that is called when an Accessory Request opcode or Accessory Request Short Event opcode is received.

◆ processAction()

void VLCB::EventProducerService::processAction ( const Action & action)
overridevirtual

Called when there is an action available.

This method does not need to be implemented if the service does react to any actions.

Parameters
actionThe action that the service may have interest in.

Reimplemented from VLCB::Service.

◆ getServiceID()

virtual VlcbServiceTypes VLCB::EventProducerService::getServiceID ( ) const
inlineoverridevirtual

Return a unique ID for this service.

This ID is used by configuration utilities to identify the service type. The service IDs are listed in the VLCB service specifications.

Implements VLCB::Service.

◆ getServiceVersionID()

virtual byte VLCB::EventProducerService::getServiceVersionID ( ) const
inlineoverridevirtual

Return the version of the service specification implemented by this service.

This version is used by configuration utilities to identify which features are implemented by this service.

Implements VLCB::Service.

◆ sendShortEvent()

void VLCB::EventProducerService::sendShortEvent ( bool state,
int eventNumber )

Send a short event.

Parameters
statesend an ON event if state is true or OFF event if false
eventNumberevent number for the short event.

The event does not need to be taught, and stored in the events table.

◆ sendLongEvent()

void VLCB::EventProducerService::sendLongEvent ( bool state,
int eventNumber )

Send a long event.

Parameters
statesend an ON event if state is true or OFF event if false
eventNumberevent number for the long event.

The event does not need to be taught, and stored in the events table. The node number is the number of this node.

◆ sendLongEventWithSpoofedNodeNumber()

void VLCB::EventProducerService::sendLongEventWithSpoofedNodeNumber ( bool state,
int nodeNumber,
int eventNumber )

Send a long event with a spoofed node number.

Parameters
statesend an ON event if state is true or OFF event if false
nodeNumbernode number to use for the long event instead of the current node.
eventNumberevent number for the long event.

The event does not need to be taught, and stored in the events table.

Use spoofed node numbers only when many nodes send the same long event. It is recommended to use short events for many-to-many events.

◆ sendEventAtIndex() [1/4]

void VLCB::EventProducerService::sendEventAtIndex ( bool state,
byte evIndex )

Send an event from the taught events table.

Parameters
statesend an ON event if state is true or OFF event if false
evIndexindex into the taught events table for the event to use.

The indexed event determines if the sent event is short or long.

◆ sendEventAtIndex() [2/4]

void VLCB::EventProducerService::sendEventAtIndex ( bool state,
byte evIndex,
byte data1 )

Send an event from the taught events table with data.

Parameters
statesend an ON event if state is true or OFF event if false
evIndexindex into the taught events table for the event to use.
data1data byte to be included in the event.

The indexed event determines if the sent event is short or long.

◆ sendEventAtIndex() [3/4]

void VLCB::EventProducerService::sendEventAtIndex ( bool state,
byte evIndex,
byte data1,
byte data2 )

Send an event from the taught events table with data.

Parameters
statesend an ON event if state is true or OFF event if false
evIndexindex into the taught events table for the event to use.
data1first data byte to be included in the event.
data2second data byte to be included in the event.

The indexed event determines if the sent event is short or long.

◆ sendEventAtIndex() [4/4]

void VLCB::EventProducerService::sendEventAtIndex ( bool state,
byte evIndex,
byte data1,
byte data2,
byte data3 )

Send an event from the taught events table with data.

Parameters
statesend an ON event if state is true or OFF event if false
evIndexindex into the taught events table for the event to use.
data1first data byte to be included in the event.
data2second data byte to be included in the event.
data3third data byte to be included in the event.

The indexed event determines if the sent event is short or long.

◆ sendEventResponse() [1/4]

void VLCB::EventProducerService::sendEventResponse ( bool state,
byte index )

Causes an Accessory Response to be sent with state indicating on for TRUE and off for FALSE. Short or Long event is determined by the nature of the request and the Event Table entry at evIndex.

◆ sendEventResponse() [2/4]

void VLCB::EventProducerService::sendEventResponse ( bool state,
byte index,
byte data1 )

Causes an Accessory Response with one data byte to be sent with state indicating on for TRUE and off for FALSE. Short or Long event is determined by the nature of the request and the Event Table entry at evIndex. The data sent is data1.

◆ sendEventResponse() [3/4]

void VLCB::EventProducerService::sendEventResponse ( bool state,
byte index,
byte data1,
byte data2 )

Causes an Accessory Response with two data bytes to be sent with state indicating on for TRUE and off for FALSE. Short or Long event is determined by the nature of the request and the Event Table entry at evIndex. The data sent is data1 and data2.

◆ sendEventResponse() [4/4]

void VLCB::EventProducerService::sendEventResponse ( bool state,
byte index,
byte data1,
byte data2,
byte data3 )

Causes an Accessory Response with three data bytes to be sent with state indicating on for TRUE and off for FALSE. Short or Long event is determined by the nature of the request and the Event Table entry at evIndex. The data sent is data1 and data2 and data3.

Member Data Documentation

◆ diagEventsProduced

unsigned int VLCB::EventProducerService::diagEventsProduced = 0
protected

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