mirror of
https://github.com/gabrielkheisa/antares-esp8266-mqtt.git
synced 2025-08-21 11:31:09 +00:00
Added subscribe functionality
This commit is contained in:
30
examples/AntaresMQTTSubscribe/AntaresMQTTSubscribe.ino
Normal file
30
examples/AntaresMQTTSubscribe/AntaresMQTTSubscribe.ino
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <AntaresESP8266MQTT.h>
|
||||
|
||||
#define ACCESSKEY "your-access-key"
|
||||
#define WIFISSID "your-wifi-ssid"
|
||||
#define PASSWORD "your-wifi-password"
|
||||
|
||||
#define projectName = "your-project-name";
|
||||
#define deviceName = "your-device-name";
|
||||
|
||||
AntaresESP8266MQTT antares(ACCESSKEY);
|
||||
|
||||
void callback(char topic[], byte payload[], unsigned int length) {
|
||||
String topicString = String(topic);
|
||||
String payloadString = antares.byteToString(payload, length);
|
||||
|
||||
Serial.println("[ANTARES] New Mesage: ");
|
||||
Serial.println(topicString);
|
||||
Serial.println(payloadString);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
antares.setDebug(true);
|
||||
antares.wifiConnection(WIFISSID, PASSWORD);
|
||||
antares.setMqttServer();
|
||||
antares.setCallback(callback);
|
||||
}
|
||||
void loop() {
|
||||
antares.checkMqttConnection();
|
||||
}
|
Reference in New Issue
Block a user