including tftp based shell and sockets from different project
This commit is contained in:
@@ -32,6 +32,9 @@
|
||||
#include "PwmExpanderPca9685.hpp"
|
||||
#include "StepperDrv8833.hpp"
|
||||
#include "stepperMotor.hpp"
|
||||
#include "cliWrapper.hpp"
|
||||
#include "udpSockets.hpp"
|
||||
#include "tcpSockets.hpp"
|
||||
|
||||
static const char *TAG = "Watch";
|
||||
static esp_eth_handle_t s_eth_handle = NULL;
|
||||
@@ -41,6 +44,103 @@ extern "C" { // This switch allows the ROS C-implementation to find this main
|
||||
void app_main(void);
|
||||
}
|
||||
|
||||
|
||||
std::unique_ptr<Cli> shellPtr;
|
||||
|
||||
/// @brief Callback for update start
|
||||
/// @param args callback arguments
|
||||
void startUpdate(Cli::CArgs args) {
|
||||
ESP_LOGI(TAG, "Invoking Update");
|
||||
if (args.size() != 1) {
|
||||
shellPtr->write("Need URL to application'\n");
|
||||
return;
|
||||
}
|
||||
// @ToDo: Start Update here
|
||||
}
|
||||
|
||||
/// @brief Callback for commands that are not directly wired
|
||||
/// @param name command name
|
||||
/// @param args callback arguments
|
||||
void onCommand(std::string name, Cli::CArgs args) {
|
||||
ESP_LOGI(TAG, "Invoking: %s", name.c_str());
|
||||
}
|
||||
|
||||
void showLogServerConfig(Cli::CArgs args) {
|
||||
ESP_LOGI(TAG, "on showLogServerConfig:");
|
||||
// auto &store = NvsApi::getInstance();
|
||||
// auto logger = store.getValue("syslogDst");
|
||||
// shellPtr->write(std::string{"syslog destination = '"} + logger + "'\n");
|
||||
}
|
||||
|
||||
void setLogServerConfig(Cli::CArgs args) {
|
||||
ESP_LOGI(TAG, "on showLogServerConfig:");
|
||||
if (args.size() != 1) {
|
||||
shellPtr->write("Need IP address to syslog server'\n");
|
||||
return;
|
||||
}
|
||||
// auto &store = NvsApi::getInstance();
|
||||
// shellPtr->write(std::string{"setting syslog destination to = '"} + args[0] + "'\n");
|
||||
// store.setValue("syslogDst", args[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Telnet socket via TCP/IP
|
||||
*
|
||||
* @details The ini-file for TeraTerm only changes CRReceive and CRSend values both to "=CR"
|
||||
* @param arg ignored task argument
|
||||
*/
|
||||
static void telnetSocketTask(int addrFamily) {
|
||||
ESP_LOGI(TAG, "Starting Telnet task");
|
||||
try {
|
||||
TelnetServer telnet(addrFamily);
|
||||
telnet.run(
|
||||
[](TcpSession &session) {
|
||||
shellPtr = std::make_unique<Cli>(session, [](std::string n, Cli::CArgs a) { onCommand(n, a); });
|
||||
shellPtr->addBinding(
|
||||
{"update", "Start OTA-Update-Process",
|
||||
[](Cli::CArgs a) { startUpdate(a); }});
|
||||
shellPtr->addBinding(
|
||||
{"logserver_show", "Shows log server config ip",
|
||||
[](Cli::CArgs a) { showLogServerConfig(a); }});
|
||||
shellPtr->addBinding(
|
||||
{"logserver_set", "Set log server config ip",
|
||||
[](Cli::CArgs a) { setLogServerConfig(a); }});
|
||||
},
|
||||
[](TcpSession &session) {
|
||||
shellPtr->process();
|
||||
Syslog::setupTask(session.getOther());
|
||||
});
|
||||
} catch (const std::exception &e) {
|
||||
ESP_LOGE("TCP", "%s", e.what());
|
||||
}
|
||||
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
void startServerTasks() {
|
||||
static int ipVersion = AF_INET;
|
||||
static fos::TaskT<int> telnetSocket(telnetSocketTask, ipVersion, "tcpServer", 4096);
|
||||
// static TaskT<int> dmxNode(dmxSocketTask, ipVersion, "dmxNode", 4096);
|
||||
// static Task otaUpdate(SystemFunctions::OtaTaskEntry, "otaTask", 8192);
|
||||
|
||||
// initialise_mdns();
|
||||
// netbiosns_init();
|
||||
// netbiosns_set_name(CONFIG_EXAMPLE_MDNS_HOST_NAME);
|
||||
// WebServer::init(FileSystem::getInstance());
|
||||
// WebServer::getInstance(FileSystem::getInstance()).registerCallback(printSysState);
|
||||
|
||||
// auto &store = NvsApi::getInstance();
|
||||
// auto broker = store.getValue("mqttBroker");
|
||||
// if (broker != "") {
|
||||
// MqttClient::init(broker);
|
||||
// }
|
||||
|
||||
// auto logger = store.getValue("syslogDst");
|
||||
// if (logger != "") {
|
||||
// Syslog::setupTask(IpAdr{logger, 0});
|
||||
// }
|
||||
}
|
||||
|
||||
/** Event handler for IP_EVENT_ETH_GOT_IP */
|
||||
static void got_ip_event_handler(void *arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void *event_data)
|
||||
@@ -54,6 +154,7 @@ static void got_ip_event_handler(void *arg, esp_event_base_t event_base,
|
||||
ESP_LOGI(TAG, "ETHMASK:" IPSTR, IP2STR(&ip_info->netmask));
|
||||
ESP_LOGI(TAG, "ETHGW:" IPSTR, IP2STR(&ip_info->gw));
|
||||
ESP_LOGI(TAG, "~~~~~~~~~~~");
|
||||
startServerTasks();
|
||||
}
|
||||
|
||||
// Event handler for Ethernet
|
||||
|
||||
Reference in New Issue
Block a user