Using Programming Interface

This chapter introduces basic API usage, allowing you to understand another way to use FIRERPA. FIRERPA provides up to 160 programming API interfaces, allowing you to manage and operate Android devices meticulously. It provides interfaces in more than a dozen major categories, including command execution, system settings, system status, application-related, automation-related, proxy, and files. It also provides a fully packaged Python library to help you get started quickly. Before proceeding, please ensure that the FIRERPA server is running normally on your phone and that you have installed the FIRERPA client library as required. Now, let’s begin the following tutorial.

A note before we start: Many of the API interfaces provided by FIRERPA return native proto classes. You can directly access these values through the output properties or by checking the proto definition and accessing the values directly through properties. For example, if an interface returns the following, you can directly access specific fields using the example method.

>>> result = status.get_battery_info()
>>> print (result)
batt_charging: true
batt_percent: 100
batt_temperature: 26.899999618530273
>>> print (result.batt_temperature)
26.899999618530273

Connecting to Device

Before connecting to the device, you need to prepare some necessary information, such as the IP address that can connect to your phone, and whether you used an encryption certificate when starting FIRERPA. After preparing this information, you can continue with the following operations.

Instantiate the device. By default, just provide the accessible IP address.

from lamda.client import *
d = Device("192.168.0.2")

If you enabled an encryption certificate when starting the FIRERPA server, connect like this.

from lamda.client import *
d = Device("192.168.0.2", certificate="/path/to/lamda.pem")

From now on, the variable d in the following text will always be this Device instance.

Simple Warm-up

Now, execute the following code. The line below will display a message Hello from Lamda! on your screen.

d.show_toast("Hello from Lamda!")

You can also use the following interface, which can make the device emit a beep. When you have a bunch of devices, you can easily locate it (requires the phone to be in non-silent mode).

d.beep()

Alright, now you understand how to use it. You can continue reading to learn about other available interfaces and how to use them.