Crates.io | flipper-rpc |
lib.rs | flipper-rpc |
version | 0.9.4 |
created_at | 2025-06-07 22:31:27.557684+00 |
updated_at | 2025-06-29 18:38:10.207866+00 |
description | Flipper Zero Remote Procedure Call Library (RPC) β A Rust π¦ library enabling apps to remotely control a Flipper Zero device, similar to qFlipper. Built using the official Flipper Zero protobuf definitions. |
homepage | |
repository | https://github.com/elijah629/flipper-rpc |
max_upload_size | |
id | 1704475 |
size | 149,603 |
flipper-rpc
β Serial RPC Control for the Flipper Zero
Finally! A Rust library to control a Flipper Zero through RPC commands.
flipper-rpc
is a Rust library for sending and receiving RPC messages to and
from a Flipper Zero over a serial connection.
tokio-tracing
compatibleNothing for now... Add an issue if you want something cool added!
Feature | Description |
---|---|
default |
minimal |
full |
Enables *-all |
minimal |
Just proto |
proto |
Protobuf encoding/decoding |
easy-rpc |
Highβlevel RPC helper API |
fs-all |
Enables all filesystem operations |
fs-read |
Read files from Flipper Zero |
fs-write |
Write files to Flipper Zero |
fs-readdir |
List directory contents |
fs-remove |
Remove files or directories |
fs-createdir |
Create directories on device |
transport-all |
All available transport mechanisms |
transport-any |
Base transport support |
transport-serial |
Serialβport communication |
transport-serial-optimized |
Optimized serial transport with a better varint decoder |
tracing |
Enable logging via tokio-tracing |
[!IMPORTANT] Please decide on features, and don't just use the
full
feature since you are lazy. Actually read the table above and enable what you need as it will significantly decrease compile time.
Run this command
cargo add flipper-rpc --features <FEATURES>
Or add this to your Cargo.toml
:
[dependencies]
flipper-rpc = { features = [], version = "0.9.0" } # Replace with the latest version from crates.io
let ports = list_flipper_ports()?;
let port = &ports[0].port_name;
let mut cli = SerialRpcTransport::new(port.to_string())?;
let response = cli.send_and_receive(Request::SystemPlayAudiovisualAlert)?;
After far too much searching for usable documentation on this API (and finding nothing), I decided to write my own. Enjoy!
[!NOTE] Read the source code for information about actual communication, the following information is only for serial transport (BLE COMING SOON)
Make a serial connection. Use your preferred serial library. This crate
uses serialport
, which is simple and only
requires the port path and a baud rate.
Baud rate... Apparently doesn't matter Serial over USB (CDC-ACM
)
abstracts baud rate away, it must be reasonable and capable by the hardware
and software.
Drain the buffer. Keep reading until you see the shell prompt string
">: "
. This clears old buffer content, since reads begin from the buffer
start β not your last write.
Enter RPC mode. Write the string: start_rpc_session\r
Note:
\r\n
does not work here. I do not know why.
Drain again. Read until you receive \n
, which indicates that the
Flipper has accepted the command.
π’ Varint is a variable-length integer encoding. The Flipper expects this as the first byte(s) of your message.
PingRequest
with [1, 2, 3, 4]
Raw request bytes:
[8, 42, 6, 10, 4, 1, 2, 3, 4]
8
is the Varint-encoded length of the rest of the message.Read the length prefix The length is a Varint and can be up to 10 bytes.
1
.src/transport/serial/rpc.rs
,
read_raw(...)
as it is too long to mention here.Read and decode Once the length is known, read that many bytes, then decode with your protobuf deserializer.
[8, 50, 6, 10, 4, 1, 2, 3, 4]
This crate was built to support another project I'm working on: π
flippy
β a CLI tool for updating
firmware and databases on the Flipper Zero from remote sources.
Since there was no existing way to speak RPC to the Flipper in Rust, I split that functionality into this standalone library.
π« Shameless plug: If you find this useful, give it a star β β I'd appreciate it!
This project would not be possible without two amazing repos: