From 1f8c5d88abc7028fd8ce1b7142316e9c65489d28 Mon Sep 17 00:00:00 2001 From: Scavanger Date: Wed, 16 Mar 2022 10:23:19 +0100 Subject: [PATCH 1/7] Initial commit --- src/main/fc/cli.c | 24 ++++++++++++++++++++++++ src/main/fc/fc_msp.c | 34 ++++++++++++++++++++++------------ 2 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/main/fc/cli.c b/src/main/fc/cli.c index a2c6362fc44..8beac13f17c 100644 --- a/src/main/fc/cli.c +++ b/src/main/fc/cli.c @@ -140,6 +140,7 @@ static uint8_t cliWriteBuffer[sizeof(*cliWriter) + 128]; static char cliBuffer[64]; static uint32_t bufferIndex = 0; +static uint16_t cliDelayMs = 0; #if defined(USE_ASSERT) static void cliAssert(char *cmdline); @@ -222,6 +223,9 @@ static void cliPrint(const char *str) static void cliPrintLinefeed(void) { cliPrint("\r\n"); + if (cliDelayMs) { + delay(cliDelayMs); + } } static void cliPrintLine(const char *str) @@ -1672,6 +1676,25 @@ static void cliModeColor(char *cmdline) } #endif +static void cliDelay(char* cmdLine) { + int ms = 0; + if (isEmpty(cmdLine)) { + cliDelayMs = 0; + cliPrintLine("CLI delay deactivated"); + return; + } + + ms = fastA2I(cmdLine); + if (ms) { + cliDelayMs = ms; + cliPrintLinef("CLI delay set to %d ms", ms); + + } else { + cliShowParseError(); + } + +} + static void printServo(uint8_t dumpMask, const servoParam_t *servoParam, const servoParam_t *defaultServoParam) { // print out servo settings @@ -3856,6 +3879,7 @@ const clicmd_t cmdTable[] = { CLI_COMMAND_DEF("color", "configure colors", NULL, cliColor), CLI_COMMAND_DEF("mode_color", "configure mode and special colors", NULL, cliModeColor), #endif + CLI_COMMAND_DEF("cli_delay", "CLI Delay", "Delay in ms", cliDelay), CLI_COMMAND_DEF("defaults", "reset to defaults and reboot", NULL, cliDefaults), CLI_COMMAND_DEF("dfu", "DFU mode on reboot", NULL, cliDfu), CLI_COMMAND_DEF("diff", "list configuration changes from default", diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index d5dbc274a7e..8e5a07e24f8 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -534,18 +534,6 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF } break; #ifdef USE_PROGRAMMING_FRAMEWORK - case MSP2_INAV_LOGIC_CONDITIONS: - for (int i = 0; i < MAX_LOGIC_CONDITIONS; i++) { - sbufWriteU8(dst, logicConditions(i)->enabled); - sbufWriteU8(dst, logicConditions(i)->activatorId); - sbufWriteU8(dst, logicConditions(i)->operation); - sbufWriteU8(dst, logicConditions(i)->operandA.type); - sbufWriteU32(dst, logicConditions(i)->operandA.value); - sbufWriteU8(dst, logicConditions(i)->operandB.type); - sbufWriteU32(dst, logicConditions(i)->operandB.value); - sbufWriteU8(dst, logicConditions(i)->flags); - } - break; case MSP2_INAV_LOGIC_CONDITIONS_STATUS: for (int i = 0; i < MAX_LOGIC_CONDITIONS; i++) { sbufWriteU32(dst, logicConditionGetValue(i)); @@ -1547,6 +1535,23 @@ static mspResult_e mspFcSafeHomeOutCommand(sbuf_t *dst, sbuf_t *src) } } +static mspResult_e mspFcLogicConditionCommand(sbuf_t *dst, sbuf_t *src) { + const uint8_t idx = sbufReadU8(src); + if (idx < MAX_LOGIC_CONDITIONS) { + sbufWriteU8(dst, logicConditions(idx)->enabled); + sbufWriteU8(dst, logicConditions(idx)->activatorId); + sbufWriteU8(dst, logicConditions(idx)->operation); + sbufWriteU8(dst, logicConditions(idx)->operandA.type); + sbufWriteU32(dst, logicConditions(idx)->operandA.value); + sbufWriteU8(dst, logicConditions(idx)->operandB.type); + sbufWriteU32(dst, logicConditions(idx)->operandB.value); + sbufWriteU8(dst, logicConditions(idx)->flags); + return MSP_RESULT_ACK; + } else { + return MSP_RESULT_ERROR; + } +} + static void mspFcWaypointOutCommand(sbuf_t *dst, sbuf_t *src) { const uint8_t msp_wp_no = sbufReadU8(src); // get the wp number @@ -3225,6 +3230,11 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu break; #endif +#ifdef USE_PROGRAMMING_FRAMEWORK + case MSP2_INAV_LOGIC_CONDITIONS: + *ret = mspFcLogicConditionCommand(dst, src); + break; +#endif case MSP2_INAV_SAFEHOME: *ret = mspFcSafeHomeOutCommand(dst, src); break; From e6c5e49a94db870e7ff09a8b142be57077ab545c Mon Sep 17 00:00:00 2001 From: Scavanger Date: Sun, 27 Mar 2022 17:33:25 +0200 Subject: [PATCH 2/7] Bump MSP Version --- src/main/msp/msp_protocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 9b9b7b08b53..0f9d551eea6 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -59,7 +59,7 @@ #define MSP_PROTOCOL_VERSION 0 // Same version over MSPv1 & MSPv2 - message format didn't change and it backward compatible #define API_VERSION_MAJOR 2 // increment when major changes are made -#define API_VERSION_MINOR 4 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR +#define API_VERSION_MINOR 5 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR #define API_VERSION_LENGTH 2 From 09f9304d91b2fdfb6eb1bc32c3a0c11a1ff187d0 Mon Sep 17 00:00:00 2001 From: Scavanger Date: Wed, 30 Mar 2022 20:17:30 +0200 Subject: [PATCH 3/7] Revert MSP bump --- src/main/msp/msp_protocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/msp/msp_protocol.h b/src/main/msp/msp_protocol.h index 0f9d551eea6..9b9b7b08b53 100644 --- a/src/main/msp/msp_protocol.h +++ b/src/main/msp/msp_protocol.h @@ -59,7 +59,7 @@ #define MSP_PROTOCOL_VERSION 0 // Same version over MSPv1 & MSPv2 - message format didn't change and it backward compatible #define API_VERSION_MAJOR 2 // increment when major changes are made -#define API_VERSION_MINOR 5 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR +#define API_VERSION_MINOR 4 // increment when any change is made, reset to zero when major changes are released after changing API_VERSION_MAJOR #define API_VERSION_LENGTH 2 From ed802fedc6eaff794b3777e6f4129bb981745859 Mon Sep 17 00:00:00 2001 From: Scavanger Date: Fri, 1 Apr 2022 13:39:01 +0200 Subject: [PATCH 4/7] Add MSP2_INAV_LOGIC_CONDITIONS_SINGLE --- src/main/fc/fc_msp.c | 14 +++++++++++++- src/main/msp/msp_protocol_v2_inav.h | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/fc/fc_msp.c b/src/main/fc/fc_msp.c index ed9aa9dc7b7..c5159bf4838 100644 --- a/src/main/fc/fc_msp.c +++ b/src/main/fc/fc_msp.c @@ -534,6 +534,18 @@ static bool mspFcProcessOutCommand(uint16_t cmdMSP, sbuf_t *dst, mspPostProcessF } break; #ifdef USE_PROGRAMMING_FRAMEWORK + case MSP2_INAV_LOGIC_CONDITIONS: + for (int i = 0; i < MAX_LOGIC_CONDITIONS; i++) { + sbufWriteU8(dst, logicConditions(i)->enabled); + sbufWriteU8(dst, logicConditions(i)->activatorId); + sbufWriteU8(dst, logicConditions(i)->operation); + sbufWriteU8(dst, logicConditions(i)->operandA.type); + sbufWriteU32(dst, logicConditions(i)->operandA.value); + sbufWriteU8(dst, logicConditions(i)->operandB.type); + sbufWriteU32(dst, logicConditions(i)->operandB.value); + sbufWriteU8(dst, logicConditions(i)->flags); + } + break; case MSP2_INAV_LOGIC_CONDITIONS_STATUS: for (int i = 0; i < MAX_LOGIC_CONDITIONS; i++) { sbufWriteU32(dst, logicConditionGetValue(i)); @@ -3232,7 +3244,7 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu #endif #ifdef USE_PROGRAMMING_FRAMEWORK - case MSP2_INAV_LOGIC_CONDITIONS: + case MSP2_INAV_LOGIC_CONDITIONS_SINGLE: *ret = mspFcLogicConditionCommand(dst, src); break; #endif diff --git a/src/main/msp/msp_protocol_v2_inav.h b/src/main/msp/msp_protocol_v2_inav.h index d3e7d14585a..51311f4557f 100755 --- a/src/main/msp/msp_protocol_v2_inav.h +++ b/src/main/msp/msp_protocol_v2_inav.h @@ -80,3 +80,4 @@ #define MSP2_INAV_SET_SAFEHOME 0x2039 #define MSP2_INAV_MISC2 0x203A +#define MSP2_INAV_LOGIC_CONDITIONS_SINGLE 0x203B From a1fc78877233c70b9481bdcfb9f64f66969b5b28 Mon Sep 17 00:00:00 2001 From: Scavanger Date: Thu, 7 Apr 2022 10:00:32 +0200 Subject: [PATCH 5/7] Add doc --- ...WIreless Connections (BLE, TCP and UDP).md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 docs/WIreless Connections (BLE, TCP and UDP).md diff --git a/docs/WIreless Connections (BLE, TCP and UDP).md b/docs/WIreless Connections (BLE, TCP and UDP).md new file mode 100644 index 00000000000..e0c4189b0db --- /dev/null +++ b/docs/WIreless Connections (BLE, TCP and UDP).md @@ -0,0 +1,53 @@ +# Wireless connections + +From iNav 5 onwards, the Configurator supports wireless connections via Bluetooth Low Energy (BLE) and Wifi (UDP and TCP). + +## BLE + +The following adapters are supported: + +- CC2541 based modules (HM1X, HC08/09) +- Nordic Semiconductor NRF5340 (Adafruit BLE Shield) +- SpeedyBee adapter + +Flightcontrollers with BLE should also work, if you have an adapter/FC that doesn't work, open an issue here on Github and we will add it. + +### Configuring the BLE modules +Activate MSP in iNav on a free UART port and set the Bluetooth module to the appropriate baud rate. + +Example for a HM-10 module: + +Connect the module to a USB/UART adapter (remember: RX to TX, TX to RX), and connect it to a serial terminal (e.g. from the Arduino IDE), +Standard baud rate is 115200 baud, CR+LF + +``` +AT+BAUD4 +AT+NAMEiNav +``` + +The baud rate values: +| Value | Baud | +|------|------| +| 1 | 9600 | +| 2 | 19200 | +| 3 | 38400 | +| 4 | 115200 | + +There are many counterfeits of the HC08/09 modules on the market, which work unreliably at high baud rates. +However, it is recommended to avoid these modules and to use an original HM-10. + +### SpeedyBee adapter + +Just connect it to the USB port, no further configuration needed. + +## TCP and UDP + +Allows connections via Wifi. + +Hardware: +- DIY, ESP8266 based: + This project can be used to make iNav Wifi enabled: https://github.com/Scavanger/MSPWifiBridge + A small ESP01S module should still fit anywhere. + +- ExpressLRS Wifi: + Should work (via TCP, port 5761), but untested due to lack of hardware from the developer. CLI and presets do not work here, problem in ELRS, not in iNav. From 791043067988e78af24137d925dbd2837b5c1bd2 Mon Sep 17 00:00:00 2001 From: Scavanger Date: Thu, 7 Apr 2022 10:01:46 +0200 Subject: [PATCH 6/7] Typo in filename --- ...Wireless Connections (BLE, TCP and UDP).md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 docs/Wireless Connections (BLE, TCP and UDP).md diff --git a/docs/Wireless Connections (BLE, TCP and UDP).md b/docs/Wireless Connections (BLE, TCP and UDP).md new file mode 100644 index 00000000000..e0c4189b0db --- /dev/null +++ b/docs/Wireless Connections (BLE, TCP and UDP).md @@ -0,0 +1,53 @@ +# Wireless connections + +From iNav 5 onwards, the Configurator supports wireless connections via Bluetooth Low Energy (BLE) and Wifi (UDP and TCP). + +## BLE + +The following adapters are supported: + +- CC2541 based modules (HM1X, HC08/09) +- Nordic Semiconductor NRF5340 (Adafruit BLE Shield) +- SpeedyBee adapter + +Flightcontrollers with BLE should also work, if you have an adapter/FC that doesn't work, open an issue here on Github and we will add it. + +### Configuring the BLE modules +Activate MSP in iNav on a free UART port and set the Bluetooth module to the appropriate baud rate. + +Example for a HM-10 module: + +Connect the module to a USB/UART adapter (remember: RX to TX, TX to RX), and connect it to a serial terminal (e.g. from the Arduino IDE), +Standard baud rate is 115200 baud, CR+LF + +``` +AT+BAUD4 +AT+NAMEiNav +``` + +The baud rate values: +| Value | Baud | +|------|------| +| 1 | 9600 | +| 2 | 19200 | +| 3 | 38400 | +| 4 | 115200 | + +There are many counterfeits of the HC08/09 modules on the market, which work unreliably at high baud rates. +However, it is recommended to avoid these modules and to use an original HM-10. + +### SpeedyBee adapter + +Just connect it to the USB port, no further configuration needed. + +## TCP and UDP + +Allows connections via Wifi. + +Hardware: +- DIY, ESP8266 based: + This project can be used to make iNav Wifi enabled: https://github.com/Scavanger/MSPWifiBridge + A small ESP01S module should still fit anywhere. + +- ExpressLRS Wifi: + Should work (via TCP, port 5761), but untested due to lack of hardware from the developer. CLI and presets do not work here, problem in ELRS, not in iNav. From 1032b8885646fa59e2eed933209251a5510f1956 Mon Sep 17 00:00:00 2001 From: Scavanger Date: Thu, 7 Apr 2022 10:02:07 +0200 Subject: [PATCH 7/7] ... --- ...WIreless Connections (BLE, TCP and UDP).md | 53 ------------------- 1 file changed, 53 deletions(-) delete mode 100644 docs/WIreless Connections (BLE, TCP and UDP).md diff --git a/docs/WIreless Connections (BLE, TCP and UDP).md b/docs/WIreless Connections (BLE, TCP and UDP).md deleted file mode 100644 index e0c4189b0db..00000000000 --- a/docs/WIreless Connections (BLE, TCP and UDP).md +++ /dev/null @@ -1,53 +0,0 @@ -# Wireless connections - -From iNav 5 onwards, the Configurator supports wireless connections via Bluetooth Low Energy (BLE) and Wifi (UDP and TCP). - -## BLE - -The following adapters are supported: - -- CC2541 based modules (HM1X, HC08/09) -- Nordic Semiconductor NRF5340 (Adafruit BLE Shield) -- SpeedyBee adapter - -Flightcontrollers with BLE should also work, if you have an adapter/FC that doesn't work, open an issue here on Github and we will add it. - -### Configuring the BLE modules -Activate MSP in iNav on a free UART port and set the Bluetooth module to the appropriate baud rate. - -Example for a HM-10 module: - -Connect the module to a USB/UART adapter (remember: RX to TX, TX to RX), and connect it to a serial terminal (e.g. from the Arduino IDE), -Standard baud rate is 115200 baud, CR+LF - -``` -AT+BAUD4 -AT+NAMEiNav -``` - -The baud rate values: -| Value | Baud | -|------|------| -| 1 | 9600 | -| 2 | 19200 | -| 3 | 38400 | -| 4 | 115200 | - -There are many counterfeits of the HC08/09 modules on the market, which work unreliably at high baud rates. -However, it is recommended to avoid these modules and to use an original HM-10. - -### SpeedyBee adapter - -Just connect it to the USB port, no further configuration needed. - -## TCP and UDP - -Allows connections via Wifi. - -Hardware: -- DIY, ESP8266 based: - This project can be used to make iNav Wifi enabled: https://github.com/Scavanger/MSPWifiBridge - A small ESP01S module should still fit anywhere. - -- ExpressLRS Wifi: - Should work (via TCP, port 5761), but untested due to lack of hardware from the developer. CLI and presets do not work here, problem in ELRS, not in iNav.