pyFlipper, is a Unoffical Flipper Zero cli wrapper written in Python.

Functions and characteristics

  •  Flipper serial CLI wrapper
  •  Websocket client interface

Setup instructions

$ git clone https://github.com/wh00hw/pyFlipper.git
$ cd pyFlipper
$ python3 -m venv venv
$ source venv/bin/activate
$ pip install -r requirements.txt

Tested on

  •  Python 3.8.10 on Linux 5.4.0 x86_64
  •  Python 3.9.10 on Windows 10
  •  Python 3.10.5 on Android 12 (Termux + OTGSerial2WebSocket NO ROOT REQUIRED)

Usage/Examples

Connection

from pyflipper import PyFlipper
Local serial port
flipper = PyFlipper(com=”/dev/ttyACM0″)
OR
Remote serial2websocket server
flipper = PyFlipper(ws=”ws://192.168.1.5:1337″)

Power

Info
info = flipper.power.info()
Poweroff
flipper.power.off()
Reboot
flipper.power.reboot()
Reboot in DFU mode
flipper.power.reboot2dfu()

Update/Backup

Install update from .fuf file
flipper.update.install(fuf_file=”/ext/update.fuf”)
Backup Flipper to .tar file
flipper.update.backup(dest_tar_file=”/ext/backup.tar”)
Restore Flipper from backup .tar file
flipper.update.restore(bak_tar_file=”/ext/backup.tar”)

Storage

Filesystem Info

Get the storage filesystem info
ext_info = flipper.storage.info(fs=”/ext”)

Explorer

Get the storage /ext dict
ext_list = flipper.storage.list(path=”/ext”)
Get the storage /ext tree dict
ext_tree = flipper.storage.tree(path=”/ext”)
Get file info
file_info = flipper.storage.stat(file=”/ext/foo/bar.txt”)
Make directory
flipper.storage.mkdir(new_dir=”/ext/foo”)

Files

Read file
plain_text = flipper.storage.read(file=”/ext/foo/bar.txt”)
Remove file
flipper.storage.remove(file=”/ext/foo/bar.txt”)
Copy file
flipper.storage.copy(src=”/ext/foo/source.txt”, dest=”/ext/bar/destination.txt”)
Rename file
flipper.storage.rename(file=”/ext/foo/bar.txt”, new_file=”/ext/foo/rab.txt”)
MD5 Hash file
md5_hash = flipper.storage.md5(file=”/ext/foo/bar.txt”)
Write file in one chunk
file = “/ext/bar.txt”
text = “””There are many variations of passages of Lorem Ipsum available,
but the majority have suffered alteration in some form, by injected humour,
or randomised words which don’t look even slightly believable.
If you are going to use a passage of Lorem Ipsum,
you need to be sure there isn’t anything embarrassing hidden in the middle of text.
“””flipper.storage.write.file(file, text)
Write file using a listener
file = “/ext/foo.txt”
text_one = “””There are many variations of passages of Lorem Ipsum available,
but the majority have suffered alteration in some form, by injected humour,
or randomised words which don’t look even slightly believable.
If you are going to use a passage of Lorem Ipsum,
you need to be sure there isn’t anything embarrassing hidden in the middle of text.
“””
flipper.storage.write.start(file)
time.sleep(2)
flipper.storage.write.send(text_one)
text_two = “””All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as
necessary, making this the first true generator on the Internet.
It uses a dictionary of over 200 Latin words, combined with a handful of
model sentence structures, to generate Lorem Ipsum which looks reasonable.
The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc.
“””flipper.storage.write.send(text_two)
time.sleep(3)
Don’t forget to stop
flipper.storage.write.stop()