-
Notifications
You must be signed in to change notification settings - Fork 150
Expand file tree
/
Copy pathCallerInterface.h
More file actions
39 lines (32 loc) · 958 Bytes
/
CallerInterface.h
File metadata and controls
39 lines (32 loc) · 958 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#pragma once
#include "Arduino.h"
#include "EspMQTTClient.h"
// check working example here https://github.com/dino-rider/IotDevice_test
class IotDevice;
class Peripheral: public EspMQTTCaller
{
protected:
EspMQTTClient *client;
String topic;
public:
Peripheral(EspMQTTClient *_client,String _topic);
void publish(String message, bool retain);
void subscribe();
void setTopic(String _topic) {topic=_topic;};
String getTopic(){return topic};
virtual void cMessageReceivedCallback(const String &topicStr, const String &message);
};
void Peripheral::publish(const String message, bool retain)
{
client->publish(topic, message, retain);
}
void Peripheral::subscribe()
{
client->subscribe(topic, static_cast<EspMQTTCaller*>(this), 0);
}
Peripheral::Peripheral(EspMQTTClient *_client, String _topic): client(_client)
{}
void Peripheral::cMessageReceivedCallback(const String &topicStr, const String &message)
{
Serial.println(message);
}