mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-14 06:45:57 +08:00
Add backbone for Web interface and Data Interface
Web Server listen on port 80 Data Bridge listen on port 8888 may need to allow configuration of this port in settings - TBD
This commit is contained in:
parent
f53b968690
commit
5b9f3835b9
32
esp8266/datainterface.cpp
Normal file
32
esp8266/datainterface.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
datainterface.cpp - esp8266 configuration class
|
||||
|
||||
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "datainterface.h"
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
|
||||
DATAINTERFACE_CLASS::DATAINTERFACE_CLASS (int port):WebServer(port)
|
||||
{
|
||||
}
|
||||
|
||||
DATAINTERFACE_CLASS data_interface(8888);
|
||||
|
39
esp8266/datainterface.h
Normal file
39
esp8266/datainterface.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
datainterface.h - esp8266 configuration class
|
||||
|
||||
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef DATAINTERFACE_h
|
||||
#define DATAINTERFACE_h
|
||||
#include <Arduino.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
|
||||
class DATAINTERFACE_CLASS
|
||||
{
|
||||
public:
|
||||
DATAINTERFACE_CLASS (int port = 8888);
|
||||
ESP8266WebServer WebServer;
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
extern DATAINTERFACE_CLASS data_interface;
|
||||
|
||||
#endif
|
@ -14,12 +14,13 @@
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Repetier-Firmware. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
This firmware is using the arduino IDE modified to support ESP8266:
|
||||
This firmware is using the standard arduino IDE with module to support ESP8266:
|
||||
https://github.com/sandeepmistry/esp8266-Arduino based on :
|
||||
https://github.com/esp8266/Arduino
|
||||
|
||||
Latest version of the code and documentation can be found here :
|
||||
https://github.com/luc-github/ESP8266
|
||||
|
||||
|
||||
Main author: luc lebosse
|
||||
|
||||
*/
|
||||
@ -33,8 +34,14 @@
|
||||
//includes: why EEPROM.h need to be there ???
|
||||
#include <EEPROM.h>
|
||||
#include "config.h"
|
||||
#include "ESP8266WiFi.h"
|
||||
#include "wifi.h"
|
||||
#include "webinterface.h"
|
||||
#include "datainterface.h"
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
|
||||
|
||||
void setup() {
|
||||
// init :
|
||||
delay(8000);
|
||||
@ -69,12 +76,23 @@ void setup() {
|
||||
Serial.begin(baud_rate);
|
||||
//setup wifi according settings
|
||||
wifi_config.Setup();
|
||||
delay(1000);
|
||||
//define interfaces
|
||||
//TODO move this to class
|
||||
web_interface.WebServer.on("/", [](){web_interface.WebServer.send(200, "text/plain", "this works as well - port 80");});
|
||||
data_interface.WebServer.on("/", [](){data_interface.WebServer.send(200, "text/plain", "this works as well - port 8888");});
|
||||
//start interfaces
|
||||
web_interface.WebServer.begin();
|
||||
data_interface.WebServer.begin();
|
||||
CONFIG::print_config();
|
||||
}
|
||||
|
||||
|
||||
//main loop
|
||||
void loop() {
|
||||
|
||||
delay (1000);
|
||||
CONFIG::print_config();
|
||||
//web requests
|
||||
web_interface.WebServer.handleClient();
|
||||
//TODO use a method to handle serial also in class and call it instead of this one
|
||||
data_interface.WebServer.handleClient();
|
||||
|
||||
}
|
||||
|
32
esp8266/webinterface.cpp
Normal file
32
esp8266/webinterface.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
webinterface.cpp - esp8266 configuration class
|
||||
|
||||
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "webinterface.h"
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
|
||||
WEBINTERFACE_CLASS::WEBINTERFACE_CLASS (int port):WebServer(port)
|
||||
{
|
||||
}
|
||||
|
||||
WEBINTERFACE_CLASS web_interface(80);
|
||||
|
39
esp8266/webinterface.h
Normal file
39
esp8266/webinterface.h
Normal file
@ -0,0 +1,39 @@
|
||||
/*
|
||||
webinterface.h - esp8266 configuration class
|
||||
|
||||
Copyright (c) 2014 Luc Lebosse. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef WEBINTERFACE_h
|
||||
#define WEBINTERFACE_h
|
||||
#include <Arduino.h>
|
||||
#include <WiFiClient.h>
|
||||
#include <WiFiServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
|
||||
class WEBINTERFACE_CLASS
|
||||
{
|
||||
public:
|
||||
WEBINTERFACE_CLASS (int port = 82);
|
||||
ESP8266WebServer WebServer;
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
extern WEBINTERFACE_CLASS web_interface;
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user