Commit 9e5e95f
feat(flipper): Flipper Zero integration for NFC dump import (#239)
* fix: replace blocking NFC calls with proper coroutine/suspend APIs across 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
* feat(flipper): add Flipper Zero integration for NFC dump import
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>
* fix(flipper): iOS BLE compilation and README update
- 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>
* fix(flipper): ktlint fixes for MockTransport and CommandStatus
- 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>
* fix(ios): use correct ObjCSignatureOverride import and NSData.dataWithBytes
- 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>
* fix(flipper): correct BLE RPC protocol and protobuf field numbers
Remove CLI start_rpc_session handshake — BLE goes directly into protobuf
mode. Fix all protobuf field numbers to match official flipper.proto
(ping=5/6, storage_list=7/8, storage_read=9/10, device_info=32/33).
Fix CommandStatus enum values to match proto (was missing ERROR_DECODE,
ERROR_NOT_IMPLEMENTED, ERROR_BUSY). Add FlipperDebugLog with build
version counter. Fix import progress indicator to be indeterminate.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor(flipper): extract shared BLE transport logic to commonMain base class
Extract FlipperBleTransportBase with shared UUID constants, read buffering
(Channel + readBuffer), flow control parsing, and close lifecycle. Android
and iOS BLE transports now extend the base class instead of duplicating
this logic. Web transport drops its local UUID aliases (JS interop has
them hardcoded).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* chore(flipper): remove debug logging infrastructure
Remove FlipperDebugLog, all log() calls in IosBleSerialTransport and
FlipperRpcClient, debugLog() calls in FlipperViewModel, the DebugLogView
composable, the debugLog field from FlipperUiState, and the iOS file
writer setup in MainViewController.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(ui): consolidate import options into bottom sheet with Flipper UX improvements
Replace separate "Import from File" and "Flipper Zero" menu items with a
single "Import" item that opens a ModalBottomSheet showing platform-aware
options (File Browser, Flipper BLE, Flipper USB). Hoist FlipperViewModel
to enable immediate connection on transport selection. Add scrim overlay
to Flipper import progress, and snackbar feedback on import completion.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(ui): polish import sheet, Flipper screen, and card status icons
Disconnect Flipper on back navigation instead of a separate button.
Show 'Flipper Zero' title during connecting state, center the spinner.
Remove Import menu item from Explore tab (Cards tab only).
Fix transparent backgrounds for bottom sheet list items.
Always show Keys menu item regardless of platform.
Pass supportedCardTypes/loadedKeyBundles to HistoryContent so imported
cards display correct status icons instead of always showing unsupported.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(ui): replace Share/Save with file-based Share icon, simplify Flipper retry
Replace two text menu items (Share, Save) with a single Share icon button
in the card screen top bar that shares a .json file via platform-native
file sharing (FileProvider on Android, temp file URL on iOS, download on
web, save dialog on desktop).
Simplify Flipper disconnected screen: since the connection protocol is
already chosen from the home screen, replace USB/BLE buttons with a
single Retry button that re-attempts the same protocol.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(flipper): use name-prefix filter for Web Bluetooth device discovery
Chrome's requestDevice with a services filter requires the device to
advertise the service UUID in its BLE advertisement packets. Flipper
Zero advertises by name but doesn't include the serial service UUID in
its advertisement data. Switch to namePrefix: 'Flipper' filter (matching
Android/iOS behavior) and move the service UUID to optionalServices.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(ui): move sample cards into import bottom sheet
Replace the overflow menu item with a 'Sample Cards' entry (with Code
icon) as the last option in the import bottom sheet.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(ui): use IosShare icon on iOS for share button
Add expect/actual platformShareIcon so iOS gets the native-looking
IosShare icon while other platforms keep the standard Share icon.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(flipper): add console logging to Web BLE transport
Add [FareBot BLE] prefixed console.log/error messages throughout the
Web Bluetooth JS interop for easier debugging in Chrome DevTools.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(ui): always show Sample Cards, move Keys to Cards tab only
Show the Sample Cards import option in all builds (not just debug).
Remove Keys menu item from Explore tab since it only applies to the
Cards tab. Add Import option to Explore tab menu.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(ui): remove Import from Explore tab menu
Import is only relevant on the Cards tab.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* feat(ui): include card name and serial in share filename
Share files are now named like 'farebot-suica-04AB1234.json' instead
of the generic 'farebot-card.json'.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(flipper): filter BLE devices by advertised service UUIDs instead of name prefix
Match the official Flipper iOS app approach: scan for advertised service
UUIDs (0x3080-0x3083) corresponding to hardware variants (f6, black,
white, clear) instead of filtering by device name prefix.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(flipper): correct protobuf field numbers in tests to match Flipper proto spec
Tests were using wrong Main envelope field numbers (e.g. 20 for
storage_list_response instead of 8, 22 for storage_read_response
instead of 10). Fixed to match the actual Flipper protobuf definition.
Also fixed CommandStatus.ERROR_STORAGE_NOT_READY assertion (value is 5,
not 2) and updated testConnectSendsStartRpcSession since BLE doesn't
use a text handshake.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* refactor(ui): use selection-mode top bar for Flipper file selection
Replace the bottom action bar (Import Selected / Import Keys buttons)
with a selection-mode TopAppBar matching the Home screen pattern:
selected files show [X] N selected [Download] in the top bar. Import
Keys moves to an overflow menu on the regular top bar.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(ui): use proper plurals and localized strings for Flipper import messages
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(ui): polish Flipper file browser path bar, list item heights, and file sizes
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(flipper): send start_rpc_session handshake for USB serial connections
USB serial connects to Flipper's CLI mode. Must send 'start_rpc_session'
and drain the CLI response before entering protobuf RPC mode. BLE
transports go directly to protobuf mode and skip this step.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(flipper): drain CLI buffer before starting RPC session over USB
The Flipper's serial buffer may contain existing CLI output. Send an
empty command to trigger a fresh prompt, drain until '>: ' is seen,
then send start_rpc_session and wait for the confirming newline.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(flipper): remove debug logging from RPC handshake
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* fix(flipper): buffer excess bytes in Web Serial reads and fix RPC handshake
Web Serial reader.read() returns variable-size chunks but the transport
was discarding all bytes beyond the requested length. Added a JS-side
buffer so excess bytes are preserved for subsequent reads. Also fixed
the USB handshake to passively wait for the CLI prompt instead of
sending an extra CR that created a stale second prompt in the buffer.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude <claude@codebutler.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent 037f2fe commit 9e5e95f
67 files changed
Lines changed: 4895 additions & 405 deletions
File tree
- app
- android/src/main
- res/xml
- desktop/src/jvmMain/kotlin/com/codebutler/farebot/desktop
- ios/FareBot
- src
- androidMain/kotlin/com/codebutler/farebot
- app/core
- di
- platform
- commonMain
- composeResources/values
- kotlin/com/codebutler/farebot
- persist
- db
- sqldelight/com/codebutler/farebot/persist/db
- commonTest/kotlin/com/codebutler/farebot/test
- web/src/wasmJsMain/kotlin/com/codebutler/farebot/web
- card/classic/src
- commonMain/kotlin/com/codebutler/farebot/card/classic
- commonTest/kotlin/com/codebutler/farebot/card/classic
- flipper
- src
- androidMain/kotlin/com/codebutler/farebot/flipper
- commonMain/kotlin/com/codebutler/farebot/flipper
- proto
- commonTest/kotlin/com/codebutler/farebot/flipper
- proto
- iosMain/kotlin/com/codebutler/farebot/flipper
- jvmMain/kotlin/com/codebutler/farebot/flipper
- wasmJsMain/kotlin/com/codebutler/farebot/flipper
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| |||
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| 21 | + | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
22 | | - | |
| 25 | + | |
23 | 26 | | |
| 27 | + | |
24 | 28 | | |
25 | 29 | | |
26 | 30 | | |
| |||
48 | 52 | | |
49 | 53 | | |
50 | 54 | | |
51 | | - | |
| 55 | + | |
52 | 56 | | |
53 | 57 | | |
54 | 58 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
97 | 107 | | |
98 | 108 | | |
99 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
87 | 89 | | |
88 | 90 | | |
89 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
90 | 96 | | |
91 | 97 | | |
92 | 98 | | |
Lines changed: 14 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | | - | |
29 | | - | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
30 | 41 | | |
31 | 42 | | |
32 | 43 | | |
| |||
47 | 58 | | |
48 | 59 | | |
49 | 60 | | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | 61 | | |
66 | 62 | | |
67 | 63 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
114 | 116 | | |
115 | 117 | | |
116 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
117 | 124 | | |
118 | 125 | | |
119 | 126 | | |
| |||
Lines changed: 15 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
87 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
88 | 99 | | |
89 | 100 | | |
90 | | - | |
91 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
92 | 104 | | |
93 | 105 | | |
94 | 106 | | |
| |||
138 | 150 | | |
139 | 151 | | |
140 | 152 | | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | 153 | | |
0 commit comments