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

Commit

Permalink
Mqtt common (#98)
Browse files Browse the repository at this point in the history
Commits missing from original PR
  • Loading branch information
gguuss authored Mar 21, 2019
1 parent 02aeb13 commit 7526b14
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
8 changes: 6 additions & 2 deletions examples/Esp32-lwmqtt/esp32-mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// This file contains static methods for API requests using Wifi / MQTT
#ifndef __ESP32_MQTT_H__
#define __ESP32_MQTT_H__
#include <String.h>

#include <Client.h>
#include <WiFi.h>
#include <WiFiClientSecure.h>
Expand Down Expand Up @@ -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();
Expand All @@ -110,4 +114,4 @@ void setupCloudIoT() {
mqtt = new CloudIoTCoreMqtt(mqttClient, netClient, device);
mqtt->startMQTT();
}
#endif //__ESP32_MQTT_H__
#endif //__ESP32_MQTT_H__
6 changes: 4 additions & 2 deletions examples/Esp8266-lwmqtt/esp8266_mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion examples/MKR1000-lwmqtt/mkr1000-mqtt.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -105,4 +109,4 @@ void setupCloudIoT() {
mqtt = new CloudIoTCoreMqtt(mqttClient, netClient, device);
mqtt->startMQTT();
}
#endif //__MKR1000_MQTT_H__
#endif //__MKR1000_MQTT_H__

0 comments on commit 7526b14

Please sign in to comment.