summaryrefslogtreecommitdiff
path: root/nfc/NfcCxSample/README.md
blob: a3af8add7a53e2f9db9c77122f53cf5bc0463256 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
---
topic: sample
description: Sample code for creating a NFC driver using the NFC Class Extension.
languages:
- cpp
products:
- windows
---

# NFC CX client driver sample

A template for creating an NFC functional driver using the NFC Class Extension (CX) driver.

This is a complete version of the code created in the [NFC CX quick start guide](https://docs.microsoft.com/windows-hardware/drivers/nfc/nfc-class-extension-quickstart).

## Prerequisites

To use the NFC CX, your NFC Controller must implement NFC Forum's [NFC Controller Interface (NCI)](https://nfc-forum.org/our-work/specifications-and-application-documents/specifications/nfc-controller-interface-nci-specification/) protocol.

In addition, the NFC CX requires the driver to use the [UMDF 2](https://docs.microsoft.com/windows-hardware/drivers/wdf/overview-of-the-umdf) framework.

## Universal windows driver compliant

This sample builds a Universal Windows Driver. It uses only APIs and DDIs that are included in OneCoreUAP.

## File manifest

### WDK

- [NfcCx.h](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/nfccx/) - The NFC CX's client driver API. (This file is included in the WDK.)

### Project

- [Driver.cpp](windows-drivertemplate-nfc/Driver.cpp)
  - `DriverEntry` - Driver initialization.

- [Device.cpp](windows-drivertemplate-nfc/Device.cpp)
  - `DeviceContext::AddDevice` - Device initialization, including initializing the NFC CX driver.
  - `DeviceContext::WriteNciPacket` - The implementation of the [`EvtNfcCxWriteNciPacket`](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/nfccx/nc-nfccx-evt_nfc_cx_write_nci_packet) callback function.
  - `DeviceContext::ReadNciPacket` - Demonstrates calling [`NfcCxNciReadNotification`](https://docs.microsoft.com/windows-hardware/drivers/ddi/content/nfccx/nf-nfccx-nfccxncireadnotification).

- [Device.h](windows-drivertemplate-nfc/Device.h)
  - `DeviceContext` - The class that stores the device instance's state.