supla-device
Loading...
Searching...
No Matches
ENC28J60.h
1/*
2 Copyright (C) AC SOFTWARE SP. Z O.O.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17*/
18
19#ifndef SRC_SUPLA_NETWORK_ENC28J60_H_
20#define SRC_SUPLA_NETWORK_ENC28J60_H_
21
22#include <Arduino.h>
23#include <EthernetENC.h>
24
25#include <supla/log_wrapper.h>
26
27#include "../supla_lib_config.h"
28#include "network.h"
29
30// TODO(klew): change logs to supla_log
31
32namespace Supla {
33class ENC28J60 : public Supla::Network {
34 public:
35 explicit ENC28J60(uint8_t mac[6], unsigned char *ip = NULL) : Network(ip) {
36 memcpy(this->mac, mac, 6);
37 }
38
39 void disable() override {
40 }
41
42 bool isReady() override {
43 return true;
44 }
45
46 void setup() override {
47 setSSLEnabled(false); // no SSL support on Arduino MEGA target
48 Serial.println(F("Connecting to network..."));
49 if (useLocalIp) {
50 Ethernet.begin(mac, localIp);
51 } else {
52 Ethernet.begin(mac);
53 }
54
55 Serial.print(F("localIP: "));
56 Serial.println(Ethernet.localIP());
57 Serial.print(F("subnetMask: "));
58 Serial.println(Ethernet.subnetMask());
59 Serial.print(F("gatewayIP: "));
60 Serial.println(Ethernet.gatewayIP());
61 Serial.print(F("dnsServerIP: "));
62 Serial.println(Ethernet.dnsServerIP());
63 }
64
65 protected:
66 uint8_t mac[6] = {};
67};
68
69}; // namespace Supla
70
71#endif // SRC_SUPLA_NETWORK_ENC28J60_H_
Definition network.h:36