mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-31 04:19:15 +03:00
Добавляем хук для возможности реагирования на сообщения из Mqtt
из любого модуля.
This commit is contained in:
@@ -51,6 +51,7 @@ class IoTItem {
|
|||||||
|
|
||||||
// хуки для системных событий
|
// хуки для системных событий
|
||||||
virtual void onRegEvent(IoTItem* item);
|
virtual void onRegEvent(IoTItem* item);
|
||||||
|
virtual void onMqttRecive(char* topic, uint8_t* payload, size_t length);
|
||||||
|
|
||||||
//методы для графиков
|
//методы для графиков
|
||||||
virtual void publishValue();
|
virtual void publishValue();
|
||||||
|
|||||||
@@ -117,6 +117,11 @@ void mqttSubscribe() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mqttCallback(char* topic, uint8_t* payload, size_t length) {
|
void mqttCallback(char* topic, uint8_t* payload, size_t length) {
|
||||||
|
// распространяем принятое сообщение через хуки
|
||||||
|
for (std::list<IoTItem*>::iterator it = IoTItems.begin(); it != IoTItems.end(); ++it) {
|
||||||
|
(*it)->onMqttRecive(topic, payload, length);
|
||||||
|
}
|
||||||
|
|
||||||
String topicStr = String(topic);
|
String topicStr = String(topic);
|
||||||
// SerialPrint("i", "=>MQTT", topicStr);
|
// SerialPrint("i", "=>MQTT", topicStr);
|
||||||
String payloadStr;
|
String payloadStr;
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ void IoTItem::checkIntFromNet() {
|
|||||||
|
|
||||||
void IoTItem::onRegEvent(IoTItem* item) {}
|
void IoTItem::onRegEvent(IoTItem* item) {}
|
||||||
|
|
||||||
|
void IoTItem::onMqttRecive(char* topic, uint8_t* payload, size_t length) {}
|
||||||
|
|
||||||
void IoTItem::publishValue() {}
|
void IoTItem::publishValue() {}
|
||||||
|
|
||||||
void IoTItem::clearValue() {}
|
void IoTItem::clearValue() {}
|
||||||
|
|||||||
Reference in New Issue
Block a user