Giter Club home page Giter Club logo

flipperzero_protobuf_py's Introduction

Python bindings for Flipper Zero protobuf protocol

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


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!

flipperzero_protobuf_py's People

Contributors

aku-plooks avatar doomwastaken avatar drzlo13 avatar evilpete avatar fmazan avatar gsurkov avatar lomalkin avatar nminaylov avatar samuelyvon avatar skotopes avatar vanish125 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flipperzero_protobuf_py's Issues

Remove deprecated `distutils` dependency (PEP 632)

distutils is deprecated in Python 3.10+ (source).

It seems on the only place that references it is in setup.py (source)

from distutils.command.install_scripts import install_scripts

The migration advice (source) recommends setuptools as the best alternative for distutils.command but it also looks like the references to install_scripts have been commented out (source) so the import might not be necessary

TypeError: 'type' object is not subscriptable

Failing to run flipperCmd using python3.8 (Ubuntu 20.04.5 LTS)

Traceback (most recent call last): File "/home/xwz/tools/venv/bin/flipperCmd", line 5, in <module> from flipperzero_protobuf.flipperCmd.flipperzero_cmd import main File "/home/xwz/tools/venv/lib/python3.8/site-packages/flipperzero_protobuf/__init__.py", line 4, in <module> from .flipper_proto import FlipperProto File "/home/xwz/tools/venv/lib/python3.8/site-packages/flipperzero_protobuf/flipper_proto.py", line 12, in <module> from .flipper_sys import FlipperProtoSys File "/home/xwz/tools/venv/lib/python3.8/site-packages/flipperzero_protobuf/flipper_sys.py", line 23, in <module> class FlipperProtoSys: File "/home/xwz/tools/venv/lib/python3.8/site-packages/flipperzero_protobuf/flipper_sys.py", line 127, in FlipperProtoSys def rpc_power_info(self) -> tuple[str, str]: TypeError: 'type' object is not subscriptable

making package installable + api wrapper.

Are there any plans to make this into an installable package?

I've put together some python binding / frameworks for wrapper code for doing file IO that uses flipperzero_protobuf interface.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.