stratux icon indicating copy to clipboard operation
stratux copied to clipboard

Support for Bluetooth Low Energy devices

Open rvt opened this issue 2 years ago • 1 comments

I have added support for Bluetooth Low Energy to stratux. To correctly handle this and beable to handle multiple GPS sources the GPS stack has been rewritten such that it will handle Location/Time services from one GPS source only with fall back to other GPS sources with a valid fix because it did not seem logical to process location/time data from all GPS sources at the same time because a bad GPS could them mess up location services from a good connected GPS. For sources like Bluetooth it will do service discovery so it's easy for users to add devices.

Each GPS source has it's own file: bleGPSDevice.go => handle bluetooth low energy devices can handle multiple devices networkDevice.go => handle network devices, multiple devices possible but only one port search be used serialGPSDevice.go => Handle only one connected device, nut it should be relative straight forward to start handling multiple serial sources gps.go => Will be the orchestrator. It will decide what GPS source to use and process these.

For this I had to separate the NMEA parser because it was directly parsing into mySituation and globalStatus to get GPS status information that needs to be tracked for all connected GPS devices.

it's also possible to update any connected GPS device although this is currently only implemented for the serialGPSDevice because of the OGN configuration.

I have taken great care to keep the parser as original as possible, but unfortunately there are some side effects. We will now process a NMEA line ONLY if it's fully valid. In the current version it was possible that even if the NMEA line had valid CRC and valid data, it could also have non valid data and we would still proces it.

A few things that are still on my TODO:

  • [ ] Validate multiple bluetooth devices connected
  • [x] Validate if Flarm data is processed over different connected devices
  • [x] Validate if NMEA over net work is correctly process (I could only simulate it, OGN compile with WIFI did not work yet)
  • [x] Validate long running of Stratux (24h) and test if it will not leak memory // 6 hour run ok // 30h ok
  • [x] Validate stability when we enable/disable GPS sources
  • [x] Understand why switching to a different GPS source time can change a lot (seen more than a second) => This was due to AT65 GPS that sends both GNC and GGA at each whole second
  • [x] Fix null pointer in gap_linux.go or workaround https://github.com/tinygo-org/bluetooth/issues/110 ( after 6 hour test) => Fixed by not continues scanning for BLE devices. I think this is a bug in the bluez/go wrappers where there might be a race condition.
  • [x] more Code cleanup
  • [ ] Configure stratux build scripts to enable bluetooth in the kernel
  • [ ] Anything else??

Notes: I did do some times before and it would crash in around ..6 h in. I think this is because of the ahrs, sometimes I have seen a stacktrace, and sometimes not. With the 30h test I have disabled ahrs and it worked fine. It's also not to say that it is the issue in ahrs, it could also be because if stratux switches from GPS device we get slightly different timings and perhaps setting time back could be an issue? ...

rvt avatar Aug 05 '22 09:08 rvt

V2 for modules was used because... if I remember correctly I had issues setting up a good module structure. If you think I was wrong then I can check that out...

rvt avatar Aug 28 '22 15:08 rvt

I thought if it is possible to use the iPad or Android Table as GPS source. There is an app that delivers GPS position data over IP: https://apps.apple.com/app/gps-2-ip/id408625926

What about adding an IP GPS source? I think would be very useful because the need for a seperate GPS source on stratux would decrease. Stratux makes only sense with an table, so the GPS receiver is always present.

rush0815 avatar Dec 28 '22 07:12 rush0815

@Rush,

from a quick look, the application could push out the right data. However, that means running an application at the background of the telephone? I am not sure if this is possible and if this is reliable. The whole idea of Stratux is that it is a reliable GPS datasource by itself and as a Electronic conspicuity device. You can use it stand alone, or feed data into EFB's like foreflight, Skydemon, EasyVFR That means that the data we feed into it also must be reliable and good, I am not sure if an iPhone/Android would be a good reliable GPS position and time source for us. Currently with the t-beam it provides 5 positional updates/sec which is very nice! I am not sure if the iPhone/Android has that capability.

You are free to try though, the current Stratux already allows for an IP input, this MR improves on that.

rvt avatar Dec 28 '22 12:12 rvt

I just tested GPS2IP and it works to some extent with Stratux, TCP Push, Port 30011, GGA/RMC milliseconds enabled.

Limitations so far:

  • Height of geoid above WGS84 ellipsoid is hard-coded to 46.9m (could certainly be fixed)
  • Horizontal Dilution of Position is hard-coded to 0.9 (we use $GxGSA for that which is not generated by this App)
  • Number of satellites tracked is fixed to 8

There are a few more sentences that could potentially be used by Stratux but they require some modifications (e.g. heading and attitude)

VirusPilot avatar Dec 28 '22 12:12 VirusPilot

Note relevant at this moment

rvt avatar Jul 09 '23 19:07 rvt