Add ESP450 to list others ESP3D

Move mDNS to a module for better abstraction layer
Change Command.txt to markdown
Fix warning on esp8266 for sign compare
Bumb version to 205
This commit is contained in:
Luc 2022-08-15 18:01:02 +08:00
parent 81418cb563
commit cf45c9251e
11 changed files with 848 additions and 357 deletions

299
docs/Commands.md Normal file
View File

@ -0,0 +1,299 @@
# Direct ESP3D commands (V3.x)
## Conventions
1 - add space to separate parameters
2 - if parameter has space add \\ in front of space to not be seen as separator
3 - json json=YES json=TRUE json=1 are paremeters to switch output to json
By default output is plain text, to get json formated output
add json or json=yes after main parameters
The json format is {
cmd:"<command id>", //the id of requested command
status:"<ok/error>" //give if it is success or an failure
data:"<response>" // response corresponding to answer in json format too
}
## Commands
* Show commands help
`[ESP]<command id> json=<no>`
* Set/Get STA SSID
`[ESP100]<SSID> json=<no> pwd=<admin password for set/get & user password to get>`
* Set STA Password
`[ESP101]<Password> json=<no> pwd=<admin password>`
* Set/Get STA IP mode (DHCP/STATIC)
`[ESP102]<mode> json=<no> pwd=<admin password>`
* Set/Get STA IP/Mask/GW/DNS
`[ESP103]IP=<IP> MSK=<IP> GW=<IP> DNS=<IP> json=<no> pwd=<admin password>`
* Set/Get sta fallback mode which can be WIFI-AP, BT, OFF
`[ESP104]<state> json=<no> pwd=<admin password>`
* Set/Get AP SSID
`[ESP105]<SSID> json=<no> pwd=<admin password>`
* Change AP Password
`[ESP106]<Password> json=<no> pwd=<admin password>`
* Set/Get AP IP
`[ESP107]<IP> json=<no> pwd=<admin password>`
* Set/Get AP channel
`[ESP108]<channel> json=<no> pwd=<admin password>`
* Set/Get radio state which can be WIFI-STA, WIFI-AP, BT, ETH-STA, ETH-AP, OFF
`[ESP110]<state> json=<no> pwd=<admin password>`
* Get current IP
`[ESP111]json=<no>`
* Get/Set hostname
`[ESP112]<Hostname> json=<no> pwd=<admin password>`
* Get /Set Boot radio state which can be ON, OFF
`[ESP114]<state> json=<no> pwd=<user/admin password>`
* Get/Set immediate network(WiFi/BT/Ethernet) state which can be ON, OFF
`[ESP115]<state> json=<no> pwd=<admin password>`
* Get/Set HTTP state which can be ON, OFF
`[ESP120]<state> json=<no> pwd=<admin password>`
* Get/Set HTTP port
`[ESP121]<port> json=<no> pwd=<admin password>`
* Get/Set Telnet state which can be ON, OFF, CLOSE
`[ESP130]<state> json=<no> pwd=<admin password>`
* Get/Set Telnet port
`[ESP131]<port> json=<no> pwd=<admin password>`
* Sync / Set / Get current time
`[ESP140]<SYNC> <srv1=XXXXX> <srv2=XXXXX> <srv3=XXXXX> <zone=xxx> <dst=YES/NO> <time=YYYY-MM-DD#H24:MM:SS> <NOW> json=<no> pwd=<admin password>`
* Get/Set display/set boot delay in ms / Verbose boot
`[ESP150]<delay=time in milliseconds><verbose=ON/OFF>pwd=<admin password>`
* Get/Set WebSocket state which can be ON, OFF
`[ESP160]<state> json=<no> pwd=<admin password>`
* Get/Set WebSocket port
`[ESP161]<port> json=<no> pwd=<admin password>`
* Get/Set Camera command value / list all values in JSON/plain
label can be: light/framesize/quality/contrast/brightness/saturation/gainceiling/colorbar/awb/agc/aec/hmirror/vflip/awb_gain/agc_gain/aec_value/aec2/cw/bpc/wpc/raw_gma/lenc/special_effect/wb_mode/ae_level
`[ESP170]<label=value> json=<no> pwd=<admin password>`
* Save frame to target path and filename (default target = today date, default name=timestamp.jpg)
`[ESP171] <path=target path> <filename=target filename>`
* Get/Set Ftp state which can be ON, OFF, CLOSE
`[ESP180]<state> json=<no> pwd=<admin password>`
* Get/Set Ftp ports
`[ESP181]ctrl=<port> active=<port> passive=<port> json=<no> pwd=<admin password>`
* Get/Set WebDav state which can be ON, OFF, CLOSE
`[ESP190]<state> json=<no> pwd=<admin password>`
* Get/Set WebDav port
`[ESP191]<port> json=<no> pwd=<admin password>`
* Get/Set SD Card Status
`[ESP200]<RELEASE> <REFRESH> json=<no> pwd=<user/admin password>`
`RELEASE` will force the release of SD from ESP3D if SD is shared
`REFRESH` will refresh the SD info is available`
* Get/Set pin value
`[ESP201]P=<pin> V=<value> [PULLUP=YES RAW=YES ANALOG=NO ANALOG_RANGE=255]pwd=<admin password>`
- if no V=<value> get P=<pin> value
- if V=<value> 0/1 set INPUT_PULLUP value, but for GPIO16(ESP8266) INPUT_PULLDOWN_16
- if PULLUP=YES set input pull up (for GPIO16(ESP8266) INPUT_PULLDOWN_16), if not set input
- if RAW=YES do not set pinmode just read value
Note: Flash pins according chip cannot be used
* Get/Set SD card Speed factor 1 2 4 6 8 16 32
`[ESP202]SPEED=<value> json=<no> pwd=<user/admin password>`
* Get Sensor Value / type/Set Sensor type
`[ESP210]<type=NONE/xxx> <interval=XXX in millisec> json=<no> pwd=<user/admin password>`
* Output to esp screen status
`[ESP214]<Text> json=<no> pwd=<user/admin password>`
* Touch Calibration
`[ESP215]<CALIBRATE> json=<no> pwd=<user password>`
* Show defined pins
`[ESP220]<SNAP> json=<no> pwd=<user password>`
* Play sound
`[ESP250]F=<frequency> D=<duration> json=<no> pwd=<user password>`
Note: No parameter just play beep
* Delay command
`[ESP290]<delay in ms> json=<no>pwd=<user password>`
* Get full EEPROM settings content
`[ESP400] pwd=<admin password>`
Note: do not give any passwords
*Set EEPROM setting
position in EEPROM, type: B(byte), I(integer/long), S(string), A(IP address / mask)
`[ESP401]P=<position> T=<type> V=<value> json=<no> pwd=<user/admin password>`
```
Description: Positions:
ESP_RADIO_MODE 0 //1 byte = flag
ESP_STA_SSID 1 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese
ESP_STA_PASSWORD 34 //65 bytes 64 +1 = string ;warning does not support multibyte char like chinese
ESP_STA_IP_MODE 99 //1 byte = flag
ESP_STA_IP_VALUE 100 //4 bytes xxx.xxx.xxx.xxx
ESP_STA_MASK_VALUE 104 //4 bytes xxx.xxx.xxx.xxx
ESP_STA_GATEWAY_VALUE 108 //4 bytes xxx.xxx.xxx.xxx
ESP_BAUD_RATE 112 //4 bytes = int
ESP_NOTIFICATION_TYPE 116 //1 byte = flag
ESP_CALIBRATION 117 //1 byte = flag
ESP_AP_CHANNEL 118 //1 byte = flag
ESP_BUZZER 119 //1 byte = flag
ESP_INTERNET_TIME 120 //1 byte = flag
ESP_HTTP_PORT 121 //4 bytes = int
ESP_TELNET_PORT 125 //4 bytes = int
ESP_SERIAL_FLAG 129 //1 bytes = flag
ESP_HOSTNAME 130 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese
ESP_SENSOR_INTERVAL 164 //4 bytes = int
ESP_SETTINGS_VERSION 168 //8 bytes = 7+1 = string ESP3D + 2 digits
ESP_ADMIN_PWD 176 //21 bytes 20+1 = string ; warning does not support multibyte char like chinese
ESP_USER_PWD 197 //21 bytes 20+1 = string ; warning does not support multibyte char like chinese
ESP_AP_SSID 218 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese
ESP_AP_PASSWORD 251 //65 bytes 64 +1 = string ;warning does not support multibyte char like chinese
ESP_AP_IP_VALUE 316 //4 bytes xxx.xxx.xxx.xxx
ESP_BOOT_DELAY 320 //4 bytes = int
ESP_WEBSOCKET_PORT 324 //4 bytes= int
ESP_HTTP_ON 328 //1 byte = flag
ESP_TELNET_ON 329 //1 byte = flag
ESP_WEBSOCKET_ON 330 //1 byte = flag
ESP_SD_SPEED_DIV 331 //1 byte = flag
ESP_NOTIFICATION_TOKEN1 332 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
ESP_NOTIFICATION_TOKEN2 396 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
ESP_SENSOR_TYPE 460 //1 bytes = flag
ESP_TARGET_FW 461 //1 bytes = flag
ESP_TIMEZONE 462 //1 bytes = flag
ESP_TIME_IS_DST 463 //1 bytes = flag
ESP_TIME_SERVER1 464 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
ESP_TIME_SERVER2 593 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
ESP_TIME_SERVER3 722 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
ESP_REMOTE_SCREEN 851 //1 bytes = flag
ESP_SD_MOUNT 852 //1 bytes = flag
ESP_SESSION_TIMEOUT 853 //1 bytes = flag
ESP_WEBSOCKET_FLAG 854 //1 bytes = flag
ESP_SD_CHECK_UPDATE_AT_BOOT 855//1 bytes = flag
ESP_NOTIFICATION_SETTINGS 856 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
ESP_CALIBRATION_1 985 //4 bytes = int
ESP_CALIBRATION_2 989 //4 bytes = int
ESP_CALIBRATION_3 993 //4 bytes = int
ESP_CALIBRATION_4 997 //4 bytes = int
ESP_CALIBRATION_5 1001 //4 bytes = int
ESP_SETUP 1005 //1 byte = flag
ESP_TELNET_FLAG 1006 //1 byte = flag
ESP_BT_FLAG 1007 //1 byte = flag
ESP_SCREEEN_FLAG 1008 //1 byte = flag
ESP_FTP_CTRL_PORT 1009 //4 bytes = int
ESP_FTP_DATA_ACTIVE_PORT 1013 //4 bytes = int
ESP_FTP_DATA_PASSIVE_PORT 1017 //4 bytes = int
ESP_FTP_ON 1021 //1 byte = flag
ESP_AUTO_NOTIFICATION 1022 //1 byte = flag
ESP_VERBOSE_BOOT 1023 //1 byte = flag
ESP_WEBDAV_ON 1024 //1 byte = flag
ESP_WEBDAV_PORT 1025 //4 bytes = int
ESP_STA_DNS_VALUE 1029 //4 bytes= int
ESP_SECURE_SERIAL 1033 //1 byte = flag \
```
* Get/Set Check update at boot state which can be ON, OFF
`[ESP402]<state> json=<no> pwd=<admin password>`
* Get available AP list (limited to 30)
output is JSON or plain text according parameter
`[ESP410]json=<no> <pwd=admin/user>`
* Get current settings of ESP3D
Output is JSON or plain text according parameter
`[ESP420]json=<no> <pwd=admin/user>`
* Set ESP State
`cmd` can be `RESTART` to restart board or `RESET` to reset all setting to defaults values
`[ESP444]<cmd> json=<no> <pwd=admin>`
* Get available ESP3D list
output is JSON or plain text according parameter
`[ESP450]json=<no> <pwd=admin/user>`
* Change admin password
`[ESP550]<password> json=<no> pwd=<admin password>`
* Change user password
`[ESP555]<password> json=<no> pwd=<admin/user password>`
* Send Notification
`[ESP600]msg json=<no> pwd=<admin/user password>`
* Set/Get Notification settings
`[ESP610]type=<NONE/PUSHOVER/EMAIL/LINE/IFTTT> T1=<token1> T2=<token2> TS=<Settings> json=<no> [pwd=<admin password>]`
Get will give type and settings only, not the protected T1/T2
* Send Notification using URL
`[ESP620]URL=<encoded url> json=<no> pwd=<admin/user password>`
* Read / Stream / Process FS file
`[ESP700]<filename> json=<no> pwd=<admin/user password>`
* Query and Control ESP700 stream
`[ESP701]action=<PAUSE/RESUME/ABORT> json=<no> pwd=<admin/user password>`
* Format ESP Filesystem
`[ESP710]FORMATFS json=<no> pwd=<admin password>`
* Format SD Filesystem
`[ESP715]FORMATSD json=<no> pwd=<admin password>`
* List ESP Filesystem
`[ESP720]<Root> json=<no> pwd=<admin password>`
* Action on ESP Filesystem
Action can be `rmdir` to remove empty directory / `remove` to delete file / `mkdir` to create directory / `exists` to check if file or directory exists / `create` create an empty file
`[ESP730]<Action>=<path> json=<no> pwd=<admin password>`
* List SD Filesystem
`[ESP740]<Root> json=<no> pwd=<admin password>`
* Action on SD Filesystem
Action can be `rmdir` to remove empty directory / `remove` to delete file / `mkdir` to create directory / `exists` to check if file or directory exists / `create` create an empty file
`[ESP750]<Action>=<path> json=<no> pwd=<admin password>`
* List Global Filesystem
`[ESP780]<Root> json=<no> pwd=<admin password>`
* Action on Global Filesystem
Action can be `rmdir` to remove empty directory / `remove` to delete file / `mkdir` to create directory / `exists` to check if file or directory exists / `create` create an empty file
`[ESP790]<Action>=<path> json=<no> pwd=<admin password>`
* FW Informations
`[ESP800]json=<no> pwd=<admin password>`
* Get state / Set Enable / Disable Serial Communication
`[ESP900]<ENABLE/DISABLE> json=<no> pwd=<admin/user password>`
* Get state / Set Enable / Disable verbose boot
`[ESP901]<ENABLE/DISABLE> json=<no> pwd=<admin/user password>`
* Get state / Set Enable / Disable buzzer
`[ESP910]<ENABLE/DISABLE> json=<no> pwd=<admin/user password>`
* Get state / Set state of output message clients
`[ESP920]<SERIAL / SCREEN / REMOTE_SCREEN/ WEBSOCKET / TELNET /BT / ALL>=<ON/OFF> json=<no> pwd=<admin/user password>`
* Set quiet boot if strapping pin is High
`[ESP999]QUIETBOOT pwd=<admin/user password>`

View File

@ -1,291 +0,0 @@
Note:
1 - add space to separate parameters
2 - if parameter has space add \\ in front of space to not be seen as separator
3 - json json=YES json=TRUE json=1 are paremeters to switch output to json
By default output is plain text, to get json formated output
add json or json=yes after main parameters
The json format is {
cmd:"<command id>", //the id of requested command
status:"<ok/error>" //give if it is success or an failure
data:"<response>" // response corresponding to answer in json format too
}
*Show commands help
[ESP]<command id> json=<no>
* Set/Get STA SSID
[ESP100]<SSID> json=<no> pwd=<admin password for set/get & user password to get>
* Set STA Password
[ESP101]<Password> json=<no> pwd=<admin password>
* Set/Get STA IP mode (DHCP/STATIC)
[ESP102]<mode> json=<no> pwd=<admin password>
* Set/Get STA IP/Mask/GW/DNS
[ESP103]IP=<IP> MSK=<IP> GW=<IP> DNS=<IP> json=<no> pwd=<admin password>
* Set/Get sta fallback mode which can be WIFI-AP, BT, OFF
[ESP104]<state> json=<no> pwd=<admin password>
* Set/Get AP SSID
[ESP105]<SSID> json=<no> pwd=<admin password>
* Change AP Password
[ESP106]<Password> json=<no> pwd=<admin password>
* Set/Get AP IP
[ESP107]<IP> json=<no> pwd=<admin password>
* Set/Get AP channel
[ESP108]<channel> json=<no> pwd=<admin password>
* Set/Get radio state which can be WIFI-STA, WIFI-AP, BT, ETH-STA, ETH-AP, OFF
[ESP110]<state> json=<no> pwd=<admin password>
* Get current IP
[ESP111]json=<no>
* Get/Set hostname
[ESP112]<Hostname> json=<no> pwd=<admin password>
* Get /Set Boot radio state which can be ON, OFF
[ESP114]<state> json=<no> pwd=<user/admin password>
* Get/Set immediate network(WiFi/BT/Ethernet) state which can be ON, OFF
[ESP115]<state> json=<no> pwd=<admin password>
* Get/Set HTTP state which can be ON, OFF
[ESP120]<state> json=<no> pwd=<admin password>
* Get/Set HTTP port
[ESP121]<port> json=<no> pwd=<admin password>
* Get/Set Telnet state which can be ON, OFF, CLOSE
[ESP130]<state> json=<no> pwd=<admin password>
* Get/Set Telnet port
[ESP131]<port> json=<no> pwd=<admin password>
* Sync / Set / Get current time
[ESP140]<SYNC> <srv1=XXXXX> <srv2=XXXXX> <srv3=XXXXX> <zone=xxx> <dst=YES/NO> <time=YYYY-MM-DD#H24:MM:SS> <NOW> json=<no> pwd=<admin password>
* Get/Set display/set boot delay in ms / Verbose boot
[ESP150]<delay=time in milliseconds><verbose=ON/OFF>[pwd=<admin password>]
* Get/Set WebSocket state which can be ON, OFF
[ESP160]<state> json=<no> pwd=<admin password>
* Get/Set WebSocket port
[ESP161]<port> json=<no> pwd=<admin password>
* Get/Set Camera command value / list all values in JSON/plain
label can be: light/framesize/quality/contrast/brightness/saturation/gainceiling/colorbar/awb/agc/aec/hmirror/vflip/awb_gain/agc_gain/aec_value/aec2/cw/bpc/wpc/raw_gma/lenc/special_effect/wb_mode/ae_level
[ESP170]<label=value> json=<no> pwd=<admin password>
* Save frame to target path and filename (default target = today date, default name=timestamp.jpg)
[ESP171] <path=target path> <filename=target filename>
* Get/Set Ftp state which can be ON, OFF, CLOSE
[ESP180]<state> json=<no> pwd=<admin password>
* Get/Set Ftp ports
[ESP181]ctrl=<port> active=<port> passive=<port> json=<no> pwd=<admin password>
* Get/Set WebDav state which can be ON, OFF, CLOSE
[ESP190]<state> json=<no> pwd=<admin password>
* Get/Set WebDav port
[ESP191]<port> json=<no> pwd=<admin password>
* Get/Set SD Card Status
[ESP200]<RELEASE> <REFRESH> json=<no> pwd=<user/admin password>
RELEASE will force the release of SD from ESP3D if SD is shared
REFRESH will refresh the SD info is available
*Get/Set pin value
[ESP201]P=<pin> V=<value> [PULLUP=YES RAW=YES ANALOG=NO ANALOG_RANGE=255]pwd=<admin password>
if no V=<value> get P=<pin> value
if V=<value> 0/1 set INPUT_PULLUP value, but for GPIO16(ESP8266) INPUT_PULLDOWN_16
if PULLUP=YES set input pull up (for GPIO16(ESP8266) INPUT_PULLDOWN_16), if not set input
if RAW=YES do not set pinmode just read value
Flash pins (6~11) cannot be used
*Get/Set SD card Speed factor 1 2 4 6 8 16 32
[ESP202]SPEED=<value> json=<no> pwd=<user/admin password>
*Get Sensor Value / type/Set Sensor type
[ESP210]<type=NONE/xxx> <interval=XXX in millisec> json=<no> pwd=<user/admin password>
* Output to esp screen status
[ESP214]<Text> json=<no> pwd=<user/admin password>
* Touch Calibration
[ESP215]<CALIBRATE> json=<no> [pwd=<user password>]
* Show defined pins
[ESP220]<SNAP> json=<no> [pwd=<user password>]
* Play sound
No parameter just play beep
[ESP250]F=<frequency> D=<duration> json=<no> [pwd=<user password>]
* Delay command
[ESP290]<delay in ms> json=<no>[pwd=<user password>]
* Get full EEPROM settings content
but do not give any passwords
[ESP400] pwd=<admin password>
*Set EEPROM setting
position in EEPROM, type: B(byte), I(integer/long), S(string), A(IP address / mask)
[ESP401]P=<position> T=<type> V=<value> json=<no> pwd=<user/admin password>
Description: Positions:
ESP_RADIO_MODE 0 //1 byte = flag
ESP_STA_SSID 1 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese
ESP_STA_PASSWORD 34 //65 bytes 64 +1 = string ;warning does not support multibyte char like chinese
ESP_STA_IP_MODE 99 //1 byte = flag
ESP_STA_IP_VALUE 100 //4 bytes xxx.xxx.xxx.xxx
ESP_STA_MASK_VALUE 104 //4 bytes xxx.xxx.xxx.xxx
ESP_STA_GATEWAY_VALUE 108 //4 bytes xxx.xxx.xxx.xxx
ESP_BAUD_RATE 112 //4 bytes = int
ESP_NOTIFICATION_TYPE 116 //1 byte = flag
ESP_CALIBRATION 117 //1 byte = flag
ESP_AP_CHANNEL 118 //1 byte = flag
ESP_BUZZER 119 //1 byte = flag
ESP_INTERNET_TIME 120 //1 byte = flag
ESP_HTTP_PORT 121 //4 bytes = int
ESP_TELNET_PORT 125 //4 bytes = int
ESP_SERIAL_FLAG 129 //1 bytes = flag
ESP_HOSTNAME 130 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese
ESP_SENSOR_INTERVAL 164 //4 bytes = int
ESP_SETTINGS_VERSION 168 //8 bytes = 7+1 = string ESP3D + 2 digits
ESP_ADMIN_PWD 176 //21 bytes 20+1 = string ; warning does not support multibyte char like chinese
ESP_USER_PWD 197 //21 bytes 20+1 = string ; warning does not support multibyte char like chinese
ESP_AP_SSID 218 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese
ESP_AP_PASSWORD 251 //65 bytes 64 +1 = string ;warning does not support multibyte char like chinese
ESP_AP_IP_VALUE 316 //4 bytes xxx.xxx.xxx.xxx
ESP_BOOT_DELAY 320 //4 bytes = int
ESP_WEBSOCKET_PORT 324 //4 bytes= int
ESP_HTTP_ON 328 //1 byte = flag
ESP_TELNET_ON 329 //1 byte = flag
ESP_WEBSOCKET_ON 330 //1 byte = flag
ESP_SD_SPEED_DIV 331 //1 byte = flag
ESP_NOTIFICATION_TOKEN1 332 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
ESP_NOTIFICATION_TOKEN2 396 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
ESP_SENSOR_TYPE 460 //1 bytes = flag
ESP_TARGET_FW 461 //1 bytes = flag
ESP_TIMEZONE 462 //1 bytes = flag
ESP_TIME_IS_DST 463 //1 bytes = flag
ESP_TIME_SERVER1 464 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
ESP_TIME_SERVER2 593 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
ESP_TIME_SERVER3 722 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
ESP_REMOTE_SCREEN 851 //1 bytes = flag
ESP_SD_MOUNT 852 //1 bytes = flag
ESP_SESSION_TIMEOUT 853 //1 bytes = flag
ESP_WEBSOCKET_FLAG 854 //1 bytes = flag
ESP_SD_CHECK_UPDATE_AT_BOOT 855//1 bytes = flag
ESP_NOTIFICATION_SETTINGS 856 //129 bytes 128+1 = string ; warning does not support multibyte char like chinese
ESP_CALIBRATION_1 985 //4 bytes = int
ESP_CALIBRATION_2 989 //4 bytes = int
ESP_CALIBRATION_3 993 //4 bytes = int
ESP_CALIBRATION_4 997 //4 bytes = int
ESP_CALIBRATION_5 1001 //4 bytes = int
ESP_SETUP 1005 //1 byte = flag
ESP_TELNET_FLAG 1006 //1 byte = flag
ESP_BT_FLAG 1007 //1 byte = flag
ESP_SCREEEN_FLAG 1008 //1 byte = flag
ESP_FTP_CTRL_PORT 1009 //4 bytes = int
ESP_FTP_DATA_ACTIVE_PORT 1013 //4 bytes = int
ESP_FTP_DATA_PASSIVE_PORT 1017 //4 bytes = int
ESP_FTP_ON 1021 //1 byte = flag
ESP_AUTO_NOTIFICATION 1022 //1 byte = flag
ESP_VERBOSE_BOOT 1023 //1 byte = flag
ESP_WEBDAV_ON 1024 //1 byte = flag
ESP_WEBDAV_PORT 1025 //4 bytes = int
ESP_STA_DNS_VALUE 1029 //4 bytes= int
ESP_SECURE_SERIAL 1033 //1 byte = flag
* Get/Set Check update at boot state which can be ON, OFF
[ESP402]<state> json=<no> pwd=<admin password>
*Get available AP list (limited to 30)
output is JSON or plain text according parameter
[ESP410]json=<no> <pwd=admin/user>
*Get current settings of ESP3D
output is plain text
[ESP420]json=<no> <pwd=admin/user>
* Set ESP State
cmd are RESTART / RESET
[ESP444]<cmd> json=<no> <pwd=admin>
* Change admin password
[ESP550]<password> json=<no> pwd=<admin password>
* Change user password
[ESP555]<password> json=<no> pwd=<admin/user password>
* Send Notification
[ESP600]msg json=<no> pwd=<admin/user password>
* Set/Get Notification settings
[ESP610]type=<NONE/PUSHOVER/EMAIL/LINE/IFTTT> T1=<token1> T2=<token2> TS=<Settings> json=<no> [pwd=<admin password>]
Get will give type and settings only, not the protected T1/T2
* Send Notification using URL
[ESP620]URL=<encoded url> json=<no>[pwd=<admin/user password>]
* Read FS file
[ESP700]<filename> json=<no>[pwd=<admin/user password>]
* Query and Control ESP700 stream
[ESP701]action=<PAUSE/RESUME/ABORT> json=<no>[pwd=<admin/user password>]
* Format ESP Filesystem
[ESP710]FORMATFS json=<no> pwd=<admin password>
* Format SD Filesystem
[ESP715]FORMATSD json=<no> pwd=<admin password>
* List ESP Filesystem
[ESP720]<Root> json=<no> pwd=<admin password>
* Action on ESP Filesystem
rmdir / remove / mkdir / exists / create
[ESP730]<Action>=<path> json=<no> pwd=<admin password>
* List SD Filesystem
[ESP740]<Root> json=<no> pwd=<admin password>
* Action on SD Filesystem
rmdir / remove / mkdir / exists / create
[ESP750]<Action>=<path> json=<no> pwd=<admin password>
* List Global Filesystem
[ESP780]<Root> json=<no> pwd=<admin password>
* Action on Global Filesystem
rmdir / remove / mkdir / exists /create
[ESP790]<Action>=<path> json=<no> pwd=<admin password>
* FW Informations
[ESP800]json=<no> pwd=<admin password>
* Get state / Set Enable / Disable Serial Communication
[ESP900]<ENABLE/DISABLE> json=<no> [pwd=<admin/user password>]
* Get state / Set Enable / Disable verbose boot
[ESP901]<ENABLE/DISABLE> json=<no> [pwd=<admin/user password>]
* Get state / Set Enable / Disable buzzer
[ESP910]<ENABLE/DISABLE> json=<no> [pwd=<admin/user password>]
* Get state / Set state of output message clients
[ESP920]<SERIAL / SCREEN / REMOTE_SCREEN/ WEBSOCKET / TELNET /BT / ALL>=<ON/OFF> json=<no> [pwd=<admin/user password>]
* Set quiet boot if strapping pin is High
[ESP999]QUIETBOOT [pwd=<admin/user password>]

View File

@ -623,6 +623,13 @@ bool Commands::execute_internal_command (int cmd, const char* cmd_params, level_
case 444:
response = ESP444(cmd_params, auth_type, output);
break;
#ifdef MDNS_FEATURE
//Get ESP3D list
//[ESP450] pwd=<admin/user password>
case 450:
response = ESP450(cmd_params, auth_type, output);
break;
#endif //MDNS_FEATURE
#ifdef AUTHENTICATION_FEATURE
//Change admin password
//[ESP550]<password>pwd=<admin password>

View File

@ -125,6 +125,9 @@ public:
#endif //WIFI_FEATURE
bool ESP420(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
bool ESP444(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
#ifdef MDNS_FEATURE
bool ESP450(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
#endif //MDNS_FEATURE
#if defined (AUTHENTICATION_FEATURE)
bool ESP550(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);
bool ESP555(const char* cmd_params, level_authenticate_type auth_level, ESP3DOutput * output);

View File

@ -113,6 +113,9 @@ const char * help[]= {"[ESP] (id) - display this help",
#endif //WIFI_FEATURE
"[ESP420](plain) - display ESP3D current status in plain/JSON",
"[ESP444](Cmd) - set ESP3D state (RESET/RESTART)",
#ifdef MDNS_FEATURE
"[ESP450]display ESP3D list on network",
#endif //MDNS_FEATURE
#if defined (AUTHENTICATION_FEATURE)
"[ESP550](password) - change admin password",
"[ESP555](password) - change user password",
@ -244,6 +247,9 @@ const uint cmdlist[]= {0,
#endif //WIFI_FEATURE
420,
444,
#ifdef MDNS_FEATURE
450,
#endif //MDNS_FEATURE
#if defined (AUTHENTICATION_FEATURE)
550,
555,

View File

@ -0,0 +1,151 @@
/*
ESP410.cpp - ESP3D command class
Copyright (c) 2014 Luc Lebosse. All rights reserved.
This code 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 code 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 code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "../../include/esp3d_config.h"
#if defined (MDNS_FEATURE)
#include "../commands.h"
#include "../esp3doutput.h"
#include "../settings_esp3d.h"
#include "../../modules/mDNS/mDNS.h"
#include "../../modules/authentication/authentication_service.h"
//Get available ESP3D list
//output is JSON or plain text according parameter
//[ESP4\50]json=<no>
#define COMMANDID 450
bool Commands::ESP450(const char* cmd_params, level_authenticate_type auth_type, ESP3DOutput * output)
{
bool noError = true;
bool json = has_tag (cmd_params, "json");
String response;
String parameter;
int errorCode = 200; //unless it is a server error use 200 as default and set error in json instead
#ifdef AUTHENTICATION_FEATURE
if (auth_type == LEVEL_GUEST) {
response = format_response(COMMANDID, json, false, "Guest user can't use this command");
noError = false;
errorCode = 401;
}
#else
(void)auth_type;
#endif //AUTHENTICATION_FEATURE
if (noError) {
parameter = clean_param(get_param (cmd_params, ""));
if (parameter.length() == 0) {
uint16_t n = 0;
if (!json) {
output->printMSGLine ("Start Scan");
}
n = esp3d_mDNS.servicesCount ();
if (json) {
output->print ("{\"cmd\":\"450\",\"status\":\"ok\",\"data\":[");
}
String line;
for (uint16_t i = 0; i < n; i++) {
line = "";
if (i > 0) {
if (json) {
line+=",";
}
}
if (json) {
line += "{\"Hostname\":\"";
line +=ESP3DOutput::encodeString(esp3d_mDNS.answerHostname(i));
} else {
line +=esp3d_mDNS.answerHostname(i);
}
if (json) {
line +="\",\"IP\":\"";
} else {
line +=" (";
}
line += esp3d_mDNS.answerIP(i);
if (!json) {
line +=":";
}
if (json) {
line +="\",\"port\":\"";
}
line += String(esp3d_mDNS.answerPort(i));
if (json) {
line +="\",\"TxT\":[";
} else {
line +=") ";
}
uint16_t nbtxt = esp3d_mDNS.answerTxtCount(i);
for (uint16_t j = 0; j < nbtxt; ++j) {
if (j>0) {
line += ",";
}
if (json) {
line += "{\"key\":\"";
}
line+=esp3d_mDNS.answerTxtKey(i, j);
if (json) {
line +="\",\"value\":\"";
} else {
line +="=";
}
line+=esp3d_mDNS.answerTxt(i, j);
if (json) {
line +="\"}";
}
}
if (json) {
line +="]}";
}
if (json) {
output->print (line.c_str());
} else {
output->printMSGLine (line.c_str());
}
}
}
if (json) {
output->printLN ("]}");
} else {
output->printMSGLine ("End Scan");
}
return true;
} else {
response = format_response(COMMANDID, json, false, "This command doesn't take parameters");
noError = false;
}
if (noError) {
if (json) {
output->printLN (response.c_str() );
} else {
output->printMSG (response.c_str() );
}
} else {
output->printERROR(response.c_str(), errorCode);
}
return noError;
}
#endif //MDNS_FEATURE

View File

@ -22,7 +22,7 @@
#define _VERSION_ESP3D_H
//version and sources location
#define FW_VERSION "3.0.0.a204"
#define FW_VERSION "3.0.0.a205"
#define REPOSITORY "https://github.com/luc-github/ESP3D/tree/3.0"
#endif //_VERSION_ESP3D_H

View File

@ -104,7 +104,7 @@ void HTTP_Server::FSFileupload ()
break;
}
}
if (pos+1 >= path.length()-1) {
if ((uint)(pos+1) >= path.length()-1) {
pos=-1;
break;
} else {

View File

@ -0,0 +1,319 @@
/*
mDNS.cpp - ESP3D mDNS encapsulation class
Copyright (c) 2014 Luc Lebosse. All rights reserved.
This code 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 code 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 code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
//#define ESP_DEBUG_FEATURE DEBUG_OUTPUT_SERIAL0
#include "../../include/esp3d_config.h"
#ifdef MDNS_FEATURE
#include "mDNS.h"
#include "../../core/settings_esp3d.h"
#include "../../core/esp3doutput.h"
#if defined( ARDUINO_ARCH_ESP8266)
#include <ESP8266mDNS.h>
#endif //ARDUINO_ARCH_ESP8266
#if defined( ARDUINO_ARCH_ESP32)
#include <ESPmDNS.h>
#endif //ARDUINO_ARCH_ESP32
mDNS_Service esp3d_mDNS;
#define MDNS_SERVICE_NAME "esp3d"
#define MDNS_SERVICE_TYPE "tcp"
mDNS_Service::mDNS_Service()
{
_started=false;
_hostname="";
_port =0;
_currentQueryCount =0;
_currentQueryTxtCount =0;
#if defined(ARDUINO_ARCH_ESP8266)
_hMDNSServiceQuery = 0;
#endif //ARDUINO_ARCH_ESP8266
}
bool mDNS_Service::begin(const char * hostname)
{
if(_started) {
end();
}
if(WiFi.getMode() != WIFI_AP) {
_hostname =hostname;
_hostname.toLowerCase();
ESP3DOutput output(ESP_ALL_CLIENTS);
log_esp3d("Start mdsn for %s", _hostname.c_str());
if (!MDNS.begin(_hostname.c_str())) {
output.printERROR("mDNS failed to start");
_started =false;
} else {
String stmp = "mDNS started with '" + _hostname + ".local'";
if (Settings_ESP3D::isVerboseBoot()) {
output.printMSG(stmp.c_str());
}
_started =true;
}
}
return _started;
}
void mDNS_Service::end()
{
_currentQueryCount =0;
_currentQueryTxtCount =0;
if(!_started || WiFi.getMode() == WIFI_AP) {
return;
}
_started =false;
#if defined(ARDUINO_ARCH_ESP8266)
if(_hMDNSServiceQuery) {
log_esp3d("Remove mdns service for %s", _hostname.c_str());
if (!MDNS.removeServiceQuery(_hMDNSServiceQuery)) {
log_esp3d("failed");
}
}
_hMDNSServiceQuery = 0;
log_esp3d("Remove mdns for %s", _hostname.c_str());
if (!MDNS.removeService(_hostname.c_str(),MDNS_SERVICE_NAME, MDNS_SERVICE_TYPE)) {
log_esp3d("failed");
}
#endif // ARDUINO_ARCH_ESP8266
#if defined(ARDUINO_ARCH_ESP32)
mdns_service_remove("_" MDNS_SERVICE_NAME, "_" MDNS_SERVICE_TYPE);
#endif // ARDUINO_ARCH_ESP32
MDNS.end();
_hostname="";
_port =0;
}
#if defined(ARDUINO_ARCH_ESP8266)
//call back function for mDNS service query
//currently not used, but necessary to setup the service query
void MDNSServiceQueryCallback(MDNSResponder::MDNSServiceInfo serviceInfo, MDNSResponder::AnswerType answerType, bool p_bSetContent) {}
#endif //ARDUINO_ARCH_ESP8266
void mDNS_Service::addESP3DServices(uint16_t port)
{
_port = port;
if(WiFi.getMode() == WIFI_AP) {
return;
}
MDNS.addService(MDNS_SERVICE_NAME, MDNS_SERVICE_TYPE, _port);
MDNS.addServiceTxt(MDNS_SERVICE_NAME, MDNS_SERVICE_TYPE, "firmware", "esp3d");
MDNS.addServiceTxt(MDNS_SERVICE_NAME, MDNS_SERVICE_TYPE, "version", FW_VERSION);
#if defined(ARDUINO_ARCH_ESP8266)
_hMDNSServiceQuery = MDNS.installServiceQuery(MDNS_SERVICE_NAME, MDNS_SERVICE_TYPE,MDNSServiceQueryCallback);
if (_hMDNSServiceQuery) {
log_esp3d("MDNS Service query services installed.");
} else {
log_esp3d("MDNS Service query services installation failed.");
}
#endif //ARDUINO_ARCH_ESP8266
}
void mDNS_Service::handle()
{
#if defined(ARDUINO_ARCH_ESP8266)
if(WiFi.getMode() == WIFI_AP) {
return;
}
MDNS.update();
#endif //ARDUINO_ARCH_ESP8266
}
uint16_t mDNS_Service::servicesCount()
{
_currentQueryCount =0;
if(WiFi.getMode() == WIFI_AP) {
return _currentQueryCount;
}
#if defined(ARDUINO_ARCH_ESP32)
_currentQueryCount = MDNS.queryService(MDNS_SERVICE_NAME, MDNS_SERVICE_TYPE);
#endif // ARDUINO_ARCH_ESP32
#if defined(ARDUINO_ARCH_ESP8266)
if(_hMDNSServiceQuery) {
_currentQueryCount =MDNS.answerCount(_hMDNSServiceQuery);
}
#endif //ARDUINO_ARCH_ESP8266
return _currentQueryCount;
}
const char* mDNS_Service::answerHostname(uint16_t index)
{
static String tmp;
if(WiFi.getMode() == WIFI_AP || _currentQueryCount==0 || index>=_currentQueryCount) {
return "";
}
#if defined(ARDUINO_ARCH_ESP32)
tmp = MDNS.hostname(index);
#endif // ARDUINO_ARCH_ESP32
#if defined(ARDUINO_ARCH_ESP8266)
tmp = MDNS.answerHostDomain(_hMDNSServiceQuery,index);
#endif // ARDUINO_ARCH_ESP8266
return tmp.c_str();
}
const char * mDNS_Service::answerIP(uint16_t index)
{
static String tmp;
if(WiFi.getMode() == WIFI_AP || _currentQueryCount==0 || index>=_currentQueryCount) {
return "";
}
#if defined(ARDUINO_ARCH_ESP32)
tmp = MDNS.IP(index).toString();
#endif // ARDUINO_ARCH_ESP32
#if defined(ARDUINO_ARCH_ESP8266)
tmp = MDNS.answerIP4Address(_hMDNSServiceQuery,index,0).toString();
#endif // ARDUINO_ARCH_ESP8266
return tmp.c_str();
}
uint16_t mDNS_Service::answerPort(uint16_t index)
{
if(WiFi.getMode() == WIFI_AP || _currentQueryCount==0 || index>=_currentQueryCount) {
return 0;
}
#if defined(ARDUINO_ARCH_ESP32)
return MDNS.port(index);
#endif // ARDUINO_ARCH_ESP32
#if defined(ARDUINO_ARCH_ESP8266)
return MDNS.answerPort(_hMDNSServiceQuery,index);
#endif // ARDUINO_ARCH_ESP8266
}
uint16_t mDNS_Service::answerTxtCount(uint16_t index)
{
_currentQueryTxtCount =0;
if(WiFi.getMode() == WIFI_AP || _currentQueryCount==0 || index>=_currentQueryCount) {
return _currentQueryTxtCount;
}
#if defined(ARDUINO_ARCH_ESP32)
_currentQueryTxtCount= MDNS.numTxt(index);
return _currentQueryTxtCount;
#endif // ARDUINO_ARCH_ESP32
#if defined(ARDUINO_ARCH_ESP8266)
if (!_hMDNSServiceQuery || !MDNS.hasAnswerTxts(_hMDNSServiceQuery, index)) {
return _currentQueryTxtCount;
}
String txt = MDNS.answerTxts(_hMDNSServiceQuery, index);
for (uint i = 0; i < txt.length(); i++) {
if (txt[i] == ';') {
_currentQueryTxtCount++;
}
}
//there are n+1 number of ';'
_currentQueryTxtCount++;
return _currentQueryTxtCount;
#endif // ARDUINO_ARCH_ESP8266
}
const char* mDNS_Service::answerTxtKey(uint16_t index, uint16_t txtIndex)
{
static String tmp;
if(WiFi.getMode() == WIFI_AP || _currentQueryCount==0 || index>=_currentQueryCount || txtIndex>=_currentQueryTxtCount || _currentQueryTxtCount==0 ) {
return "";
}
#if defined(ARDUINO_ARCH_ESP32)
tmp = MDNS.txtKey(index, txtIndex);
return tmp.c_str();
#endif // ARDUINO_ARCH_ESP32
#if defined(ARDUINO_ARCH_ESP8266)
String txt = MDNS.answerTxts(_hMDNSServiceQuery, index);
log_esp3d("txt: %s", txt.c_str());
String keyValue = "";
bool found = false;
if (txt.indexOf(";") == -1) {
keyValue = txt;
} else {
uint currentIndex = 0;
uint pos = 0;
while (!found) {
int posend = txt.indexOf(";", pos);
if (posend==-1) {
posend=txt.length();
}
keyValue = txt.substring(pos, posend);
if (currentIndex == txtIndex) {
found = true;
} else {
pos=posend+1;
currentIndex++;
}
}
}
for(uint p=0; p<keyValue.length(); p++) {
if(keyValue[p] == '=') {
tmp = keyValue.substring(0,p);
}
}
return tmp.c_str();
#endif // ARDUINO_ARCH_ESP8266
}
const char* mDNS_Service::answerTxt(uint16_t index, uint16_t txtIndex)
{
static String tmp;
if(WiFi.getMode() == WIFI_AP || _currentQueryCount==0 || index>=_currentQueryCount || txtIndex>=_currentQueryTxtCount || _currentQueryTxtCount==0 ) {
return "";
}
#if defined(ARDUINO_ARCH_ESP32)
tmp = MDNS.txt(index, txtIndex);
return tmp.c_str();
#endif // ARDUINO_ARCH_ESP32
#if defined(ARDUINO_ARCH_ESP8266)
String txt = MDNS.answerTxts(_hMDNSServiceQuery, index);
log_esp3d("txt: %s", txt.c_str());
String keyValue = "";
bool found = false;
if (txt.indexOf(";") == -1) {
keyValue = txt;
} else {
uint currentIndex = 0;
uint pos = 0;
while (!found) {
int posend = txt.indexOf(";",pos);
if (posend==-1) {
posend=txt.length();
}
keyValue = txt.substring(pos, posend);
if (currentIndex == txtIndex) {
found = true;
} else {
pos=posend+1;
currentIndex++;
}
}
}
for(uint p=0; p<keyValue.length(); p++) {
if(keyValue[p] == '=') {
tmp = keyValue.substring(p+1,keyValue.length());
}
}
return tmp.c_str();
#endif // ARDUINO_ARCH_ESP8266
}
mDNS_Service::~mDNS_Service()
{
end();
}
#endif //MDNS_FEATURE

View File

@ -0,0 +1,54 @@
/*
mDNS.h - ESP3D mDNS encapsulation class
Copyright (c) 2014 Luc Lebosse. All rights reserved.
This code 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 code 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 code; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _MDNS_H
#define _MDNS_H
#include <Arduino.h>
class mDNS_Service
{
public:
mDNS_Service();
~mDNS_Service();
bool started()
{
return _started;
}
bool begin(const char * hostname);
void end();
void handle();
void addESP3DServices(uint16_t port);
uint16_t servicesCount();
const char* answerHostname(uint16_t index);
const char* answerIP(uint16_t index);
uint16_t answerPort(uint16_t index);
uint16_t answerTxtCount(uint16_t index);
const char* answerTxtKey(uint16_t index, uint16_t txtIndex);
const char* answerTxt(uint16_t index, uint16_t txtIndex);
private:
bool _started;
uint16_t _port;
uint16_t _currentQueryCount;
uint16_t _currentQueryTxtCount;
String _hostname;
#if defined(ARDUINO_ARCH_ESP8266)
const void* _hMDNSServiceQuery;
#endif //ARDUINO_ARCH_ESP8266
};
extern mDNS_Service esp3d_mDNS;
#endif //_MDNS_H

View File

@ -24,18 +24,15 @@
#include "netservices.h"
#include "../../core/settings_esp3d.h"
#include "../../core/esp3doutput.h"
#if defined( ARDUINO_ARCH_ESP8266)
#ifdef MDNS_FEATURE
#include <ESP8266mDNS.h>
#include "../mDNS/mDNS.h"
#endif //MDNS_FEATURE
#if defined( ARDUINO_ARCH_ESP8266)
#ifdef SSDP_FEATURE
#include <ESP8266SSDP.h>
#endif //SSDP_FEATURE
#endif //ARDUINO_ARCH_ESP8266
#if defined( ARDUINO_ARCH_ESP32)
#ifdef MDNS_FEATURE
#include <ESPmDNS.h>
#endif //MDNS_FEATURE
#ifdef SSDP_FEATURE
#include <ESP32SSDP.h>
#endif //SSDP_FEATURE
@ -106,20 +103,7 @@ bool NetServices::begin()
#endif //TIMESTAMP_FEATURE
#if defined(MDNS_FEATURE) && defined(ARDUINO_ARCH_ESP8266)
if(WiFi.getMode() != WIFI_AP) {
String lhostname =hostname;
lhostname.toLowerCase();
log_esp3d("Start mdsn for %s", hostname.c_str());
if (!MDNS.begin(hostname.c_str())) {
output.printERROR("mDNS failed to start");
_started =false;
} else {
String stmp = "mDNS started with '" + lhostname + ".local'";
if (Settings_ESP3D::isVerboseBoot()) {
output.printMSG(stmp.c_str());
}
}
}
esp3d_mDNS.begin(hostname.c_str());
#endif //MDNS_FEATURE && ARDUINO_ARCH_ESP8266
#ifdef OTA_FEATURE
@ -176,19 +160,7 @@ bool NetServices::begin()
#endif
#if defined(MDNS_FEATURE) && defined(ARDUINO_ARCH_ESP32)
if(WiFi.getMode() != WIFI_AP) {
String lhostname =hostname;
lhostname.toLowerCase();
if (!MDNS.begin(hostname.c_str())) {
output.printERROR("mDNS failed to start");
_started =false;
} else {
String stmp = "mDNS started with '" + lhostname + ".local'";
if (Settings_ESP3D::isVerboseBoot()) {
output.printMSG(stmp.c_str());
}
}
}
esp3d_mDNS.begin(hostname.c_str());
#endif //MDNS_FEATURE && ARDUINO_ARCH_ESP8266
#ifdef CAPTIVE_PORTAL_FEATURE
@ -274,17 +246,7 @@ bool NetServices::begin()
}
#endif //HTTP_FEATURE
#ifdef MDNS_FEATURE
if(WiFi.getMode() != WIFI_AP) {
// Add service to MDNS-SD
log_esp3d("Add mdns service http / tcp port %d", HTTP_Server::port());
MDNS.addService("http", "tcp", HTTP_Server::port());
//ESP3D service
//TODO list all services available (http/tcp/ws/ftp/webdav/etc...)
MDNS.addService("esp3d", "tcp", HTTP_Server::port());
MDNS.addServiceTxt("esp3d", "tcp", "version", FW_VERSION);
//Add TXT records
MDNS.addServiceTxt("http", "tcp", "ESP3D", FW_VERSION);
}
esp3d_mDNS.addESP3DServices(HTTP_Server::port());
#endif //MDNS_FEATURE
#ifdef SSDP_FEATURE
//SSDP service presentation
@ -359,24 +321,7 @@ void NetServices::end()
#endif //ARDUINO_ARCH_ESP32
#endif //SSDP_FEATURE
#ifdef MDNS_FEATURE
if(WiFi.getMode() != WIFI_AP) {
#if defined(ARDUINO_ARCH_ESP8266)
String hostname = Settings_ESP3D::read_string(ESP_HOSTNAME);
hostname.toLowerCase();
log_esp3d("Remove mdns for %s", hostname.c_str());
if (!MDNS.removeService(hostname.c_str(),"http", "tcp")) {
log_esp3d("failed");
}
if (!MDNS.removeService(hostname.c_str(),"esp3d", "tcp")) {
log_esp3d("failed");
}
#endif // ARDUINO_ARCH_ESP8266
#if defined(ARDUINO_ARCH_ESP32)
mdns_service_remove("_http", "_tcp");
mdns_service_remove("_esp3d", "_tcp");
#endif // ARDUINO_ARCH_ESP32
MDNS.end();
}
esp3d_mDNS.end();
#endif //MDNS_FEATURE
#ifdef OTA_FEATURE
@ -413,9 +358,7 @@ void NetServices::handle()
MKSService::handle();
#endif //COMMUNICATION_PROTOCOL == MKS_SERIAL
#ifdef MDNS_FEATURE
#if defined(ARDUINO_ARCH_ESP8266)
MDNS.update();
#endif //ARDUINO_ARCH_ESP8266
esp3d_mDNS.handle();
#endif //MDNS_FEATURE
#ifdef OTA_FEATURE
ArduinoOTA.handle();