12char *
const tcpServer
PROGMEM =
"192.168.0.102";
15uint16_t
const tcpPort
PROGMEM = 7001;
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 client on connection #" + String(client_num));
89 Serial.println(
"\tReceived: " + String(recvData));
92 Serial.print(
"\tConnection problem: ");
97 Serial.println(
"\tDisconnected");
99 Serial.println(
"\tConnected");
102 Serial.println(
"Received invalid response type");
110 if (res->
argc() == 1) {
115 Serial.println(F(
"WIFI CONNECTED"));
118 Serial.print(F(
"WIFI NOT READY: "));
132 Serial.println(F(
"EL-Client starting!"));
141 if (!ok)
Serial.println(F(
"EL-Client sync failed!"));
143 Serial.println(F(
"EL-Client synced!"));
148 Serial.print(F(
"Waiting for WiFi "));
149 if ((packet=
esp.WaitReturn()) != NULL) {
159 Serial.println(F(
"TCP socket setup failed, try again in 10 seconds after reboot"));
161 asm volatile (
" jmp 0");
163 Serial.println(String(tcpServer)+
":"+String(tcpPort)+
" is served over connection number # = "+String(
tcpConnNum));
166 Serial.println(F(
"EL-TCP ready"));
167 wait = millis()+29000;
176 if (millis() -
wait > 30000) {
180 Serial.print(F(
"Sending message to "));
184 tcp.send(
"Message from Uno WiFi over TCP socket");
189 Serial.println(F(
"Lost WiFi connection, try to reboot"));
191 asm volatile (
" jmp 0");
Definitions for ELClientSocket.
#define SOCKET_TCP_CLIENT_LISTEN
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