Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bekopharm committed Oct 11, 2023
1 parent 0c88537 commit 333ce86
Show file tree
Hide file tree
Showing 9 changed files with 1,057 additions and 0 deletions.
69 changes: 69 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# fdudp-server

A Fly Dangerous telemetry UDP server that converts FD data to an Elite Dangerous Status.

It collects the raw Fly Dangerous telemetry on UDP:11000 and converts the data to the more well known Elite Dangerous Status as described on https://elite-journal.readthedocs.io/en/latest/Status%20File/

This program does not do much on it's own. It's basically just a blueprint for a Node-RED Flow garnished with TypeScript to keep me sane

The exported Node-RED Flow can be found in `dist/node-red-flow.json`.

I wrote this to connect Fly Dangerous to my simulated home cockpit (https://SimPit.dev) to bring my status indicators and my Primary Flight Display to live when hooning around in FD.

Maybe it is of use for others too. Probably not. Anyway here goes.

---
## Requirements

For development you will need Node.js and npm.

To only use this you have to import `dist/node-red-flow.json` into a Node-RED Flow.

### Node
- #### Node installation on Windows

Just go on [official Node.js website](https://nodejs.org/) and download the installer.
Also, be sure to have `git` available in your PATH, `npm` might need it (You can find git [here](https://git-scm.com/)).

- #### Node installation on Ubuntu

You can install nodejs and npm easily with apt install, just run the following commands.

$ sudo apt install nodejs
$ sudo apt install npm

- #### Node installation on Fedora

You can install nodejs and npm easily with dnf install, just run the following commands.

$ sudo dnf install nodejs
$ sudo dnf install npm

- #### Other Operating Systems
You can find more information about the installation on the [official Node.js website](https://nodejs.org/) and the [official NPM website](https://npmjs.org/).

## Install

$ git clone https://github.com/bekopharm/fdudp-server
$ cd fdudp-server
$ npm install

## Using the Node-RED flow

* Launch Node-RED
* Point your browser to http://127.0.0.1:1880/
* Menu => Import => path/to/dist/fdudp-server/node-red-flow.json
* Launch Fly Dangerous from your Steam library
* Options => Integrations => Enable Raw Telemetry
* Options => Integrations => Telemetry Mode JSON
* Launch any game, data should arrive in Node-RED now

Hint: Just remove the "function" after the JSON parsing to get the raw game data.

## Simple build and run for development

$ npm run start:dev

## Simple build and run for production

$ npm run start
84 changes: 84 additions & 0 deletions dist/node-red-flow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
[
{
"id": "3753113e4e85d148",
"type": "tab",
"label": "Fly Dangerous Telemetry",
"disabled": false,
"info": "",
"env": []
},
{
"id": "4a5ee71242f8fdb1",
"type": "udp in",
"z": "3753113e4e85d148",
"name": "FlyDangerous",
"iface": "",
"port": "11000",
"ipv": "udp4",
"multicast": "false",
"group": "",
"datatype": "utf8",
"x": 130,
"y": 220,
"wires": [["4426df8096a51560"]]
},
{
"id": "fd3bb54f21449185",
"type": "json",
"z": "3753113e4e85d148",
"name": "",
"property": "payload",
"action": "",
"pretty": false,
"x": 530,
"y": 220,
"wires": [["2ceb509d85fd9947"]]
},
{
"id": "2ceb509d85fd9947",
"type": "function",
"z": "3753113e4e85d148",
"name": "convertToStatus",
"func": " msg = msg.payload;\n\n if (!msg || msg.flyDangerousTelemetryId != 1) {\n return {};\n }\n\n // console.log(data);\n\n // see https://elite-journal.readthedocs.io/en/latest/Status%20File/\n let flags = 0;\n if (msg.boostChargeReady) flags += 8; // shields ready\n if (msg.isBoostThrustActive) flags += 16; //super cruise\n if (!msg.vectorFlightAssistActive && !msg.rotationalFlightAssistActive)\n flags += 32;\n if (msg.velocityLimiterActive) flags += 512; // Cargo Scoop Deployed\n if (msg.underWater) flags += 1024; // silent running\n if (msg.isBoostSpooling) flags += 65536; //mass locked\n if (msg.isBoostSpooling) flags += 131072; //fsd charging\n if (msg.isBoostThrustActive) flags += 262144; //fsd cooldown\n if (msg.proximityWarning) flags += 4194304; // IsInDanger\n if (msg.lightsActive) flags += 268435456; // night vision\n\n const status = {\n timestamp: new Date().getTime(),\n event: \"Status\",\n Flags: flags,\n Cargo: 0,\n // TODO: that's absolute numbers\n Latitude: 0, //data.lateralHPosition,\n Longitude: 0, //data.lateralVPosition,\n // TODO: to be calculated\n GuiFocus: 0,\n Heading: msg.shipWorldRotationEuler.y,\n Altitude: msg.shipAltitude < 2000 ? msg.shipHeightFromGround : msg.shipAltitude,\n Speed: msg.shipSpeed,\n BodyName: msg.currentLevelName,\n PlanetRadius: 6371,\n }\n\n return {payload: status}",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 700,
"y": 220,
"wires": [["6ee7395b6c5b5866"]]
},
{
"id": "4426df8096a51560",
"type": "delay",
"z": "3753113e4e85d148",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "0.2",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": true,
"allowrate": false,
"outputs": 1,
"x": 340,
"y": 220,
"wires": [["fd3bb54f21449185"]]
},
{
"id": "6ee7395b6c5b5866",
"type": "link out",
"z": "3753113e4e85d148",
"name": "Fly Dangerous UDP Server",
"mode": "link",
"links": ["38e7dc14145211d9"],
"x": 865,
"y": 220,
"wires": []
}
]
6 changes: 6 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"watch": ["src"],
"ext": ".ts,.js",
"ignore": [],
"exec": "npx ts-node ./src/index.ts"
}
Loading

0 comments on commit 333ce86

Please sign in to comment.