Skip to content

Conversation

@AlessandroAU
Copy link
Member

@AlessandroAU AlessandroAU commented Jan 13, 2022

Look ma, no cables!

Adds three new abstraction libraries:

msp2crsf
crsf2msp
tcpsocket

The first two libraries convert raw MSP() frames between MSP encapsulated CRSF frames and back. They support MSPv1 MSPV1Jumbo and MSPv2. Frames are automatically chunked into segments and reassembled as is required by the CRSF protocol. Buffers are sized to handle 512B MSP frames. tcpsocket provides an abstraction over the ESPAsyncTCP to buffer in/out frames. This can also be used to send arbitary MSP frames down the CRSF pipe, and we should try to migrate some of the CRSF CMD frames to MSP frames in the future. Eg the VTX commands.

The main immediate application is allowing betaflight configurator to be used wirelessly through any wifi-capable RX ExpressLRS receiver. Currently listens on port 5761 which is default for the TCP socket for BF configurator. The users needs to either type in the address of the receiver on the local network when on home wifi, or enter tcp://10.0.0.1 when in hotspot mode.

image
Demo:
ezgif-3-9741986ee7

Has also been tested to work with betaflight configurator on Andriod.

Known issues:
CLI doesn't work (there is currently no way encapsulate MSP frames to CLI)
Presets don't work (requires CLI)
Setting the target address as tcp://elrs_rx in betaflight configurator doesn't work as it doesn't try to resolve hostnames (upstream issue)

@CapnBry
Copy link
Member

CapnBry commented Jan 14, 2022

EDIT: Disregard this post. I am an idiot.

This definitely worked when I was testing it before the PR, but if I switch over to the tcp2msp branch now I get all timeouts in the configurator with BF 4.3 RC2 (which theoretically has your fix for the bigger CRSF MSP timeouts and buffer size)
image

Some pages will eventually load, but mostly it just gets stuck. When running on my home network instead of just in AP mode, I can't even usually get a real connection through the configurator, it times out during the handshake:

2022-01-14 @15:48:10 -- Serial port successfully opened with ID: 4
2022-01-14 @15:48:11 -- MultiWii API version: 1.44.0
2022-01-14 @15:48:14 -- Flight controller info, identifier: BTFL, version: 4.3.0
2022-01-14 @15:48:20 -- No configuration received within 10 seconds, communication failed
2022-01-14 @15:48:20 -- Serial port successfully closed

@pkendall64
Copy link
Collaborator

@CapnBry make sure you do not have -DDEBUG_LOG otherwise it causes problems with the link.
I had this problem and it took me hours before I realised my mistake!

@CapnBry
Copy link
Member

CapnBry commented Jan 14, 2022

@CapnBry make sure you do not have -DDEBUG_LOG otherwise it causes problems with the link. I had this problem and it took me hours before I realised my mistake!

Ah crepes, PK, you're right. I did build it with DEBUG_LOG on like a damn fool. Works perfectly like it did when I tried it before the PR. Thank you!

@AlessandroAU
Copy link
Member Author

Ah sorry guys, yeah I should have mentioned! Betaflight does not like the debug output getting spit over serial.

@pkendall64
Copy link
Collaborator

Ah sorry guys, yeah I should have mentioned! Betaflight does not like the debug output getting spit over serial.

I wonder if on the RXes we could dual use the GPIO0 (boot pad) to be a soft serial for debug output.

@AlessandroAU
Copy link
Member Author

Not a bad idea, I've also gotten debug via websockets to work, so that's another option.

@pkendall64
Copy link
Collaborator

Not a bad idea, I've also gotten debug via websockets to work, so that's another option.

I like the websockets, but the problem is that you can't really run wifi and the radio on the RX at the same time!
I think the wifi is just too hungry to allow the radio to work reliably.

@AlessandroAU
Copy link
Member Author

Yeah, good point, but I don't think we tested that since you changed over to the async library. We should try it again.

@pkendall64
Copy link
Collaborator

Yeah, good point, but I don't think we tested that since you changed over to the async library. We should try it again.

Ah, true. Perhaps I'll give that go later then.

@RipperGOT
Copy link

Can work with Inav?
The Speedybee app only connects to the port of their own device, right?

@AlessandroAU
Copy link
Member Author

