broker: declare and define per module (#2253)

* broker: declare and define per module

We no longer need to specify each Broker type in broker.h
But, we exchange that bit for explicit initialization of the instance

Define helper macros to generate boilerplate code
- namespace with Instance, Register(), Publish()
- forward Register(...) -> Instance.Register(...),
  Publish(...) -> Instance.Publish(...)

* don't check for broker when deps enable it
This commit is contained in:
Max Prokhorov
2020-05-18 02:29:17 +03:00
committed by GitHub
parent 21e75bef51
commit 84b51cf680
21 changed files with 124 additions and 64 deletions

View File

@@ -26,6 +26,8 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include "libs/DebounceEvent.h"
BrokerBind(ButtonBroker);
// TODO: if we are using such conversion helpers across the codebase, should convert() be in internal ns?
namespace settings {
@@ -455,6 +457,10 @@ void buttonEvent(unsigned char id, button_event_t event) {
auto& button = _buttons[id];
auto action = _buttonDecodeEventAction(button.actions, event);
#if BROKER_SUPPORT
ButtonBroker::Publish(id, event);
#endif
#if MQTT_SUPPORT
if (action || _buttons_mqtt_send_all[id]) {
buttonMQTT(id, event);