VLCB
Loading...
Searching...
No Matches
EventConsumerService.h
Go to the documentation of this file.
1// Copyright (C) Martin Da Costa 2023 (martindc.merg@gmail.com)
2// This file is part of VLCB-Arduino project on https://github.com/SvenRosvall/VLCB-Arduino
3// Licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
4// The full licence can be found at: http://creativecommons.org/licenses/by-nc-sa/4.0/
5
6#pragma once
7
8#include "Service.h"
9#include <vlcbdefs.hpp>
10
11namespace VLCB {
12
13struct VlcbMessage;
25{
26public:
29 void setEventHandler(void (*fptr)(byte index, const VlcbMessage *msg));
31 virtual void processAction(const Action &action) override;
32
33 virtual VlcbServiceTypes getServiceID() const override
34 {
36 }
37 virtual byte getServiceVersionID() const override
38 {
39 return 1;
40 }
41
42private:
43 void (*eventhandler)(byte index, const VlcbMessage *msg) = nullptr;
44 void handleConsumedMessage(const VlcbMessage *msg);
45 void processAccessoryEvent(const VlcbMessage *msg, unsigned int nn, unsigned int en);
46
47protected:
48 unsigned int diagEventsConsumed = 0;
49 unsigned int diagEventsAcknowledged = 0;
51};
52
53} // VLCB
Service for consuming events.
Definition EventConsumerService.h:25
unsigned int diagEventsConsumed
Definition EventConsumerService.h:48
void setEventHandler(void(*fptr)(byte index, const VlcbMessage *msg))
register the user handler for learned events
Definition EventConsumerService.cpp:17
virtual void processAction(const Action &action) override
Called when there is an action available.
Definition EventConsumerService.cpp:51
virtual byte getServiceVersionID() const override
Return the version of the service specification implemented by this service.
Definition EventConsumerService.h:37
virtual VlcbServiceTypes getServiceID() const override
Return a unique ID for this service.
Definition EventConsumerService.h:33
unsigned int diagEventsAcknowledged
Definition EventConsumerService.h:49
Interface base class for all VLCB services.
Definition Service.h:25
Definition AbstractEventTeachingService.cpp:13
An action to be performed.
Definition Controller.h:51
CAN/Controller message type.
Definition Controller.h:30
VlcbServiceTypes
Definition vlcbdefs.hpp:487
@ SERVICE_ID_CONSUMER
Definition vlcbdefs.hpp:497