This doesn't support speedybee, and probably can't. Inav should work too, but there was some upstream changes needed in BF to fix MSP-CRSF encapsulation. Inav will probably be the same

Copy link
Collaborator

@pkendall64 pkendall64 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically just making the #ifdef's consistent

@yanwenjun
Copy link

@CapnBry make sure you do not have -DDEBUG_LOG otherwise it causes problems with the link. I had this problem and it took me hours before I realised my mistake!

I am a fool novice, how can I turn off DEBUG_LOG?

@pkendall64
Copy link
Collaborator

@CapnBry make sure you do not have -DDEBUG_LOG otherwise it causes problems with the link. I had this problem and it took me hours before I realised my mistake!

I am a fool novice, how can I turn off DEBUG_LOG?

If you are using configurator then I think it's off already.

@yanwenjun
Copy link

Can this function also be achieved by connecting to the WIFI of the ELRS TX?

@pkendall64 pkendall64 self-requested a review February 21, 2022 01:26
@CapnBry
Copy link
Member

CapnBry commented Feb 21, 2022

Can this function also be achieved by connecting to the WIFI of the ELRS TX?

No, that would require a whole lot more code to make happen, and the performance would be absolutely terrible. The configuration connection expects a pretty high bandwidth and low latency connection since it normally runs over serial. Running it over an extremely high latency link at ~5kbit throughput will cause Betaflight Configurator to timeout repeatedly and make a lot of redundant requests that will be discarded.

There would be a lot of work needed in BF Configurator to be even tolerant of a low bandwidth high latency connection. It is just a mountain of work for both projects, and the user experience is going to still be pretty awful due to the link speed limitations like trying to stream full resolution video over a dialup modem. There are plenty of ESP-based ELRS RX that will support this though, so it isn't too much to ask of the user to just spend $15 on a new RX if they want this feature instead of getting it for free on old R9 hardware + TX MSP passthrough and then complaining about how terribly it works.

adds lib

adds msp<->crsf  encap and decap lib

base libs working

lib updates

lib updates

fix test cases and mspv1 jumbo

testing something

more

Update CRSF.cpp

Update CRSF.cpp

Add missing functions

pushSize, popSize & peekSize

Fix CRC8 being limited to 255 bytes size

Add missing includes and members

Fix unit test
Fix compilation on different target platforms

working fine with 4.3 RC2

revert unneeded define

fix missing logging.h and line feed

Fix compilation on non ESP based targets

Fix RX as TX target
@reednoel4u
Copy link

Not yet, I waitìng for the new version, that be add labrary tcp

@5t0x2fH1z
Copy link

hmmm. I'm using 2.4.0 firmware version with betafpv nano rx and betaflight can't connect.

@pkendall64
Copy link
Collaborator

This feature will not be available until release 3.0

@5t0x2fH1z
Copy link

Is it available in any other branch so I can merge it in my own?

This code is merged into the master branch. If you are wishing to test, then you could flash master to both your TX module and an RX.

@pkendall64
Copy link
Collaborator

Is it available in any other branch so I can merge it in my own?

This code is merged into the master branch. If you are wishing to test, then you could flash master to both your TX module and an RX.

No it's not on any other branch. All the changed files are in this PR, so you could try to put them into a 2.4 if you want to try it for yourself.

@5t0x2fH1z
Copy link

Is it available in any other branch so I can merge it in my own?

This code is merged into the master branch. If you are wishing to test, then you could flash master to both your TX module and an RX.

No it's not on any other branch. All the changed files are in this PR, so you could try to put them into a 2.4 if you want to try it for yourself.

Good to know. Thanks

@5t0x2fH1z
Copy link

But as I can see this PR is already marked as merged

@pkendall64
Copy link
Collaborator

But as I can see this PR is already marked as merged

Yes, to the master branch, which will become 3.0 when we are ready.

@5t0x2fH1z
Copy link

5t0x2fH1z commented May 8, 2022

Yes, to the master branch, which will become 3.0 when we are ready.

So flashing rx with the master branch should make this feature available, right?

@howels
Copy link

howels commented May 8, 2022

Yes, to the master branch, which will become 3.0 when we are ready.

So flashing rx with the master branch should make this feature available, right?

You need to flash TX also or TX won't talk to the RX. At least I think so, OTA protocol has had some updates for 3.0 and I think it breaks compatibility with 2.x

@5t0x2fH1z
Copy link

