MQTTHelpers.h
2.18 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include <Arduino.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
const size_t fullJsonDocSize = 2 * 1024;
const char * chipID();
const char * shortID();
void discoveryMessageSetIDs(char * discoveryMsgJson);
const char * topicByReference(const char * key,
const char * discoveryMsgJson);
bool validJson(const char * discoveryMsgJson);
bool connectMQTT(PubSubClient & client,
const char * clientID,
const char * user,
const char * password);
bool publish(PubSubClient & client,
const char * topic,
const char * payload,
size_t payloadLength,
bool retained = false);
bool publish(PubSubClient & client,
const char * topic,
const char * payload,
bool retained = false);
bool discoveryMsgToJsonDoc(JsonDocument & discoveryMsgDoc,
const char * discoveryMsgJson);
bool addEntity(PubSubClient & client,
const char * component,
const char * object,
JsonDocument & discoveryMsgDoc);
bool addEntity(PubSubClient & client,
const char * component,
const char * object,
const char * discoveryMsgJson);
bool subscribe(PubSubClient & client,
const char * discoveryMessage,
const char * key);