Czy ktoś ma jakieś doświadczenie z odczytem danych z urządzeń MIKROTIK poprzez API / SSH / TELNET?
Interesuje mnie tylko program do pobierania danych przez ESP8266 / ESP32 w Arduino.
Mikrotik API
-
cinas
- Posts: 650
- Joined: Sun Aug 14, 2022 6:59 am
- Location: Kaczory
- Has thanked: 3 times
- Been thanked: 7 times
tu np wysyłałem konfigurację do firewalla
Możesz mieniać komendy na te z konsoli MT
set user "login
"
spawn telnet "192.168.0.253"
expect "Login:" { send "login
"; exp_continue }
expect "Password:" { send "tajeeeehaslohaslo
"; exp_continue }
expect ">"
send "ip firewall address-list set address=8.8.8.8 numbers=0
"
expect ">"
send "quit
"
expect eof
Możesz mieniać komendy na te z konsoli MT
set user "login
"
spawn telnet "192.168.0.253"
expect "Login:" { send "login
"; exp_continue }
expect "Password:" { send "tajeeeehaslohaslo
"; exp_continue }
expect ">"
send "ip firewall address-list set address=8.8.8.8 numbers=0
"
expect ">"
send "quit
"
expect eof
-
klew
- Posts: 13905
- Joined: Thu Jun 27, 2019 12:16 pm
- Location: Wrocław
- Has thanked: 134 times
- Been thanked: 137 times
Telnet to zwykłe połączenie po TCP, gdzie piszesz i czytasz tekst jak po Serialu.
Wrzuć sobie w google "telnet Arduino" i na bank znajdziesz przykłady
Najlepsze suple dla Twojego domu 
-
klimasstudio
- Posts: 1273
- Joined: Wed Aug 28, 2019 9:35 pm
- Location: localhost
Zawsze można poprosić ChatGPT aby przepisał kod na inny język lub napisał kod. Mi tak wiele razy pomógł z napisaniem kodu. Nie musiałem uczyć się od podstaw. Napisał mi prawie gotowca którego delikatnie przerobiłem lub coś dorzuciłem i działa 
Więc chodź OSUPLUJE Ci dom
Druk 3D - > https://klimastech.eu.org/druk-3d
Druk 3D - > https://klimastech.eu.org/druk-3d
-
krycha88
- Posts: 5575
- Joined: Fri Nov 16, 2018 7:25 am
- Been thanked: 5 times
wydaje się proste do ogarnięcia, po prostu musisz wykorzystać bibliotekę WiFiClient do nawiązania połączenia telnet.
Code: Select all
#include <ESP8266WiFi.h>
const char* ssid = "NazwaTwojejSieci";
const char* password = "HasloTwojejSieci";
const char* host = "192.168.0.253";
const int port = 23; // Port Telnet
void setup() {
Serial.begin(115200);
delay(10);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi...");
}
Serial.println("Connected to WiFi");
}
void loop() {
if (WiFi.status() == WL_CONNECTED) {
WiFiClient client;
if (client.connect(host, port)) {
Serial.println("Connected to Telnet server");
client.print("login");
delay(100);
client.print("\r");
delay(1000); // Odczekaj na odpowiedź
client.print("tajeeeehaslohaslo");
delay(100);
client.print("\r");
delay(1000); // Odczekaj na odpowiedź
client.print("ip firewall address-list set address=8.8.8.8 numbers=0");
delay(100);
client.print("\r");
delay(1000); // Odczekaj na odpowiedź
client.print("quit");
delay(100);
client.print("\r");
delay(1000); // Odczekaj na odpowiedź
client.stop();
Serial.println("Disconnected from Telnet server");
} else {
Serial.println("Connection to Telnet server failed");
}
}
}
https://gui-generic-builder.supla.io/
