mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-11 17:49:03 +08:00
echo to websocket : serial in and out
This commit is contained in:
parent
44747339dd
commit
6df87a9602
187
esp3d/config.h
187
esp3d/config.h
@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
//version and sources location
|
//version and sources location
|
||||||
#define FW_VERSION "2.1.1.b1"
|
#define FW_VERSION "2.1.1.b2"
|
||||||
#define REPOSITORY "https://github.com/luc-github/ESP3D"
|
#define REPOSITORY "https://github.com/luc-github/ESP3D"
|
||||||
|
|
||||||
//Customize ESP3D ////////////////////////////////////////////////////////////////////////
|
//Customize ESP3D ////////////////////////////////////////////////////////////////////////
|
||||||
@ -128,7 +128,7 @@
|
|||||||
#define OLED_DISPLAY_SSD1306 // OLED Display Type: SSD1306(OLED_DISPLAY_SSD1306) / SH1106(OLED_DISPLAY_SH1106), comment this line out to disable oled
|
#define OLED_DISPLAY_SSD1306 // OLED Display Type: SSD1306(OLED_DISPLAY_SSD1306) / SH1106(OLED_DISPLAY_SH1106), comment this line out to disable oled
|
||||||
#define OLED_PIN_SDA 4 //5 //SDA; // i2c SDA Pin
|
#define OLED_PIN_SDA 4 //5 //SDA; // i2c SDA Pin
|
||||||
#define OLED_PIN_SCL 15 //4 //SCL; // i2c SCL Pin
|
#define OLED_PIN_SCL 15 //4 //SCL; // i2c SCL Pin
|
||||||
#define OLED_ADDR 0x3c
|
#define OLED_ADDR 0x3c
|
||||||
#define HELTEC_EMBEDDED_PIN 16 //0 to disable
|
#define HELTEC_EMBEDDED_PIN 16 //0 to disable
|
||||||
#define OLED_FLIP_VERTICALY 1 //0 to disable
|
#define OLED_FLIP_VERTICALY 1 //0 to disable
|
||||||
#endif
|
#endif
|
||||||
@ -136,12 +136,12 @@
|
|||||||
|
|
||||||
//Supported FW /////////////////////////////////////////////////////////////
|
//Supported FW /////////////////////////////////////////////////////////////
|
||||||
#define UNKNOWN_FW 0
|
#define UNKNOWN_FW 0
|
||||||
#define REPETIER4DV 1
|
#define REPETIER4DV 1
|
||||||
#define MARLIN 2
|
#define MARLIN 2
|
||||||
#define MARLINKIMBRA 3
|
#define MARLINKIMBRA 3
|
||||||
#define SMOOTHIEWARE 4
|
#define SMOOTHIEWARE 4
|
||||||
#define REPETIER 5
|
#define REPETIER 5
|
||||||
#define GRBL 6
|
#define GRBL 6
|
||||||
#define MAX_FW_ID 6
|
#define MAX_FW_ID 6
|
||||||
|
|
||||||
//Do not Edit after this line //////////////////////////////////////////////
|
//Do not Edit after this line //////////////////////////////////////////////
|
||||||
@ -152,6 +152,7 @@
|
|||||||
//#define DEBUG_OUTPUT_SPIFFS
|
//#define DEBUG_OUTPUT_SPIFFS
|
||||||
//#define DEBUG_OUTPUT_SERIAL
|
//#define DEBUG_OUTPUT_SERIAL
|
||||||
//#define DEBUG_OUTPUT_TCP
|
//#define DEBUG_OUTPUT_TCP
|
||||||
|
#define DEBUG_OUTPUT_SOCKET
|
||||||
|
|
||||||
//Sanity check
|
//Sanity check
|
||||||
#ifndef SDCARD_FEATURE
|
#ifndef SDCARD_FEATURE
|
||||||
@ -290,49 +291,49 @@ typedef enum {
|
|||||||
|
|
||||||
|
|
||||||
//flags
|
//flags
|
||||||
#define AP_MODE 1
|
#define AP_MODE 1
|
||||||
#define CLIENT_MODE 2
|
#define CLIENT_MODE 2
|
||||||
#define DHCP_MODE 1
|
#define DHCP_MODE 1
|
||||||
#define STATIC_IP_MODE 2
|
#define STATIC_IP_MODE 2
|
||||||
|
|
||||||
//position in EEPROM
|
//position in EEPROM
|
||||||
//AP mode = 1; Station client mode = 2
|
//AP mode = 1; Station client mode = 2
|
||||||
#define EP_WIFI_MODE 0 //1 byte = flag
|
#define EP_WIFI_MODE 0 //1 byte = flag
|
||||||
#define EP_STA_SSID 1 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese
|
#define EP_STA_SSID 1 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese
|
||||||
#define EP_STA_PASSWORD 34 //65 bytes 64 +1 = string ;warning does not support multibyte char like chinese
|
#define EP_STA_PASSWORD 34 //65 bytes 64 +1 = string ;warning does not support multibyte char like chinese
|
||||||
#define EP_STA_IP_MODE 99 //1 byte = flag
|
#define EP_STA_IP_MODE 99 //1 byte = flag
|
||||||
#define EP_STA_IP_VALUE 100 //4 bytes xxx.xxx.xxx.xxx
|
#define EP_STA_IP_VALUE 100 //4 bytes xxx.xxx.xxx.xxx
|
||||||
#define EP_STA_MASK_VALUE 104 //4 bytes xxx.xxx.xxx.xxx
|
#define EP_STA_MASK_VALUE 104 //4 bytes xxx.xxx.xxx.xxx
|
||||||
#define EP_STA_GATEWAY_VALUE 108 //4 bytes xxx.xxx.xxx.xxx
|
#define EP_STA_GATEWAY_VALUE 108 //4 bytes xxx.xxx.xxx.xxx
|
||||||
#define EP_BAUD_RATE 112 //4 bytes = int
|
#define EP_BAUD_RATE 112 //4 bytes = int
|
||||||
#define EP_STA_PHY_MODE 116 //1 byte = flag
|
#define EP_STA_PHY_MODE 116 //1 byte = flag
|
||||||
#define EP_SLEEP_MODE 117 //1 byte = flag
|
#define EP_SLEEP_MODE 117 //1 byte = flag
|
||||||
#define EP_CHANNEL 118 //1 byte = flag
|
#define EP_CHANNEL 118 //1 byte = flag
|
||||||
#define EP_AUTH_TYPE 119 //1 byte = flag
|
#define EP_AUTH_TYPE 119 //1 byte = flag
|
||||||
#define EP_SSID_VISIBLE 120 //1 byte = flag
|
#define EP_SSID_VISIBLE 120 //1 byte = flag
|
||||||
#define EP_WEB_PORT 121 //4 bytes = int
|
#define EP_WEB_PORT 121 //4 bytes = int
|
||||||
#define EP_DATA_PORT 125 //4 bytes = int
|
#define EP_DATA_PORT 125 //4 bytes = int
|
||||||
#define EP_OUTPUT_FLAG 129 //1 bytes = flag
|
#define EP_OUTPUT_FLAG 129 //1 bytes = flag
|
||||||
#define EP_HOSTNAME 130//33 bytes 32+1 = string ; warning does not support multibyte char like chinese
|
#define EP_HOSTNAME 130//33 bytes 32+1 = string ; warning does not support multibyte char like chinese
|
||||||
#define EP_DHT_INTERVAL 164//4 bytes = int
|
#define EP_DHT_INTERVAL 164//4 bytes = int
|
||||||
#define ESP_NOTIFICATION_TYPE 168 //1 byte = flag
|
#define ESP_NOTIFICATION_TYPE 168 //1 byte = flag
|
||||||
#define ESP_AUTO_NOTIFICATION 170//1 bytes = flag
|
#define ESP_AUTO_NOTIFICATION 170//1 bytes = flag
|
||||||
#define EP_FREE_BYTE1 171//1 bytes = flag
|
#define EP_FREE_BYTE1 171//1 bytes = flag
|
||||||
#define EP_FREE_INT3 172//4 bytes = int
|
#define EP_FREE_INT3 172//4 bytes = int
|
||||||
#define EP_ADMIN_PWD 176//21 bytes 20+1 = string ; warning does not support multibyte char like chinese
|
#define EP_ADMIN_PWD 176//21 bytes 20+1 = string ; warning does not support multibyte char like chinese
|
||||||
#define EP_USER_PWD 197//21 bytes 20+1 = string ; warning does not support multibyte char like chinese
|
#define EP_USER_PWD 197//21 bytes 20+1 = string ; warning does not support multibyte char like chinese
|
||||||
#define EP_AP_SSID 218 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese
|
#define EP_AP_SSID 218 //33 bytes 32+1 = string ; warning does not support multibyte char like chinese
|
||||||
#define EP_AP_PASSWORD 251 //65 bytes 64 +1 = string ;warning does not support multibyte char like chinese
|
#define EP_AP_PASSWORD 251 //65 bytes 64 +1 = string ;warning does not support multibyte char like chinese
|
||||||
#define EP_AP_IP_VALUE 316 //4 bytes xxx.xxx.xxx.xxx
|
#define EP_AP_IP_VALUE 316 //4 bytes xxx.xxx.xxx.xxx
|
||||||
#define EP_AP_MASK_VALUE 320 //4 bytes xxx.xxx.xxx.xxx
|
#define EP_AP_MASK_VALUE 320 //4 bytes xxx.xxx.xxx.xxx
|
||||||
#define EP_AP_GATEWAY_VALUE 324 //4 bytes xxx.xxx.xxx.xxx
|
#define EP_AP_GATEWAY_VALUE 324 //4 bytes xxx.xxx.xxx.xxx
|
||||||
#define EP_AP_IP_MODE 329 //1 byte = flag
|
#define EP_AP_IP_MODE 329 //1 byte = flag
|
||||||
#define EP_AP_PHY_MODE 330 //1 byte = flag
|
#define EP_AP_PHY_MODE 330 //1 byte = flag
|
||||||
#define EP_SD_SPEED_DIV 331 //1 byte = flag
|
#define EP_SD_SPEED_DIV 331 //1 byte = flag
|
||||||
#define ESP_NOTIFICATION_TOKEN1 332 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
|
#define ESP_NOTIFICATION_TOKEN1 332 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
|
||||||
#define ESP_NOTIFICATION_TOKEN2 396 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
|
#define ESP_NOTIFICATION_TOKEN2 396 //64 bytes 63+1 = string ; warning does not support multibyte char like chinese
|
||||||
#define EP_DHT_TYPE 460 //1 bytes = flag
|
#define EP_DHT_TYPE 460 //1 bytes = flag
|
||||||
#define EP_TARGET_FW 461 //1 bytes = flag
|
#define EP_TARGET_FW 461 //1 bytes = flag
|
||||||
#define EP_TIMEZONE 462//1 bytes = flag
|
#define EP_TIMEZONE 462//1 bytes = flag
|
||||||
#define EP_TIME_ISDST 463//1 bytes = flag
|
#define EP_TIME_ISDST 463//1 bytes = flag
|
||||||
#define EP_TIME_SERVER1 464//129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
#define EP_TIME_SERVER1 464//129 bytes 128+1 = string ; warning does not support multibyte char like chinese
|
||||||
@ -350,35 +351,35 @@ typedef enum {
|
|||||||
#define LAST_EEPROM_ADDRESS 983
|
#define LAST_EEPROM_ADDRESS 983
|
||||||
|
|
||||||
//default values
|
//default values
|
||||||
#define DEFAULT_WIFI_MODE AP_MODE
|
#define DEFAULT_WIFI_MODE AP_MODE
|
||||||
const char DEFAULT_AP_SSID [] PROGMEM = "ESP3D";
|
const char DEFAULT_AP_SSID [] PROGMEM = "ESP3D";
|
||||||
const char DEFAULT_AP_PASSWORD [] PROGMEM = "12345678";
|
const char DEFAULT_AP_PASSWORD [] PROGMEM = "12345678";
|
||||||
const char DEFAULT_STA_SSID [] PROGMEM = "ESP3D";
|
const char DEFAULT_STA_SSID [] PROGMEM = "ESP3D";
|
||||||
const char DEFAULT_STA_PASSWORD [] PROGMEM = "12345678";
|
const char DEFAULT_STA_PASSWORD [] PROGMEM = "12345678";
|
||||||
const byte DEFAULT_STA_IP_MODE = DHCP_MODE;
|
const byte DEFAULT_STA_IP_MODE = DHCP_MODE;
|
||||||
const byte DEFAULT_AP_IP_MODE = STATIC_IP_MODE;
|
const byte DEFAULT_AP_IP_MODE = STATIC_IP_MODE;
|
||||||
const byte DEFAULT_IP_VALUE[] = {192, 168, 0, 1};
|
const byte DEFAULT_IP_VALUE[] = {192, 168, 0, 1};
|
||||||
const byte DEFAULT_MASK_VALUE[] = {255, 255, 255, 0};
|
const byte DEFAULT_MASK_VALUE[] = {255, 255, 255, 0};
|
||||||
#define DEFAULT_GATEWAY_VALUE DEFAULT_IP_VALUE
|
#define DEFAULT_GATEWAY_VALUE DEFAULT_IP_VALUE
|
||||||
const long DEFAULT_BAUD_RATE = 115200;
|
const long DEFAULT_BAUD_RATE = 115200;
|
||||||
#define DEFAULT_PHY_MODE WIFI_PHY_MODE_11G
|
#define DEFAULT_PHY_MODE WIFI_PHY_MODE_11G
|
||||||
#define DEFAULT_SLEEP_MODE WIFI_MODEM_SLEEP
|
#define DEFAULT_SLEEP_MODE WIFI_MODEM_SLEEP
|
||||||
#define DEFAULT_CHANNEL 11
|
#define DEFAULT_CHANNEL 11
|
||||||
#define DEFAULT_AUTH_TYPE AUTH_WPA_PSK
|
#define DEFAULT_AUTH_TYPE AUTH_WPA_PSK
|
||||||
#define DEFAULT_SSID_VISIBLE 1
|
#define DEFAULT_SSID_VISIBLE 1
|
||||||
#define DEFAULT_MAX_CONNECTIONS 4
|
#define DEFAULT_MAX_CONNECTIONS 4
|
||||||
#define DEFAULT_BEACON_INTERVAL 100
|
#define DEFAULT_BEACON_INTERVAL 100
|
||||||
const int DEFAULT_WEB_PORT = 80;
|
const int DEFAULT_WEB_PORT = 80;
|
||||||
const int DEFAULT_DATA_PORT = 8888;
|
const int DEFAULT_DATA_PORT = 8888;
|
||||||
const char DEFAULT_ADMIN_PWD [] PROGMEM = "admin";
|
const char DEFAULT_ADMIN_PWD [] PROGMEM = "admin";
|
||||||
const char DEFAULT_USER_PWD [] PROGMEM = "user";
|
const char DEFAULT_USER_PWD [] PROGMEM = "user";
|
||||||
const char DEFAULT_ADMIN_LOGIN [] PROGMEM = "admin";
|
const char DEFAULT_ADMIN_LOGIN [] PROGMEM = "admin";
|
||||||
const char DEFAULT_USER_LOGIN [] PROGMEM = "user";
|
const char DEFAULT_USER_LOGIN [] PROGMEM = "user";
|
||||||
const char DEFAULT_TIME_SERVER1 [] PROGMEM = "1.pool.ntp.org";
|
const char DEFAULT_TIME_SERVER1 [] PROGMEM = "1.pool.ntp.org";
|
||||||
const char DEFAULT_TIME_SERVER2 [] PROGMEM = "2.pool.ntp.org";
|
const char DEFAULT_TIME_SERVER2 [] PROGMEM = "2.pool.ntp.org";
|
||||||
const char DEFAULT_TIME_SERVER3 [] PROGMEM = "0.pool.ntp.org";
|
const char DEFAULT_TIME_SERVER3 [] PROGMEM = "0.pool.ntp.org";
|
||||||
#define DEFAULT_TIME_ZONE 0
|
#define DEFAULT_TIME_ZONE 0
|
||||||
#define DEFAULT_TIME_DST 0
|
#define DEFAULT_TIME_DST 0
|
||||||
#define DEFAULT_PRIMARY_SD 2
|
#define DEFAULT_PRIMARY_SD 2
|
||||||
#define DEFAULT_SECONDARY_SD 1
|
#define DEFAULT_SECONDARY_SD 1
|
||||||
#define DEFAULT_DIRECT_SD_CHECK 0
|
#define DEFAULT_DIRECT_SD_CHECK 0
|
||||||
@ -401,9 +402,9 @@ const int DEFAULT_DHT_INTERVAL = 30;
|
|||||||
#define NOTIFICATION_ESP_ONLINE "Hi, %ESP_NAME% is now online at %ESP_IP%"
|
#define NOTIFICATION_ESP_ONLINE "Hi, %ESP_NAME% is now online at %ESP_IP%"
|
||||||
|
|
||||||
//Notifications
|
//Notifications
|
||||||
#define ESP_PUSHOVER_NOTIFICATION 1
|
#define ESP_PUSHOVER_NOTIFICATION 1
|
||||||
#define ESP_EMAIL_NOTIFICATION 2
|
#define ESP_EMAIL_NOTIFICATION 2
|
||||||
#define ESP_LINE_NOTIFICATION 3
|
#define ESP_LINE_NOTIFICATION 3
|
||||||
|
|
||||||
#ifdef SDCARD_FEATURE
|
#ifdef SDCARD_FEATURE
|
||||||
#define DEFAULT_IS_DIRECT_SD 1
|
#define DEFAULT_IS_DIRECT_SD 1
|
||||||
@ -473,29 +474,29 @@ const uint16_t Setting[][2] = {
|
|||||||
#define FLAG_BLOCK_TCP 0x010
|
#define FLAG_BLOCK_TCP 0x010
|
||||||
|
|
||||||
//values
|
//values
|
||||||
#define DEFAULT_MAX_WEB_PORT 65001
|
#define DEFAULT_MAX_WEB_PORT 65001
|
||||||
#define DEFAULT_MIN_WEB_PORT 1
|
#define DEFAULT_MIN_WEB_PORT 1
|
||||||
#define DEFAULT_MAX_DATA_PORT 65001
|
#define DEFAULT_MAX_DATA_PORT 65001
|
||||||
#define DEFAULT_MIN_DATA_PORT 1
|
#define DEFAULT_MIN_DATA_PORT 1
|
||||||
|
|
||||||
#define MAX_TRY 2000
|
#define MAX_TRY 2000
|
||||||
|
|
||||||
//sizes
|
//sizes
|
||||||
#define EEPROM_SIZE 1024 //max is 1024
|
#define EEPROM_SIZE 1024 //max is 1024
|
||||||
#define MAX_SSID_LENGTH 32
|
#define MAX_SSID_LENGTH 32
|
||||||
#define MIN_SSID_LENGTH 1
|
#define MIN_SSID_LENGTH 1
|
||||||
#define MAX_PASSWORD_LENGTH 64
|
#define MAX_PASSWORD_LENGTH 64
|
||||||
//min size of password is 0 or upper than 8 char
|
//min size of password is 0 or upper than 8 char
|
||||||
//so let set min is 0
|
//so let set min is 0
|
||||||
#define MIN_PASSWORD_LENGTH 0
|
#define MIN_PASSWORD_LENGTH 0
|
||||||
#define MAX_LOCAL_PASSWORD_LENGTH 16
|
#define MAX_LOCAL_PASSWORD_LENGTH 16
|
||||||
#define MIN_LOCAL_PASSWORD_LENGTH 1
|
#define MIN_LOCAL_PASSWORD_LENGTH 1
|
||||||
#define MAX_DATA_LENGTH 128
|
#define MAX_DATA_LENGTH 128
|
||||||
#define MIN_DATA_LENGTH 0
|
#define MIN_DATA_LENGTH 0
|
||||||
#define IP_LENGTH 4
|
#define IP_LENGTH 4
|
||||||
#define INTEGER_LENGTH 4
|
#define INTEGER_LENGTH 4
|
||||||
#define MAX_HOSTNAME_LENGTH 32
|
#define MAX_HOSTNAME_LENGTH 32
|
||||||
#define MIN_HOSTNAME_LENGTH 1
|
#define MIN_HOSTNAME_LENGTH 1
|
||||||
#define WL_MAC_ADDR_LENGTH 6
|
#define WL_MAC_ADDR_LENGTH 6
|
||||||
|
|
||||||
//EEPROM Version
|
//EEPROM Version
|
||||||
|
@ -65,8 +65,15 @@ long ESPCOM::readBytes (tpipe output, uint8_t * sbuf, size_t len)
|
|||||||
{
|
{
|
||||||
switch (output) {
|
switch (output) {
|
||||||
#ifdef USE_SERIAL_0
|
#ifdef USE_SERIAL_0
|
||||||
case SERIAL_PIPE:
|
case SERIAL_PIPE:{
|
||||||
return Serial.readBytes(sbuf,len);
|
long l = Serial.readBytes(sbuf,len);
|
||||||
|
#ifdef DEBUG_OUTPUT_SOCKET
|
||||||
|
if(socket_server){
|
||||||
|
socket_server->sendBIN(ESPCOM::current_socket_id,sbuf,len);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return l;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_SERIAL_1
|
#ifdef USE_SERIAL_1
|
||||||
@ -243,6 +250,11 @@ void ESPCOM::print (const char * data, tpipe output, ESPResponseStream *espresp
|
|||||||
switch (output) {
|
switch (output) {
|
||||||
#ifdef USE_SERIAL_0
|
#ifdef USE_SERIAL_0
|
||||||
case SERIAL_PIPE:
|
case SERIAL_PIPE:
|
||||||
|
#ifdef DEBUG_OUTPUT_SOCKET
|
||||||
|
if(socket_server){
|
||||||
|
socket_server->sendBIN(ESPCOM::current_socket_id,(const uint8_t*)data,strlen(data));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Serial.print (data);
|
Serial.print (data);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
@ -288,7 +300,9 @@ void ESPCOM::print (const char * data, tpipe output, ESPResponseStream *espresp
|
|||||||
#if defined(ASYNCWEBSERVER)
|
#if defined(ASYNCWEBSERVER)
|
||||||
//Todo
|
//Todo
|
||||||
#else
|
#else
|
||||||
socket_server->sendBIN(current_socket_id,(const uint8_t *)data,strlen(data));
|
if(socket_server){
|
||||||
|
socket_server->sendBIN(current_socket_id,(const uint8_t *)data,strlen(data));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -406,7 +420,11 @@ bool ESPCOM::processFromSerial (bool async)
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (!CONFIG::is_locked(FLAG_BLOCK_WSOCKET) && socket_server) {
|
if (!CONFIG::is_locked(FLAG_BLOCK_WSOCKET) && socket_server) {
|
||||||
socket_server->sendBIN(current_socket_id,sbuf,len);
|
#ifndef DEBUG_OUTPUT_SOCKET
|
||||||
|
if(socket_server){
|
||||||
|
socket_server->sendBIN(current_socket_id,sbuf,len);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user