dlktdr / HeadTracker

This project is built to record the orientation a FPV headset to allow the camera on your RC to follow your head movements.
GNU General Public License v3.0
363 stars 82 forks source link

Add in bluetooth module will not stream data wirelessly. #22

Closed dlktdr closed 3 years ago

dlktdr commented 3 years ago

The stand-alone bluetooth module available for the X10 X10S and X12S will not stream data. There is a few variations in the BLE protocol and will not send data to the head tracker.

Two users have this module in a Jumper TX16s and would not function. I would have to assume that it won't work in the X10, X10S and X12S as well.

twistedwings commented 3 years ago

yes, I know. I assume trainer would work if the headtracker behaves like the old module. Whatever that means, I am no bluetooth expert.

rotorman commented 3 years ago

Found a long docu about OpenTX for FrSky and clones and it lists on page 836 CC2650 as PARA chip: https://www.schorse-video.de/images/webshare/OpenTX_Manual_Deutsch.pdf

dlktdr commented 3 years ago

Well Guess what...

I got a connection!

"Trainer signal recovered" never sounded so good.

I almost was about to give up and didn't realize it was actually receiving data!

I've been porting all the code over to Zephyr OS. It's Bluetooth library is more mature and also supports pairing out of the box.

I know probably everyone with this board has probably already swapped it.. but there is hope for those that haven't!

Because I have to ditch all the Arduino code and have to re-work parts of it it's going to be a bit before a working copy is ready. So far just serial and Bluetooth are working. Initial tests are it's a far better operating system. Just the support for thread pre-emption is worth learning it.

I have high hopes with this setup there will be no disconnects and I can up the update rate now that it can interrupt other parts of the code easily.

rotorman commented 3 years ago

I am still stuck with the "cheap" CC2540, so this is absolutely awesome news! For my understanding - the encrypted connection with CC2540 works under Zephyr, but didn't under Arduino? (pairing code likely 000000 ?) Best!

dlktdr commented 3 years ago

So there is no passcode after all.

In Zephyr you can set the characteristic permissions to be BT_GATT_PERM_WRITE_ENCRYPT or BT_GATT_PERM_WRITE_AUTHEN. The latter which requires an actual authentication. Turns out it's just encrypted so sniffers can't see the data hence why we can see it on our phones without a code. Learning more about BLE as I go...

I have to admit, I didn't try too hard on the modified Arduino library with pairing support so it might have still been able to do it. I really wanted to solve the other Bluetooth issues so I thought I would give Zephyr a go.. so far so good. And since I still have the cheap CC2540 module in both of my radios right now this was my first try.

Currently working the unforeseen issues. Now that threads can be pre-empted has caused a bunch of non-thread safe & re-entrant code to fail. Also have to re-work the I2C libs, Flash, Analog and remote para still. Luckily since I did PPM, SBUS and PWM on hardware level they work as expected :)

rotorman commented 3 years ago

It looks FrSky is not making, at least CC2540 boards, themselves but get them from Shenzhen RF-star Technology Co., Ltd.: https://www.rfstariot.com/product/141.html and https://www.szrfstar.com/upload/file/1586418083.pdf (page 2).

And in RCGroups post here: https://www.rcgroups.com/forums/showpost.php?p=47198353&postcount=10405 there seems to be the bootloader and firmware binaries available for this module: https://www.rcgroups.com/forums/showatt.php?attachmentid=15013387&d=1622028449

CorruptName commented 3 years ago

So I found this thread because I purchased: https://www.horusrc.com/en/frsky-horus-x10-para-wireless-module.html After watching AndyRC's video. I have bluetooth address but the name wont change from "hello" and I'm not able to connect to it. Any Suggestions?

dlktdr commented 3 years ago

@CorruptName So with the para module the name is always hello. That's normal no matter what you set it to on your radio.

Just to check you have your radio set to Bluetooth trainer under the hardware page. Under the model page you should choose Trainer -> Master / Bluetooth at the bottom.

