Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Readme
Using python to connect the Infinite Flight Connect API v1/v2.
pip3 install ifcclient
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)
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.
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')
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)
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')
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)
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()
FAQs
Python client for Infinite Flight Connect API v1/2
We found that ifcclient demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.