# fuchsia.hardware.nfc

<br />

Added: HEAD

## **PROTOCOLS**

## Device

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=86)*

Device protocol used to connect to an NFC device.

The data sent by clients to `Write` and returned by `Read` are NCI commands, responses and
and data messages. The detailed format is defined in NFC Controller Interface(NCI)
specification https://nfc-forum.org/our-work/specification-releases/.
The device is only capable of operating if there are pending Read calls with
available VMOs to receive data. Otherwise, data loss might occur.

<br />

### CoreInitialize

Initialize or perform any required setup before reading/writing to the
device.

The API should be called only once after connecting to the protocol.
Calling it twice will return INVALID_STATE.
Error means that the specific initialization wasn't carried out.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_CoreInitialize_Result` |

### FactoryReset

Performs a factory reset, which will erase any user data and returns the
device to default settings.

Error means that the factory reset failed.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_FactoryReset_Result` |

### HciNetworkReset

Resets the session ids of all the Secure Elements in the HCI network.

Returns `UNSPECIFIED` when the operation fails.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_HciNetworkReset_Result` |

### Read

Reads NCI responses or data from device into vmo pointed by `vmo_id`.

This call will not return until data is read into the vmo. Clients can have
multiple calls to `Read` queued up to a maximum of `MAX_NUMBER_OF_OUTSTANDING_READS`.
Returns the number of bytes read on success.
Returns:
`TOO_MANY_OUTSTANDING_READS` when too many `Read` calls are queued.
`VMO_ALREADY_IN_USE` when the client queues more than 1 `Read` on the same vmo_id.

#### Request

| Name | Type |
|---|---|
| `vmo_id` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#VmoId` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_Read_Result` |

### RegisterVmos

Registers multiple vmos `nfc_vmos` each with a `vmo_id` with an internal
vmo manager.

Success means the provided vmo list is registered successfully
and Read/Write can be performed.
Error means that no vmos were registered.
Returns:
`VMO_NOT_FOUND` when the provided vmo is not valid or found.
`VMO_ALREADY_EXISTS` when trying to register an already existing vmo.
`INVALID_ARGS` if the input parameters are invalid.

#### Request

| Name | Type |
|---|---|
| `nfc_vmos` | `vector<https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#NfcVmoRequest>:32` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_RegisterVmos_Result` |

### Reset

Performs a reset of the device.

`CoreInitialize` should be called after a `Reset`.
Error means that the HW was not reset properly, client should request
reset again.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_Reset_Result` |

### SetMode

Sets Nfc device to `mode`.

Error means that the device may not be in the intended `mode`.

#### Request

| Name | Type |
|---|---|
| `mode` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#NfcMode` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_SetMode_Result` |

### UnregisterVmos

Unregisters multiple vmos `nfc_vmos` each with a `vmo_id`.

Any subsequent read/writes to the vmos will fail until `RegisterVmos` is called
with that `vmo_id`.
Error means that no vmos were unregistered, so client should try UnregisterVmos again.

#### Request

| Name | Type |
|---|---|
| `nfc_vmos` | `vector<https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#VmoId>:32` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_UnregisterVmos_Result` |

### WatchEvents

`WatchEvents` is a hanging get API which will return only if there is an event to
report.

The events will be delivered only if there is a hanging watcher.
The client should attach the watcher again whenever the event is
delivered, to continue getting events.

#### Request

\<EMPTY\>

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_WatchEvents_Result` |

### Write

Writes `length` bytes of NCI commands or data in the vmo pointed by `vmo_id` to device.

Success means that the data was written to the HW device. If the payload
contains a command requiring a response, a subsequent response to Read will
contain the response. Multiple `Write` calls can be queued up to a maximum of
MAX_NUMBER_OF_OUTSTANDING_WRITES, but each call should be on a different `vmo_id`.
Writes are queued and executed in order.
On Error, the data provided was not written to the HW device.
Returns:
`OUT_OF_RANGE` when the data provided was too large.
`UNSPECIFIED` in specific cases.
`IO_NOT_PRESENT` when device is unavailable.
`REFUSED` for example, when performing a write to a read only vmo.
`TOO_MANY_OUTSTANDING_WRITES` when too many `Write` calls are queued.

#### Request

| Name | Type |
|---|---|
| `length` | `uint64` |
| `vmo_id` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#VmoId` |

#### Response

