Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
}