bugfix:修复八达通卡支持,增加呼和浩特地铁储值卡,裁剪武汉通卡号#42
Conversation
Signed-off-by: Zamir SUN <sztsian@gmail.com>
Signed-off-by: Zamir SUN <sztsian@gmail.com>
Signed-off-by: Zamir SUN <sztsian@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR adjusts NFC polling/decoding logic to improve Octopus (八达通) detection on iOS, adds a new China Post region code for Hohhot Metro (呼和浩特地铁), and changes WuhanTong (武汉通) card-number extraction to display a shorter number.
Changes:
- Enable ISO-18092 reading during
FlutterNfcKit.pollto support Octopus. - Update JS card parsing to treat Octopus as
iso18092and adjust WuhanTong card number slicing. - Add
"0003": "呼和浩特地铁"toChinaPostCode.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| lib/main.dart | Enables readIso18092 in the main NFC poll path. |
| assets/read.js | Updates Octopus type gating and changes WuhanTong card-number extraction. |
| assets/codes.js | Adds the Hohhot Metro issuer/region code mapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| final tag = await FlutterNfcKit.poll( | ||
| iosAlertMessage: S(context).waitForCard, | ||
| readIso18092: true, | ||
| ); |
There was a problem hiding this comment.
Only this poll call enables readIso18092: true. There is at least one other FlutterNfcKit.poll(...) call site (lib/ui/scripts.dart) that does not set this option, which can lead to inconsistent tag.type values between entry points (and break scripts/logic that expect ISO-18092 tags for Octopus). Consider centralizing poll options or updating the other call site(s) to keep behavior consistent.
| if (tag.type === "iso18092") { | ||
| if (tag.systemCode === "8008") { | ||
| // Octopus | ||
| return await ReadOctopus(); | ||
| } |
There was a problem hiding this comment.
Octopus detection is now gated on tag.type === "iso18092" only. This removes support for tags reported as type === "felica" (which was previously handled) and can regress Octopus reads depending on platform / polling options. Consider accepting both (iso18092 and felica) or normalizing the type before branching.
| let f15 = await BasicInfoFile(fci); | ||
| if (!f15) return {}; | ||
| const number = f15.slice(24, 40); | ||
| const number = f15.slice(31, 40); |
There was a problem hiding this comment.
f15 is a hex string (from buf2hex / APDU response). f15.slice(31, 40) starts at an odd index (splits a byte) and also selects the last 9 chars of the previous 16-char range (24..40), not the “first 9 digits” described in the PR. This is likely an off-by-one / wrong-range bug; consider extracting the full card number field first (byte-aligned) and then truncating to the desired 9-digit display string.
| const number = f15.slice(31, 40); | |
| const card_number_field = f15.slice(24, 40); | |
| const number = card_number_field.slice(0, 9); |
八达通:FlutterNfcKit.poll 时启用 ISO-18092
CU: 增加呼和浩特地铁储值卡发卡信息
武汉通:缩短卡号为9位显示。武汉通卡面显示为 10 位,在该修改之后,显示的卡号与卡面前9位相同。