Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR ESP32 #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

ERROR ESP32 #1

wants to merge 3 commits into from

Conversation

Sam240596
Copy link

12:04:48.122 -> WiFi connected
12:04:48.122 -> IP address: 20.0.0.248
12:04:48.122 -> Connecting....
12:04:48.122 ->
12:04:48.122 -> press Enter to begin:
12:04:48.122 ->
12:04:48.122 ->
login|connecting...
12:04:50.860 -> login|connected!
12:04:50.892 -> negotiate|server:IAC
12:04:50.892 -> negotiate|server:DO
12:04:50.892 -> negotiate|server opt:
12:04:50.892 -> 24
12:04:50.892 -> negotiate|client:IAC
12:04:50.892 -> negotiate|client:WONT
12:05:05.899 -> listen|TIMEOUT!!!

#include <ESPTelnetClient.h>

#ifdef ESP32
#include <WiFi.h>
#include <WiFiMulti.h>
#else
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#endif

//Enter your Wifi details here (multiple SSIDs possible)
#ifndef STASSID
#define STASSID "Internet Gratis"
#define STAPSK ""
#endif

//put here your raspi ip address, and login details
IPAddress mikrotikRouterIp(20, 0, 0, 1);

const char* user = "admin2";
const char* pwd = "12345678";

const char* ssid = STASSID;
const char* password = STAPSK;

WiFiClient client;

ESPtelnetClient tc(client);

void setup () {

Serial.begin (115200);
// We start by connecting to a WiFi network

WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);

Serial.println();
Serial.println();
Serial.print("Wait for WiFi... ");

while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}

Serial.println("");
Serial.println("WiFi connected");
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("Connecting.... ");

//WHICH CHARACTER SHOULD BE INTERPRETED AS "PROMPT"?
tc.setPromptChar('>');

//this is to trigger manually the login
//since it could be a problem to attach the serial monitor while negotiating with the server (it cause the board reset)
//remove it or replace it with a delay/wait of a digital input in case you're not using the serial monitors
char key = 0;
Serial.println("\r\npress Enter to begin:");
do{
key = Serial.read();
}while(key<=0);

//PUT HERE YOUR USERNAME/PASSWORD
if(tc.login(mikrotikRouterIp, user, pwd)){ //tc.login(mikrotikRouterIp, "admin", "", 1234) if you want to specify a port different than 23
tc.sendCommand("ip");
tc.sendCommand("address");
tc.sendCommand("print");

}
else{
Serial.println("login failed");
}
tc.disconnect();
}

void loop () { // run your loop routine
}

ivanalayan15 and others added 3 commits September 6, 2021 08:24
Signed-off-by: Ivan Julius Alayan <ivan.a@tc-gaming.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants