1. Remove 'phLibNfc_SE_ActModeApdu' value from '', as it doesn't do
anything.
2. Delete the 'phLibNfc_SE_LowPowerMode_t' enum. This enum is not used
in LibNFC, so it has no business being part of that lib.
3. Add the ability to turn on/off wired mode for the SE. This includes
ensuring the SE is enabled if either wired mode or Card Emulation is
enabled. And disabling the SE otherwise.
The ATR of a NFC tag can be provided during different stages of the NFC
discovery sequence, depending on the type of tag being read. Currently
NfcCx only ever caches ATRs retrieved during device discovery. This
change ensures that NfcCx also caches ATRs retrieved during device
connect.
When attempting to write and NDEF to a Type 1 (Topaz) tag, the stack is
checking the capability container (CC) version (byte 1) has a value of
0x10 (i.e. version 1.0). However, a type 1 tag could also be version 1.1
or 1.2 at this point in time. A version 1.x tag will be compatible with
a stack using 1.0 features. Therefore, the version check should ignore
minor version and only validate the major version is 1.
The 'WdfDeviceStopIdle' function returns STATUS_PENDING when the device
is booting up asynchronously. As STATUS_PENDING is a success code (not
an error code) this generally doesn't cause too many problems. However
STATUS_PENDING does have a special meaning in some circumstances. So to
be safe, we should convert it to STATUS_SUCCESS.
In order to be backward-compatible with old client drivers which were built
before the new functions (like NfcCxEvtReleaseHardwareControl and
NfcCxEvtReacquireHardwareControl) were introduced to NfcCx, it should allow
to bind to only first FunctionTableCount functions in the NfcCx export list.
In particular, this will change will allow RS1 NFC Client drivers to use
RS2+ NfcCx.dll.
IOCTLs.
Currently the NFC radio is kept on whenever there is an open smartcard
handle. This change changes this to only requiring either a pending
IOCTL or a connected smartcard (i.e. a card in the NFC radio field).
The IOCTLs that are of interest are IS_ABSENT, IS_PRESENT and TRANSMIT.
All the other IOCTLs don't require the NFC radio. In addition, TRANSMIT
already has its own power management logic and this doesn't need to be
changed.
IS_ABSENT and IS_PRESENT used to use a WdfIoQueue to both track the
pending IOCTL requests and to automatically handle request cancelation.
However to be able to be handle power references correctly, without race
conditions, I needed to change this to manually track the requests and
cancelation.
As part of this change, a de-bounce was added to powering down the RF.
This was added to prevent powering on and off the RF quickly within a
short timeframe.
In addition, this change simplifies the way the RF Interface receives
the desired state of the RF from the Power Manager. This was done to
remove race conditions and improve performance.
Miscellanious changes:
- Removed the NCI_POWER_POLICY type, as it was just adding unneccessary
boilerplate.
This change gives the Power Management class its own struct, instead of having all
its variables part of the NFCCX_FDO_CONTEXT. This change also ensures that all
resources owned by the Power Manager class are initialized by the Power Manager
class.
When RFInterface is deinitializing, there might be pending/running WorkCallbacks in rfInterface->tpTagPrescenceWork. They can continue running after deinitialization in this case.
This change will ensure that there are not running/pending callbacks before CloseThreadpoolWork() call.
Once NFCEE initialization is complete reflect eSE_ActivationMode state so
that in next step of enumeration, the SE is detected as activated.
This will fix the behavior of NfcCxRFInterfaceDisableSecureElements called
during secure elements enumeration where the secure elements states were
not reflected correctly.
NFCEE_STATUS_NTF is giving indication on the NFCEE.
2 status are giving indication about the NFCEE activation states:
- NFCEE Initialization sequence started
- NFCEE Initialization sequence completed
In NCI2.0, the TLV length is not exactly the remaining data length after
the supported nfcee protocols. An additional parameter has been added:
NFCEE Power Supply.
No NFCEE_DISCOVER_NTF is generated as a consequence no SeHandle with
information about nfcee status, nfceeid are created.
Create a Dummy pSeHandle for next processing.
* Fix dwNfcTimerId life cycle management
NCI: Handle NCI_RESET_RSP and NCI_RESET_NTF to manage NCI1.x and NCI2.x
ff56ba3701
is introducing a regression in the dwNfcTimerId life cycle management.
Messages like:
- "Deactivate ntf timer start FAILED" or "Timer Create had failed"
in nfc/libs/NfcCoreLib/lib/Nci/phNciNfc_Discovery.c
function phNciNfc_CompleteDeactivate.
- "IsoDep Chk Pres ntf timer start FAILED" or "Timer Create had failed"
in nfc/libs/NfcCoreLib/lib/Nci/phNciNfc.c
function phNciNfc_CompleteIsoDepPresChkSequence.
Are now raised because it is deleted and zeroed improperly. It may give
instable behavior.
* Rework CORE_RESET_NTF Callback (phNciNfc_ResetNtfCb)
This rework fix the way CORE_RESET_NTF is handled.
A CORE_RESET_NTF (in NCI1x or NCI2x) can be raised by the NFC Controller
any time in the NCI state machine (i.e: In case of CLF error, if the NFCC
was powered on (NCI2x), if a CORE_RESET_CMD was received...).
In any case, the overall state machine needs to be resetted (NCI state
machine, IoQueue...).
* Revert "NCI2.0: RF_ISO_DEP_NAK_PRESENCE and CORE_SET_POWER_SUB_STATE_CMD are NCI2.0 command"
This reverts commit 6ea83f8e09.
This will allow IHV to still use NFC_CX_DRIVER_ISODEP_RNAK_PRESENCE_CHK_SUPPORTED
or NFC_CX_DRIVER_RF_ROUTING_POWER_SUB_STATES_SUPPORTED in an accurate way
even if using NCI2.0.
For instance the NCI1.x way of doing the equivalent of an RNAK_PRESENCE_CHK
is also a valid alternative in NCI2.0.
* Add missing NCI2.0 RF_DEACTIVATE_NTF Deactivation Reason
Adding a missing deactivation reasons "DH request failed due to error"
specified in NCI2.0 specification Table 81.
We are following conditions described in 5.2.5 State RFST_POLL_ACTIVE for
"DH request failed due to error" Deactivation Reason
- "In this state the DH MAY send RF_DEACTIVATE_CMD (Sleep Mode or Sleep_AF
Mode) to deactivate communication with the Remote NFC Endpoint.
The NFCC SHALL send RF_DEACTIVATE_RSP with STATUS_OK. Depending on the
activated interface and protocol, the NFCC might need to issue RF commands
to put the Remote NFC Endpoint into sleep state. If there was an error in
executing the protocol deactivation procedures defined by the RF Interface,
the NFCC SHALL notify the DH by sending RF_DEACTIVATE_NTF (Sleep Mode or
Sleep_AF Mode, DH request failed due to error), and the state will remain
RFST_POLL_ACTIVE."
- "In this state the DH MAY send RF_DEACTIVATE_CMD (Idle Mode) to
deactivate communication with the Remote NFC Endpoint and stop RF Discovery.
The NFCC SHALL send RF_DEACTIVATE_RSP with STATUS_OK and, depending on the
activated interface and protocol, might issue RF commands to deactivate the
Remote NFC Endpoint. If there was an error in executing the protocol
deactivation procedures defined by the RF Interface, the NFCC SHALL notify
the DH by sending RF_DEACTIVATE_NTF (Idle Mode, DH request failed due
to error)."
* Fix sequence executed after receiving a DISCOVER_TARGET_ACTIVATION_FAILED error
In NCI1x or NCI2x we can receive
CORE_GENERIC_ERROR_NTF(DISCOVER_TARGET_ACTIVATION_FAILED) in 2 states:
- RFST_DISCOVERY (in this case the current code is fine).
- RFST_W4_HOST_SELECT (in this case the current code does not restart the
polling loop).
Following the 5.2 State machine and the NfcCx commands exchanges when using
a tag (for instance in our tests Mifare Ultralight):
- in RFST_DISCOVERY state: when approching a tag a RF_INTF_ACTIVATED_NTF will
change the current state to RFST_POLL_ACTIVE.
- In RFST_POLL_ACTIVE state: the NfcCx send a RF_DEACTIVATE_CMD(Sleep Mode).
This is changing the state to RFST_W4_HOST_SELECT.
- In RFST_W4_HOST_SELECT: A CORE_GENERIC_ERROR_NTF(DISCOVER_TARGET_ACTIVATION_FAILED)
may happen.
According to 5.2.4:
"If the activation was not successful, the NFCC SHALL send CORE_ERROR_NTF to
the DH with a Status of DISCOVERY_TARGET_ACTIVATION_FAILED and the state will
remain as RFST_W4_HOST_SELECT"
"If the DH sends RF_DEACTIVATE_CMD,
the NFCC SHALL ignore the Deactivation Type parameter, stop the RF Discovery
Process and send RF_DEACTIVATE_RSP. The state will then change to RFST_IDLE."
- In RFST_IDLE: no field is generated until the NCI state machine is change
to RFST_DISCOVERY.
In order to consider both cases we are now sending the NFC controller in
RFST_IDLE state and move to RFST_DISCOVERY with a RF_DISCOVER_CMD.
* Fix event log messages
* Fix PHNFCINFC_CORE_RESET_NTF_MIN_LEN_2x mispelling
Rename PHNFCINFC_CORE_RESET_NTF_MIN_LEN_2x PHNCINFC_CORE_RESET_NTF_MIN_LEN_2x
* Adding comments on conditions when checking CORE_RESET_NTF parameters.
Nci Version is only available in Nci2.0 CORE_RESET_NTF frame.
Furthermore Nci1.x CORE_RESET_NTF frame is only 2 bytes long
(Reason code(1 byte) and Configuration status(1 byte).
We are assuming here that a CORE_RESET_NTF with a size longer
or egal to PHNCINFC_CORE_RESET_NTF_MIN_LEN_2x(5) is a NCI2x frame.
* Adding missing brackets
* Be more explicit when resetting dwNtfTimerId
PH_OSALNFC_TIMER_ID_INVALID is 0, reset the current line so that it is
more explicit to reader.
* Add Warning if dwNtfTimerId != PH_OSALNFC_TIMER_ID_INVALID before phOsalNfc_Timer_Create call
For debug purpose, log a warning message if dwNtfTimerId is not in reset
state (or when dwNtfTimerId != PH_OSALNFC_TIMER_ID_INVALID) before its
creation.
phNciNfc_TlvUtilsGetNxtTlv used to extract the Rf Interfaces information.
In case of invalid TLV, phNciNfc_TlvUtilsGetNxtTlv will return an error
code.
Also there was an error in the naming, we changed from
CORE_RESET_RSP_LEN_xxx to CORE_INIT_RSP_LEN_xxx.
Note: PH_NCINFC_MIN_CORE_RESET_RSP_LEN got removed.
Also there was an error in the naming, we changed from
CORE_RESET_RSP_LEN_xxx to CORE_INIT_RSP_LEN_xxx.
Note: PH_NCINFC_MIN_CORE_RESET_RSP_LEN is kept to keep the compiler happy
and will be removed when add the equivalent macro for NCI2x.