mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
Serial
This commit is contained in:
@@ -24,6 +24,7 @@ class Telnet : public Module {
|
|||||||
void sendData(const String&);
|
void sendData(const String&);
|
||||||
bool hasClient();
|
bool hasClient();
|
||||||
bool isShellActive();
|
bool isShellActive();
|
||||||
|
void setCommandShell(CommandShell*);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool onInit() override;
|
bool onInit() override;
|
||||||
|
|||||||
17
src/Cmd.cpp
17
src/Cmd.cpp
@@ -1,5 +1,8 @@
|
|||||||
#include "Global.h"
|
#include "Global.h"
|
||||||
|
|
||||||
|
#include "Module/Terminal.h"
|
||||||
|
Terminal *term = nullptr;
|
||||||
|
|
||||||
boolean but[NUM_BUTTONS];
|
boolean but[NUM_BUTTONS];
|
||||||
Bounce *buttons = new Bounce[NUM_BUTTONS];
|
Bounce *buttons = new Bounce[NUM_BUTTONS];
|
||||||
|
|
||||||
@@ -516,14 +519,24 @@ void serialBegin() {
|
|||||||
if (mySerial) {
|
if (mySerial) {
|
||||||
delete mySerial;
|
delete mySerial;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (term) {
|
||||||
|
delete term;
|
||||||
|
}
|
||||||
|
|
||||||
mySerial = new SoftwareSerial(rxPin.toInt(), txPin.toInt());
|
mySerial = new SoftwareSerial(rxPin.toInt(), txPin.toInt());
|
||||||
mySerial->begin(s_speed.toInt());
|
mySerial->begin(s_speed.toInt());
|
||||||
|
|
||||||
|
term = new Terminal(mySerial);
|
||||||
|
term->setOnReadLine([](const char *str) {
|
||||||
|
order_loop += String(str) + ",";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void serialWrite() {
|
void serialWrite() {
|
||||||
String payload = sCmd.next();
|
String payload = sCmd.next();
|
||||||
if (mySerial) {
|
if (term) {
|
||||||
mySerial->println(payload);
|
term->println(payload.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,9 +6,6 @@ bool Telnet::onInit() {
|
|||||||
_term->enableControlCodes();
|
_term->enableControlCodes();
|
||||||
_term->enableEcho(false);
|
_term->enableEcho(false);
|
||||||
_term->setStream(&_client);
|
_term->setStream(&_client);
|
||||||
|
|
||||||
// _shell = new CommandShell(Cli::get());
|
|
||||||
_shell->setTerm(_term);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,6 +34,11 @@ void Telnet::sendData(const String& data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Telnet::setCommandShell(CommandShell* shell) {
|
||||||
|
_shell = shell;
|
||||||
|
_shell->setTerm(_term);
|
||||||
|
}
|
||||||
|
|
||||||
void Telnet::setEventHandler(TelnetEventHandler h) { _eventHandler = h; }
|
void Telnet::setEventHandler(TelnetEventHandler h) { _eventHandler = h; }
|
||||||
|
|
||||||
void Telnet::onLoop() {
|
void Telnet::onLoop() {
|
||||||
|
|||||||
Reference in New Issue
Block a user