| Name | Type |
|---|---|
| `payload` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_Write_Result` |

## **STRUCTS**

### Device_CoreInitialize_Response

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=101)*

\<EMPTY\>

### Device_FactoryReset_Response

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=107)*

\<EMPTY\>

### Device_HciNetworkReset_Response

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=175)*

\<EMPTY\>

### Device_Read_Response

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=126)*

| Field | Type | Description | Default |
|---|---|---|---|
| `length` | `uint64` |   | No default |

### Device_RegisterVmos_Response

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=161)*

\<EMPTY\>

### Device_Reset_Response

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=114)*

\<EMPTY\>

### Device_SetMode_Response

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=93)*

\<EMPTY\>

### Device_UnregisterVmos_Response

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=170)*

\<EMPTY\>

### Device_Write_Response

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=147)*

\<EMPTY\>

### NfcVmoRequest [resource](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#value-vs-resource)

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=64)*

| Field | Type | Description | Default |
|---|---|---|---|
| `vmo_id` | `uint32` |   | No default |
| `vmo` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#NfcVmo` |   | No default |

## **ENUMS**

### Error [flexible](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

Type: `uint32`

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=31)*

NFC specific error values

<br />

| Name | Value | Description |
|---|---|---|
| ### INVALID_PARAMS | `1` | Invalid parameters to fidl |
| ### UNSPECIFIED | `2` | Catch all error that is context specific. |
| ### OUT_OF_RANGE | `3` | Data transfer was too large to be handled by the transport. |
| ### IO_NOT_PRESENT | `4` | IO device not found. |
| ### REFUSED | `5` | Request was refused, because client is trying to perform an invalid/illegal operation. |
| ### INVALID_STATE | `6` | NFC is in not in the correct state. |
| ### VMO_NOT_FOUND | `7` | The VMO ID passed to Write()/UnregisterVmo() was not found. |
| ### VMO_ALREADY_EXISTS | `8` | The VMO ID passed to RegisterVmo() is already in use. |
| ### TOO_MANY_OUTSTANDING_READS | `9` | Too many outstanding `Read` calls. |
| ### VMO_ALREADY_IN_USE | `10` | Vmo already in use by the driver. |
| ### TOO_MANY_OUTSTANDING_WRITES | `11` | Too many outstanding `Write` calls. |

### NfcMode [flexible](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

Type: `uint32`

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=19)*

| Name | Value | Description |
|---|---|---|
| ### ACTIVE | `1` | Nfc device is in active mode. |
| ### PASSIVE | `2` | Nfc device is in passive mode. |
| ### POWER_OFF | `3` | Powers off the device. |

## **UNIONS**

### Device_CoreInitialize_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=101)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_CoreInitialize_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Error` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Device_FactoryReset_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=107)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_FactoryReset_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Error` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Device_HciNetworkReset_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=175)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_HciNetworkReset_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Error` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Device_Read_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=126)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_Read_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Error` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Device_RegisterVmos_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=161)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_RegisterVmos_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Error` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Device_Reset_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=114)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_Reset_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Error` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Device_SetMode_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=93)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_SetMode_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Error` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Device_UnregisterVmos_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=170)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_UnregisterVmos_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Error` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Device_WatchEvents_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=183)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#NfcEvent` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### Device_Write_Result [strict](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=147)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `response` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Device_Write_Response` |   |
| ### 2 | `err` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Error` |   |
| ### 3 | `framework_err` | `internal` |   |

<br />

### NfcEvent [flexible](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible)

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=74)*

Asynchronous events sent by the driver when something goes wrong in the HW or
state machine.

`error` is signalled when an internal error like a HW error occurs
which could be used by client to reset the HW and get it back into a good state.

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `error` | `https://fuchsia.dev/reference/fidl/fuchsia.hardware.nfc#Error` |   |

<br />

### NfcVmo [flexible](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#strict-vs-flexible) [resource](https://fuchsia.dev/fuchsia-src/reference/fidl/language/language#value-vs-resource)

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=57)*

| Ordinal | Variant | Type | Description |
|---|---|---|---|
| ### 1 | `write_vmo` | `handle<vmo>` |   |
| ### 2 | `read_vmo` | `handle<vmo>` |   |

<br />

## **CONSTANTS**

| Name | Value | Type | Description |
|---|---|---|---|
| [MAX_NUMBER_OF_OUTSTANDING_READS](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=14) | `10` | `uint32` | The maximum number of outstanding reads allowed. |
| [MAX_NUMBER_OF_OUTSTANDING_WRITES](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=17) | `10` | `uint32` | The maximum number of outstanding writes allowed. |
| [MAX_VMOS](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=11) | `32` | `uint32` | The maximum number of vmos that is registered with the driver for read/write. |

## **ALIASES**

| Name | Value | Description |
|---|---|---|
| [VmoId](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=28) | `uint32` |   |

## **SERVICES**

### Service

*Defined in [fuchsia.hardware.nfc/nfc.fidl](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=186)*

| Name | Type | Transport |
|---|---|---|
| [device](https://cs.opensource.google/fuchsia/fuchsia/+/main:sdk/fidl/fuchsia.hardware.nfc/nfc.fidl;l=187) | `fuchsia.hardware.nfc/Device` | Channel |

<br />