I just got my Ethernet Shield and started off with the Ethernet Telnet example,
I need help ;D ![]()
I want to obtain information from my modem/router through telnet 192.168.1.1:23 (login: admin, password: admin)
I want to launch a command from arduino uno which allows me to obtain the status of my router with the command telnet ($show status) and display later the result on a lcd display.
after several nights of testing, I manage to connect to my router through telnet and introduce the login and password using the "finder.find" function but the problem that I cannot display the result at " serial monitor "and execute a"$show status" command.
thank you so much ![]()
--------------result serial monitor ----------
Connection en cours...
192.168.1.11
Connection au modem...
connecté
⸮
#include <SPI.h>
#include <Ethernet.h>
#include <TextFinder.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,11);
IPAddress server(192,168,1,1);
EthernetClient client;
TextFinder finder( client);
const unsigned long requestInterval = 15000; // delay between requests
unsigned long lastAttemptTime = 0; // last time you connected to the server, in milliseconds
void setup()
{
Ethernet.begin(mac, ip);
Serial.begin(9600);
Serial.println("Connection en cours...");
Serial.println(Ethernet.localIP());
delay(2000);
}
void loop()
{
if (client.connected()) {
// checke_page();
if(finder.find("Username: ")){
client.println("admin");
}
if(finder.find("Password: ")){
client.println("admin");
}
checke_page();
}
else if (millis() - lastAttemptTime > requestInterval) {
// if you're not connected, and two minutes have passed since
// your last connection, then attempt to connect again:
connectToServer();
}
}
void checke_page(){
// from the server, read them and print them:
if (client.available()) {
if(finder.find("$")){
client.println("show status");
}
char c = client.read();
Serial.print(c);
}
// as long as there are bytes in the serial queue,
// read them and send them out the socket if it's open:
while (Serial.available() > 0) {
char inChar = Serial.read();
if (client.connected()) {
client.print(inChar);
}
}
}
void connectToServer() {
// attempt to connect, and wait a millisecond:
Serial.println("Connection au modem...");
if (client.connect(server, 23)) {
Serial.println("connecté");
char c = client.read();
Serial.print(c);
}
else {
Serial.println("erreur de connexion");
}
// remettre le compteur a zero pour la prochaine connexion:
lastAttemptTime = millis();
}

