ESP3D
3.0
Firmware for ESP boards connected to 3D Printer
netconfig.h
Go to the documentation of this file.
1
/*
2
netconfig.h - network functions class
3
4
Copyright (c) 2014 Luc Lebosse. All rights reserved.
5
6
This library is free software; you can redistribute it and/or
7
modify it under the terms of the GNU Lesser General Public
8
License as published by the Free Software Foundation; either
9
version 2.1 of the License, or (at your option) any later version.
10
11
This library is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
Lesser General Public License for more details.
15
16
You should have received a copy of the GNU Lesser General Public
17
License along with this library; if not, write to the Free Software
18
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
*/
20
21
//boundaries
22
23
24
#define MAX_HTTP_PORT 65001
25
#define MIN_HTTP_PORT 1
26
#define MAX_FTP_PORT 65001
27
#define MIN_FTP_PORT 1
28
#define MAX_TELNET_PORT 65001
29
#define MIN_TELNET_PORT 1
30
#define MAX_WEBSOCKET_PORT 65001
31
#define MIN_WEBSOCKET_PORT 1
32
#define MAX_HOSTNAME_LENGTH 32
33
#define MIN_HOSTNAME_LENGTH 1
34
35
//IP mode
36
#define DHCP_MODE 1
37
#define STATIC_IP_MODE 2
38
39
//Network Mode
40
#define ESP_RADIO_OFF 0
41
#define ESP_WIFI_STA 1
42
#define ESP_WIFI_AP 2
43
#define ESP_BT 3
44
#define ESP_ETH_STA 4
45
//#define ESP_ETH_SRV 5
46
47
#ifdef ARDUINO_ARCH_ESP32
48
#include <WiFi.h>
49
#endif //ARDUINO_ARCH_ESP32
50
#ifdef ARDUINO_ARCH_ESP8266
51
#include <ESP8266WiFi.h>
52
#endif //ARDUINO_ARCH_ESP8266
53
54
#ifndef _NET_CONFIG_H
55
#define _NET_CONFIG_H
56
57
class
NetConfig
58
{
59
public
:
60
NetConfig
();
61
~NetConfig
();
62
static
bool
isValidIP
(
const
char
*
string
);
63
static
bool
isHostnameValid
(
const
char
*
hostname
);
64
static
uint32_t
IP_int_from_string
(
const
char
* s);
65
static
String
IP_string_from_int
(uint32_t ip_int);
66
static
bool
isIPModeDHCP
(uint8_t mode);
67
static
bool
isDHCPServer
(uint8_t mode);
68
static
const
char
*
hostname
(
bool
fromsettings =
false
);
69
static
char
*
mac2str
(uint8_t mac [8]);
70
static
bool
begin
();
71
static
void
end
();
72
static
void
handle
();
73
static
uint8_t
getMode
();
74
static
bool
started
()
75
{
76
return
_started;
77
}
78
static
String
localIP
();
79
private :
80
static
String _hostname;
81
static
void
onWiFiEvent(WiFiEvent_t event);
82
static
bool
_needReconnect2AP;
83
static
bool
_events_registered;
84
static
bool
_started;
85
static
uint8_t _mode;
86
};
87
88
#endif //_NET_CONFIG_H
NetConfig::isValidIP
static bool isValidIP(const char *string)
Definition:
netconfig.cpp:144
NetConfig::IP_string_from_int
static String IP_string_from_int(uint32_t ip_int)
Definition:
netconfig.cpp:86
NetConfig::isIPModeDHCP
static bool isIPModeDHCP(uint8_t mode)
Definition:
netconfig.cpp:385
NetConfig::end
static void end()
Definition:
netconfig.cpp:308
NetConfig::~NetConfig
~NetConfig()
Definition:
netconfig.cpp:54
NetConfig::hostname
static const char * hostname(bool fromsettings=false)
Definition:
netconfig.cpp:331
NetConfig::handle
static void handle()
Definition:
netconfig.cpp:361
NetConfig::getMode
static uint8_t getMode()
Definition:
netconfig.cpp:207
NetConfig::begin
static bool begin()
Definition:
netconfig.cpp:215
NetConfig::isHostnameValid
static bool isHostnameValid(const char *hostname)
Definition:
netconfig.cpp:96
NetConfig
Definition:
netconfig.h:57
NetConfig::started
static bool started()
Definition:
netconfig.h:74
NetConfig::NetConfig
NetConfig()
Definition:
netconfig.cpp:50
NetConfig::mac2str
static char * mac2str(uint8_t mac[8])
Definition:
netconfig.cpp:60
NetConfig::IP_int_from_string
static uint32_t IP_int_from_string(const char *s)
Definition:
netconfig.cpp:73
NetConfig::localIP
static String localIP()
Definition:
netconfig.cpp:119
NetConfig::isDHCPServer
static bool isDHCPServer(uint8_t mode)
Definition:
netconfig.cpp:400
esp3d
src
modules
network
netconfig.h
Generated by
1.8.17