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
@ -19,7 +19,7 @@
|
||||
*/
|
||||
|
||||
//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"
|
||||
|
||||
//Customize ESP3D ////////////////////////////////////////////////////////////////////////
|
||||
@ -152,6 +152,7 @@
|
||||
//#define DEBUG_OUTPUT_SPIFFS
|
||||
//#define DEBUG_OUTPUT_SERIAL
|
||||
//#define DEBUG_OUTPUT_TCP
|
||||
#define DEBUG_OUTPUT_SOCKET
|
||||
|
||||
//Sanity check
|
||||
#ifndef SDCARD_FEATURE
|
||||
|
@ -65,8 +65,15 @@ long ESPCOM::readBytes (tpipe output, uint8_t * sbuf, size_t len)
|
||||
{
|
||||
switch (output) {
|
||||
#ifdef USE_SERIAL_0
|
||||
case SERIAL_PIPE:
|
||||
return Serial.readBytes(sbuf,len);
|
||||
case SERIAL_PIPE:{
|
||||
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;
|
||||
#endif
|
||||
#ifdef USE_SERIAL_1
|
||||
@ -243,6 +250,11 @@ void ESPCOM::print (const char * data, tpipe output, ESPResponseStream *espresp
|
||||
switch (output) {
|
||||
#ifdef USE_SERIAL_0
|
||||
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);
|
||||
break;
|
||||
#endif
|
||||
@ -288,7 +300,9 @@ void ESPCOM::print (const char * data, tpipe output, ESPResponseStream *espresp
|
||||
#if defined(ASYNCWEBSERVER)
|
||||
//Todo
|
||||
#else
|
||||
if(socket_server){
|
||||
socket_server->sendBIN(current_socket_id,(const uint8_t *)data,strlen(data));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
@ -406,9 +420,13 @@ bool ESPCOM::processFromSerial (bool async)
|
||||
}
|
||||
#else
|
||||
if (!CONFIG::is_locked(FLAG_BLOCK_WSOCKET) && socket_server) {
|
||||
#ifndef DEBUG_OUTPUT_SOCKET
|
||||
if(socket_server){
|
||||
socket_server->sendBIN(current_socket_id,sbuf,len);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
//process data if any
|
||||
|
Loading…
x
Reference in New Issue
Block a user