fsmosquito / FSMosquitoClient

Client for FSMosquito which relays SimVars from SimConnect via MQTT
3 stars 3 forks source link
fs2020 mqtt simconnect simvars

FSMosquitoClient

Deprecation Notice - This repository is archived in favor of https://github.com/fsmosquito/fsmosquito which includes all the functionality contained in this repository (within /fsmosquito-simconnect-client) with the addition of a desktop application that displays a moving map and eventually more.

Client application that connects to FS2020 via SimConnect and relays data to the FSMosquito Server via MQTT

Build FSMosquito Client

Getting Started

  1. Download the latest FSMosquito Client release on the releases tab and unzip into a folder of your choosing.
  2. Register for an account at www.fsmosquito.com - Currently in Alpha
  3. After email verification, once logged in, obtain the authentication token from the 'account' page (UI/XP needs to be improved)
  4. Within the folder that you unzipped the FSMosquito Client, with a text editor such as notepad, edit the appsettings.json and place your username and the authentication token in the appropriate fields and save the file.
  5. Launch the client by 2x clicking FSMosquitoClient.exe
  6. Start FS2020 and Fly!

Developing

Prerequisites (For just the client):

Pretty straight forward, this is a .Net Core 3.1 application using Windows Forms.

The necessary FS2020 SDK files are included in the /lib folder (these will probably need to be updated over time as FS2020 is updated)

I'm using VS2019 for development, but there shouldn't be anything that prevents VSCode from being the IDE of choice during the development process except for it's annoyances with C#. Maybe JetBrains Rider is a good alternative that doesn't require a full VS2019 license.

With VS2019, just open the .sln file and run.

There are four main classes involved:

The adapter then then serializes this data into a MQTT message and publishes it to the broker.

The metrics that are transmitted are very much like individual data points that an IoT device would be relaying to an IoT edge server which can be analyzed. In FSMosquito's case this data is subscribed by various server components which notify the web client of position updates and react to events such as taking off and landing at airports.


SimConnect requires a client app to register 'subscriptions' to various events that occur in FS2020 prior to having those events be raised by the instance of a SimConnect class. The FSMosquitoClient doesn't statically register these events, but subscribes to requests for registration events coming from the MQTT broker (FSMosquitoServer) and then correspondingly registers the event with SimConnect.

This allows for the data points that are utilized by the FSMosquitoServer to change and grow over time. Effectively, the FSMosquitoClient is just a "dumb pipe" that facilitates communication between FS2020 and the FSMosquitoServer.


The client currently also accepts SimVars to be set via MQTT messages as well, this opens up some interesting possibilities for automation.

TODO: System variables, invoking various SimConnect functions

MQTT Broker

While by default the client is configured to use FSMosquito's hosted broker, the client can be pointed at any MQTT Broker that supports web sockets. Simply change the connection string in appconfig.json to point to your own MQTT broker

Some available MQTT Brokers:

Logs

Currently the FSMosquitoClient creates log files located in the ./logs folder relative to where the FSMosquitoClient.exe is located.

Releasing

This project contains a publishing profile that will bundle the application (including all .net dependencies) into a single file.