supla-device
Toggle main menu visibility
Loading...
Searching...
No Matches
src
supla
network
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
#ifdef ARDUINO_ARCH_AVR
23
#include <Arduino.h>
24
#include <EthernetENC.h>
25
26
#include <supla/log_wrapper.h>
27
28
#include "../supla_lib_config.h"
29
#include "network.h"
30
31
// TODO(klew): change logs to supla_log
32
33
namespace
Supla {
34
class
ENC28J60 :
public
Supla::Network {
35
public
:
36
explicit
ENC28J60(uint8_t mac[6],
unsigned
char
*ip = NULL) : Network(ip) {
37
memcpy(this->mac, mac, 6);
38
}
39
40
void
disable()
override
{
41
}
42
43
bool
isReady()
override
{
44
return
true
;
45
}
46
47
void
setup()
override
{
48
setSSLEnabled(
false
);
// no SSL support on Arduino MEGA target
49
Serial.println(F(
"Connecting to network..."
));
50
if
(useLocalIp) {
51
Ethernet.begin(mac, localIp);
52
}
else
{
53
Ethernet.begin(mac);
54
}
55
56
Serial.print(F(
"localIP: "
));
57
Serial.println(Ethernet.localIP());
58
Serial.print(F(
"subnetMask: "
));
59
Serial.println(Ethernet.subnetMask());
60
Serial.print(F(
"gatewayIP: "
));
61
Serial.println(Ethernet.gatewayIP());
62
Serial.print(F(
"dnsServerIP: "
));
63
Serial.println(Ethernet.dnsServerIP());
64
}
65
66
protected
:
67
uint8_t mac[6] = {};
68
};
69
70
};
// namespace Supla
71
72
#endif
// ARDUINO_ARCH_AVR
73
74
#endif
// SRC_SUPLA_NETWORK_ENC28J60_H_
Generated by
1.17.0