EvenAR / node-simconnect

A cross platform SimConnect client library for Node.JS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MSFS Navdata API Implementation - Request

whakamolenz opened this issue · comments

In SU10, Asobo introduced an enhanced nav data api to get various nav and airport related data. Any chance of an implementation?

https://docs.flightsimulator.com/html/Programming_Tools/SimConnect/API_Reference/Facilities/SimConnect_AddToFacilityDefinition.htm

Thanks for the feature request!

If anyone knows the new IDs for the request/subscribe/add packets, I believe this should be fairly straight forward to implement. My first guess is that the new IDs just continues where the FSX packet IDs ends (67 / 0x43), but there must be a better way to find them than with trial and failure.

Edit: here's a tool I found on the MSFS forums which I think can be used to analyse the SimConnect packets, but it requires a client that already uses the new protocol features. I might look into this in a few days unless someone else does it.

I did have a basic example getting some parking data form the new APIs - let me see if i can use that tool to get some ideas on the packets.

I'm using the older node-simconnect v2 beta in my existing code for this sample code, and i can't work out how to get that older code version to talk to a different simconnect port to use that proxy tool. SimConnect.cfg doesn't seem to do anything?

But below is the basic code that does the new API calls, if that is quicker to get you able to test yourself? The complexity with these calls is this OPEN / CLOSE definitions to surround the data you are interested in.

hr = SimConnect_AddToFacilityDefinition(
hSimConnect,
facilityDataDefinitionId,
"OPEN AIRPORT");

hr = SimConnect_AddToFacilityDefinition(
     hSimConnect,
     facilityDataDefinitionId,
     "PRIMARY_DESIGNATOR");

hr = SimConnect_AddToFacilityDefinition(
     hSimConnect,
     facilityDataDefinitionId,
     "N_TAXI_PARKINGS");

hr = SimConnect_AddToFacilityDefinition(
     hSimConnect,
     facilityDataDefinitionId,
     "OPEN TAXI_PARKING");

hr = SimConnect_AddToFacilityDefinition(
     hSimConnect,
     facilityDataDefinitionId,
     "RADIUS");

hr = SimConnect_AddToFacilityDefinition(
     hSimConnect,
     facilityDataDefinitionId,
     "CLOSE TAXI_PARKING");

hr = SimConnect_AddToFacilityDefinition(
    hSimConnect,
    facilityDataDefinitionId,
    "CLOSE AIRPORT");

HRESULT hr = SimConnect_RequestFacilityData(
    hSimConnect,
    facilityDataDefinitionId,
    facilityRequestId,
    airportICAO.c_str());

Thanks @whakamolenz. With the help from "SimConnect_Proxy" I think I managed to get the codes and packet formats right 🤞 I used one of the SimConnect samples from Asobo which uses the new features, as a client.

Could you give the beta a try and see if it works as expected? Here's the code that I used for testing.

npm install node-simconnect@beta

@EvenAR - wonderful - yes will give it a try over the next 24 hours and let you know! thanks for picking this up so quickly. Not sure if you have seen FSLTL (open source AI traffic package) for MSFS - but we use this simconnect package for the injector code. This new version just makes everything so much easier!

I couldn't wait to try :-) So far it looks great for what i need right now - but i will be trying out more with respect to Approach data etc to try and work around some issues Asobo introduced in SU11 for AI traffic. For me all the api calls i've used in MSFS that are supported by the platform have worked flawlessly so far.

Thanks for the quick feedback @whakamolenz ! I'm glad you find it useful and it's really cool to hear that you are using it in FSLTL 😃

I took the time to implement the rest of the new facility-features I could find. In case you need any of them they are available in 3.2.0-beta.1

  • SimConnect_RequestFacilityData_EX1
  • SimConnect_RequestFacilitiesList_EX1
  • SimConnect_SubscribeToFacilities_EX1
  • SimConnect_UnsubscribeToFacilities_EX1

The new features are now included in the official verion so I will close this.