GUI needs to have the Bluetooth mode enabled on the bluetooth tab first. Remeber to click Save to NVM too.

Then choose Discover option below Master/Bluetooth on your radio, the Address of the Headtracker should be pop up in a few seconds and match the address the GUI shows.

You don't hear trainer signal recovered the first connection. But if you power off nano33 board you should hear trainer signal lost and plug in again should say recovered then.

After that should just be setting the channels you want on the mixes page to TRx..

CorruptName commented 3 years ago

Thanks for the help. Do you know if telemetry works over this module as well? Or should I get a better module? If so, which one?

On Mon, Jun 7, 2021, 10:58 PM Cliff @.***> wrote:

So with the para module the name is always hello. That's normal no matter what you set it to on your radio.

Just to check you have your radio set to Bluetooth trainer under the hardware page. Under the model page you should choose Master / Bluetooth at the bottom.

GUI needs to have the Bluetooth mode enabled on the bluetooth tab first.

Then choose Discover option below Master/Bluetooth on your radio, the Address of the Headtracker should be pop up in a few seconds and match the address the GUI shows.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/dlktdr/HeadTracker/issues/22#issuecomment-856399322, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGFWWL4SB5DAPGFOX5ZOITLTRWBNHANCNFSM4ZNW6GLQ .

dlktdr commented 3 years ago

Afaik it does, haven't personally tried tho. Pretty sure the PARA one is their most recent module. Did you manage to get it to connect?

devosthomas commented 3 years ago

Any update yet on the "cheap CC2540 module" connectivity using Zephyr? Quite frustrating that the BT connection is fine but no data comes through.

dlktdr commented 3 years ago

Well I've been working on it again tonight, and it's looking good so far..

Transmits data now, won't consistently receive it but that isn't as important :( my cheapo Bluetooth scanner is too slow to pick up what is really going on too.

There are a few issues still but I think might be usable for the basics.

Edit: FYI. You need to use a 0.9gui to revert back to the old firmware. another issue... or some well timed double presses of the white button when waiting for programming port.

Feel free to test away, firmware included https://drive.google.com/file/d/1fRXrUo6H1Pf6rAomMv9A2IFUffkKjELv/view?usp=sharing

rotorman commented 3 years ago

Just tested the Zip from last post. For flashing the firmware\BLE v2.00Zephyr.bin to Arduino Nano 33 BLE Sense, I needed to resort to Segger, it did not work from GUI. Otherwise calibration now works also with GUI 2.0 and Zephyr binary.

But most importantly, the data transfer works with cheap FrSky BT CC2540 module as well ;)))

Tiny beautybug with Headtracker 2.00 GUI: when in Bluetooth tab FrSky - Wireless transmitter (Head) is selected, the connected address displayed remains 00:00:00:00:00:00. More a feature request and an idea - when the checkbox for proximity detection is ticked, the tab group title could change from "Nano 33 BLE" to "Nano 33 BLE Sense" and back.

dlktdr commented 3 years ago

Address not showing - Turns out this isn't quite as easy as I thought it would be. Coming back to this one. Can't program in GUI.. double press the white button right when it says waiting for programming port.. Need to get 1200bps touch working, so that functions correct.

Not a bad idea... APSD sensor still to do could easily pass back if it found or not.

two issue above, analog reference level and receiving data from the transmitter are still on the list to be done.

CorruptName commented 3 years ago

Afaik it does, haven't personally tried tho. Pretty sure the PARA one is their most recent module. Did you manage to get it to connect?

Sorry for the delay. Everything works perfectly with the head tracker as expected so far. Thanks for your awesome work.

dlktdr commented 3 years ago

Going to finally close this issue out... WOOT

Here is 2.0 https://github.com/dlktdr/HeadTracker/releases/tag/v2.0

devosthomas commented 3 years ago

just tested it out. Works like a charm on CC2540 based Bluetooth board installed in my Radiomaster TX16s. Thanks for the hard work. Made my day.