Commit 037f2fe
fix: replace blocking NFC calls with proper coroutine/suspend APIs across all platforms (#238)
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
Co-authored-by: Claude <claude@codebutler.com>1 parent a5b8e57 commit 037f2fe
16 files changed
Lines changed: 261 additions & 299 deletions
File tree
- app
- desktop/src/jvmMain/kotlin/com/codebutler/farebot/desktop
- ios
- FareBot.xcodeproj
- web/src/wasmJsMain/kotlin/com/codebutler/farebot/web
- card
- desfire/src/commonMain/kotlin/com/codebutler/farebot/card/desfire
- felica/src/iosMain/kotlin/com/codebutler/farebot/card/felica
- src
- iosMain/kotlin/com/codebutler/farebot/card/nfc
- jvmMain/kotlin/com/codebutler/farebot/card/nfc/pn533
- wasmJsMain/kotlin/com/codebutler/farebot/card/nfc/pn533
Whitespace-only changes.
Lines changed: 32 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
94 | 99 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | 100 | | |
99 | 101 | | |
100 | | - | |
101 | 102 | | |
102 | | - | |
| 103 | + | |
103 | 104 | | |
104 | | - | |
105 | | - | |
106 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
107 | 111 | | |
108 | | - | |
109 | 112 | | |
110 | 113 | | |
111 | 114 | | |
112 | 115 | | |
113 | 116 | | |
114 | 117 | | |
115 | | - | |
116 | | - | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
Lines changed: 3 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
44 | | - | |
45 | 44 | | |
46 | 45 | | |
47 | 46 | | |
| |||
59 | 58 | | |
60 | 59 | | |
61 | 60 | | |
62 | | - | |
| 61 | + | |
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
| |||
72 | 71 | | |
73 | 72 | | |
74 | 73 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 74 | + | |
| 75 | + | |
79 | 76 | | |
80 | 77 | | |
81 | 78 | | |
| |||
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
54 | | - | |
| 53 | + | |
55 | 54 | | |
56 | 55 | | |
57 | 56 | | |
| |||
96 | 95 | | |
97 | 96 | | |
98 | 97 | | |
99 | | - | |
| 98 | + | |
100 | 99 | | |
101 | 100 | | |
102 | 101 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | | - | |
14 | 12 | | |
15 | 13 | | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | 14 | | |
31 | 15 | | |
32 | 16 | | |
33 | 17 | | |
34 | 18 | | |
35 | | - | |
36 | 19 | | |
37 | 20 | | |
38 | 21 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | 22 | | |
51 | 23 | | |
52 | 24 | | |
| |||
67 | 39 | | |
68 | 40 | | |
69 | 41 | | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | 42 | | |
79 | 43 | | |
80 | 44 | | |
81 | 45 | | |
82 | | - | |
83 | 46 | | |
84 | 47 | | |
85 | 48 | | |
| |||
94 | 57 | | |
95 | 58 | | |
96 | 59 | | |
97 | | - | |
98 | | - | |
99 | 60 | | |
100 | 61 | | |
101 | 62 | | |
| |||
176 | 137 | | |
177 | 138 | | |
178 | 139 | | |
179 | | - | |
| 140 | + | |
180 | 141 | | |
181 | 142 | | |
182 | 143 | | |
| |||
324 | 285 | | |
325 | 286 | | |
326 | 287 | | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
332 | 292 | | |
333 | 293 | | |
334 | 294 | | |
| |||
357 | 317 | | |
358 | 318 | | |
359 | 319 | | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
365 | 324 | | |
366 | 325 | | |
367 | 326 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | 41 | | |
45 | 42 | | |
46 | 43 | | |
| |||
Lines changed: 50 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
42 | | - | |
| 46 | + | |
43 | 47 | | |
44 | 48 | | |
45 | 49 | | |
46 | 50 | | |
47 | 51 | | |
48 | 52 | | |
| 53 | + | |
49 | 54 | | |
50 | 55 | | |
51 | 56 | | |
| |||
116 | 121 | | |
117 | 122 | | |
118 | 123 | | |
119 | | - | |
| 124 | + | |
120 | 125 | | |
121 | 126 | | |
122 | 127 | | |
| |||
170 | 175 | | |
171 | 176 | | |
172 | 177 | | |
173 | | - | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
179 | 199 | | |
180 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
181 | 212 | | |
182 | 213 | | |
183 | 214 | | |
| |||
197 | 228 | | |
198 | 229 | | |
199 | 230 | | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
208 | 237 | | |
209 | 238 | | |
210 | 239 | | |
| |||
228 | 257 | | |
229 | 258 | | |
230 | 259 | | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
231 | 264 | | |
232 | 265 | | |
233 | 266 | | |
234 | | - | |
| 267 | + | |
235 | 268 | | |
236 | 269 | | |
237 | 270 | | |
| |||
0 commit comments