sync with devt branch
22
.travis.yml
@ -11,27 +11,15 @@ before_install:
|
||||
before_script:
|
||||
- "export DISPLAY=:99.0"
|
||||
- sleep 3 # give xvfb some time to start
|
||||
- wget http://downloads.arduino.cc/arduino-1.6.5-linux64.tar.xz
|
||||
- tar xf arduino-1.6.5-linux64.tar.xz
|
||||
- mv arduino-1.6.5 $HOME/arduino_ide
|
||||
- wget http://downloads.arduino.cc/arduino-1.6.8-linux64.tar.xz
|
||||
- tar xf arduino-1.6.8-linux64.tar.xz
|
||||
- mv arduino-1.6.8 $HOME/arduino_ide
|
||||
- cd $HOME/arduino_ide/hardware
|
||||
- mkdir esp8266com
|
||||
- cd esp8266com
|
||||
- wget https://github.com/esp8266/Arduino/releases/download/2.1.0/esp8266-2.1.0.zip
|
||||
- unzip esp8266-2.1.0.zip
|
||||
- mv esp8266-2.1.0 esp8266
|
||||
- wget http://arduino.esp8266.com/versions/2.1.0/package_esp8266com_index.json
|
||||
- mkdir esp8266/package
|
||||
- mv package_esp8266com_index.json esp8266/package/package_esp8266com_index.template.json
|
||||
- git clone https://github.com/esp8266/Arduino.git esp8266
|
||||
- cd esp8266/tools
|
||||
- python get.py
|
||||
- cd ..
|
||||
- head -11 ./platform.txt > pt.txt
|
||||
- echo 'runtime.tools.xtensa-lx106-elf-gcc.path={runtime.platform.path}/tools/xtensa-lx106-elf' >> pt.txt
|
||||
- echo 'runtime.tools.esptool.path={runtime.platform.path}/tools/esptool' >> pt.txt
|
||||
- tail -110 ./platform.txt >> pt.txt
|
||||
- rm -fr platform.txt
|
||||
- mv pt.txt platform.txt
|
||||
|
||||
|
||||
script:
|
||||
@ -41,7 +29,7 @@ script:
|
||||
- arduino --board esp8266com:esp8266:generic --save-prefs
|
||||
- arduino --get-pref sketchbook.path
|
||||
- build_sketch esp8266/esp8266.ino
|
||||
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: change
|
||||
|
218
README.md
@ -1,63 +1,45 @@
|
||||
# ESP8266
|
||||
Firmware for ESP8266 used with 3D printer using [arduino core version](https://github.com/esp8266/Arduino)
|
||||
This firmware allows not only to have a cheap bridge between Wifi and serial, but also to have a web UI to configure wifi, to monitor 3D printer and even control it, and to make things easy,
|
||||
UI is fully customizable without reflashing FW.
|
||||
Firmware should work with any 3D printer firmware (repetier/marlin/etc..) if serial connection has correct setup.
|
||||
I currently use it with my personnal flavor of [repetier for Due based boards](https://github.com/luc-github/Repetier-Firmware-0.92).
|
||||
Please use ESP with at least 1M flash, for ESP with 512K there is limited version [here](https://github.com/luc-github/ESP8266/tree/ESP-512K-64KSPIFFS)
|
||||
|
||||
[](https://gitter.im/luc-github/ESP8266?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
FW for ESP8266 used with 3D printer
|
||||
Development version:
|
||||
Arduino ide 1.6.5 with stable 2.1.0 from ESP8266 : [](https://travis-ci.org/luc-github/ESP8266)
|
||||
Stable version:
|
||||
Arduino ide 1.6.5 with stable 2.0.0 from ESP8266, please use https://github.com/luc-github/ESP8266/releases/tag/v0.5.1
|
||||
<u>Stable version:</u>
|
||||
Arduino ide 1.6.5 with stable [2.0.0](http://arduino.esp8266.com/versions/2.1.0/package_esp8266com_index.json) from ESP8266, please use https://github.com/luc-github/ESP8266/releases/tag/v0.5.1
|
||||
|
||||
Both version seems having instability if compiled/flashed under linux (https://github.com/luc-github/ESP8266/issues/64) - so consider to use windows to compile/flash until core is fixed.
|
||||
<u>Development version:</u>
|
||||
Arduino ide 1.6.8 with git from ESP8266 : [](https://travis-ci.org/luc-github/ESP8266)
|
||||
|
||||
##Description
|
||||
Thanks to @disneysw for bringing this module idea
|
||||
Thanks to @lkarlslund for suggestion about independant reset using GPIO2
|
||||
Thanks to all contributors (treepleks, j0hnlittle , and feedbacks owners)
|
||||
[All releases](https://github.com/luc-github/ESP8266/wiki)
|
||||
|
||||
Have a bridge configurable by web (implemented) and optionally by printer (not yet implemented)
|
||||
Have a front end to know what is the wifi status (implemented) or know what is the print status (not yet implemented) - this part can be optional and removed by compilation directive if no need
|
||||
:question:Any question ?[](https://gitter.im/luc-github/ESP8266?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
:exclamation:Any issue ? [submit ticket](https://github.com/luc-github/ESP8266/issues)
|
||||
|
||||
Should be compatible with reprap printer (Marlin FW/Repetier FW) as soon as you can make both serial to communicate.
|
||||
:warning: All versions seem having instability if compiled/flashed under linux (https://github.com/luc-github/ESP8266/issues/64), so consider to use windows to compile/flash until core is fixed.
|
||||
|
||||
Current release listed here: https://github.com/luc-github/ESP8266/wiki
|
||||
:+1:Thanks
|
||||
* to @disneysw for bringing this module idea
|
||||
* to @lkarlslund for suggestion about independant reset using GPIO2
|
||||
* to all contributors (treepleks, j0hnlittle, all feedbacks owners and donations)
|
||||
|
||||
Master is using 2.1.0 of https://github.com/esp8266/arduino
|
||||
use http://arduino.esp8266.com/versions/2.1.0/package_esp8266com_index.json in arduino 1.6.5 IDE preferences
|
||||
Every support is welcome: [<img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG_global.gif" border="0" alt="PayPal – The safer, easier way to pay online.">](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y8FFE7NA4LJWQ)
|
||||
Especially if need to buy new modules for testing.
|
||||
|
||||
If you use an ESP with 512K flash like ESP01 please go here : https://github.com/luc-github/ESP8266/tree/ESP-512K-64KSPIFFS, it is dedicated to low memory device.
|
||||
If you use an ESP with more than 512K flash please use master.
|
||||
|
||||
##Hardware connection
|
||||
--Use GPIO2 to ground to reset all settings in hard way - 2-6 sec after boot / not before!! Set GPIO2 to ground before boot change boot mode and go to special boot that do not reach FW. Currently boot take 10 sec - giving 8 seconds to connect GPIO2 to GND and do an hard recovery for settings
|
||||
--Use GPIO0 to ground to be in update mode
|
||||
--Use a switch to reset/disable module
|
||||
For ESP01:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Wires.png><br>
|
||||
|
||||
For ESP12E:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/WiresESP12E.png><br>
|
||||
<br>
|
||||
For Davinci Board:<BR>
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/davinci.png><br>
|
||||
|
||||
##Development
|
||||
Currently using [Arduino IDE 1.6.5](http://arduino.cc/en/Main/Software) with the esp8266 module from board manager added from [github.com/esp8266/Arduino](https://github.com/esp8266/Arduino)
|
||||
please use 2.1.0 relased version (http://arduino.esp8266.com/versions/2.1.0/package_esp8266com_index.json)
|
||||
staging version (http://arduino.esp8266.com/staging/package_esp8266com_index.json) is not yet stable neither compatible with current master please check dev branch https://github.com/luc-github/ESP8266/tree/devt
|
||||
|
||||
Additionnaly:
|
||||
--Use minimal css from http://getbootstrap.com/examples/theme/
|
||||
|
||||
##Flash the Module
|
||||
*Tools:
|
||||
--Use IDE to upload directly (latest version of board manager module generate one binary)
|
||||
-- to flash the htm files present in data directory you need to use another tool, installation and usage is explained here: https://github.com/esp8266/Arduino/blob/master/doc/filesystem.md
|
||||
Once flashed you also can use the web updater to flash new FW in System Configuration Page
|
||||
|
||||
*Connection
|
||||
--Connect GPIO0 to ground to be in update mode
|
||||
|
||||
<H3>Do not flash Printer fw with ESP connected - it bring troubles, at least on DaVinci </H3>
|
||||
##Features
|
||||
* Serial/Wifi bridge using configurable port 8888, here to enable/disable [TCP_IP_DATA_FEATURE](https://github.com/luc-github/ESP8266/blob/master/esp8266/config.h)
|
||||
* Use GPIO2 to ground to reset all settings in hard way - 2-6 sec after boot / not before!! Set GPIO2 to ground before boot change boot mode and go to special boot that do not reach FW. Currently boot take 10 sec - giving 8 seconds to connect GPIO2 to GND and do an hard recovery for settings, here to enable/disable [RECOVERY_FEATURE](https://github.com/luc-github/ESP8266/blob/master/esp8266/config.h)
|
||||
* Wifi configuration by web browser (Station or Access point)
|
||||
* Authentication for sensitive pages, here to enable/disable [AUTHENTICATION_FEATURE](https://github.com/luc-github/ESP8266/blob/master/esp8266/config.h)
|
||||
* Update firmware by web browser, here to enable/disable [WEB_UPDATE_FEATURE](https://github.com/luc-github/ESP8266/blob/master/esp8266/config.h)
|
||||
* Control ESP module using commands on serial or data port, here to enable/disable [SERIAL_COMMAND_FEATURE](https://github.com/luc-github/ESP8266/blob/master/esp8266/config.h)
|
||||
* UI fully constomizable without reflashing FW using html templates, [keywords](https://raw.githubusercontent.com/luc-github/ESP8266/master/docs/keywords.txt) and html files/images
|
||||
* Captive portal in Access point mode which redirect all unknow call to main page, here to enable/disable [CAPTIVE_PORTAL_FEATURE](https://github.com/luc-github/ESP8266/blob/master/esp8266/config.h)
|
||||
* mDNS which allows to key the name defined in web browser and connect only with bonjour installed on computer, here to enable/disable [MDNS_FEATURE](https://github.com/luc-github/ESP8266/blob/master/esp8266/config.h)
|
||||
* SSDP, this feature is a discovery protocol, supported on Windows out of the box, here to enable/disable [SSDP_FEATURE](https://github.com/luc-github/ESP8266/blob/master/esp8266/config.h)
|
||||
* Printer monitoring / control (temperatures/speed/jog/list SDCard content/launch,pause or stop a print/etc...), here to enable/disable [MONITORING_FEATURE/INFO_MSG_FEATURE/ERROR_MSG_FEATURE/STATUS_MSG_FEATURE](https://github.com/luc-github/ESP8266/blob/master/esp8266/config.h)
|
||||
* Fail safe mode (Access point)is enabled if cannot connect to defined station at boot.
|
||||
|
||||
##Web configuration
|
||||
*Wifi Mode : Access point / Client station
|
||||
@ -89,62 +71,34 @@ Password: admin
|
||||
|
||||
These are the pages defined using template:
|
||||
Home page :
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Page1.png><br>
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/UI/Page1.png><br>
|
||||
System Configuration Page:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Page2.png><br>
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/UI/Page2.png><br>
|
||||
Access Point Configuration Page:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Page3.png><br>
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/UI/Page3.png><br>
|
||||
Client Configuration Page:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Page4.png><br>
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/UI/Page4.png><br>
|
||||
Printer Status Page for 64K SPIFFS, due to limited space available no fancy:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Page5-2.png><br>
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/UI/Page5-2.png><br>
|
||||
Printer Status Page for more than 64K SPIFFS, fancy one:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/page5.png><br>
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/UI/page5.png><br>
|
||||
Extra Settings Page, for web UI and for printer:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Page6.png><br>
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/UI/Page6.png><br>
|
||||
Change password Page:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Page7.png><br>
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/UI/Page7.png><br>
|
||||
Login Page:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Page8.png><br>
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/UI/Page8.png><br>
|
||||
the template files are stored on SPIFFS:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/files.png><br>
|
||||
and uploaded using [IDE](http://arduino.esp8266.com/versions/1.6.5-1160-gef26c5f/doc/reference.html#file-system)
|
||||
The list of keywords can be find here : https://github.com/luc-github/ESP8266/blob/master/keywords.txt
|
||||
Any files on SPIFFS can be called on web interface without having the path hard coded - this give more flexibility, favicon.ico is a good example of it.
|
||||
So UI is kind of separated from FW which allow easier modifications. For this a light file manager is available in extra settings page, it allows to upload/download/delete files. as SPIFFS is flat filesystem no directory management is necessary so it is very simple.
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/UI/files.png><br>
|
||||
and uploaded using [pluggin IDE](http://esp8266.github.io/Arduino/versions/2.1.0/doc/filesystem.html#uploading-files-to-file-system)
|
||||
Any files on SPIFFS can be called on web interface without having the path hard coded, this give more flexibility, favicon.ico is a good example of it.
|
||||
So UI is kind of separated from FW which allow easier modifications. For this a light file manager is available in extra settings page, it allows to upload/download/delete files.
|
||||
Because SPIFFS is flat filesystem, no directory management is necessary, so it is very simple.
|
||||
|
||||
Additionally 404.tpl (the page not found) and restart.tpl(restart page when applying changes) are not mandatory, a fail safe version is embeded if they are not present.
|
||||
|
||||
Currently, I tested on ESP01 using 64K SPIFFS ( please use data directory content accordingly due to space limitation) and NodeMCU 1.0 1M SPIFFS.
|
||||
##Modifying and Testing tpl files
|
||||
To help to visualize tpl modifications a local tool has been created by [j0hnlittle](https://github.com/j0hnlittle) to avoid to upload everytime your tpl files just to see the results of your modifications
|
||||
It is a python script (2.7+) located in tools directory, launch it: python server.py, then open browser: http://localhost:8080
|
||||
It will display the web ui and allow some navigation
|
||||
##Direct commands:
|
||||
|
||||
##Protocol for discovery
|
||||
*mDNS : on Station mode only with bonjour installed on computer (done)
|
||||
*SSDP : on Station and AP mode (done)
|
||||
*Captive portal : on AP mode only (done)
|
||||
|
||||
##Basic Authentification
|
||||
Can be disabled in FW
|
||||
default user: admin
|
||||
default password: admin
|
||||
|
||||
#OTA support
|
||||
Currently only web update is supported not telnet one
|
||||
|
||||
##Commands/msg from/to serial(not fully implemented):
|
||||
*from module to printer by serial communication
|
||||
-M117 [Message], Error/status message from module (done)
|
||||
-Send Wifi settings [AP/STATION,SSID,DHC/STATIC,IP,MASK,GW,STATUS,MAC ADDRESSS, BAUD?], ]Module configuration without password
|
||||
|
||||
*from host to printer on port 8888 (implemented)
|
||||
- bridge from TCP/IP to Serial and vice-versa (done)
|
||||
|
||||
*from printer/host to module (not fully implemented)
|
||||
-request configuration/status
|
||||
-set AP/STATION,SSID,PASSSWORD,DHC/STATIC,IP,MASK,GW,BAUD from serial
|
||||
-restart module from host/printer: [ESP888]RESTART
|
||||
-Get IP (only printer see answer): [ESP111]M117
|
||||
-reset EEPROM and restart: [ESP444]RESET
|
||||
@ -157,44 +111,50 @@ Currently only web update is supported not telnet one
|
||||
-IP Static: [ESP104]STATIC
|
||||
-IP DHCP: [ESP104]DHCP
|
||||
|
||||
##Installation
|
||||
* For stable:
|
||||
Please use [Arduino IDE 1.6.5](http://arduino.cc/en/Main/Software) with the esp8266 module from board manager use 2.0.0 stable version (not 2.1.0 it has bugs) by adding in your preferences http://arduino.esp8266.com/stable/package_esp8266com_index.json
|
||||
|
||||
* For development:
|
||||
Please use [Arduino IDE 1.6.8](http://arduino.cc/en/Main/Software) and [git version of esp8266 module](http://esp8266.github.io/Arduino/versions/2.1.0/doc/installing.html#using-git-version)
|
||||
|
||||
* To flash the module :
|
||||
Use IDE to upload directly (latest version of board manager module generate one binary)
|
||||
* To flash the html files present in data directory you need to use another tool, installation and usage is explained [here](https://github.com/esp8266/Arduino/blob/master/doc/filesystem.md#uploading-files-to-file-system)
|
||||
Once flashed you also can use the web updater to flash new FW in System Configuration Page or go to settings to change html files
|
||||
|
||||
<H3>:warning:Do not flash Printer fw with ESP connected - it bring troubles, at least on DaVinci</H3>
|
||||
|
||||
##Contribution/customization
|
||||
To modifying and Testing tpl files a local tool has been created by [j0hnlittle](https://github.com/j0hnlittle) to avoid to upload everytime your tpl files just to see the results of your modifications. It is a python script (2.7+) located in tools directory, launch it: python server.py, then open browser: http://localhost:8080
|
||||
It will display the web ui and allow some navigation
|
||||
|
||||
To style the code before pushing PR please use [astyle --style=otbs *.h *.cpp *.ino](http://astyle.sourceforge.net/)
|
||||
|
||||
Feedback/suggestion/discussions are always welcome
|
||||
|
||||
##Front End (implemented)
|
||||
--Display printer status (done)
|
||||
--Display temperatures (done)
|
||||
--Display positions/flow/speed (done)
|
||||
--Display print progress if any (done)
|
||||
--List SDCard Content (done)
|
||||
--Launch a Print (done)
|
||||
--Stop/Pause a Print (done)
|
||||
--Emergency Stop (done)
|
||||
--Jog control / custom commands (done)
|
||||
|
||||
##Result of ESP12E on Davinci
|
||||
I use a proto board to connect ESP12E socket, one micro switch for recovery, one jumper for normal usage/ flash, I did not put hardware switch.
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/Davinci/board.jpg><br>
|
||||
Connected to Davinci:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/Davinci/boardconnected.jpg><br>
|
||||
The back cover:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/Davinci/backside.jpg><br>
|
||||
The screen when connected to AP:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/Davinci/screen.jpg><br>
|
||||
The settings:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/Davinci/Capture.PNG><br>
|
||||
|
||||
##Result of ESP12E on Due/RADDS
|
||||
the rendering on screen when connection to AP is done:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/RADDS/screen.jpg><br>
|
||||
The settings:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/images/RADDS/Capture.PNG><br>
|
||||
|
||||
|
||||
##TODO
|
||||
-- Close open topics
|
||||
-- Do testing (a lot)
|
||||
-- UI Improvement
|
||||
--<s>Printer EEPROM management</s> (Canceled/Postponed for next stage)
|
||||
|
||||
##Result of ESP12E on Davinci
|
||||
I use a proto board to connect ESP12E socket, one micro switch for recovery, one jumper for normal usage/ flash, I did not put hardware switch.
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Davinci/board.jpg><br>
|
||||
Connected to Davinci:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Davinci/boardconnected.jpg><br>
|
||||
The back cover:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Davinci/backside.jpg><br>
|
||||
The screen when connected to AP:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Davinci/screen.jpg><br>
|
||||
The settings:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/Davinci/Capture.PNG><br>
|
||||
|
||||
##Result of ESP12E on Due/RADDS
|
||||
Use Serial1 for communications
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/RADDS/RADDS.png><br>
|
||||
the rendering on screen when connection to AP is done:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/RADDS/screen.jpg><br>
|
||||
The settings:
|
||||
<img src=https://raw.githubusercontent.com/luc-github/ESP8266/master/RADDS/Capture.PNG><br>
|
||||
|
||||
##Donation:
|
||||
Every support is welcome: [<img src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG_global.gif" border="0" alt="PayPal – The safer, easier way to pay online.">](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y8FFE7NA4LJWQ)
|
||||
Especially if need to buy new modules for testing.
|
||||
-- Printer EEPROM management
|
||||
|
5
TODO.txt
Normal file
@ -0,0 +1,5 @@
|
||||
TODO
|
||||
MONITORING_FEATURE : temperatures
|
||||
INFO_MSG_FEATURE
|
||||
ERROR_MSG_FEATURE
|
||||
STATUS_MSG_FEATURE
|
@ -236,6 +236,7 @@ void CONFIG::print_config()
|
||||
{
|
||||
//use biggest size for buffer
|
||||
char sbuf[MAX_PASSWORD_LENGTH+1];
|
||||
uint8_t ipbuf[4];
|
||||
byte bbuf=0;
|
||||
int ibuf=0;
|
||||
if (CONFIG::read_byte(EP_WIFI_MODE, &bbuf )) {
|
||||
@ -257,7 +258,6 @@ void CONFIG::print_config()
|
||||
} else {
|
||||
Serial.println(F("Error reading SSID"));
|
||||
}
|
||||
//if (CONFIG::read_string(EP_PASSWORD, sbuf , MAX_PASSWORD_LENGTH))Serial.println(sbuf);
|
||||
|
||||
if (CONFIG::read_byte(EP_IP_MODE, &bbuf )) {
|
||||
Serial.print(F("IP Mode: "));
|
||||
@ -272,23 +272,23 @@ void CONFIG::print_config()
|
||||
Serial.println(F("Error reading IP mode"));
|
||||
}
|
||||
|
||||
if (CONFIG::read_buffer(EP_IP_VALUE,(byte *)sbuf , IP_LENGTH)) {
|
||||
if (CONFIG::read_buffer(EP_IP_VALUE,(byte *)ipbuf , IP_LENGTH)) {
|
||||
Serial.print(F("IP: "));
|
||||
Serial.println(wifi_config.ip2str((byte *)sbuf));
|
||||
Serial.println(IPAddress(ipbuf).toString());
|
||||
} else {
|
||||
Serial.println(F("Error reading IP"));
|
||||
}
|
||||
|
||||
if (CONFIG::read_buffer(EP_MASK_VALUE, (byte *)sbuf , IP_LENGTH)) {
|
||||
if (CONFIG::read_buffer(EP_MASK_VALUE, (byte *)ipbuf , IP_LENGTH)) {
|
||||
Serial.print(F("Subnet: "));
|
||||
Serial.println(wifi_config.ip2str((byte *)sbuf));
|
||||
Serial.println(IPAddress(ipbuf).toString());
|
||||
} else {
|
||||
Serial.println(F("Error reading subnet"));
|
||||
}
|
||||
|
||||
if (CONFIG::read_buffer(EP_GATEWAY_VALUE, (byte *)sbuf , IP_LENGTH)) {
|
||||
if (CONFIG::read_buffer(EP_GATEWAY_VALUE, (byte *)ipbuf , IP_LENGTH)) {
|
||||
Serial.print(F("Gateway: "));
|
||||
Serial.println(wifi_config.ip2str((byte *)sbuf));
|
||||
Serial.println(IPAddress(ipbuf).toString());
|
||||
} else {
|
||||
Serial.println(F("Error reading gateway"));
|
||||
}
|
||||
@ -443,5 +443,17 @@ void CONFIG::print_config()
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
Serial.print(F("Pin 2 Recovery: "));
|
||||
#ifdef RECOVERY_FEATURE
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
Serial.print(F("Authentication: "));
|
||||
#ifdef AUTHENTICATION_FEATURE
|
||||
Serial.println(F("Enabled"));
|
||||
#else
|
||||
Serial.println(F("Disabled"));
|
||||
#endif
|
||||
}
|
||||
|
@ -21,7 +21,7 @@
|
||||
//comment to disable
|
||||
//MDNS_FEATURE: this feature allow type the name defined
|
||||
//in web browser by default: http:\\esp8266.local and connect
|
||||
#define MDNS_FEATURE
|
||||
//#define MDNS_FEATURE
|
||||
|
||||
//SSDD_FEATURE: this feature is a discovery protocol, supported on Windows out of the box
|
||||
#define SSDP_FEATURE
|
||||
@ -41,16 +41,16 @@
|
||||
//TCP_IP_DATA_FEATURE: allow to connect serial from TCP/IP
|
||||
#define TCP_IP_DATA_FEATURE
|
||||
|
||||
//RECOVERY_FEATURE: allow to use GPIO2 pin as hardware reset for EEPROM, add 8s to boot time to let user to jump GPIO2 to GND
|
||||
#define RECOVERY_FEATURE
|
||||
|
||||
#ifndef CONFIG_h
|
||||
#define CONFIG_h
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "wifi.h"
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
//version and sources location
|
||||
#define FW_VERSION "0.6.0"
|
||||
#define FW_VERSION "0.6.1"
|
||||
#define REPOSITORY "https://github.com/luc-github/ESP8266"
|
||||
|
||||
|
||||
@ -99,8 +99,8 @@ const byte DEFAULT_MASK_VALUE[] = {255, 255, 255, 0};
|
||||
#define DEFAULT_GATEWAY_VALUE DEFAULT_IP_VALUE
|
||||
const long DEFAULT_BAUD_RATE = 9600;
|
||||
const char M117_[] PROGMEM = "M117 ";
|
||||
#define DEFAULT_PHY_MODE PHY_MODE_11G
|
||||
#define DEFAULT_SLEEP_MODE MODEM_SLEEP_T
|
||||
#define DEFAULT_PHY_MODE WIFI_PHY_MODE_11G
|
||||
#define DEFAULT_SLEEP_MODE WIFI_MODEM_SLEEP
|
||||
#define DEFAULT_CHANNEL 11
|
||||
#define DEFAULT_AUTH_TYPE AUTH_WPA_PSK
|
||||
#define DEFAULT_SSID_VISIBLE 1
|
||||
|
@ -7,7 +7,7 @@
|
||||
<BR><BR>
|
||||
if not redirected, <a href='http://$WEB_ADDRESS$'>click here</a>
|
||||
<BR><BR>
|
||||
<PROGRESS name='prg' id='prg'>
|
||||
<PROGRESS name='prg' id='prg'></PROGRESS>
|
||||
|
||||
<script>
|
||||
var i = 0;
|
||||
|
@ -10,7 +10,7 @@ $INCLUDE[css.inc]$
|
||||
<body>
|
||||
<div class="container"><table class="nav">
|
||||
<tr width=100%>
|
||||
<td class="$MENU_HOME$"><a href="http://$WEB_ADDRESS$">Home</a></td>
|
||||
<td class="$MENU_HOME$"><a href="http://$WEB_ADDRESS$/HOME">Home</a></td>
|
||||
<td class="$MENU_SYSTEM$"><a href="http://$WEB_ADDRESS$/CONFIGSYS">System</a></td>
|
||||
<td class="$MENU_AP$"><a href="http://$WEB_ADDRESS$/CONFIGAP">Access Point</a></td>
|
||||
<td class="$MENU_STA$"><a href="http://$WEB_ADDRESS$/CONFIGSTA">Station</a></td>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<BODY>
|
||||
<CENTER>Restarting, please wait....
|
||||
<BR>
|
||||
<PROGRESS name='prg' id='prg'>
|
||||
<PROGRESS name='prg' id='prg'></PROGRESS>
|
||||
</CENTER>
|
||||
<script>
|
||||
var i = 0;
|
||||
|
@ -26,7 +26,7 @@ $SLEEP_MODE_OPTIONS_LIST$
|
||||
</select></div>
|
||||
<div class="form-group $WEB_PORT_STATUS$"><label class="control-label" for="CONFIG3">Web port:</label><br>
|
||||
<input type="number" class="form-control" id="CONFIG3" name="WEBPORT" min="1" max="65000" step="1" placeholder="1~65000" value="$WEB_PORT$" style="width: auto;"></div>
|
||||
<div class="form-group $DATA_PORT_STATUS$" style="$DATA_PORT_VISIBILITY$"><label class="control-label" for="CONFIG4">Data port:</label><br>
|
||||
<div id='dataport' class="form-group $DATA_PORT_STATUS$" style="$DATA_PORT_VISIBILITY$"><label class="control-label" for="CONFIG4">Data port:</label><br>
|
||||
<input type="number" class="form-control" id="CONFIG4" name="DATAPORT" min="1" max="65000" step="1" placeholder="1~65000" value="$DATA_PORT$" style="width: auto;"></div>
|
||||
<div class="alert alert-danger" role="alert" style="$ERROR_MSG_VISIBILITY$" >
|
||||
$ERROR_MSG$
|
||||
@ -69,6 +69,8 @@ document.getElementById('upload-button').style.visibility = 'hidden';
|
||||
document.getElementById('upload-button').style.width = '0px';
|
||||
document.getElementById('system').style.visibility = 'hidden';
|
||||
document.getElementById('system').style.height = '0px';
|
||||
document.getElementById('dataport').style.visibility = 'hidden';
|
||||
document.getElementById('dataport').style.height = '0px';
|
||||
document.getElementById('msg').style.visibility = "visible";
|
||||
document.getElementById('file-select').value="";
|
||||
document.getElementById('file-select').style.visibility = 'hidden';
|
||||
|
4
esp8266/data/tags.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"WEB_ADDRESS":"localhost",
|
||||
"PAGE_TITLE":"Testing things..."
|
||||
}
|
@ -27,7 +27,6 @@
|
||||
#ifndef ARDUINO_ARCH_ESP8266
|
||||
#error Oops! Make sure you have 'ESP8266' compatible board selected from the 'Tools -> Boards' menu.
|
||||
#endif
|
||||
#include <SPI.h>
|
||||
#include <EEPROM.h>
|
||||
#include "config.h"
|
||||
#include "wifi.h"
|
||||
@ -47,9 +46,6 @@ DNSServer dnsServer;
|
||||
#ifdef SSDP_FEATURE
|
||||
#include <ESP8266SSDP.h>
|
||||
#endif
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#include <FS.h>
|
||||
#define MAX_SRV_CLIENTS 1
|
||||
WiFiServer * data_server;
|
||||
@ -61,14 +57,16 @@ void setup()
|
||||
web_interface = NULL;
|
||||
data_server = NULL;
|
||||
WiFi.disconnect();
|
||||
system_update_cpu_freq(SYS_CPU_160MHZ);
|
||||
delay(8000);
|
||||
WiFi.mode(WIFI_OFF);
|
||||
bool breset_config=false;
|
||||
#ifdef RECOVERY_FEATURE
|
||||
delay(8000);
|
||||
//check if reset config is requested
|
||||
pinMode(RESET_CONFIG_PIN, INPUT);
|
||||
if (digitalRead(RESET_CONFIG_PIN)==0) {
|
||||
breset_config=true; //if requested =>reset settings
|
||||
}
|
||||
#endif
|
||||
//default baud rate
|
||||
long baud_rate=0;
|
||||
|
||||
@ -97,7 +95,7 @@ void setup()
|
||||
delay(1000);
|
||||
//put some default value to a void some exception at first start
|
||||
WiFi.mode(WIFI_AP);
|
||||
wifi_set_phy_mode(PHY_MODE_11G);
|
||||
WiFi.setPhyMode(WIFI_PHY_MODE_11G);
|
||||
Serial.flush();
|
||||
delay(500);
|
||||
Serial.swap();
|
||||
@ -124,6 +122,13 @@ void setup()
|
||||
size_t headerkeyssize = sizeof(headerkeys)/sizeof(char*);
|
||||
//ask server to track these headers
|
||||
web_interface->WebServer.collectHeaders(headerkeys, headerkeyssize );
|
||||
#ifdef CAPTIVE_PORTAL_FEATURE
|
||||
if (WiFi.getMode()!=WIFI_STA ) {
|
||||
// if DNSServer is started with "*" for domain name, it will reply with
|
||||
// provided IP to all DNS request
|
||||
dnsServer.start(DNS_PORT, "*", WiFi.softAPIP());
|
||||
}
|
||||
#endif
|
||||
web_interface->WebServer.begin();
|
||||
#ifdef TCP_IP_DATA_FEATURE
|
||||
//start TCP/IP interface
|
||||
@ -137,15 +142,6 @@ void setup()
|
||||
wifi_config.mdns.addService("http", "tcp", wifi_config.iweb_port);
|
||||
#endif
|
||||
|
||||
#ifdef CAPTIVE_PORTAL_FEATURE
|
||||
if (wifi_get_opmode()!=WIFI_STA ) {
|
||||
// if DNSServer is started with "*" for domain name, it will reply with
|
||||
// provided IP to all DNS request
|
||||
dnsServer.setErrorReplyCode(DNSReplyCode::NoError);
|
||||
dnsServer.start(DNS_PORT, "*", WiFi.softAPIP());
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SSDP_FEATURE
|
||||
String stmp;
|
||||
SSDP.setSchemaURL("description.xml");
|
||||
@ -154,7 +150,7 @@ void setup()
|
||||
stmp=wifi_config.get_default_hostname();
|
||||
}
|
||||
SSDP.setName(stmp.c_str());
|
||||
stmp=String(system_get_chip_id());
|
||||
stmp=String(ESP.getChipId());
|
||||
SSDP.setSerialNumber(stmp.c_str());
|
||||
SSDP.setURL("/");
|
||||
SSDP.setModelName("ESP8266 01");
|
||||
@ -172,12 +168,13 @@ void setup()
|
||||
void loop()
|
||||
{
|
||||
#ifdef CAPTIVE_PORTAL_FEATURE
|
||||
if (wifi_get_opmode()!=WIFI_STA ) {
|
||||
if (WiFi.getMode()!=WIFI_STA ) {
|
||||
dnsServer.processNextRequest();
|
||||
}
|
||||
#endif
|
||||
//web requests
|
||||
web_interface->WebServer.handleClient();
|
||||
|
||||
//TODO use a method to handle serial also in class and call it instead of this one
|
||||
uint8_t i,data;
|
||||
#ifdef TCP_IP_DATA_FEATURE
|
||||
|
@ -46,8 +46,8 @@ extern "C" {
|
||||
#define UPLOAD_STATUS_SUCCESSFUL 3
|
||||
#define UPLOAD_STATUS_ONGOING 4
|
||||
|
||||
const char PAGE_404 [] PROGMEM ="<HTML>\n<HEAD>\n<title>Redirecting...</title> \n</HEAD>\n<BODY>\n<CENTER>Unknown page - you will be redirected...\n<BR><BR>\nif not redirected, <a href='http://$WEB_ADDRESS$'>click here</a>\n<BR><BR>\n<PROGRESS name='prg' id='prg'>\n\n<script>\nvar i = 0; \nvar x = document.getElementById(\"prg\"); \nx.max=5; \nvar interval=setInterval(function(){\ni=i+1; \nvar x = document.getElementById(\"prg\"); \nx.value=i; \nif (i>5) \n{\nclearInterval(interval);\nwindow.location.href='/';\n}\n},1000);\n</script>\n</CENTER>\n</BODY>\n</HTML>\n\n";
|
||||
const char PAGE_RESTART [] PROGMEM ="<HTML>\n<HEAD>\n<title>Restarting...</title> \n</HEAD>\n<BODY>\n<CENTER>Restarting, please wait....\n<BR>\n<PROGRESS name='prg' id='prg'>\n</CENTER>\n<script>\nvar i = 0;\nvar interval; \nvar x = document.getElementById(\"prg\"); \nx.max=40; \ninterval = setInterval(function(){\ni=i+1; \nvar x = document.getElementById(\"prg\"); \nx.value=i; \nif (i>40) \n{\nclearInterval(interval);\nwindow.location.href='/';\n}\n},1000);\n</script>\n</BODY>\n</HTML>\n";
|
||||
const char PAGE_404 [] PROGMEM ="<HTML>\n<HEAD>\n<title>Redirecting...</title> \n</HEAD>\n<BODY>\n<CENTER>Unknown page - you will be redirected...\n<BR><BR>\nif not redirected, <a href='http://$WEB_ADDRESS$'>click here</a>\n<BR><BR>\n<PROGRESS name='prg' id='prg'></PROGRESS>\n\n<script>\nvar i = 0; \nvar x = document.getElementById(\"prg\"); \nx.max=5; \nvar interval=setInterval(function(){\ni=i+1; \nvar x = document.getElementById(\"prg\"); \nx.value=i; \nif (i>5) \n{\nclearInterval(interval);\nwindow.location.href='/';\n}\n},1000);\n</script>\n</CENTER>\n</BODY>\n</HTML>\n\n";
|
||||
const char PAGE_RESTART [] PROGMEM ="<HTML>\n<HEAD>\n<title>Restarting...</title> \n</HEAD>\n<BODY>\n<CENTER>Restarting, please wait....\n<BR>\n<PROGRESS name='prg' id='prg'></PROGRESS>\n</CENTER>\n<script>\nvar i = 0;\nvar interval; \nvar x = document.getElementById(\"prg\"); \nx.max=40; \ninterval = setInterval(function(){\ni=i+1; \nvar x = document.getElementById(\"prg\"); \nx.value=i; \nif (i>40) \n{\nclearInterval(interval);\nwindow.location.href='/';\n}\n},1000);\n</script>\n</BODY>\n</HTML>\n";
|
||||
const char RESTARTCMD [] PROGMEM ="<script>setTimeout(function(){window.location.href='/RESTART'},3000);</script>";
|
||||
const char VALUE_11B[] PROGMEM = "11b";
|
||||
const char VALUE_11N[] PROGMEM = "11n";
|
||||
@ -339,9 +339,10 @@ char * intTostr(int value)
|
||||
bool processTemplate(const char * filename, STORESTRINGS_CLASS & KeysList , STORESTRINGS_CLASS & ValuesList )
|
||||
{
|
||||
if(KeysList.size() != ValuesList.size()) { //Sanity check
|
||||
Serial.print("Error");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
LinkedList<File> myFileList = LinkedList<File>();
|
||||
String buffer2send;
|
||||
String bufferheader(F("HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: "));
|
||||
@ -480,6 +481,7 @@ bool processTemplate(const char * filename, STORESTRINGS_CLASS & KeysList , ST
|
||||
//send header with calculated size
|
||||
header_sent=true;
|
||||
web_interface->WebServer.sendContent(bufferheader);
|
||||
|
||||
}
|
||||
//send data
|
||||
web_interface->WebServer.sendContent(buffer2send);
|
||||
@ -521,6 +523,7 @@ bool processTemplate(const char * filename, STORESTRINGS_CLASS & KeysList , ST
|
||||
}
|
||||
//send data
|
||||
web_interface->WebServer.sendContent(buffer2send);
|
||||
|
||||
}
|
||||
}
|
||||
//if we end size calculation loop
|
||||
@ -701,6 +704,13 @@ void ProcessNoAlert(STORESTRINGS_CLASS & KeysList, STORESTRINGS_CLASS & ValuesLi
|
||||
|
||||
//root insterface
|
||||
void handle_web_interface_root()
|
||||
{
|
||||
static const char HOME_PAGE [] PROGMEM = "HTTP/1.1 301 OK\r\nLocation: /HOME\r\nCache-Control: no-cache\r\n\r\n";
|
||||
web_interface->WebServer.sendContent_P(HOME_PAGE);
|
||||
}
|
||||
|
||||
//root insterface
|
||||
void handle_web_interface_home()
|
||||
{
|
||||
String stmp;
|
||||
long lstatus;
|
||||
@ -861,7 +871,7 @@ void handle_web_interface_root()
|
||||
//IP
|
||||
stmp = "$IP_CONNECTED["+String(client_counter)+"]$";
|
||||
KeysList.add(stmp.c_str());
|
||||
ValuesList.add(wifi_config.ip2str((byte *)&station->ip));
|
||||
ValuesList.add(IPAddress((const uint8_t *)&station->ip).toString().c_str());
|
||||
//increment counter
|
||||
client_counter++;
|
||||
//go next record
|
||||
@ -940,13 +950,13 @@ void handle_web_interface_root()
|
||||
if (wifi_get_ip_info(SOFTAP_IF,&info)) {
|
||||
//IP address
|
||||
KeysList.add(FPSTR(KEY_AP_IP));
|
||||
ValuesList.add(wifi_config.ip2str(info.ip.addr));
|
||||
ValuesList.add(IPAddress((const uint8_t *)&(info.ip.addr)).toString().c_str());
|
||||
//GW address
|
||||
KeysList.add(FPSTR(KEY_AP_GW));
|
||||
ValuesList.add(wifi_config.ip2str(info.gw.addr));
|
||||
ValuesList.add(IPAddress((const uint8_t *)&(info.gw.addr)).toString().c_str());
|
||||
//Sub Net Mask
|
||||
KeysList.add(FPSTR(KEY_AP_SUBNET));
|
||||
ValuesList.add(wifi_config.ip2str(info.netmask.addr));
|
||||
ValuesList.add(IPAddress((const uint8_t *)&(info.netmask.addr)).toString().c_str());
|
||||
} else {
|
||||
//IP address
|
||||
KeysList.add(FPSTR(KEY_AP_IP));
|
||||
@ -1022,7 +1032,6 @@ void handle_web_interface_root()
|
||||
ValuesList.add("");
|
||||
//Firmware & Free Mem, at the end to reflect situation
|
||||
GetFreeMem(KeysList, ValuesList);
|
||||
|
||||
//process the template file and provide list of variables
|
||||
processTemplate("/home.tpl", KeysList , ValuesList);
|
||||
//need to clean to speed up memory recovery
|
||||
@ -1525,22 +1534,23 @@ void handle_web_interface_configAP()
|
||||
}
|
||||
//IP for static IP
|
||||
if (!CONFIG::read_buffer(EP_IP_VALUE,ip_sav , IP_LENGTH) ) {
|
||||
sIP=wifi_config.ip2str((byte *)DEFAULT_IP_VALUE);
|
||||
sIP=IPAddress((const uint8_t *)DEFAULT_IP_VALUE).toString();
|
||||
|
||||
} else {
|
||||
sIP=wifi_config.ip2str(ip_sav);
|
||||
sIP=IPAddress((const uint8_t *)ip_sav).toString();
|
||||
}
|
||||
//GW for static IP
|
||||
if (!CONFIG::read_buffer(EP_GATEWAY_VALUE,gw_sav , IP_LENGTH) ) {
|
||||
sGW=wifi_config.ip2str((byte *)DEFAULT_GATEWAY_VALUE);
|
||||
sGW=IPAddress((const uint8_t *)DEFAULT_GATEWAY_VALUE).toString();
|
||||
} else {
|
||||
sGW=wifi_config.ip2str(gw_sav);
|
||||
sGW=IPAddress((const uint8_t *)gw_sav).toString();
|
||||
}
|
||||
|
||||
//Subnet for static IP
|
||||
if (!CONFIG::read_buffer(EP_MASK_VALUE,msk_sav , IP_LENGTH) ) {
|
||||
sMask=wifi_config.ip2str((byte *)DEFAULT_MASK_VALUE);
|
||||
sMask=IPAddress((const uint8_t *)DEFAULT_MASK_VALUE).toString();
|
||||
} else {
|
||||
sMask=wifi_config.ip2str(msk_sav);
|
||||
sMask=IPAddress((const uint8_t *)msk_sav).toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1839,21 +1849,21 @@ void handle_web_interface_configSTA()
|
||||
}
|
||||
//IP for static IP
|
||||
if (!CONFIG::read_buffer(EP_IP_VALUE,ip_sav , IP_LENGTH) ) {
|
||||
sIP=wifi_config.ip2str((byte *)DEFAULT_IP_VALUE);
|
||||
sIP=IPAddress((const uint8_t *)DEFAULT_IP_VALUE).toString();
|
||||
} else {
|
||||
sIP=wifi_config.ip2str(ip_sav);
|
||||
sIP=IPAddress((const uint8_t *)ip_sav).toString();
|
||||
}
|
||||
//GW for static IP
|
||||
if (!CONFIG::read_buffer(EP_GATEWAY_VALUE,gw_sav , IP_LENGTH) ) {
|
||||
sGW=wifi_config.ip2str((byte *)DEFAULT_GATEWAY_VALUE);
|
||||
sGW=IPAddress((const uint8_t *)DEFAULT_GATEWAY_VALUE).toString();
|
||||
} else {
|
||||
sGW=wifi_config.ip2str(gw_sav);
|
||||
sGW=IPAddress((const uint8_t *)gw_sav).toString();
|
||||
}
|
||||
//Subnet for static IP
|
||||
if (!CONFIG::read_buffer(EP_MASK_VALUE,msk_sav , IP_LENGTH) ) {
|
||||
sMask=wifi_config.ip2str((byte *)DEFAULT_MASK_VALUE);
|
||||
sMask=IPAddress((const uint8_t *)DEFAULT_MASK_VALUE).toString();
|
||||
} else {
|
||||
sMask=wifi_config.ip2str(msk_sav);
|
||||
sMask=IPAddress((const uint8_t *)msk_sav).toString();
|
||||
}
|
||||
}
|
||||
//Display values
|
||||
@ -2534,7 +2544,7 @@ void handleSDFileList()
|
||||
//and handle not registred path
|
||||
void handle_not_found()
|
||||
{
|
||||
static const char NOT_AUTH_NF [] PROGMEM = "HTTP/1.1 301 OK\r\nLocation: /\r\nCache-Control: no-cache\r\n\r\n";
|
||||
static const char NOT_AUTH_NF [] PROGMEM = "HTTP/1.1 301 OK\r\nLocation: /HOME\r\nCache-Control: no-cache\r\n\r\n";
|
||||
|
||||
if (!web_interface->is_authenticated()) {
|
||||
web_interface->WebServer.sendContent_P(NOT_AUTH_NF);
|
||||
@ -2833,6 +2843,7 @@ WEBINTERFACE_CLASS::WEBINTERFACE_CLASS (int port):WebServer(port)
|
||||
{
|
||||
//init what will handle "/"
|
||||
WebServer.on("/",HTTP_ANY, handle_web_interface_root);
|
||||
WebServer.on("/HOME",HTTP_ANY, handle_web_interface_home);
|
||||
WebServer.on("/CONFIGSYS",HTTP_ANY, handle_web_interface_configSys);
|
||||
WebServer.on("/CONFIGAP",HTTP_ANY, handle_web_interface_configAP);
|
||||
WebServer.on("/CONFIGSTA",HTTP_ANY, handle_web_interface_configSTA);
|
||||
|
@ -25,14 +25,13 @@
|
||||
#ifdef MDNS_FEATURE
|
||||
#include <ESP8266mDNS.h>
|
||||
#endif
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
#ifdef CAPTIVE_PORTAL_FEATURE
|
||||
#include <DNSServer.h>
|
||||
extern DNSServer dnsServer;
|
||||
#endif
|
||||
|
||||
extern "C" {
|
||||
#include "user_interface.h"
|
||||
}
|
||||
WIFI_CONFIG::WIFI_CONFIG()
|
||||
{
|
||||
iweb_port=DEFAULT_WEB_PORT;
|
||||
@ -65,8 +64,9 @@ const char * WIFI_CONFIG::get_default_hostname()
|
||||
return hostname;
|
||||
}
|
||||
|
||||
//no strtok so this is simplified version
|
||||
//return number of part
|
||||
//helper to convert string to IP
|
||||
//do not use IPAddress.fromString() because lack of check point and error result
|
||||
//return number of parts
|
||||
byte WIFI_CONFIG::split_ip (const char * ptr,byte * part)
|
||||
{
|
||||
if (strlen(ptr)>15 || strlen(ptr)< 7) {
|
||||
@ -112,16 +112,7 @@ char * WIFI_CONFIG::mac2str(uint8_t mac [WL_MAC_ADDR_LENGTH])
|
||||
return macstr;
|
||||
}
|
||||
|
||||
//just simple helper to convert IP address to string
|
||||
char * WIFI_CONFIG::ip2str(IPAddress Ip )
|
||||
{
|
||||
static char ipstr [16];
|
||||
if (0>sprintf(ipstr, "%i.%i.%i.%i",Ip[0],Ip[1],Ip[2],Ip[3])) {
|
||||
strcpy (ipstr, "0.0.0.0");
|
||||
}
|
||||
return ipstr;
|
||||
}
|
||||
|
||||
//safe setup if no connection
|
||||
void WIFI_CONFIG::Safe_Setup()
|
||||
{
|
||||
#ifdef CAPTIVE_PORTAL_FEATURE
|
||||
@ -153,24 +144,52 @@ bool WIFI_CONFIG::Setup()
|
||||
int wstatus;
|
||||
IPAddress currentIP;
|
||||
byte bflag=0;
|
||||
|
||||
byte bmode=0;
|
||||
//system_update_cpu_freq(SYS_CPU_160MHZ);
|
||||
//set the sleep mode
|
||||
if (!CONFIG::read_byte(EP_SLEEP_MODE, &bflag )) {
|
||||
return false;
|
||||
}
|
||||
wifi_set_sleep_type ((sleep_type_t)bflag);
|
||||
WiFi.setSleepMode ((WiFiSleepType_t)bflag);
|
||||
sleep_mode=bflag;
|
||||
//AP or client ?
|
||||
if (!CONFIG::read_byte(EP_WIFI_MODE, &bflag ) || !CONFIG::read_string(EP_SSID, sbuf , MAX_SSID_LENGTH) ||!CONFIG::read_string(EP_PASSWORD, pwd , MAX_PASSWORD_LENGTH)) {
|
||||
if (!CONFIG::read_byte(EP_WIFI_MODE, &bmode ) || !CONFIG::read_string(EP_SSID, sbuf , MAX_SSID_LENGTH) ||!CONFIG::read_string(EP_PASSWORD, pwd , MAX_PASSWORD_LENGTH)) {
|
||||
return false;
|
||||
}
|
||||
if (!CONFIG::read_string(EP_HOSTNAME, hostname , MAX_HOSTNAME_LENGTH)) {
|
||||
strcpy(hostname,get_default_hostname());
|
||||
}
|
||||
//disconnect if connected
|
||||
WiFi.disconnect();
|
||||
//DHCP or Static IP ?
|
||||
if (!CONFIG::read_byte(EP_IP_MODE, &bflag )) {
|
||||
return false;
|
||||
}
|
||||
if (bflag==STATIC_IP_MODE) {
|
||||
byte ip_buf[4];
|
||||
//get the IP
|
||||
if (!CONFIG::read_buffer(EP_IP_VALUE,ip_buf , IP_LENGTH)) {
|
||||
return false;
|
||||
}
|
||||
IPAddress local_ip (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
|
||||
//get the gateway
|
||||
if (!CONFIG::read_buffer(EP_GATEWAY_VALUE,ip_buf , IP_LENGTH)) {
|
||||
return false;
|
||||
}
|
||||
IPAddress gateway (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
|
||||
//get the mask
|
||||
if (!CONFIG::read_buffer(EP_MASK_VALUE,ip_buf , IP_LENGTH)) {
|
||||
return false;
|
||||
}
|
||||
IPAddress subnet (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
|
||||
//apply according active wifi mode
|
||||
if (bmode==AP_MODE) {
|
||||
WiFi.softAPConfig( local_ip, gateway, subnet);
|
||||
} else {
|
||||
WiFi.config( local_ip, gateway, subnet);
|
||||
}
|
||||
}
|
||||
//this is AP mode
|
||||
if (bflag==AP_MODE) {
|
||||
if (bmode==AP_MODE) {
|
||||
WiFi.enableSTA(true);
|
||||
//setup Soft AP
|
||||
WiFi.mode(WIFI_AP);
|
||||
WiFi.softAP(sbuf, pwd);
|
||||
@ -178,7 +197,7 @@ bool WIFI_CONFIG::Setup()
|
||||
if (!CONFIG::read_byte(EP_PHY_MODE, &bflag )) {
|
||||
return false;
|
||||
}
|
||||
wifi_set_phy_mode((phy_mode_t)bflag);
|
||||
WiFi.setPhyMode((WiFiPhyMode_t)bflag);
|
||||
//get current config
|
||||
struct softap_config apconfig;
|
||||
wifi_softap_get_config(&apconfig);
|
||||
@ -206,6 +225,7 @@ bool WIFI_CONFIG::Setup()
|
||||
delay(1000);
|
||||
}
|
||||
} else {
|
||||
WiFi.enableAP(false);
|
||||
//setup station mode
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(sbuf, pwd);
|
||||
@ -214,7 +234,7 @@ bool WIFI_CONFIG::Setup()
|
||||
if (!CONFIG::read_byte(EP_PHY_MODE, &bflag )) {
|
||||
return false;
|
||||
}
|
||||
wifi_set_phy_mode((phy_mode_t)bflag);
|
||||
WiFi.setPhyMode((WiFiPhyMode_t)bflag);
|
||||
delay(500);
|
||||
byte i=0;
|
||||
//try to connect
|
||||
@ -244,34 +264,7 @@ bool WIFI_CONFIG::Setup()
|
||||
WiFi.hostname(hostname);
|
||||
}
|
||||
|
||||
//DHCP or Static IP ?
|
||||
if (!CONFIG::read_byte(EP_IP_MODE, &bflag )) {
|
||||
return false;
|
||||
}
|
||||
if (bflag==STATIC_IP_MODE) {
|
||||
byte ip_buf[4];
|
||||
//get the IP
|
||||
if (!CONFIG::read_buffer(EP_IP_VALUE,ip_buf , IP_LENGTH)) {
|
||||
return false;
|
||||
}
|
||||
IPAddress local_ip (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
|
||||
//get the gateway
|
||||
if (!CONFIG::read_buffer(EP_GATEWAY_VALUE,ip_buf , IP_LENGTH)) {
|
||||
return false;
|
||||
}
|
||||
IPAddress gateway (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
|
||||
//get the mask
|
||||
if (!CONFIG::read_buffer(EP_MASK_VALUE,ip_buf , IP_LENGTH)) {
|
||||
return false;
|
||||
}
|
||||
IPAddress subnet (ip_buf[0],ip_buf[1],ip_buf[2],ip_buf[3]);
|
||||
//apply according active wifi mode
|
||||
if (wifi_get_opmode()==WIFI_AP || wifi_get_opmode()==WIFI_AP_STA) {
|
||||
WiFi.softAPConfig( local_ip, gateway, subnet);
|
||||
} else {
|
||||
WiFi.config( local_ip, gateway, subnet);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MDNS_FEATURE
|
||||
// Set up mDNS responder:
|
||||
if (!mdns.begin(hostname)) {
|
||||
@ -281,7 +274,7 @@ bool WIFI_CONFIG::Setup()
|
||||
}
|
||||
#endif
|
||||
//Get IP
|
||||
if (wifi_get_opmode()==WIFI_STA) {
|
||||
if (WiFi.getMode()==WIFI_STA) {
|
||||
currentIP=WiFi.localIP();
|
||||
} else {
|
||||
currentIP=WiFi.softAPIP();
|
||||
|
@ -44,7 +44,6 @@ public:
|
||||
bool Setup();
|
||||
void Safe_Setup();
|
||||
char * mac2str(uint8_t mac [WL_MAC_ADDR_LENGTH]);
|
||||
char * ip2str(IPAddress Ip );
|
||||
byte split_ip (const char * ptr,byte * part);
|
||||
const char * get_default_hostname();
|
||||
const char * get_hostname();
|
||||
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 368 KiB After Width: | Height: | Size: 368 KiB |
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
Before Width: | Height: | Size: 1.1 MiB After Width: | Height: | Size: 1.1 MiB |
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
Before Width: | Height: | Size: 1.5 MiB After Width: | Height: | Size: 1.5 MiB |
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 93 KiB |
Before Width: | Height: | Size: 65 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 266 KiB After Width: | Height: | Size: 266 KiB |
Before Width: | Height: | Size: 226 KiB After Width: | Height: | Size: 226 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |