38 lines
873 B
Plaintext
38 lines
873 B
Plaintext
#include <ESPMegaPRO_OOP.hpp>
|
|
#include <ETH.h>
|
|
// Instantiate ESPMega
|
|
ESPMegaPRO espmega = ESPMegaPRO();
|
|
|
|
void mqtt_callback(char *topic, char *payload)
|
|
{
|
|
Serial.print("MQTT Callback: ");
|
|
Serial.print(topic);
|
|
Serial.print(" ");
|
|
Serial.println(payload);
|
|
}
|
|
|
|
IPAddress ip(192, 168, 0, 11);
|
|
IPAddress gateway(192, 168, 0, 1);
|
|
IPAddress subnet(255, 255, 255, 0);
|
|
|
|
void setup()
|
|
{
|
|
// Initialize ESPMega
|
|
espmega.begin();
|
|
espmega.enableIotModule();
|
|
ETH.begin();
|
|
ETH.config(ip, gateway, subnet);
|
|
espmega.iot.setBaseTopic("/testmegaoop");
|
|
espmega.iot.connectToMqtt("espmega", "192.168.0.26", 1883);
|
|
espmega.iot.publishRelative("test", "test");
|
|
espmega.iot.subscribeRelative("test");
|
|
espmega.iot.registerMqttCallback(mqtt_callback);
|
|
espmega.iot.registerCard(1);
|
|
espmega.iot.publishCard(1);
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
// Call ESPMega loop
|
|
espmega.loop();
|
|
} |