12char *
const tcpServer
PROGMEM =
"192.168.0.102";
15uint16_t
const tcpPort
PROGMEM = 7002;
22SC16IS750
i2cuart = SC16IS750(SC16IS750_PROTOCOL_I2C,SC16IS750_ADDRESS_AA);
65char*
const errTxt[]
PROGMEM = {
"No error, everything OK.",
"Out of memory.",
"Unknown code.",
"Timeout.",
"Routing problem.",
"Operation in progress.",
66 "Unknown code.",
"Total number exceeds the maximum limitation.",
"Connection aborted.",
"Connection reset.",
"Connection closed.",
67 "Not connected.",
"Illegal argument.",
"Unknown code.",
"UDP send error.",
"Already connected."};
69 commError = commError*-1;
70 if (commError <= 15) {
71 return (
char *) pgm_read_word (&errTxt[commError]);
73 return (
char *) pgm_read_word (&errTxt[2]);
79void tcpCb(uint8_t resp_type, uint8_t client_num, uint16_t len,
char *data) {
80 Serial.println(
"tcpCb connection #"+String(client_num));
82 Serial.println(
"\tSent " + String(len) +
" bytes over client#" + String(client_num));
85 memcpy(recvData, data, len);
88 Serial.println(
"\tReceived " + String(len) +
" bytes over the server on connection #" + String(client_num));
89 Serial.println(
"\tReceived: " + String(recvData));
91 char respData[len+11];
92 char *respHdr =
"Received: ";
93 memcpy (respData, respHdr, 10);
94 memcpy(&respData[10], recvData, len);
95 respData[len+10] =
'\0';
96 Serial.println(
"\tSend response: " + String(respData));
100 Serial.print(
"\tConnection problem: ");
105 Serial.println(
"\tDisconnected");
107 Serial.println(
"\tConnected");
110 Serial.println(
"Received invalid response type");
118 if (res->
argc() == 1) {
123 Serial.println(F(
"WIFI CONNECTED"));
126 Serial.print(F(
"WIFI NOT READY: "));
140 Serial.println(F(
"EL-Client starting!"));
149 if (!ok)
Serial.println(F(
"EL-Client sync failed!"));
151 Serial.println(F(
"EL-Client synced!"));
156 Serial.print(F(
"Waiting for WiFi "));
157 if ((packet=
esp.WaitReturn()) != NULL) {
167 Serial.println(F(
"TCP socket setup failed, try again in 10 seconds after reboot"));
169 asm volatile (
" jmp 0");
171 Serial.println(String(tcpServer)+
":"+String(tcpPort)+
" is served over connection number # = "+String(
tcpConnNum));
173 Serial.println(F(
"EL-TCP ready"));
Definitions for ELClientSocket.
#define SOCKET_TCP_SERVER
Definitions for ELClient.
int16_t popArg(void *data, uint16_t maxLen)
Extract an argument from the response packet.
void tcpCb(uint8_t resp_type, uint8_t client_num, uint16_t len, char *data)
void wifiCb(void *response)
char * getErrTxt(int16_t commError)
char *const tcpServer PROGMEM