Skip to content

feat(flipper): Flipper Zero integration for NFC dump import#239

Open
codebutler wants to merge 5 commits intomasterfrom
flipper
Open

feat(flipper): Flipper Zero integration for NFC dump import#239
codebutler wants to merge 5 commits intomasterfrom
flipper

Conversation

@codebutler
Copy link
Owner

Summary

  • New :flipper KMP module with protobuf RPC client for Flipper Zero communication over USB serial and BLE
  • Platform transports: Android USB + BLE, iOS BLE, Desktop jSerialComm, Web Serial + Web Bluetooth
  • FlipperScreen UI with file browser, connection management, and batch import
  • Global MIFARE Classic key dictionary stored in DB, used as fallback in ClassicCardReader
  • FlipperNfcParser extracts Classic keys from sector trailers during import
  • FlipperKeyDictParser imports Flipper user key dictionary files
  • Comprehensive unit and integration tests

Platform Support

Platform USB BLE
Android
iOS
Desktop
Web

New Files

  • flipper/ — entire new KMP module (RPC client, transports, protobuf, parsers)
  • FlipperScreen.kt, FlipperUiState.kt, FlipperViewModel.kt — UI layer
  • FlipperTransportFactory + 4 platform implementations — DI-wired transport creation

Modified Files

  • ClassicCardReader — global key dictionary fallback auth
  • CardKeysPersister — global key CRUD methods
  • SavedKey.sqglobal_keys table
  • Platform DI graphs — FlipperTransportFactory providers
  • HomeScreen — "Flipper Zero" menu item
  • App.kt — FlipperScreen navigation route
  • strings.xml — localized Flipper UI strings

Test plan

  • :flipper:jvmTest — all pass (varint, protobuf, RPC client, key dict parser, integration)
  • :card:classic:jvmTest — global key auth test passes
  • :app:compileKotlinJvm — builds
  • :app:desktop:compileKotlinJvm — builds
  • :app:compileKotlinWasmJs — builds
  • Manual test with real Flipper Zero hardware

🤖 Generated with Claude Code

Claude and others added 5 commits February 16, 2026 22:21
…ross all platforms

iOS:
- Replace dispatch_semaphore bridging with suspendCancellableCoroutine in
  IosCardTransceiver, IosUltralightTechnology, IosVicinityTechnology, and
  IosFeliCaTagAdapter
- Replace runBlocking in IosNfcScanner with CoroutineScope(Dispatchers.IO)
  + GCD semaphore to avoid blocking GCD's worker queue thread
- Use DESFire native protocol directly instead of ISO 7816 SELECT, which
  requires AIDs registered in Info.plist (unregistered AIDs kill the session)
- Add NFCPollingISO15693 to NFC session polling options for NFC-V support
- Fix Xcode project paths from stale farebot-app/ to app/

Desktop:
- Make NfcReaderBackend.scanLoop() a suspend function, removing runBlocking
  from PN53xReaderBackend and PcscReaderBackend
- Wrap scan coroutine in try/finally to ensure _isScanning resets on cancel
- Share a single libusb context in PN533Device instead of per-call init/exit

WebUSB:
- Remove flush-on-open which left dangling transferIn promises that consumed
  subsequent device responses
- Increase transferIn buffer from 64 to 265 bytes for full PN533 frames
- Pass atrRetries to setMaxRetries so InListPassiveTarget self-resolves
  instead of relying on client-side abort (which WebUSB can't do)

DESFire:
- Handle COMMAND_ABORTED (0xCA) status code as access control exception
Add new :flipper KMP module with protobuf RPC client that communicates
with Flipper Zero over USB serial and BLE. Supports browsing the NFC
file system, importing card dumps, and importing MIFARE Classic key
dictionaries into the app's global key store.

Platform transports:
- Android: USB Host API (CDC ACM) + BLE GATT
- iOS: Core Bluetooth BLE
- Desktop: jSerialComm USB serial
- Web: Web Serial API + Web Bluetooth API

Also adds:
- Global MIFARE Classic key dictionary (global_keys DB table)
- ClassicCardReader global key auth fallback
- FlipperScreen Compose UI with file browser
- FlipperViewModel with connect/import logic
- FlipperNfcParser Classic key extraction from sector trailers
- Comprehensive tests (unit + integration)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add @ObjCSignatureOverride to conflicting CoreBluetooth delegate
  methods (centralManager and peripheral overloads)
- Fix characteristics list fallback (use early return instead of
  emptyList<CBCharacteristic>())
- Add Flipper Zero integration section to README
- Add flipper/ to project structure in README

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Rename _connected to connected (backing property rule)
- Rename FlipperMain.kt to CommandStatus.kt (single class naming)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…hBytes

- Import ObjCSignatureOverride from kotlinx.cinterop (not kotlin.experimental)
- Use NSData.dataWithBytes() instead of NSData.create() matching existing
  NfcDataConversions.kt pattern
- Remove unnecessary memScoped wrapper from toNSData()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant