ESP3D  3.0
Firmware for ESP boards connected to 3D Printer
settings_esp3d.h
Go to the documentation of this file.
1 
2 /*
3  settings_esp3d.h - settings esp3d functions class
4 
5  Copyright (c) 2014 Luc Lebosse. All rights reserved.
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Lesser General Public
9  License as published by the Free Software Foundation; either
10  version 2.1 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public
18  License along with this library; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 
22 
23 
24 #ifndef _SETTINGS_ESP3D_H
25 #define _SETTINGS_ESP3D_H
26 
27 //Supported FW /////////////////////////////////////////////////////////////
28 #define UNKNOWN_FW 0
29 #define REPETIER4DV 1
30 #define MARLIN 2
31 #define MARLINKIMBRA 3
32 #define SMOOTHIEWARE 4
33 #define REPETIER 5
34 #define GRBL 6
35 #define MAX_FW_ID 6
36 
37 #define NO_NETWORK 0
38 //position in EEPROM / preferences will use `P_` + <position> to make a string : P_0 for 0
39 #define ESP_RADIO_MODE 0 //1 byte = flag
40 #define ESP_STA_SSID 1 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese
41 #define ESP_STA_PASSWORD 34 //65 bytes 64 +1 = string ;warning does not support multibyte char like chinese
42 #define ESP_STA_IP_MODE 99 //1 byte = flag
43 #define ESP_STA_IP_VALUE 100 //4 bytes xxx.xxx.xxx.xxx
44 #define ESP_STA_MASK_VALUE 104 //4 bytes xxx.xxx.xxx.xxx
45 #define ESP_STA_GATEWAY_VALUE 108 //4 bytes xxx.xxx.xxx.xxx
46 #define ESP_BAUD_RATE 112 //4 bytes = int
47 #define ESP_NOTIFICATION_TYPE 116 //1 byte = flag
48 #define ESP_CALIBRATION 117 //1 byte = flag
49 #define ESP_AP_CHANNEL 118 //1 byte = flag
50 #define ESP_BUZZER 119 //1 byte = flag
51 #define ESP_INTERNET_TIME 120 //1 byte = flag
52 #define ESP_HTTP_PORT 121 //4 bytes = int
53 #define ESP_TELNET_PORT 125 //4 bytes = int
54 #define ESP_OUTPUT_FLAG 129 //1 bytes = flag
55 #define ESP_HOSTNAME 130 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese
56 #define ESP_DHT_INTERVAL 164 //4 bytes = int
57 #define ESP_SETTINGS_VERSION 168 //8 bytes = 7+1 = string ESP3D + 2 digits
58 #define ESP_ADMIN_PWD 176 //21 bytes 20+1 = string ; warning does not support multibyte char like chinese
59 #define ESP_USER_PWD 197 //21 bytes 20+1 = string ; warning does not support multibyte char like chinese
60 #define ESP_AP_SSID 218 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese
61 #define ESP_AP_PASSWORD 251 //65 bytes 64 +1 = string ;warning does not support multibyte char like chinese
62 #define ESP_AP_IP_VALUE 316 //4 bytes xxx.xxx.xxx.xxx
63 #define ESP_BOOT_DELAY 320 //4 bytes xxx.xxx.xxx.xxx
64 #define ESP_WEBSOCKET_PORT 324 //4 bytes xxx.xxx.xxx.xxx
65 #define ESP_HTTP_ON 328 //1 byte = flag
66 #define ESP_TELNET_ON 329 //1 byte = flag
67 #define ESP_WEBSOCKET_ON 330 //1 byte = flag
68 #define ESP_SD_SPEED_DIV 331 //1 byte = flag
69 #define ESP_NOTIFICATION_TOKEN1 332 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
70 #define ESP_NOTIFICATION_TOKEN2 396 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
71 #define ESP_DHT_TYPE 460 //1 bytes = flag
72 #define ESP_TARGET_FW 461 //1 bytes = flag
73 #define ESP_TIMEZONE 462 //1 bytes = flag
74 #define ESP_TIME_IS_DST 463 //1 bytes = flag
75 #define ESP_TIME_SERVER1 464 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
76 #define ESP_TIME_SERVER2 593 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
77 #define ESP_TIME_SERVER3 722 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
78 #define ESP_SD_DEVICE_TYPE 850 //1 bytes = flag
79 #define ESP_SD_MOUNT 851 //1 bytes = flag
80 #define ESP_FREE_BYTE 852 //1 bytes = flag
81 #define ESP_DIRECT_SD_CHECK 853 //1 bytes = flag
82 #define ESP_SD_CHECK_UPDATE_AT_BOOT 854//1 bytes = flag
83 #define ESP_NOTIFICATION_SETTINGS 855 //128 bytes 127+1 = string ; warning does not support multibyte char like chinese
84 #define ESP_CALIBRATION_1 983 //4 bytes = int
85 #define ESP_CALIBRATION_2 987 //4 bytes = int
86 #define ESP_CALIBRATION_3 991 //4 bytes = int
87 #define ESP_CALIBRATION_4 995 //4 bytes = int
88 #define ESP_CALIBRATION_5 999 //4 bytes = int
89 #define ESP_AUTO_NOTIFICATION 1004 //1 byte = flag
90 #define ESP_CAMERA_PORT 1005 //4 bytes = int
91 #define ESP_FTP_CTRL_PORT 1009 //4 bytes = int
92 #define ESP_FTP_DATA_ACTIVE_PORT 1013 //4 bytes = int
93 #define ESP_FTP_DATA_PASSIVE_PORT 1017 //4 bytes = int
94 #define ESP_FTP_ON 1021 //1 byte = flag
95 
96 //Hidden password
97 #define HIDDEN_PASSWORD "********"
98 
99 
100 #include <Arduino.h>
101 
103 {
104 public:
105  Settings_ESP3D();
106  ~Settings_ESP3D();
107  static bool begin();
108  static uint8_t get_default_byte_value(int pos);
109  static uint32_t get_default_int32_value(int pos);
110  static uint32_t get_default_IP_value(int pos);
111  static const String & get_default_string_value(int pos);
112  static uint8_t get_max_string_size(int pos);
113  static uint8_t get_min_string_size(int pos);
114  static uint32_t get_max_int32_value(int pos);
115  static uint32_t get_min_int32_value(int pos);
116  static uint8_t get_max_byte(int pos);
117  static uint8_t get_min_byte(int pos);
118  static uint8_t read_byte (int pos, bool * haserror = NULL);
119  static uint32_t read_uint32(int pos, bool * haserror = NULL);
120  static uint32_t read_IP(int pos, bool * haserror = NULL);
121  static String read_IP_String(int pos, bool * haserror = NULL);
122  static const char * read_string (int pos, bool *haserror = NULL);
123  static bool write_byte (int pos, const uint8_t value);
124  static bool write_string (int pos, const char * byte_buffer);
125  static bool write_uint32 (int pos, const uint32_t value);
126  static bool write_IP (int pos, const uint32_t value);
127  static bool write_IP_String (int pos, const char * value);
128  static bool reset();
129  static int8_t GetSettingsVersion();
130  static uint8_t GetFirmwareTarget(bool fromsettings = false);
131  static uint8_t GetSDDevice(bool fromsettings = false);
132  static const char* GetFirmwareTargetShortName();
133  static String IPtoString(uint32_t ip_int);
134  static uint32_t StringtoIP(const char *s);
135  static const char * TargetBoard();
136  static bool isLocalPasswordValid (const char * password);
137 private:
138  static bool is_string(const char * s, uint len);
139  static uint8_t _FirmwareTarget;
140  static bool _SDdevice;
141 };
142 
143 
144 #endif //_SETTINGS_ESP3D_H
145 
Settings_ESP3D::write_byte
static bool write_byte(int pos, const uint8_t value)
Definition: settings_esp3d.cpp:749
Settings_ESP3D::read_string
static const char * read_string(int pos, bool *haserror=NULL)
Definition: settings_esp3d.cpp:794
Settings_ESP3D::isLocalPasswordValid
static bool isLocalPasswordValid(const char *password)
Definition: settings_esp3d.cpp:1236
Settings_ESP3D::get_default_int32_value
static uint32_t get_default_int32_value(int pos)
Definition: settings_esp3d.cpp:342
Settings_ESP3D::get_max_int32_value
static uint32_t get_max_int32_value(int pos)
Definition: settings_esp3d.cpp:416
Settings_ESP3D::get_default_byte_value
static uint8_t get_default_byte_value(int pos)
Definition: settings_esp3d.cpp:225
Settings_ESP3D::GetSettingsVersion
static int8_t GetSettingsVersion()
Definition: settings_esp3d.cpp:1188
Settings_ESP3D::get_default_string_value
static const String & get_default_string_value(int pos)
Definition: settings_esp3d.cpp:554
Settings_ESP3D::Settings_ESP3D
Settings_ESP3D()
Definition: settings_esp3d.cpp:164
Settings_ESP3D::GetSDDevice
static uint8_t GetSDDevice(bool fromsettings=false)
Definition: settings_esp3d.cpp:191
Settings_ESP3D::write_uint32
static bool write_uint32(int pos, const uint32_t value)
Definition: settings_esp3d.cpp:970
Settings_ESP3D::GetFirmwareTarget
static uint8_t GetFirmwareTarget(bool fromsettings=false)
Definition: settings_esp3d.cpp:183
Settings_ESP3D::get_min_string_size
static uint8_t get_min_string_size(int pos)
Definition: settings_esp3d.cpp:668
Settings_ESP3D::begin
static bool begin()
Definition: settings_esp3d.cpp:171
Settings_ESP3D::GetFirmwareTargetShortName
static const char * GetFirmwareTargetShortName()
Definition: settings_esp3d.cpp:203
Settings_ESP3D::write_IP
static bool write_IP(int pos, const uint32_t value)
Definition: settings_esp3d.cpp:1008
Settings_ESP3D::~Settings_ESP3D
~Settings_ESP3D()
Definition: settings_esp3d.cpp:167
Settings_ESP3D::read_IP
static uint32_t read_IP(int pos, bool *haserror=NULL)
Definition: settings_esp3d.cpp:958
Settings_ESP3D::get_min_int32_value
static uint32_t get_min_int32_value(int pos)
Definition: settings_esp3d.cpp:462
Settings_ESP3D::write_string
static bool write_string(int pos, const char *byte_buffer)
Definition: settings_esp3d.cpp:870
Settings_ESP3D::get_max_byte
static uint8_t get_max_byte(int pos)
Definition: settings_esp3d.cpp:507
Settings_ESP3D::read_uint32
static uint32_t read_uint32(int pos, bool *haserror=NULL)
Definition: settings_esp3d.cpp:919
Settings_ESP3D::get_default_IP_value
static uint32_t get_default_IP_value(int pos)
Definition: settings_esp3d.cpp:548
Settings_ESP3D::reset
static bool reset()
Definition: settings_esp3d.cpp:1014
Settings_ESP3D::get_max_string_size
static uint8_t get_max_string_size(int pos)
Definition: settings_esp3d.cpp:617
Settings_ESP3D::TargetBoard
static const char * TargetBoard()
Definition: settings_esp3d.cpp:1226
Settings_ESP3D::read_byte
static uint8_t read_byte(int pos, bool *haserror=NULL)
Definition: settings_esp3d.cpp:715
Settings_ESP3D::write_IP_String
static bool write_IP_String(int pos, const char *value)
Definition: settings_esp3d.cpp:1202
Settings_ESP3D::get_min_byte
static uint8_t get_min_byte(int pos)
Definition: settings_esp3d.cpp:527
Settings_ESP3D::IPtoString
static String IPtoString(uint32_t ip_int)
Definition: settings_esp3d.cpp:1219
Settings_ESP3D
Definition: settings_esp3d.h:102
Settings_ESP3D::read_IP_String
static String read_IP_String(int pos, bool *haserror=NULL)
Definition: settings_esp3d.cpp:964
Settings_ESP3D::StringtoIP
static uint32_t StringtoIP(const char *s)
Definition: settings_esp3d.cpp:1208