Skip to main content

Python client for Infinite Flight Connect API v1/2

Project description

Infinite Flight Connect API Client

Using python to connect the Infinite Flight Connect API v1/v2.

Installation

pip3 install ifcclient

Usage

Before getting started, make sure to enable the Infinite Flight Coneect in the app Settings > General > Enable Infinite Flight Connect

First, import the module in Python and discover devcies in the same network, you can use duration to specific the time to discover, you can use duration=0 to return the first device you discovered.

import ifcclient
devices = ifcclient.IFCClient.discover_devices(duration=0)

API V2

Init the client object.

ifc = ifcclient.IFClient.connect(devices[0], version=2) # version is 2 by default

There are three ways to use the Infinite Flight Connected API V2, GetState, SetState, RunCommand. You can check Infinite Flight website for the detail of API.

GetState

To get a state from the API, send a get_state_by_name() request as follows:

ifc.get_state_by_name(name)
# For example
ifc.get_state_by_name('aircraft/0/systems/flaps/state')

SetState

To set states -- assigning new values to them -- through the API by sending a request as outlined below.

However, not all states can be set and the manifest offers no indication of which states can be set and which can't. The only way to determine this is trial-and-error and some common sense.

ifc.set_state_by_name(name, value)
# For example
ifc.set_state_by_name('aircraft/0/systems/flaps/state', 2)

RunCommand

To execute a command through the API, send a run_command_by_name() request.

ifc.run_command_by_name(command)
# For example
ifc.run_command_by_name('commands/NextCamera')

API V1

Init the client object for V1.

ifc = ifcclient.IFClient.connect(devices[0], version=1)

With V1, to send a command, use the send_command function. The first parameter is the command, the second parameter are the parameters passed to Infinite Flight while the third parameter determines whether to wait for a response or not. Await response is false by default although it must be enabled when expecting a response.

ifc.send_command("{CommandName}", [Parameters], await_response=True)
ifc.send_command("{CommandName}", [Parameters]) # await_response is False by default
# For example
ifc.send_command("airplane.getstate", [], await_response=True)
ifc.send_command("flightplan.get", [], await_response=True)

functions share with v1/v2

Two commonly used operations, one is to get the state of the aircraft, the other is to get the flightplan, these two methods, get_aircraft_state() and get_flightplan() which can be used in both V1/V2. It also provides a function display_commands() to list all the avaliable commands.

ifc.get_aircraft_state()
ifc.get_flightplan()
ifc.display_command()

Future updates

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ifcclient-0.0.5.1.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ifcclient-0.0.5.1-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file ifcclient-0.0.5.1.tar.gz.

File metadata

  • Download URL: ifcclient-0.0.5.1.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.6

File hashes

Hashes for ifcclient-0.0.5.1.tar.gz
Algorithm Hash digest
SHA256 35e6c91655ae4e2f360501a51fadcde600860f52c34eb1d2c6c682ad500ae610
MD5 1a65ffa311280f39fe921483a2cca58a
BLAKE2b-256 074aa6317989fb9cbe18144c18021e155eabedac3482c02336cf1c27e182b505

See more details on using hashes here.

File details

Details for the file ifcclient-0.0.5.1-py3-none-any.whl.

File metadata

  • Download URL: ifcclient-0.0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.6

File hashes

Hashes for ifcclient-0.0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b8a38c056bf58fd2b5120cae97bdb1804664062e1a9588e18f1b405f8cad13f4
MD5 6d11e79c0e0595fa7ede9a3381899410
BLAKE2b-256 aba255eb14395d1e69c425b683aef2dc10bf4ed1279c04f69dcfae5da09c4cea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page