mirror of
https://git.mirrors.martin98.com/https://github.com/luc-github/ESP3D.git
synced 2025-08-12 00:08:58 +08:00
echo to websocket : serial in and out
This commit is contained in:
parent
44747339dd
commit
6df87a9602
@ -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 ////////////////////////////////////////////////////////////////////////
|
||||||
@ -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
|
||||||
|
@ -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
|
||||||
|
if(socket_server){
|
||||||
socket_server->sendBIN(current_socket_id,(const uint8_t *)data,strlen(data));
|
socket_server->sendBIN(current_socket_id,(const uint8_t *)data,strlen(data));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -406,9 +420,13 @@ 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) {
|
||||||
|
#ifndef DEBUG_OUTPUT_SOCKET
|
||||||
|
if(socket_server){
|
||||||
socket_server->sendBIN(current_socket_id,sbuf,len);
|
socket_server->sendBIN(current_socket_id,sbuf,len);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
//process data if any
|
//process data if any
|
||||||
|
Loading…
x
Reference in New Issue
Block a user