I need to communicate with my Arduino Uno using telnet where i can send a char to it via telnet. I have modified the WiFi Chat Server code from Arduino.cc (https://www.arduino.cc/en/Tutorial/WiFiChatServer) to be suited to be used with Cytron ESP8266 WiFi Shield. However, i am facing a problem while compiling my code. Can you please help? Below is my modified code:
- CODE: SELECT_ALL_CODE
#include <Keyboard.h>
#include <CytronWiFiShield.h>
#include <CytronWiFiServer.h>
#include <SoftwareSerial.h>
#define WiFi wifi
#include <SPI.h>
#include <string.h>
#include <stdio.h>
#ifdef __AVR__
#endif
char ssid[] = "TDE Office"; // your network SSID (name)
char pass[] = "tde257a698n";
int keyIndex = 0; // your network key Index number (needed only for WEP)
ESP8266Server server(23);
boolean alreadyConnected = false; // whether or not the client was connected previously
boolean status = false;
void setup() {
Serial.begin(9600);
while (!Serial) {
;
}
if (!WiFi.begin(2, 3)) {
Serial.println("WiFi shield not present");
while (true); // don't continue
}
String fv = WiFi.firmwareVersion();
Serial.println(fv);
// attempt to connect to Wifi network:
while (!status) {
Serial.print("Attempting to connect to Network named: ");
Serial.println(ssid); // print the network name (SSID);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.connectAP(ssid, pass);
}
server.begin(); // start the web server on port 80
printWifiStatus(); // you're connected now, so print out the status
}
void loop() {
// wait for a new client:
ESP8266Client client = server.available();
// when the client sends the first byte, say hello:
if (client) {
if (!alreadyConnected) {
// clead out the input buffer:
client.flush();
Serial.println("We have a new client");
client.println("Hello, client!");
alreadyConnected = true;
}
if (client.available() > 0) {
// read the bytes incoming from the client:
char thisChar = client.read();
// echo the bytes back to the client:
server.write(thisChar);
// echo the bytes to the server as well:
Serial.write(thisChar);
alreadyConnected = false;
client.println("bye");
client.stop();
}
}
}
void printWifiStatus() {
// print the SSID of the network you're attached to:
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
// print your WiFi shield's IP address:
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print the received signal strength:
long rssi = WiFi.RSSI();
Serial.print("signal strength (RSSI):");
Serial.print(rssi);
Serial.println(" dBm");
}
and here is my error message:
- CODE: SELECT_ALL_CODE
Arduino: 1.6.12 (Windows 7), Board: "Arduino/Genuino Uno"
In file included from C:\Users\AppData\Local\Temp\untitled1835968125.tmp\sketch_dec12a\sketch_dec12a.ino:1:0:
C:\Program Files\Arduino\libraries\Keyboard\src/Keyboard.h:29:2: warning: #warning "Using legacy HID core (non pluggable)" [-Wcpp]
#warning "Using legacy HID core (non pluggable)"
^
In file included from C:\Users\AppData\Local\Temp\untitled1835968125.tmp\sketch_dec12a\sketch_dec12a.ino:2:0:
C:\Users\Documents\Arduino\libraries\CytronWiFiShield-master\src/CytronWiFiShield.h:71:1: warning: 'typedef' was ignored in this declaration
};
^
In file included from C:\Users\Documents\Arduino\libraries\CytronWiFiShield-master\src/CytronWiFiServer.h:26:0,
from C:\Users\AppData\Local\Temp\untitled1835968125.tmp\sketch_dec12a\sketch_dec12a.ino:3:
C:\Users\Documents\Arduino\libraries\CytronWiFiShield-master\src/CytronWiFiClient.h: In instantiation of 'size_t ESP8266Client::write(T&) [with T = char; size_t = unsigned int]':
C:\Users\Documents\Arduino\libraries\CytronWiFiShield-master\src/CytronWiFiServer.h:59:34: required from 'size_t ESP8266Server::write(T&) [with T = char; size_t = unsigned int]'
C:\Users\AppData\Local\Temp\untitled1835968125.tmp\sketch_dec12a\sketch_dec12a.ino:66:28: required from here
C:\Users\Documents\Arduino\libraries\CytronWiFiShield-master\src/CytronWiFiClient.h:76:25: error: request for member 'available' in 'src', which is of non-class type 'char'
while (src.available() > 2048)
^
C:\Users\Documents\Arduino\libraries\CytronWiFiShield-master\src/CytronWiFiClient.h:94:13: error: request for member 'read' in 'src', which is of non-class type 'char'
doneLen += send(src.read());
^
C:\Users\Documents\Arduino\libraries\CytronWiFiShield-master\src/CytronWiFiClient.h:102:35: error: request for member 'available' in 'src', which is of non-class type 'char'
uint16_t leftLen = src.available();
^
C:\Users\Documents\Arduino\libraries\CytronWiFiShield-master\src/CytronWiFiClient.h:111:12: error: request for member 'read' in 'src', which is of non-class type 'char'
doneLen += send(src.read());
^
exit status 1
Error compiling for board Arduino/Genuino Uno.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.