Skip to content
Snippets Groups Projects
Commit 8dfa3fa4 authored by Cyril Danilevski's avatar Cyril Danilevski
Browse files

Use WiFi stack for networking

parent 301d2cac
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,12 @@ ESP32 firmware for the IMC, based on Arduino and the `ESP32-Ethernet-Kit_A_V1.2` ...@@ -5,6 +5,12 @@ ESP32 firmware for the IMC, based on Arduino and the `ESP32-Ethernet-Kit_A_V1.2`
This project depends on [`Arduino_SNMP`](https://github.com/patricklaf/SNMP). This project depends on [`Arduino_SNMP`](https://github.com/patricklaf/SNMP).
### Quirks
Despite communication being over Ethernet, the project makes use of the ESP32 Wifi stack, hence some
references to Wifi here and there (eg. `WiFiUdp`).
### Installation ### Installation
Either use the Arduino IDE and use its library manager to find the SNMP library, or use `arduino-cli`: Either use the Arduino IDE and use its library manager to find the SNMP library, or use `arduino-cli`:
......
#include <EthernetUdp.h> #include <WiFiUdp.h>
#include <SNMP.h> #include <SNMP.h>
#include "esp32_ethernet.hpp" #include "esp32_ethernet.hpp"
EthernetUDP udp; WiFiUDP udp;
SNMP::Manager snmp; SNMP::Manager snmp;
// Use some SNMP classes // Use some SNMP classes
...@@ -238,9 +238,9 @@ void setup() { ...@@ -238,9 +238,9 @@ void setup() {
// Start // Start
start = millis(); start = millis();
// MPOD // MPOD
//SNMP::Message *message = mpod.setup(); SNMP::Message *message = mpod.setup();
//snmp.send(message, IPAddress(10, 42, 0, 3), SNMP::PORT::SNMP); snmp.send(message, IPAddress(10, 42, 0, 1), SNMP::PORT::SNMP);
//delete message; delete message;
} }
enum { enum {
...@@ -269,7 +269,7 @@ void loop() { ...@@ -269,7 +269,7 @@ void loop() {
// If ON or OFF, send SETREQUEST to MPOD // If ON or OFF, send SETREQUEST to MPOD
SNMP::Message *message = mpod.output(output == ON); SNMP::Message *message = mpod.output(output == ON);
Serial.print("Sending message "); Serial.print("Sending message ");
snmp.send(message, IPAddress(10, 42, 0, 3), SNMP::PORT::SNMP); snmp.send(message, IPAddress(10, 42, 0, 1), SNMP::PORT::SNMP);
Serial.println("Sent"); Serial.println("Sent");
delete message; delete message;
} }
...@@ -279,7 +279,7 @@ void loop() { ...@@ -279,7 +279,7 @@ void loop() {
start = millis(); start = millis();
// Create message to query MPOD and send it // Create message to query MPOD and send it
SNMP::Message* message = mpod.read(); SNMP::Message* message = mpod.read();
snmp.send(message, IPAddress(10, 42, 0, 3), SNMP::PORT::SNMP); snmp.send(message, IPAddress(10, 42, 0, 1), SNMP::PORT::SNMP);
delete message; delete message;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment