Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP add Request::initialize_as_target #9

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

dimpolo
Copy link
Collaborator

@dimpolo dimpolo commented Jan 30, 2023

I took a stab at adding a initialize_as_target Request builder.

I'm afraid I currently don't know enough about this kind of functionality so I'll leave some questions here.
@averyanalex maybe you could shed some light on them?

Comment on lines +306 to +309
pub enum TargetMode {
// TODO is this a valid mode?
/// Accept all target modes
Any = 0b000,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is setting Mode to 0b000 valid?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think yes: there is no SyntaxError, and chip responds when I bring android phone to pn532 when target_mode is TargetMode::Any

Comment on lines +333 to +339
pub struct TargetMifareParams {
/// 2 bytes LSB first, as defined in ISO/IEC14443-3
pub sens_res: [u8; 2],
/// has a fixed length of 3 bytes containing the nfcid11 to nfcid13 bytes.
/// Indeed, the PN532 can handle only nfcid1t in single size
pub nfcid1t: [u8; 3],
pub sel_res: TargetSelRes,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are there some default values that make sense here?

Comment on lines +356 to +361
pub struct TargetFelicaParams {
pub fncid2t: [u8; 8],
pub pad: [u8; 8],
/// These two bytes are returned in the POL_RES frame
/// if the 4th byte of the incoming POL_REQ command frame is 0x01.
pub system_code: [u8; 2],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Are there some default values that make sense here?

Comment on lines +141 to +142
0, // no general bytes
0, // no historical bytes
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

is it ok to skip general bytes and historical bytes here?

Copy link
Contributor

@averyanalex averyanalex Jan 30, 2023

Choose a reason for hiding this comment

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

If lib will just skip this in TgInitAsTarget command, there will be no way to set these later, because lib will wait chip's response, so you can't send TgSetGeneralBytes command just after TgInitAsTarget

@dimpolo dimpolo mentioned this pull request Jan 30, 2023
@averyanalex
Copy link
Contributor

What I can say about default values: with everything set to [0; N], TargetMode::PassiveOnly and TargetSelRes::PICC, my Android phone detects FeliCa:
IMG_20230130_230001

When I set params to some random recommendations from stackoverflow, NFC Tools can't see pn532, but it responses to microcontroller. (so there is a connection, but chip is not recognized by phone).

Also I don't know how to emulate ISO 14443-3A (but I want to do it).

@dimpolo
Copy link
Collaborator Author

dimpolo commented Jan 31, 2023

Just thought I'd let you know. I'm rather limited on time currently so it might take me some weeks to properly finish this.

(btw, I spent like 4 hours today on esp-rs/esp-hal#295 (comment) which you also seem to have encountered 🤣)

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