15
15
#include " CloudIoTCoreMqtt.h"
16
16
17
17
// Forward global callback declarations
18
- String getJwt ();
18
+ String getJwt ();
19
19
void messageReceived (String &topic, String &payload);
20
20
21
21
@@ -42,15 +42,27 @@ void CloudIoTCoreMqtt::publishTelemetry(String data) {
42
42
this ->mqttClient ->publish (device->getEventsTopic (), data);
43
43
}
44
44
45
+ void CloudIoTCoreMqtt::publishTelemetry (const char * data, int length) {
46
+ this ->mqttClient ->publish (device->getEventsTopic ().c_str (), data, length);
47
+ }
48
+
45
49
void CloudIoTCoreMqtt::publishTelemetry (String subtopic, String data) {
46
50
this ->mqttClient ->publish (device->getEventsTopic () + subtopic, data);
47
51
}
48
52
53
+ void CloudIoTCoreMqtt::publishTelemetry (String subtopic, const char * data, int length) {
54
+ this ->mqttClient ->publish (String (device->getEventsTopic () + subtopic).c_str (), data, length);
55
+ }
56
+
49
57
// Helper that just sends default sensor
50
58
void CloudIoTCoreMqtt::publishState (String data) {
51
59
this ->mqttClient ->publish (device->getStateTopic (), data);
52
60
}
53
61
62
+ void CloudIoTCoreMqtt::publishState (const char * data, int length) {
63
+ this ->mqttClient ->publish (device->getStateTopic ().c_str (), data, length);
64
+ }
65
+
54
66
void CloudIoTCoreMqtt::onConnect () {
55
67
if (logConnect) {
56
68
publishState (" connected" );
@@ -170,7 +182,7 @@ void CloudIoTCoreMqtt::mqttConnect() {
170
182
}
171
183
172
184
// Set QoS to 1 (ack) for configuration messages
173
- this ->mqttClient ->subscribe (device->getConfigTopic (), 1 );
185
+ this ->mqttClient ->subscribe (device->getConfigTopic (), 1 );
174
186
// QoS 0 (no ack) for commands
175
187
this ->mqttClient ->subscribe (device->getCommandsTopic (), 0 );
176
188
0 commit comments