Skip to content

bugfix:修复八达通卡支持,增加呼和浩特地铁储值卡,裁剪武汉通卡号#42

Open
sztsian wants to merge 3 commits into
nfcim:masterfrom
sztsian:wuhan
Open

bugfix:修复八达通卡支持,增加呼和浩特地铁储值卡,裁剪武汉通卡号#42
sztsian wants to merge 3 commits into
nfcim:masterfrom
sztsian:wuhan

Conversation

@sztsian

@sztsian sztsian commented Apr 6, 2026

Copy link
Copy Markdown
Collaborator

八达通:FlutterNfcKit.poll 时启用 ISO-18092

CU: 增加呼和浩特地铁储值卡发卡信息

武汉通:缩短卡号为9位显示。武汉通卡面显示为 10 位,在该修改之后,显示的卡号与卡面前9位相同。

sztsian added 3 commits April 6, 2026 22:03
Signed-off-by: Zamir SUN <sztsian@gmail.com>
Signed-off-by: Zamir SUN <sztsian@gmail.com>
Signed-off-by: Zamir SUN <sztsian@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.poll to support Octopus.
  • Update JS card parsing to treat Octopus as iso18092 and adjust WuhanTong card number slicing.
  • Add "0003": "呼和浩特地铁" to ChinaPostCode.

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.

Comment thread lib/main.dart
Comment on lines +156 to +159
final tag = await FlutterNfcKit.poll(
iosAlertMessage: S(context).waitForCard,
readIso18092: true,
);

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread assets/read.js
Comment on lines +843 to +847
if (tag.type === "iso18092") {
if (tag.systemCode === "8008") {
// Octopus
return await ReadOctopus();
}

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment thread assets/read.js
let f15 = await BasicInfoFile(fci);
if (!f15) return {};
const number = f15.slice(24, 40);
const number = f15.slice(31, 40);

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
const number = f15.slice(31, 40);
const card_number_field = f15.slice(24, 40);
const number = card_number_field.slice(0, 9);

Copilot uses AI. Check for mistakes.
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.

2 participants