Yes, to the master branch, which will become 3.0 when we are ready.

So flashing rx with the master branch should make this feature available, right?

You need to flash TX also or TX won't talk to the RX. At least I think so, OTA protocol has had some updates for 3.0 and I think it breaks compatibility with 2.x

I guess TX is not needed in order this feature to work, but good to know it also have to be updated

@AVIC621
Copy link

AVIC621 commented May 21, 2022

Need some help! master branch can not for build

image

@slmnow
Copy link

slmnow commented Jul 12, 2022

Great work! Hoping a mavlink2crsf (mavlink over expesslrs) version for ardupilot is coming.

@fa-lk
Copy link

fa-lk commented Aug 26, 2022

What would be needed to get this also working with INAV?

@RomanLut
Copy link

RomanLut commented May 5, 2023

Lost few hours intill I noticed that "Telemetry output" is not enabled in "Receiver tab" in Betaflight configurator in my ad-hoc setup...

@CREASE-gum-EAR
Copy link

What's the baud rate of this serial over wifi connection? I use it for INAV configuration on my big planes and it can be a little slow. But that may be just wifi interference with such small wifi antennas. I was thinking of trying Airport for configuring at the bench. But is Wifi still wayyyy faster than Airport? This PR appears to be the only official documentation of this feature. Maybe after this I'll commit something to the docs.

@RomanLut
Copy link

I use it for INAV configuration on my big planes and it can be a little slow.

This feature does not work with inav. Inav is missing mspV2 support in mspOverCrsf implementation. Inav configurator is sending mspv2 packets.

For inav you have to look at esp-link or bronebridge connected to msp uart.

@howels
Copy link

howels commented Jun 29, 2023

What's the baud rate of this serial over wifi connection? I use it for INAV configuration on my big planes and it can be a little slow. But that may be just wifi interference with such small wifi antennas. I was thinking of trying Airport for configuring at the bench. But is Wifi still wayyyy faster than Airport? This PR appears to be the only official documentation of this feature. Maybe after this I'll commit something to the docs.

Slightly slower with eLRS than Crossifre and Tracer, so there was some modification recently in Betaflight to check the serial of the CRSF device - eLRS devices all have the serial EXPRESSLRS which can be used to tune throughput and avoid dropped MSP frames.
iNav should look at this - the RX uses mDNS to advertise itself so it's very friendly to autodetect on wifi

@psfales
Copy link

psfales commented Sep 28, 2023

I was intrigued by this and noticed that the original comment says "Has also been tested to work with betaflight configurator on Andriod. [sic]" Can anyone shed some light on what Android app works with this? It works very well on my computer at home, but it would be great if could be used at the field with an Android app!

@klmn1k
Copy link

klmn1k commented Jan 19, 2024

Can I flash firmware with it?

@pkendall64
Copy link
Collaborator

Can I flash firmware with it?

It's built in to all V3 firmwares

@klmn1k
Copy link

klmn1k commented Jan 19, 2024

Can I flash firmware with it?

It's built in to all V3 firmwares

I mean Betaflight. Can I update betaflight using this? Via wifi?

@pkendall64
Copy link
Collaborator

Can I flash firmware with it?

It's built in to all V3 firmwares

I mean Betaflight. Can I update betaflight using this? Via wifi?

No, you cannot update betaflight firmware via the wifi connection.

@bastian2001
Copy link

Hi there, and sorry for reviving such an old PR...
I know we all hate MSP Jumbo frames, but I think there might be something wrong in the implementation. From the iNav docs it seems like in a V1 Jumbo frame, the length bytes are the indices 4 and 5, but in msp2crsf.cpp, line 120 bytes 5 and 6 are used. Similarly, here bytes 2 and 3 are used, as opposed to 1 and 2 (byte 0 is 255, followed by the actual length in bytes 1 and 2). Am I missing something here?

@pkendall64
Copy link
Collaborator

Am I missing something here?

Yes, MSP V1 Jumbo frames have the payload_size at index 3 set to 255, and the actual size is in the payload at index 5 & 6. Specified in the docs that you link to!

@bastian2001
Copy link

bastian2001 commented May 18, 2025

is in the payload

Ah I totally misread that, thanks. I always thought that the length is set to 255, and then it's immediately followed by the actual size (i.e. before the command).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects

Development

Successfully merging this pull request may close these issues.