Git Product home page Git Product logo

fsmosquitoclient's Introduction

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):

  • FS2020
  • Git
  • Visual Studio 2019 (or other IDE that supports .net core development)

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:

  • FsSimConnect - Basically a wrapper around SimConnect that makes it easier to be controlled
  • FsMqtt - Provides the communication layer to a MQTT broker
  • SimConnectMqttAdapter - Performs the functional adaptation of the comms between SimConnect and Mqtt.
  • MainForm - Provides a minimalistic UI - and importantly a WinHandle that SimConnect posts messages to.

Design

How SimConnect works is that it uses Windows Procedures to communicate with applications out-of-process

Within the SimConnect constructor, one passes the handle of the window that should be notified by FS2020 when a message is available.

This mechanism happens within Forms/MainForm.cs class with the WndProc override.

When that message is recieved by the MainForm, it raises an event which is handled by the SimConnectMqttAdapter which then requests the actual data associated with the message from SimConnect.

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.

  • In VS2019, right click the FSMosquitoClient project and select "Publish".
  • Choose the 'Create FSMosquitoClient Release' publishing profile
  • Press the 'Publish' button. A new single-file build will be located in $(ProjectLocation)\bin\x64\Release\netcoreapp3.1\win-x64\publish

A GitHub action is included that will automatically build and publish new releases to GitHub

  • On Push to Master or on PR - Builds the project and stores the result as an artifact (except for changes to README.md and /docs/*)
  • On tag that starts with 'v' (ex: git tag -a v0.2.0-alpha01 -m "Release Description" && git push --tags) Builds the project and creates a release that corresponds to the tag.

Resources

https://csharp.hotexamples.com/examples/-/SimConnect/RequestDataOnSimObject/php-simconnect-requestdataonsimobject-method-examples.html

fsmosquitoclient's People

Contributors

oceanswave avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

fsmosquitoclient's Issues

No data

Hey, i tried to use this app. The app is connected to SimConnect and to FSMosquito, but i see nothing about the flight.
The logfile says allways "Main form activated". What do i wrong?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.