From 7526b1466927704b4dd43168c18eac479ee7968d Mon Sep 17 00:00:00 2001 From: Gus Class Date: Thu, 21 Mar 2019 15:38:23 -0700 Subject: [PATCH] Mqtt common (#98) Commits missing from original PR --- examples/Esp32-lwmqtt/esp32-mqtt.h | 8 ++++++-- examples/Esp8266-lwmqtt/esp8266_mqtt.h | 6 ++++-- examples/MKR1000-lwmqtt/mkr1000-mqtt.h | 6 +++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/examples/Esp32-lwmqtt/esp32-mqtt.h b/examples/Esp32-lwmqtt/esp32-mqtt.h index 79b7a43e..0c6a705b 100644 --- a/examples/Esp32-lwmqtt/esp32-mqtt.h +++ b/examples/Esp32-lwmqtt/esp32-mqtt.h @@ -15,7 +15,7 @@ // This file contains static methods for API requests using Wifi / MQTT #ifndef __ESP32_MQTT_H__ #define __ESP32_MQTT_H__ -#include + #include #include #include @@ -93,6 +93,10 @@ void publishTelemetry(String data) { mqtt->publishTelemetry(data); } +void publishTelemetry(String subfolder, String data) { + mqtt->publishTelemetry(subfolder, data); +} + void connect() { connectWifi(); mqtt->mqttConnect(); @@ -110,4 +114,4 @@ void setupCloudIoT() { mqtt = new CloudIoTCoreMqtt(mqttClient, netClient, device); mqtt->startMQTT(); } -#endif //__ESP32_MQTT_H__ +#endif //__ESP32_MQTT_H__ diff --git a/examples/Esp8266-lwmqtt/esp8266_mqtt.h b/examples/Esp8266-lwmqtt/esp8266_mqtt.h index 297f21d8..68df48e8 100644 --- a/examples/Esp8266-lwmqtt/esp8266_mqtt.h +++ b/examples/Esp8266-lwmqtt/esp8266_mqtt.h @@ -63,9 +63,11 @@ String getJwt() { void setupCert() { // Set CA cert on wifi client - // If using a static (binary) cert: - // netClient->setCACert_P(ca_crt, ca_crt_len); + // If using a static (binary) cert, uncomment in ciotc_config.h: + //((WiFiClientSecure*)netClient)->setCACert_P(ca_crt, ca_crt_len); + //return; + // If using the (preferred) method with the cert in /data (SPIFFS) if (!SPIFFS.begin()) { Serial.println("Failed to mount file system"); return; diff --git a/examples/MKR1000-lwmqtt/mkr1000-mqtt.h b/examples/MKR1000-lwmqtt/mkr1000-mqtt.h index db377ebd..eb2da857 100644 --- a/examples/MKR1000-lwmqtt/mkr1000-mqtt.h +++ b/examples/MKR1000-lwmqtt/mkr1000-mqtt.h @@ -92,6 +92,10 @@ void publishTelemetry(String data) { mqtt->publishTelemetry(data); } +void publishTelemetry(String subfolder, String data) { + mqtt->publishTelemetry(subfolder, data); +} + void setupCloudIoT() { device = new CloudIoTCoreDevice( project_id, location, registry_id, device_id, @@ -105,4 +109,4 @@ void setupCloudIoT() { mqtt = new CloudIoTCoreMqtt(mqttClient, netClient, device); mqtt->startMQTT(); } -#endif //__MKR1000_MQTT_H__ +#endif //__MKR1000_MQTT_H__