Loom 4 v4.5
Arduino library for Internet of Things Rapid Prototyping in environmental sensing
Loading...
Searching...
No Matches
Loom_Ethernet.h
1#pragma once
2
3#include <Ethernet.h>
4#include <EthernetClient.h>
5#include <EthernetUdp.h>
6
7#include "Module.h"
8#include "Loom_Manager.h"
9
10
16class Loom_Ethernet : public Module{
17
18 protected:
19
20 /* These aren't used with the Wifi manager */
21 void measure() override {};
22
23 void package() override {};
24
25 // Initialize the device and connect to the network
26 void initialize() override;
27
28 // Reconnect to the network
29 void power_up() override {};
30
31 // Disconnect from the network
32 void power_down() override {};
33
34 public:
35
42 Loom_Ethernet(Manager& man, uint8_t mac[6], IPAddress ip);
43
50
58 void loadConfigFromJSON(char* json);
59
63 void connect();
64
69 EthernetClient& getClient() { return ethernetClient; };
70
74 EthernetUDP* getUDP() { return new EthernetUDP(); };
75
79 IPAddress getIPAddress();
80
84 IPAddress getSubnetMask();
85
89 IPAddress getGateway();
90
94 IPAddress getBroadcast();
98 void ipToString(IPAddress ip, char array[16]) {
99 snprintf(array, 16, "%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
100 };
101
102 private:
103 Manager* manInst; // Pointer to the manager
104
105 EthernetClient ethernetClient; // Ethernet client that can be used with the MQTT client or other additional objects
106
107 bool hasInitialized = false; // Has the Ethernet module run through the initialization process
108
109 uint8_t mac[6]; // MAC Address of the connected device
110 IPAddress ip; // The IP we should assign to this device
111
112 IPAddress remoteIP; // IP address to send the UDP requests to
113
114
115};
Definition: Loom_Ethernet.h:16
IPAddress getIPAddress()
Definition: Loom_Ethernet.cpp:96
EthernetUDP * getUDP()
Definition: Loom_Ethernet.h:74
void connect()
Definition: Loom_Ethernet.cpp:46
IPAddress getSubnetMask()
Definition: Loom_Ethernet.cpp:103
void ipToString(IPAddress ip, char array[16])
Definition: Loom_Ethernet.h:98
EthernetClient & getClient()
Definition: Loom_Ethernet.h:69
void loadConfigFromJSON(char *json)
Definition: Loom_Ethernet.cpp:69
IPAddress getGateway()
Definition: Loom_Ethernet.cpp:110
IPAddress getBroadcast()
Definition: Loom_Ethernet.cpp:117
Definition: Loom_Manager.h:18
Definition: Module.h:30