31 typedef enum {
OK = 0,
50 const int serverSocketPort,
52 size_t readBufferSize = 1024 );
65 const char* espServerAddr,
66 const int espServerPort,
68 size_t readBufferSize = 1024 );
203 return "unrecognized-esp-stream";
236 return "ES_FILTERING";
240 return "ES_FILTERING_ERR";
242 return "ES_PROCESSING";
244 return "ES_PROCESS_FAILED";
246 return "ES_PROCESSED";
248 return "ES_UNLOADING";
250 return "(invalid EspState)";
256 if( strcmp(
"IDLE", str ) == 0 )
return ES_IDLE;
257 if( strcmp(
"LOADING", str ) == 0 )
return ES_LOADING;
258 if( strcmp(
"READY", str ) == 0 )
return ES_READY;
259 if( strcmp(
"FILTERING", str ) == 0 )
return ES_FILTERING;
260 if( strcmp(
"PAUSED", str ) == 0 )
return ES_PAUSED;
264 if( strcmp(
"PROCESSED", str ) == 0 )
return ES_PROCESSED;
265 if( strcmp(
"UNLOADING", str ) == 0 )
return ES_UNLOADING;
330 int sendLine(
const char* buffer,
size_t bufferSize = 0xFFFFFFFF );
339 Str escape(
const char* buffer,
size_t bufferSize = 0xFFFFFFFF );
396 int sendLineAux(
Socket* socket,
const char* buffer,
size_t bufferSize = 0xFFFFFFFF );
Client-side interface for injecting log data into the log queue.
Definition: Logger.h:30
EspStream currentStream_
Definition: ESPComm.h:377
Definition: ESPComm.h:177
A wrapper around sys/socket.h for tcp communications between Socket instances – use daughter classes...
Definition: Socket.h:33
bool hasEspServerAddressAndPort()
Do we already know the address and port where the ESP is/will be running as server?
Definition: ESPComm.h:122
Socket * socketClient_
Definition: ESPComm.h:372
virtual bool isWritable()
Definition: ESPComm.h:163
virtual bool eof()
Definition: ESPComm.h:158
ESPComm::Error lastError_
Definition: ESPComm.h:387
LineReader class declaration.
Definition: ESPComm.h:178
Str lastResult_
Definition: ESPComm.h:379
ESPComm & open()
Starts the server on the given port.
Definition: ESPComm.cpp:90
Definition: ESPComm.h:220
virtual bool isReadable()
Definition: ESPComm.h:153
Definition: ESPComm.h:214
void logError(Str msg)
Definition: ESPComm.cpp:599
Definition: ESPComm.h:210
EspState
Definition: ESPComm.h:208
bool onlyLog_
Definition: ESPComm.h:392
void setDebug(bool debugOn)
Definition: ESPComm.h:354
Str * getLastResult()
Gets the last result received from the ESP.
Definition: ESPComm.cpp:491
int readLine(char *buffer, size_t bufferSize, EspStream *stream=0)
Reads a line (non-blocking) from the ESP.
Definition: ESPComm.cpp:362
Str showEspServerAddressAndPort()
log helper: "address:port" string with the espServerAddr_ and espServerPort fields.
Definition: ESPComm.h:130
ESPComm & submitAbort()
Issues command to request the ESP to interrupt the thread associated with this client.
Definition: ESPComm.cpp:291
Utility for the concrete concern of reading lines from a given file descriptor in a non-blocking fash...
Definition: LineReader.h:26
Str * getLastException()
Gets the last exception received from the ESP.
Definition: ESPComm.cpp:503
Base socket-level interface to the ESP.
Definition: ESPComm.h:26
Str espServerAddr_
Definition: ESPComm.h:369
Contains the SocketServer class declaration.
size_t length() const
Definition: Str.h:196
SocketServer * socketServer_
Definition: ESPComm.h:367
Definition: ESPComm.h:217
void logDebug(Str msg)
Definition: ESPComm.cpp:593
int espServerPort_
Definition: ESPComm.h:370
const char * streamName(EspStream stream)
Definition: ESPComm.h:182
EspState espStateFromReportedString(const char *str)
Definition: ESPComm.h:254
Str lastException_
Definition: ESPComm.h:382
const char * errorString()
Definition: ESPComm.cpp:605
bool debug_
Definition: ESPComm.h:394
void setEspLogFile(const char *path, bool onlyLog=true)
Received lines from the ESP are reported in the given file.
Definition: ESPComm.cpp:342
Definition: ESPComm.h:216
Definition: ESPComm.h:212
ESPComm(Str name, const int serverSocketPort, Logger &logger, size_t readBufferSize=1024)
Constructor for when the LRAUV is to act as the server in the socket communication.
Definition: ESPComm.cpp:14
Str escape(const char *buffer, size_t bufferSize=0xFFFFFFFF)
Debugging utility: returns a readable version of contents received from the ESP.
Definition: ESPComm.cpp:515
Error
Errors.
Definition: ESPComm.h:31
int serverSocketPort_
Definition: ESPComm.h:366
ESPComm & acceptClient(int timeoutMillis=0)
Client connection accept with timeout (0 by default)
Definition: ESPComm.cpp:124
Logger logger_
Definition: ESPComm.h:389
Definition: ESPComm.h:175
ESPComm::Error getError()
get last error
Definition: ESPComm.h:342
Replacement for standard template class string.
Definition: Str.h:12
Contains the SocketClient class declaration.
void syslog(const char *msg, Syslog::Severity sev=Syslog::DEBUG)
Create a syslog entry, push into queue, C char* version.
Definition: Logger.cpp:67
Definition: ESPComm.h:173
EspState getEspState()
Definition: ESPComm.h:291
~ESPComm()
Destructor.
Definition: ESPComm.cpp:79
Definition: ESPComm.h:211
EspStream
the ESP virtual streams
Definition: ESPComm.h:169
Definition: ESPComm.h:219
Implements a listening Socket server.
Definition: SocketServer.h:19
Definition: ESPComm.h:179
std::ofstream * espLogFile_
Definition: ESPComm.h:391
Contains the Logger class definition.
Definition: ESPComm.h:171
Definition: ESPComm.h:213
ESPComm & setEspServerAddressAndPort(Str espServerAddr, const int espServerPort)
Sets the address and port of the ESP server.
Definition: ESPComm.cpp:283
size_t readBufferSize_
Definition: ESPComm.h:375
int sendLine(const char *buffer, size_t bufferSize=0xFFFFFFFF)
Sends a single line to the ESP.
Definition: ESPComm.cpp:559
Str getPeerAddress()
Gets the address of peer connected to the client socket.
Definition: ESPComm.cpp:183
int sendLineAux(Socket *socket, const char *buffer, size_t bufferSize=0xFFFFFFFF)
Definition: ESPComm.cpp:564
EspState espState_
Definition: ESPComm.h:385
bool lastExceptionComplete_
Definition: ESPComm.h:383
bool isClientConnected()
is a client connected?
Definition: ESPComm.h:145
Definition: ESPComm.h:215
LineReader * lineReader_
Definition: ESPComm.h:374
Definition: ESPComm.h:174
Str name_
Definition: ESPComm.h:364
Definition: ESPComm.h:218
ESPComm & close()
Closes underlying sockets.
Definition: ESPComm.cpp:316
bool lastResultComplete_
Definition: ESPComm.h:380
Definition: ESPComm.h:172
bool hasError()
Definition: ESPComm.h:347
ESPComm & connectAsClient()
Can be called when hasEspServerAddressAndPort is true.
Definition: ESPComm.cpp:214
const char * espStateName(EspState espState)
Definition: ESPComm.h:223
EspStream getCurrentStream()
Definition: ESPComm.h:296
Definition: ESPComm.h:176