From d3cfc5f1cbe6ceb71a694c5b17afc03184e83741 Mon Sep 17 00:00:00 2001 From: KiteAnton Date: Wed, 13 Jul 2016 19:37:36 +0200 Subject: [PATCH] Added name command to CLI --- src/main/config/config.c | 2 ++ src/main/config/config.h | 2 ++ src/main/config/config_master.h | 3 +++ src/main/io/serial_cli.c | 19 +++++++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/src/main/config/config.c b/src/main/config/config.c index 06ba7c9c0..7841ef932 100755 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -441,6 +441,7 @@ static void resetConf(void) featureSet(FEATURE_VBAT); #endif + masterConfig.version = EEPROM_CONF_VERSION; masterConfig.mixerMode = MIXER_QUADX; @@ -657,6 +658,7 @@ static void resetConf(void) targetConfiguration(); #endif + // copy first profile into remaining profile for (int i = 1; i < MAX_PROFILE_COUNT; i++) { memcpy(&masterConfig.profile[i], currentProfile, sizeof(profile_t)); diff --git a/src/main/config/config.h b/src/main/config/config.h index 5a46a78c3..ffcbea169 100644 --- a/src/main/config/config.h +++ b/src/main/config/config.h @@ -24,6 +24,8 @@ #endif #define MAX_RATEPROFILES 3 #define ONESHOT_FEATURE_CHANGED_DELAY_ON_BOOT_MS 1500 +#define MAX_NAME_LENGTH 32 + typedef enum { FEATURE_RX_PPM = 1 << 0, diff --git a/src/main/config/config_master.h b/src/main/config/config_master.h index c6f01b402..37ecaa825 100644 --- a/src/main/config/config_master.h +++ b/src/main/config/config_master.h @@ -161,6 +161,9 @@ typedef struct master_t { uint8_t magic_ef; // magic number, should be 0xEF uint8_t chk; // XOR checksum + + char name[MAX_NAME_LENGTH]; + } master_t; extern master_t masterConfig; diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index c0f3a8c41..5624fd1b7 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -119,6 +119,7 @@ void cliDumpRateProfile(uint8_t rateProfileIndex) ; static void cliExit(char *cmdline); static void cliFeature(char *cmdline); static void cliMotor(char *cmdline); +static void cliName(char *cmdline); static void cliPlaySound(char *cmdline); static void cliProfile(char *cmdline); static void cliRateProfile(char *cmdline); @@ -340,6 +341,7 @@ const clicmd_t cmdTable[] = { #ifdef VTX CLI_COMMAND_DEF("vtx", "vtx channels on switch", NULL, cliVtx), #endif + CLI_COMMAND_DEF("name", "Name of vessel", NULL, cliName), }; #define CMD_COUNT (sizeof(cmdTable) / sizeof(clicmd_t)) @@ -1953,6 +1955,7 @@ static void cliDump(char *cmdline) cliPrint("\r\n# version\r\n"); cliVersion(NULL); + cliName(""); cliPrint("\r\n# dump master\r\n"); cliPrint("\r\n# mixer\r\n"); @@ -2494,6 +2497,22 @@ static void cliMotor(char *cmdline) cliPrintf("motor %d: %d\r\n", motor_index, motor_disarmed[motor_index]); } +static void cliName(char *cmdline) +{ + + uint32_t len = strlen(cmdline); + if (isEmpty(cmdline)) { + cliPrintf("name %s\r\n", masterConfig.name); + } else if (len <= MAX_NAME_LENGTH) { + strcpy(masterConfig.name, cmdline); + cliPrintf("name %s\r\n", masterConfig.name); + } else { + cliPrintf("Max allowed name size is %d\r\n", MAX_NAME_LENGTH); + } + + return; +} + static void cliPlaySound(char *cmdline) { #if FLASH_SIZE <= 64