Skip to main content

Python bindings for Flipper Zero protobuf protocol

Project description

Python bindings for Flipper Zero protobuf protocol

Python API binding/wrappers for Flipper Zero protobuf protocol and command line tool

[!NOTE]
This is a fork based on the original repo by Flipper Zero. I'm just a guy with no affiliation to Flipper Devices Inc.


flipperCmd

The command tool flipperCmd is terminal based tool for file transfer and remote command. It can be run from the command line or as an interactive app.

It is still a work in progress (Alpha) but is functional. We are looking for help with stabilization of this build, making it work on any system.

If you want to contribute, we run black and isort for code formatting purposes.


Command Line Examples

List and manage files from command line

$ flipperCmd ls
Using port /dev/cu.usbmodemflip_Unyana1
.fseventsd/              .Spotlight-V100/         badusb/                  dolphin/
ibutton/                 infrared/                lfrfid/                  music_player/
nfc/                     subghz/                  u2f/                     wav_player/
.metadata_never_index    favorites.txt            Manifest                 rwfiletest.bin

Copy single files to fromFlipper device

$ flipperCmd put My_Home_TV.ir /ext/infrared
Using port /dev/cu.usbmodemflip_UOhBaby
PUT My_Home_TV.ir /ext/infrared
putting 206 bytes

Copy directory tree to Flipper device

$ flipperCmd put-tree subghz/samples /ext/subghz

Interactive Command Mode Examples

$ flipperCmd
Using port /dev/cu.usbmodemflip_UOhBaby
Entering interactive mode

/ext flipper> help
    CAT                 : read flipper file to screen
    CD CHDIR            : change current directory on flipper
    DEV-INFO            : print device info
    DF INFO             : get Filesystem info
    DU DISK-USAGE       : display disk usage statistic
    GET GETFILE         : copy file from flipper
    GET-TREE GETTREE    : copy directory tree from flipper
    HELP ?              : print command list
    HISTORY HIST        : Print command history
    LCD LCHDIR          : Change local current directory
    LPWD                : print local working directory
    LS LIST             : list files and dirs on Flipper device
    MD MKDIR            : create a new directory
    MD5SUM MD5          : md5 hash of the file
    MV RENAME           : rename file or dir
    PRINT-SCREEN        : Take screendump in ascii or PBM format
    PUT PUTFILE         : copy file to flipper
    PUT-TREE PUTTREE    : copy directory tree to flipper
    QUIT EXIT           : Exit Program
    REBOOT              : reboot flipper
    RM DEL DELETE       : delete file of directory on flipper device
    SEND SEND-COMMAND   : Send non rpc command to flipper
    SET                 : set or print current option value
    STAT                : get info about file or dir
    START-SESSION       : (re) start RPC session
    STOP-SESSION        : stop RPC session
    TIME                : Set or Get Current time from Flipper
    ZIP                 : Generate Zip Archive

/ext flipper> ls
.Spotlight-V100/         .Trashes/                apps/                    badusb/
dolphin/                 elf/                     ibutton/                 infrared/
lfrfid/                  music_player/            nfc/                     subghz/
u2f/                     wav_player/              .metadata_never_index    favorites.txt
Manifest                 rwfiletest.bin
/ext flipper> ls ?
Syntax :
	LS [-l] [-m] <path>
    
/ext flipper> ls -lm
Storage List result:  /ext
.Spotlight-V100          	   DIR
.Trashes                 	   DIR
apps                     	   DIR
badusb                   	   DIR
dolphin                  	   DIR
elf                      	   DIR
ibutton                  	   DIR
infrared                 	   DIR
lfrfid                   	   DIR
music_player             	   DIR
nfc                      	   DIR
subghz                   	   DIR
u2f                      	   DIR
wav_player               	   DIR
.metadata_never_index    	     0 d41d8cd98f00b204e9800998ecf8427e
favorites.txt            	    93 50c7a56f93d8f6c87f205691def774fa
Manifest                 	 16871 c74a84dea8d644198d27755313942614
rwfiletest.bin           	 16384 3df67097cee5e4cea36e0f941c134ffc
Total Bytes: 33348

/ext flipper> rcd infrared/
remote directory = /ext/infrared 

/ext/infrared flipper> ls
assets/                  IRDB/                    Sanyo/                   TV_Philips/
Minolta.ir               My_Home_TV.ir

/ext/infrared flipper> quit
Quit interactive mode

API Examples:

#!/usr/bin/env python3

from flipperzero_protobuf.cli_helpers import print_hex, dict2datetime
from flipperzero_protobuf.flipper_proto import FlipperProto


def main():

    proto = FlipperProto()

    print("\n\nPing")
    ping_rep = proto.rpc_system_ping()
    print_hex(ping_rep)

    print("\n\n]DeviceInfo")
    device_info = proto.rpc_device_info()
    print(device_info)

    print("\n\nGetDateTime")
    dtime_resp = proto.rpc_get_datetime()
    dt = dict2datetime(dtime_resp)
    print(dt.ctime())

    print("\n\nList files")
    list_resp = proto.rpc_storage_list('/ext')
    for li in list_resp:
        print(f"[{li['type']}]\t{li['name']}")

    # run Infrared App
    print("\n\nrun Infrared App")
    proto.rpc_app_start('Infrared', '/ext/infrared/Tv_Tivo.ir')


if __name__ == '__main__':
    main()


See Also:
flipperdevices/flipperzero-protobuf
flipperdevices/go-flipper

Special thanks: Evilpete - for making a wrapper and a code cleanup for our internal tool!

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

flipperzero_protobuf-0.1.20221108.tar.gz (34.3 kB view details)

Uploaded Source

Built Distribution

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

flipperzero_protobuf-0.1.20221108-py3-none-any.whl (42.9 kB view details)

Uploaded Python 3

File details

Details for the file flipperzero_protobuf-0.1.20221108.tar.gz.

File metadata

File hashes

Hashes for flipperzero_protobuf-0.1.20221108.tar.gz
Algorithm Hash digest
SHA256 64e4117a9fe3e06f7d652c513774ade7fc22bd25c2ddcef3f460582e9d31fe80
MD5 b049143c996b06f5b56ea5deec15d61c
BLAKE2b-256 9a56d395d8d4f1267c63d4159b0f00b91a60e4345d990bb108e184bbd5167b12

See more details on using hashes here.

File details

Details for the file flipperzero_protobuf-0.1.20221108-py3-none-any.whl.

File metadata

File hashes

Hashes for flipperzero_protobuf-0.1.20221108-py3-none-any.whl
Algorithm Hash digest
SHA256 f96a99aec1e01f46d24f05ef1dcab11d9b4d7c6f92abece030b414ef62c82fd2
MD5 7cbc013d3d5bfdbe09f9a7eec824c0cf
BLAKE2b-256 3ef6b7f86453c691d40bd772b14d94ec5c48b5f46d376cb710f7c3739dfeed4f

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