Package: pyflipper
PyFlipperUnoffical Flipper Zero cli wrapper written in PythonArticlesHow to hack a restaurantFunctions and characteristics:Flipper serial CLI wrapperWebsocket client interfaceSetup instructions:$pipinstallpyflipperTested on:Python 3.8.10 on Linux 5.4.0 x86_64Python 3.9.10 on Windows 10Python 3.10.5 on Android 12 (Termux +OTGSerial2WebSocketNO ROOT REQUIRED)Usage/ExamplesConnectionfrompyflipper.pyflipperimportPyFlipper#Local serial portflipper=PyFlipper(com="/dev/ttyACM0")#OR#Remote serial2websocket serverflipper=PyFlipper(ws="ws://192.168.1.5:1337")Power#Infoinfo=flipper.power.info()#Poweroffflipper.power.off()#Rebootflipper.power.reboot()#Reboot in DFU modeflipper.power.reboot2dfu()Update/Backup#Install update from .fuf fileflipper.update.install(fuf_file="/ext/update.fuf")#Backup Flipper to .tar fileflipper.update.backup(dest_tar_file="/ext/backup.tar")#Restore Flipper from backup .tar fileflipper.update.restore(bak_tar_file="/ext/backup.tar")Loader#List installed appsapps=flipper.loader.list()#Open appflipper.loader.open(app_name="Clock")Flipper Info#Get flipper datedate=flipper.date.date()#Get flipper timestamptimestamp=flipper.date.timestamp()#Get the processes dict listps=flipper.ps.list()#Get device info dictdevice_info=flipper.device_info.info()#Get heap info dictheap=flipper.free.info()#Get free_blocks stringfree_blocks=flipper.free.blocks()#Get bluetooth infobt_info=flipper.bt.info()StorageFilesystem Info#Get the storage filesystem infoext_info=flipper.storage.info(fs="/ext")Explorer#Get the storage /ext dictext_list=flipper.storage.list(path="/ext")#Get the storage /ext tree dictext_tree=flipper.storage.tree(path="/ext")#Get file infofile_info=flipper.storage.stat(file="/ext/foo/bar.txt")#Make directoryflipper.storage.mkdir(new_dir="/ext/foo")Files#Read fileplain_text=flipper.storage.read(file="/ext/foo/bar.txt")#Remove fileflipper.storage.remove(file="/ext/foo/bar.txt")#Copy fileflipper.storage.copy(src="/ext/foo/source.txt",dest="/ext/bar/destination.txt")#Rename fileflipper.storage.rename(file="/ext/foo/bar.txt",new_file="/ext/foo/rab.txt")#MD5 Hash filemd5_hash=flipper.storage.md5(file="/ext/foo/bar.txt")#Write file in one chunkfile="/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 listenerfile="/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 asnecessary, making this the first true generator on the Internet.It uses a dictionary of over 200 Latin words, combined with a handful ofmodel 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 stopflipper.storage.write.stop()LED/Backlight#Set generic led on (r,b,g,bl)flipper.led.set(led='r',value=255)#Set blue led offflipper.led.blue(value=0)#Set green led valueflipper.led.green(value=175)#Set backlight onflipper.led.backlight_on()#Set backlight offflipper.led.backlight_off()#Turn off ledflipper.led.off()Vibro#Set vibro True or Falseflipper.vibro.set(True)#Set vibro onflipper.vibro.on()#Set vibro offflipper.vibro.off()GPIO#Set gpio mode: 0 - input, 1 - outputflipper.gpio.mode(pin_name=PIN_NAME,value=1)#Set gpio pin value: 0 - off, 1 - onflipper.gpio.set(pin_name=PIN_NAME,value=1)#Read gpio pin valueflipper.gpio.read(pin_name=PIN_NAME)MusicPlayer#Play song in RTTTL formatrttl_song="Littleroot Town - Pokemon:d=4,o=5,b=100:8c5,8f5,8g5,4a5,8p,8g5,8a5,8g5,8a5,8a#5,8p,4c6,8d6,8a5,8g5,8a5,8c#6,4d6,4e6,4d6,8a5,8g5,8f5,8e5,8f5,8a5,4d6,8d5,8e5,2f5,8c6,8a#5,8a#5,8a5,2f5,8d6,8a5,8a5,8g5,2f5,8p,8f5,8d5,8f5,8e5,4e5,8f5,8g5"#Play in loopflipper.music_player.play(rtttl_code=rttl_song)#Stop loopflipper.music_player.stop()#Play for 20 secondsflipper.music_player.play(rtttl_code=rttl_song,duration=20)#Beepflipper.music_player.beep()#Beep for 5 secondsflipper.music_player.beep(duration=5)NFC#Synchronous default timeout 5 seconds#Detect NFCnfc_detected=flipper.nfc.detect()#Emulate NFCflipper.nfc.emulate()#Activate fieldflipper.nfc.field()RFID#Synchronous default timeout 5 seconds#Read RFIDrfid=flipper.rfid.read()#Emulate RFIDemulated=flipper.rfid.emulate(key_type="EM4100",key_data="5500824806")#Write RFIDwritten=flipper.rfid.write(key_type="EM4100",key_data="5500824806")SubGhz#Transmit hex_key N times(default count = 10)flipper.subghz.tx(hex_key="DEADBEEF",frequency=433920000,count=5)#Receive (default frequency=433920000 raw=False timeout=5 seconds)received=flipper.subghz.rx(frequency="433920000",raw=True,timeout=10)#Decode raw .sub filedecoded=flipper.subghz.decode_raw(sub_file="/ext/subghz/foo.sub")Infrared#Transmit hex_address and hex_command selecting a protocolflipper.ir.tx(protocol="Samsung32",hex_address="C000FFEE",hex_command="DEADBEEF")#Raw Transmit samplesflipper.ir.tx_raw(frequency=38000,duty_cycle=0.33,samples=[1337,8888,3000,5555])#Synchronous default timeout 5 seconds#Receive txr=flipper.ir.rx(timeout=10)IKEY#Read (default timeout 5 seconds)ikey=flipper.ikey.read()#Write (default timeout 5 seconds)flipper.ikey.write(key_type="Dallas",key_data="DEADBEEFCOOOFFEE")#Emulate (default timeout 5 seconds)flipper.ikey.emulate(key_type="Dallas",key_data="DEADBEEFCOOOFFEE")Log#Attach event logger (default timeout 10 seconds)logs=flipper.log.attach()Debug#Activate debug modeflipper.debug.on()#Deactivate debug modeflipper.debug.off()Onewire#Searchresponse=flipper.onewire.search()I2C#Getresponse=flipper.i2c.get()Input#Input dumpdump=flipper.input.dump()#Send inputflipper.input.send("up","press")OptimizationsFeel free to contribute in any wayQueue Thread orchestratorImplement all the cli functionsAsync SubGhz ChatLicenseMITBuy me a pintZEC:zs13zdde4mu5rj5yjm2kt6al5yxz2qjjjgxau9zaxs6np9ldxj65cepfyw55qvfp9v8cvd725f7tz7ETH:0xef3cF1Eb85382EdEEE10A2df2b348866a35C6A54BTC:15umRZXBzgUacwLVgpLPoa2gv7MyoTrKatContactsDiscord: white_rabbit#4124Twitter: @nic_whrGPG: 0x94EDEADC