Browse Source

Merge pull request #7931 from Scavanger/BLE

BLE Support
master
Paweł Spychalski 3 years ago
committed by GitHub
parent
commit
666f98ee8d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 53
      docs/Wireless Connections (BLE, TCP and UDP).md
  2. 24
      src/main/fc/cli.c
  3. 22
      src/main/fc/fc_msp.c
  4. 1
      src/main/msp/msp_protocol_v2_inav.h

53
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.

24
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",

22
src/main/fc/fc_msp.c

@ -1548,6 +1548,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
@ -3226,6 +3243,11 @@ bool mspFCProcessInOutCommand(uint16_t cmdMSP, sbuf_t *dst, sbuf_t *src, mspResu
break;
#endif
#ifdef USE_PROGRAMMING_FRAMEWORK
case MSP2_INAV_LOGIC_CONDITIONS_SINGLE:
*ret = mspFcLogicConditionCommand(dst, src);
break;
#endif
case MSP2_INAV_SAFEHOME:
*ret = mspFcSafeHomeOutCommand(dst, src);
break;

1
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
Loading…
Cancel
Save