forked from ardyesp/ESPWebDAV
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathESPWebDAV.ino
96 lines (84 loc) · 2.11 KB
/
ESPWebDAV.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
// Using the WebDAV server with Rigidbot 3D printer.
// Printer controller is a variation of Rambo running Marlin firmware
#include "serial.h"
#include "parser.h"
#include "config.h"
#include "network.h"
#include "gcode.h"
#include "sdControl.h"
// LED is connected to GPIO2 on this board
#define INIT_LED {pinMode(2, OUTPUT);}
#define LED_ON {digitalWrite(2, LOW);}
#define LED_OFF {digitalWrite(2, HIGH);}
// ------------------------
void setup() {
SERIAL_INIT(115200);
INIT_LED;
blink();
sdcontrol.setup();
// ----- WIFI -------
if(config.load() == 1) { // Connected before
if(!network.start()) {
SERIAL_ECHOLN("Connect fail, please check your INI file or set the wifi config and connect again");
SERIAL_ECHOLN("- M50: Set the wifi ssid , 'M50 ssid-name'");
SERIAL_ECHOLN("- M51: Set the wifi password , 'M51 password'");
SERIAL_ECHOLN("- M52: Start to connect the wifi");
SERIAL_ECHOLN("- M53: Check the connection status");
}
}
else {
SERIAL_ECHOLN("Welcome to FYSETC: www.fysetc.com");
SERIAL_ECHOLN("Please set the wifi config first");
SERIAL_ECHOLN("- M50: Set the wifi ssid , 'M50 ssid-name'");
SERIAL_ECHOLN("- M51: Set the wifi password , 'M51 password'");
SERIAL_ECHOLN("- M52: Start to connect the wifi");
SERIAL_ECHOLN("- M53: Check the connection status");
}
}
// ------------------------
void loop() {
// handle the request
network.handle();
// Handle gcode
gcode.Handle();
// blink
statusBlink();
}
// ------------------------
void blink() {
// ------------------------
LED_ON;
delay(100);
LED_OFF;
delay(400);
}
// ------------------------
void errorBlink() {
// ------------------------
for(int i = 0; i < 100; i++) {
LED_ON;
delay(50);
LED_OFF;
delay(50);
}
}
void statusBlink() {
static unsigned long time = 0;
if(millis() > time + 1000 ) {
if(network.isConnecting()) {
LED_OFF;
}
else if(network.isConnected()) {
LED_ON;
delay(50);
LED_OFF;
}
else {
LED_ON;
}
time = millis();
}
// SPI bus not ready
//if(millis() < spiBlockoutTime)
// blink();
}