Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with compilation #19

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
12 changes: 12 additions & 0 deletions ESPWebDAV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,18 @@ bool ESPWebDAV::init(int chipSelectPin, SPISettings spiSettings, int serverPort)
return sd.begin(chipSelectPin, spiSettings);
}

// ------------------------
bool ESPWebDAV::initSD(int chipSelectPin, SPISettings spiSettings) {
// initialize the SD card
return sd.begin(chipSelectPin, spiSettings);
}

// ------------------------
bool ESPWebDAV::startServer() {
// ------------------------
// start the wifi server
server->begin();
}

// ------------------------
void ESPWebDAV::handleNotFound() {
Expand Down Expand Up @@ -555,3 +566,4 @@ void ESPWebDAV::handleDelete(ResourceType resource) {
send("200 OK", NULL, "");
}

ESPWebDAV dav;
22 changes: 12 additions & 10 deletions ESPWebDAV.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#include <ESP8266WiFi.h>
#include <SdFat.h>

// debugging
// #define DBG_PRINT(...) { Serial.print(__VA_ARGS__); }
// #define DBG_PRINTLN(...) { Serial.println(__VA_ARGS__); }
// production
#define DBG_PRINT(...) { }
#define DBG_PRINTLN(...) { }
#define DEBUG

#ifdef DEBUG
#define DBG_PRINT(...) { Serial.print(__VA_ARGS__); }
#define DBG_PRINTLN(...) { Serial.println(__VA_ARGS__); }
#else
#define DBG_PRINT(...) {}
#define DBG_PRINTLN(...) {}
#endif

// constants for WebServer
#define CONTENT_LENGTH_UNKNOWN ((size_t) -1)
Expand All @@ -20,6 +23,8 @@ enum DepthType { DEPTH_NONE, DEPTH_CHILD, DEPTH_ALL };
class ESPWebDAV {
public:
bool init(int chipSelectPin, SPISettings spiSettings, int serverPort);
bool initSD(int chipSelectPin, SPISettings spiSettings);
bool startServer();
bool isClientWaiting();
void handleClient(String blank = "");
void rejectClient(String rejectMessage);
Expand Down Expand Up @@ -76,7 +81,4 @@ class ESPWebDAV {
int _contentLength;
};





extern ESPWebDAV dav;
96 changes: 96 additions & 0 deletions ESPWebDAV.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,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();
}
92 changes: 76 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# WebDAV Server and a 3D Printer

This project is a WiFi WebDAV server using ESP8266 SoC. It maintains the filesystem on an SD card.

Supports the basic WebDav operations - *PROPFIND*, *GET*, *PUT*, *DELETE*, *MKCOL*, *MOVE* etc.
Expand All @@ -11,38 +12,97 @@ I am using this setup as a networked drive for 3D Printer running Marlin. Follow

GCode can be directly uploaded from the slicer (Cura) to this remote drive, thereby simplifying the workflow.


![Printer Hookup Diagram](PrinterHookup2.jpg)

## Dependencies:

1. [ESP8266 Arduino Core version 2.4](https://github.com/esp8266/Arduino)
2. [SdFat library](https://github.com/greiman/SdFat)


## Use:
Compile and upload the program to an ESP8266 module. ESP12-E was used for development and testing.
Connect the SPI bus lines to SD card.

ESP Module|SD Card
---|---
GPIO13|MOSI
GPIO12|MISO
GPIO14|SCK
GPIO4|CS
GPIO5|CS Sense
### Compile and upload

#### Compile

If you don't want to update the firmware. You don't need to do this. Compile and upload the program to an ESP8266 module.

- Open the project

Download this project and open it with [arduino](https://www.arduino.cc/) software.

- Add board manager link

Add boards manager link: `https://arduino.esp8266.com/stable/package_esp8266com_index.json` to File->Preferences board manager, Documentation: https://arduino-esp8266.readthedocs.io/en/2.7.1/

- Select board

Select Tools->boards->Generic ESP8285 Module.

- Click the Arduino compile button

#### Upload

1. Pulg in the USB cable to your computer
2. Diag the switch on the module to `USB2UART`
3. Press and hold the module FLSH
4. Connect the USB cable to the module
5. Release the module FLSH button
6. Click the Arduino upload button

### Config

First you can see our video [here](https://www.youtube.com/watch?v=YAFAK-jPcOs). You have two ways to config the module.

*note: The card should be formatted for Fat16 or Fat32*

The card should be formatted for Fat16 or Fat32
#### Option 1: INI file

To access the drive from Windows, type ```\\esp_hostname_or_ip\DavWWWRoot``` at the Run prompt, or use Map Network Drive menu in Windows Explorer.
You can edit the example ```SETUP.INI``` file in ```ini``` folder, change the SSID and PASSWORD value. And then copy ```SETUP.INI``` file to your root SD card. Then insert it to the module.

1. Turn the module option button to ```USB2UART```
2. Open a COM software in your computer
3. Connect the module to your computer with USB cable
4. Open the software COM port

you can see the module IP and other information.

*note: if you miss the serial output, you can click the ```RST``` button in the module.*

#### Option 2 : Command

Insert your sdcard to the module.

1. Turn the module option button to ```USB2UART```
2. Open a COM software in your computer
3. Connect the module to your computer with USB cable
4. Open the software COM port

And use the following command to connect the network or check the network status

M50: Set the wifi ssid , 'M50 ssid-name'
M51: Set the wifi password , 'M51 password'
M52: Start to connect the wifi
M53: Check the connection status

### Access

#### windows

To access the drive from Windows, type ```\\ip\DavWWWRoot``` at the Run prompt, this will show in serial output as our [video](https://www.youtube.com/watch?v=YAFAK-jPcOs) shows.

Or use Map Network Drive menu in Windows Explorer.

#### MAC

Just need to use ```http://192.168.0.x``` in access network drive option

## References

Marlin Firmware - [http://marlinfw.org/](http://marlinfw.org/)

Cura Slicer - [https://ultimaker.com/en/products/ultimaker-cura-software](https://ultimaker.com/en/products/ultimaker-cura-software)

3D Printer LCD and SD Card Interface - [http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller](http://reprap.org/wiki/RepRapDiscount_Full_Graphic_Smart_Controller)

LCD Schematics - [http://reprap.org/mediawiki/images/7/79/LCD_connect_SCHDOC.pdf](http://reprap.org/mediawiki/images/7/79/LCD_connect_SCHDOC.pdf)



Loading