36 lines
951 B
C++
36 lines
951 B
C++
|
#include <ESPMegaPRO_OOP.hpp>
|
||
|
|
||
|
ESPMegaPRO espmega = ESPMegaPRO();
|
||
|
|
||
|
void setup() {
|
||
|
espmega.begin();
|
||
|
espmega.enableIotModule();
|
||
|
NetworkConfig config = {
|
||
|
.ip = {192, 168, 0, 11},
|
||
|
.gateway = {192, 168, 0, 1},
|
||
|
.subnet = {255, 255, 255, 0},
|
||
|
.dns1 = {192, 168, 0, 1},
|
||
|
.dns2 = {192, 168, 0, 1},
|
||
|
.useStaticIp = true,
|
||
|
.useWifi = false,
|
||
|
.wifiUseAuth = false,
|
||
|
};
|
||
|
strcpy(config.ssid, "ssid");
|
||
|
strcpy(config.password, "password");
|
||
|
strcpy(config.hostname, "espmega");
|
||
|
espmega.iot.setNetworkConfig(config);
|
||
|
espmega.iot.connectNetwork();
|
||
|
MqttConfig mqtt_config = {
|
||
|
.mqtt_port = 1883,
|
||
|
.mqtt_useauth = false
|
||
|
};
|
||
|
strcpy(mqtt_config.mqtt_server, "192.168.0.26");
|
||
|
espmega.iot.setMqttConfig(mqtt_config);
|
||
|
espmega.iot.connectToMqtt();
|
||
|
espmega.iot.registerCard(0);
|
||
|
espmega.iot.registerCard(1);
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
espmega.loop();
|
||
|
}
|