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.

34 lines
870 B

6 years ago
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. Module key prefix: bkr
  5. */
  6. #if BROKER_SUPPORT
  7. #include <vector>
  8. std::vector<void (*)(const char *, unsigned char, const char *)> _broker_callbacks;
  9. // -----------------------------------------------------------------------------
  10. void brokerRegister(void (*callback)(const char *, unsigned char, const char *)) {
  11. _broker_callbacks.push_back(callback);
  12. }
  13. void brokerPublish(const char * topic, unsigned char id, const char * message) {
  14. //DEBUG_MSG_P(PSTR("[BROKER] Message %s[%u] => %s\n"), topic, id, message);
  15. for (unsigned char i=0; i<_broker_callbacks.size(); i++) {
  16. (_broker_callbacks[i])(topic, id, message);
  17. }
  18. }
  19. void brokerPublish(const char * topic, const char * message) {
  20. brokerPublish(topic, 0, message);
  21. }
  22. #endif // BROKER_SUPPORT