I’ve been doing some experimentation with the v2 Connect API with the aim of updating some of projects including a module I built for NodeJS previously for V1, a Node server which could be used to expose a Web API to the Connect API (partially built for V1 but now migrating to V2) and also an iOS app that is in the idea phase right now.
Experimenting from Node and Swift I can connect, send a command, and get something back but am struggling with interpreting the response. In the docs, there is an example of fetching the strobe lights state with command 635
for the Cessna 172. I can send 635
followed by false
– that works and I get back a series of data which is in hex as follows when my strobes are on:
7B 02 00 00 04 00 00 00 00 00 E0 41 00 00 00 00 04 00 00 00 20 00 00 00
I am struggling with completely understanding what this represents. As I understand the documentation for the v2 API, I should get back something like this example from the docs:
635
,1
,1
I interpret the 635
as echoing back the command, the first 1
as length of the data being returned (in this case, 1 byte I guess) and the second 1
as being the actual state data. I’m not clear if I should expect the commas in the data or actually three items of data back-to-back (or separate by some hex or other delimiter). I’m guessing there is no comma or delimiter in the actual data returned from the formatting of the documentation (the commas in the docs aren’t code-formatted).
From that point I get lost trying to correlate the data I get back to that example, however. I believe the first two bytes map to the 635
command since 7B 02
swapped to 027B
is 635
in decimal. But after that I get confused. I can’t see anything there that would indicate two values of 1
and 1
or anything else logical to me.
I have looked at the v2 demo .Net code – but having zero .Net experience isn’t helping me navigate the code. What I can get out of it is that the stream should be:
-
An integer for the command code (the first two bytes, presumably)
-
An integer for the length (the next two bytes, I assume) – which above means a length of
0
? Surely that doesn’t make sense (or, does it). -
The data itself – which, if it should be an integer per the docs/example, would mean the next two bytes? That would be a value of ‘0004’? So – that’s
4
in decimal which I don’t know what it would mean here.
And then I’m left wondering what the rest of that data I got back in the stream actually means when I didn’t send any other commands.
Am I missing something fundamental here? Any advice appreciated.
Arman