Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit 7526b14

Browse files
authored
Mqtt common (#98)
Commits missing from original PR
1 parent 02aeb13 commit 7526b14

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

examples/Esp32-lwmqtt/esp32-mqtt.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// This file contains static methods for API requests using Wifi / MQTT
1616
#ifndef __ESP32_MQTT_H__
1717
#define __ESP32_MQTT_H__
18-
#include <String.h>
18+
1919
#include <Client.h>
2020
#include <WiFi.h>
2121
#include <WiFiClientSecure.h>
@@ -93,6 +93,10 @@ void publishTelemetry(String data) {
9393
mqtt->publishTelemetry(data);
9494
}
9595

96+
void publishTelemetry(String subfolder, String data) {
97+
mqtt->publishTelemetry(subfolder, data);
98+
}
99+
96100
void connect() {
97101
connectWifi();
98102
mqtt->mqttConnect();
@@ -110,4 +114,4 @@ void setupCloudIoT() {
110114
mqtt = new CloudIoTCoreMqtt(mqttClient, netClient, device);
111115
mqtt->startMQTT();
112116
}
113-
#endif //__ESP32_MQTT_H__
117+
#endif //__ESP32_MQTT_H__

examples/Esp8266-lwmqtt/esp8266_mqtt.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ String getJwt() {
6363

6464
void setupCert() {
6565
// Set CA cert on wifi client
66-
// If using a static (binary) cert:
67-
// netClient->setCACert_P(ca_crt, ca_crt_len);
66+
// If using a static (binary) cert, uncomment in ciotc_config.h:
67+
//((WiFiClientSecure*)netClient)->setCACert_P(ca_crt, ca_crt_len);
68+
//return;
6869

70+
// If using the (preferred) method with the cert in /data (SPIFFS)
6971
if (!SPIFFS.begin()) {
7072
Serial.println("Failed to mount file system");
7173
return;

examples/MKR1000-lwmqtt/mkr1000-mqtt.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ void publishTelemetry(String data) {
9292
mqtt->publishTelemetry(data);
9393
}
9494

95+
void publishTelemetry(String subfolder, String data) {
96+
mqtt->publishTelemetry(subfolder, data);
97+
}
98+
9599
void setupCloudIoT() {
96100
device = new CloudIoTCoreDevice(
97101
project_id, location, registry_id, device_id,
@@ -105,4 +109,4 @@ void setupCloudIoT() {
105109
mqtt = new CloudIoTCoreMqtt(mqttClient, netClient, device);
106110
mqtt->startMQTT();
107111
}
108-
#endif //__MKR1000_MQTT_H__
112+
#endif //__MKR1000_MQTT_H__

0 commit comments

Comments
 (0)