ConnectAPI Docs - v2.0

Hi all, I’ve been working with @Cameron on docs for the new API, which are now live on the official GitHub page: https://github.com/flyingdevelopmentstudio/infiniteflight-api. Docs for v1 are still available at the bottom of the page.

The docs are current as of Infinite Flight 19.4, and contain information on states associated with the 172 (Steam) aircraft. I’ll be working to add more aircraft info to the docs as I have time.

If you have any questions, would like to contribute, or need clarification on any commands please don’t hesitate to shoot me a PM.

Happy app building!

6 Likes

Incredible job! These are so so so detailed! The new API looks great too!

1 Like

That’s great to see! Just recently added that to the Trello board perhaps I should move it to ‘in progress’.

2 Likes

Holy Moly, that’s a lot of info! Thanks so much!

2 Likes

Hey @tomthetank I’ve been trying to get the Connect API V2 to work but I think there’s an issue with how I’m sending data. Are the values (ie 635,false etc) meant to be sent as an array? Or CSV? I’ve tried both to no avail. Thanks!

It’s sent as the data converted to an array of bytes. One way of doing this is using the following method (for C#).

Here’s my own implementation of my sendInt function in Swift:

private func sendInt(val: Int32) {
    var intData = val
    let data = Data(bytes: &intData, count: MemoryLayout.size(ofValue: intData))
    _ = data.withUnsafeBytes {
        guard let pointer = $0.baseAddress?.assumingMemoryBound(to: Byte.self) else {
            print("Error sending command")
            return
        }
        self.outputStream.write(pointer, maxLength: data.count)
    }
}

Call me stupid but what is this data? I’m in Node here, this is what I’ve got;

  1. Command String is 1048616,false but I’ve also tried [1048616, false] and 1048616, false. All produce these results.
  2. Create Uint8Array from data
  3. Create buffer from Uint8Array
  4. Send write that buffer to the socket
  5. No response from IF

The data is what you want to send (an int, bool, whatever…) which you then convert to bytes.

So for your example, you’d send just an int 1048616 converted to bytes, Then a bool false. Your method sounds correct otherwise, but I’m not familiar with node or js.

Are they comma separated on am I sending 2 separate messages?

Two separate messages

1 Like

I see, that’s where I’ve been going wrong. Thanks!

1 Like

After a lot of tinkering I’ve managed to at least get a response from the API, but the bytes don’t seem to result to any sort of string. Here are the bytes. I sent 1048616 for FlapsFullDown then false as instructed.

0, 0, 0, 0, 4, 0, 0, 0
32, 0, 0, 0
0, 0, 0, 0, 4, 0, 0, 0, 32, 0, 0, 0
0, 0, 0, 0, 4, 0, 0, 0, 32, 0, 0, 0

Can anyone make any sense of those? Those are all separate messages I got.

Any news on these, I’m getting slighting different buffers

10 00 00 00 04 00 00 00 00 00 00 00

But still meaning less.

How are you getting these?

IF sends them when you run a command

Can you be more specific?

  • What language are you using?
  • What command are you sending and how are you sending it?
  • What response do you get and how do you process it, if at all?
  • NodeJS
  • I’m sending the autopilot toggle (integer 1048635), and boolean false. Note: The 10, 04 buffer seems to be indiscriminate of what command is sent.
    Im sending it by converting the data to buffers and then sending them to IF:
let buffer;
      switch(typeof inData){
        case "boolean":
          buffer = Buffer.allocUnsafe(4);
          buffer.writeInt32BE(inData == true ? 1 : 0);
          break;
        case "number":
          buffer = Buffer.allocUnsafe(4);
          buffer.writeInt32LE(inData);
        break;
      }
      
      IFC.sockets.client.write(buffer);
  • I’m simply listening for data and no processing other than regurgitating what buffer it is

It may also be of importance to note the command does not result in an action. However the code above does work for requesting the manifest so…

I’m gonna redo my code. Give me a while then ill get back to you, see if I still have this problem

1 Like

Why do you use Big Endian for boolean and Little Endian for integer?

It might not be necessary to allocate 4 bytes for your boolean sending, just 1 should be enough…