cli improvement
This commit is contained in:
+1
-1
Submodule core updated: 8af1c2f555...e09e7dc576
+45
-39
@@ -10,6 +10,11 @@
|
|||||||
4 2
|
4 2
|
||||||
3
|
3
|
||||||
*/
|
*/
|
||||||
|
// Profiles = 5 (0..4)
|
||||||
|
// DynRange =
|
||||||
|
// MinSteps (6..20), MaxSteps (10..40)
|
||||||
|
// activeState.accel = (min .5 / max 3)
|
||||||
|
// activeState.speed = (min .5 / max 3)
|
||||||
|
|
||||||
#include "watchMain.hpp"
|
#include "watchMain.hpp"
|
||||||
#include "interconConfig.hpp"
|
#include "interconConfig.hpp"
|
||||||
@@ -73,7 +78,7 @@ void onCommand(std::string name, Cli::CArgs args) {
|
|||||||
void startUpdate(Cli::CArgs args) {
|
void startUpdate(Cli::CArgs args) {
|
||||||
ESP_LOGI(TAG, "Invoking Update");
|
ESP_LOGI(TAG, "Invoking Update");
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
pShell->write("Need URL to application'\n");
|
pShell->writeLine("Need URL to application");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// @ToDo: Start Update here
|
// @ToDo: Start Update here
|
||||||
@@ -81,18 +86,18 @@ void startUpdate(Cli::CArgs args) {
|
|||||||
|
|
||||||
void getConfig(Cli::CArgs args) {
|
void getConfig(Cli::CArgs args) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
pShell->write("Needs string key for query'\n");
|
pShell->writeLine("Needs string key for query");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto key = args[0];
|
auto key = args[0];
|
||||||
auto &store = NvsApi::getInstance();
|
auto &store = NvsApi::getInstance();
|
||||||
auto val = store.getValue(key);
|
auto val = store.getValue(key);
|
||||||
pShell->write(key + ": " + val + "\n");
|
pShell->writeLine(key + ": " + val + "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void testPictoIllum(Cli::CArgs args) {
|
void testPictoIllum(Cli::CArgs args) {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
pShell->write("Needs position argument for illuminated position 0 for off, 1..6 for pictograms'\n");
|
pShell->writeLine("Needs position argument for illuminated position 0 for off, 1..6 for pictograms");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -105,30 +110,38 @@ void testPictoIllum(Cli::CArgs args) {
|
|||||||
|
|
||||||
void testMovement(Cli::CArgs args) {
|
void testMovement(Cli::CArgs args) {
|
||||||
ESP_LOGI(TAG, "on triggerMovement:");
|
ESP_LOGI(TAG, "on triggerMovement:");
|
||||||
if (args.size() != 1) {
|
if (args.size() < 1) {
|
||||||
pShell->write("need target position (1..6)'\n");
|
pShell->writeLine("need target position (1..6)");
|
||||||
|
pShell->writeLine("additional optional arguments: Profile (0..4), MinSteps (6..20), MaxSteps (10..40)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int p = std::stoi(args[0]);
|
int p = std::stoi(args[0]);
|
||||||
activeState.profile = p;
|
if (args.size() >= 2) {
|
||||||
|
activeState.profile = std::min(4, std::stoi(args[1]));
|
||||||
|
}
|
||||||
|
if (args.size() >= 3) {
|
||||||
|
activeState.minJumps = std::min(20, std::stoi(args[2])) ;
|
||||||
|
}
|
||||||
|
if (args.size() >= 4) {
|
||||||
|
activeState.minJumps = std::min(40, std::stoi(args[3])) ;
|
||||||
|
}
|
||||||
commandQueue.enqueue(std::make_unique<MoveCommand>(MoveType::StepTo, p));
|
commandQueue.enqueue(std::make_unique<MoveCommand>(MoveType::StepTo, p));
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
ESP_LOGI(TAG, "Failed to parse %s and %s", args[0].c_str(), args[1].c_str());
|
ESP_LOGI(TAG, "Failed to parse %s", args[0].c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setConfig(Cli::CArgs args) {
|
void setConfig(Cli::CArgs args) {
|
||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
pShell->write("Needs string key and value'\n");
|
pShell->writeLine("Needs string key and value");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auto key = args[0];
|
auto key = args[0];
|
||||||
auto val = args[1];
|
auto val = args[1];
|
||||||
|
|
||||||
auto &store = NvsApi::getInstance();
|
auto &store = NvsApi::getInstance();
|
||||||
pShell->write(std::string{"Storing value = '"} + val + "'\n");
|
pShell->writeLine(std::string{"Storing value = '"} + val + "'");
|
||||||
store.setValue(key, val);
|
store.setValue(key, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,18 +150,18 @@ void setLogServerConfig(Cli::CArgs args) {
|
|||||||
auto &store = NvsApi::getInstance();
|
auto &store = NvsApi::getInstance();
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
auto logger = store.getValue("syslogDst");
|
auto logger = store.getValue("syslogDst");
|
||||||
pShell->write(std::string{"syslog destination = '"} + logger + "'\n");
|
pShell->writeLine(std::string{"syslog destination = '"} + logger + "'");
|
||||||
pShell->write("provide argument to change syslog server'\n");
|
pShell->writeLine("provide argument to change syslog server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pShell->write(std::string{"setting syslog destination to = '"} + args[0] + "'\n");
|
pShell->writeLine(std::string{"setting syslog destination to = '"} + args[0] + "'");
|
||||||
store.setValue("syslogDst", args[0]);
|
store.setValue("syslogDst", args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setDynamics(Cli::CArgs args) {
|
void setDynamics(Cli::CArgs args) {
|
||||||
ESP_LOGI(TAG, "on setDynamics:");
|
ESP_LOGI(TAG, "on setDynamics:");
|
||||||
if (args.size() != 2) {
|
if (args.size() != 2) {
|
||||||
pShell->write("need float values for velocity and acceleration'\n");
|
pShell->writeLine("need float values for velocity and acceleration");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +347,7 @@ fos::Semaphore spitProjectFinish;
|
|||||||
|
|
||||||
/** Event handler for IP_EVENT_ETH_GOT_IP */
|
/** Event handler for IP_EVENT_ETH_GOT_IP */
|
||||||
void got_ip_event_handler(void *arg, esp_event_base_t event_base,
|
void got_ip_event_handler(void *arg, esp_event_base_t event_base,
|
||||||
int32_t event_id, void *event_data) {
|
int32_t event_id, void *event_data) {
|
||||||
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
|
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
|
||||||
const esp_netif_ip_info_t *ip_info = &event->ip_info;
|
const esp_netif_ip_info_t *ip_info = &event->ip_info;
|
||||||
|
|
||||||
@@ -403,9 +416,8 @@ namespace Effect {
|
|||||||
void LightingTask() {
|
void LightingTask() {
|
||||||
ESP_LOGI(TAG, "Start Lighting");
|
ESP_LOGI(TAG, "Start Lighting");
|
||||||
|
|
||||||
static I2cMaster master(I2C_NUM_0,
|
static I2cMaster master(I2C_NUM_0,
|
||||||
{ /*sda=*/GPIO_NUM_10, /*scl=*/GPIO_NUM_11}
|
{/*sda=*/GPIO_NUM_10, /*scl=*/GPIO_NUM_11});
|
||||||
);
|
|
||||||
// static PmwExpanderPca9685 pca9685(master);
|
// static PmwExpanderPca9685 pca9685(master);
|
||||||
static PmwExpanderPca9685 ledDriver1(master, /*iverted=*/false);
|
static PmwExpanderPca9685 ledDriver1(master, /*iverted=*/false);
|
||||||
static PmwExpanderPca9685 ledDriver2(master, /*iverted=*/false, 0x41);
|
static PmwExpanderPca9685 ledDriver2(master, /*iverted=*/false, 0x41);
|
||||||
@@ -815,18 +827,18 @@ void SpitClientApp() {
|
|||||||
auto ip = spit::Socket::getAdaptersInfo();
|
auto ip = spit::Socket::getAdaptersInfo();
|
||||||
spit::Socket socket(ip);
|
spit::Socket socket(ip);
|
||||||
SClient spitClient(ClientName, ProjectName, socket,
|
SClient spitClient(ClientName, ProjectName, socket,
|
||||||
{
|
{
|
||||||
.onServerEvent = onServerEvent,
|
.onServerEvent = onServerEvent,
|
||||||
.onConnectionStatus = onConnectionStatus,
|
.onConnectionStatus = onConnectionStatus,
|
||||||
.onProjectUpdate = onProjectUpdate,
|
.onProjectUpdate = onProjectUpdate,
|
||||||
.onSpitType = onSpitType,
|
.onSpitType = onSpitType,
|
||||||
.onSpitObject = onSpitObject,
|
.onSpitObject = onSpitObject,
|
||||||
.onPlay = onPlay,
|
.onPlay = onPlay,
|
||||||
.onPlaySpitType = onPlaySpitType,
|
.onPlaySpitType = onPlaySpitType,
|
||||||
.onPlayRemoteObjectStatus = onPlayRemoteObjectStatus,
|
.onPlayRemoteObjectStatus = onPlayRemoteObjectStatus,
|
||||||
.onCheckSpitTypeVeto = onCheckSpitTypeVeto,
|
.onCheckSpitTypeVeto = onCheckSpitTypeVeto,
|
||||||
.onCheckSpitObjectVeto = onCheckSpitObjectVeto,
|
.onCheckSpitObjectVeto = onCheckSpitObjectVeto,
|
||||||
});
|
});
|
||||||
|
|
||||||
for (auto &obj : ProvidedObj) {
|
for (auto &obj : ProvidedObj) {
|
||||||
SType *ptrSPITType1Fix = spitClient.createSPITTypeFixed(obj.iD, obj.groupName, obj.name, 0, 0);
|
SType *ptrSPITType1Fix = spitClient.createSPITTypeFixed(obj.iD, obj.groupName, obj.name, 0, 0);
|
||||||
@@ -877,19 +889,13 @@ void MqttThread() {
|
|||||||
if (res->type == ResponseType::StartMoving) {
|
if (res->type == ResponseType::StartMoving) {
|
||||||
client.publish(MqttTopics.changingPosition, "");
|
client.publish(MqttTopics.changingPosition, "");
|
||||||
} else if (res->type == ResponseType::StepAt) {
|
} else if (res->type == ResponseType::StepAt) {
|
||||||
client.publish(MqttTopics.inPosition, std::to_string(res->pos) );
|
client.publish(MqttTopics.inPosition, std::to_string(res->pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_main(void) {
|
void app_main(void) {
|
||||||
// esp_err_t ret = nvs_flash_init();
|
|
||||||
// if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
|
||||||
// ESP_ERROR_CHECK(nvs_flash_erase());
|
|
||||||
// ret = nvs_flash_init();
|
|
||||||
// }
|
|
||||||
// ESP_ERROR_CHECK(ret); // moved to NvsApi::init();
|
|
||||||
initialize_ethernet();
|
initialize_ethernet();
|
||||||
NvsApi::init();
|
NvsApi::init();
|
||||||
static fos::Task lightingTask(LightingTask, "Lights", 0x8000uL);
|
static fos::Task lightingTask(LightingTask, "Lights", 0x8000uL);
|
||||||
@@ -904,7 +910,7 @@ void app_main(void) {
|
|||||||
static fos::TaskT<int> telnetSocket(telnetSocketTask, ipVersion, "tcpServer", 4096);
|
static fos::TaskT<int> telnetSocket(telnetSocketTask, ipVersion, "tcpServer", 4096);
|
||||||
static fos::TaskT<int> dmxNode(dmxSocketTask, ipVersion, "dmxNode", 4096);
|
static fos::TaskT<int> dmxNode(dmxSocketTask, ipVersion, "dmxNode", 4096);
|
||||||
// static fos::Task spit(SpitClientApp, "SpitClient");
|
// static fos::Task spit(SpitClientApp, "SpitClient");
|
||||||
static fos::Task mqtt(MqttThread, "MqttEndpoint");
|
// static fos::Task mqtt(MqttThread, "MqttEndpoint");
|
||||||
// static Task otaUpdate(SystemFunctions::OtaTaskEntry, "otaTask", 8192);
|
// static Task otaUpdate(SystemFunctions::OtaTaskEntry, "otaTask", 8192);
|
||||||
|
|
||||||
auto &store = NvsApi::getInstance();
|
auto &store = NvsApi::getInstance();
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
#include "cliWrapper.hpp"
|
#include "cliWrapper.hpp"
|
||||||
#include "udpSockets.hpp"
|
#include "udpSockets.hpp"
|
||||||
#include "tcpSockets.hpp"
|
#include "tcpSockets.hpp"
|
||||||
|
#include "syslog.hpp"
|
||||||
|
#include "telnetServer.hpp"
|
||||||
#include "Mutex.hpp"
|
#include "Mutex.hpp"
|
||||||
#include "Queue.hpp"
|
#include "Queue.hpp"
|
||||||
#include "Semaphore.hpp"
|
#include "Semaphore.hpp"
|
||||||
|
|||||||
@@ -2145,6 +2145,17 @@ CONFIG_LITTLEFS_MALLOC_STRATEGY_DEFAULT=y
|
|||||||
# CONFIG_LITTLEFS_MALLOC_STRATEGY_INTERNAL is not set
|
# CONFIG_LITTLEFS_MALLOC_STRATEGY_INTERNAL is not set
|
||||||
CONFIG_LITTLEFS_ASSERTS=y
|
CONFIG_LITTLEFS_ASSERTS=y
|
||||||
# end of LittleFS
|
# end of LittleFS
|
||||||
|
|
||||||
|
#
|
||||||
|
# Telnet Server
|
||||||
|
#
|
||||||
|
CONFIG_TELNET_SERVER_DEFAULT_PORT=23
|
||||||
|
CONFIG_TELNET_SERVER_MAX_CONNECTIONS=5
|
||||||
|
CONFIG_TELNET_SERVER_STACK_SIZE=4096
|
||||||
|
CONFIG_TELNET_SERVER_TASK_PRIORITY=24
|
||||||
|
CONFIG_TELNET_SERVER_TASK_CORE=0
|
||||||
|
CONFIG_TELNET_SERVER_REDIRECT_LOGS=0
|
||||||
|
# end of Telnet Server
|
||||||
# end of Component config
|
# end of Component config
|
||||||
|
|
||||||
# CONFIG_IDF_EXPERIMENTAL_FEATURES is not set
|
# CONFIG_IDF_EXPERIMENTAL_FEATURES is not set
|
||||||
|
|||||||
Reference in New Issue
Block a user