I've equipped an Arduino Due with a WiFi shield and now I want to run a Telnet server on the Arduino. I've found here how to: https://www.arduino.cc/en/Tutorial/WiFiChatServer
I copied the whole Code and just changed SSID and the passphrase.
I'm aware of the fact that Telnet isnt a secure connection, but this is just for testing purposes.
When opening a terminal and entering
$telnet
$open 192.168.178.27 23 (this is the IP adress the Arduino gets when opening serial monitor)
I get a "connection refused" as an answer. I'm using Kubuntu 14.04 LTE I already tryed deaktivating the firewall with
$sudo ufw disable
without succes.
Pinging my device seems to work:
64 bytes from 192.168.178.27: icmp_seq=1 ttl=255 time=24.6 ms
64 bytes from 192.168.178.27: icmp_seq=2 ttl=255 time=1.62 ms
64 bytes from 192.168.178.27: icmp_seq=3 ttl=255 time=2.22 ms
64 bytes from 192.168.178.27: icmp_seq=4 ttl=255 time=4.04 ms
64 bytes from 192.168.178.27: icmp_seq=5 ttl=255 time=1.75 ms
I also made sure my router allows communication with devices via wlan.
But after succesfully updating the firmware (I guess it was succesful), the very same code just doesnt work, but this "connectwithwpa" example works.
As an error it only shows in the serial monitor one line "Attempting to connect to Network named: NSA BASE NORTHERN GERMANY", which is my WiFi..
Also the initial error I have with the WiFi chat client is still there...
/*
Chat Server
A simple server that distributes any incoming messages to all
connected clients. To use telnet to your device's IP address and type.
You can see the client's input in the serial monitor as well.
This example is written for a network using WPA encryption. For
WEP or WPA, change the Wifi.begin() call accordingly.
Circuit:
* WiFi shield attached
created 18 Dec 2009
by David A. Mellis
modified 31 May 2012
by Tom Igoe
*/
#include <SPI.h>
#include <WiFi.h>
char ssid[] = "NSA BASE NORTHERN GERMANY"; // your network SSID (name)
char pass[] = "LaurinPupskoenig&Sofflkopf<3"; // your network password (use for WPA, or use as key for WEP)
int keyIndex = 0; // your network key Index number (needed only for WEP)
int status = WL_IDLE_STATUS;
WiFiServer server(23);
boolean alreadyConnected = false; // whether or not the client was connected previously
void setup() {
//Initialize serial and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
// don't continue:
while(true);
}
// attempt to connect to Wifi network:
while ( status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:
delay(10000);
}
// start the server:
server.begin();
// you're connected now, so print out the status:
printWifiStatus();
}
void loop() {
// wait for a new client:
WiFiClient 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);
}
}
}
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");
}
How do I post code better? I'm finding options for images, hyperlinks and fonts, but nothing for code :x Edit: done
Chat servers usually use udp, not tcp. They also work differently from telnet servers. You need to install (or write) a telnet server on (for) the Arduino.
As an error it only shows in the serial monitor one line "Attempting to connect to Network named: NSA BASE NORTHERN GERMANY", which is my WiFi..
So, the Arduino with WiFi shield fails to connect to your network, and you wonder why you can't telnet to it. It seems perfectly obvious to me why you can't telnet to it.