Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
846 B

6 years ago
6 years ago
  1. /*
  2. BROKER MODULE
  3. Copyright (C) 2017-2018 by Xose Pérez <xose dot perez at gmail dot com>
  4. */
  5. #if BROKER_SUPPORT
  6. #include <vector>
  7. std::vector<void (*)(const char *, unsigned char, const char *)> _broker_callbacks;
  8. // -----------------------------------------------------------------------------
  9. void brokerRegister(void (*callback)(const char *, unsigned char, const char *)) {
  10. _broker_callbacks.push_back(callback);
  11. }
  12. void brokerPublish(const char * topic, unsigned char id, const char * message) {
  13. //DEBUG_MSG_P(PSTR("[BROKER] Message %s[%u] => %s\n"), topic, id, message);
  14. for (unsigned char i=0; i<_broker_callbacks.size(); i++) {
  15. (_broker_callbacks[i])(topic, id, message);
  16. }
  17. }
  18. void brokerPublish(const char * topic, const char * message) {
  19. brokerPublish(topic, 0, message);
  20. }
  21. #endif // BROKER_SUPPORT