nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
record.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef NFC_NDEF_RECORD_H_
8#define NFC_NDEF_RECORD_H_
9
10#include <zephyr/types.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
27#define NDEF_RECORD_IL_MASK 0x08
29#define NDEF_RECORD_TNF_MASK 0x07
33#define NDEF_RECORD_SR_MASK 0x10
35#define NDEF_RECORD_PAYLOAD_LEN_LONG_SIZE 4
37#define NDEF_RECORD_PAYLOAD_LEN_SHORT_SIZE 1
38#define NDEF_RECORD_ID_LEN_SIZE 1
39
57typedef int (*payload_constructor_t)(void *payload_descriptor,
58 uint8_t *buffer,
59 uint32_t *len);
69 TNF_EMPTY = 0x00,
86};
87
97 uint8_t id_length;
99 uint8_t const *id;
101 uint8_t type_length;
103 uint8_t const *type;
108};
109
119 NDEF_LONE_RECORD = 0xC0
121
123#define NDEF_RECORD_LOCATION_MASK (NDEF_LONE_RECORD)
124
129 uint8_t const *payload;
130 uint32_t payload_length;
131};
132
157#define NFC_NDEF_GENERIC_RECORD_DESC_DEF(name, \
158 tnf_arg, \
159 id_arg, \
160 id_len, \
161 type_arg, \
162 type_len, \
163 payload_constructor_arg, \
164 payload_descriptor_arg) \
165 struct nfc_ndef_record_desc name##_ndef_generic_record_desc = \
166 { \
167 .tnf = tnf_arg, \
168 .id_length = id_len, \
169 .id = id_arg, \
170 .type_length = type_len, \
171 .type = type_arg, \
172 .payload_constructor = \
173 (payload_constructor_t)payload_constructor_arg, \
174 .payload_descriptor = (void *) payload_descriptor_arg \
175 }
176
180#define NFC_NDEF_GENERIC_RECORD_DESC(name) (name##_ndef_generic_record_desc)
181
205#define NFC_NDEF_RECORD_BIN_DATA_DEF(name, \
206 tnf_arg, \
207 id_arg, \
208 id_len, \
209 type_arg, \
210 type_len, \
211 payload_arg, \
212 payload_len) \
213 struct nfc_ndef_bin_payload_desc name##_nfc_ndef_bin_payload_desc = \
214 { \
215 .payload = payload_arg, \
216 .payload_length = payload_len \
217 }; \
218 \
219 struct nfc_ndef_record_desc name##_nfc_ndef_bin_record_desc = \
220 { \
221 .tnf = tnf_arg, \
222 .id_length = id_len, \
223 .id = id_arg, \
224 .type_length = type_len, \
225 .type = type_arg, \
226 .payload_constructor = \
227 (payload_constructor_t) nfc_ndef_bin_payload_memcopy, \
228 .payload_descriptor = \
229 (void *) &name##_nfc_ndef_bin_payload_desc \
230 }
231
235#define NFC_NDEF_RECORD_BIN_DATA(name) (name##_nfc_ndef_bin_record_desc)
236
241#define NFC_NDEF_BIN_PAYLOAD_DESC(name) (name##_nfc_ndef_bin_payload_desc)
242
259int nfc_ndef_record_encode(struct nfc_ndef_record_desc const *ndef_record_desc,
260 enum nfc_ndef_record_location const record_location,
261 uint8_t *record_buffer,
262 uint32_t *record_len);
263
281 struct nfc_ndef_bin_payload_desc *payload_descriptor,
282 uint8_t *buffer,
283 uint32_t *len);
284
290#ifdef __cplusplus
291}
292#endif
293
294#endif /* NFC_NDEF_RECORD_H_ */
int(* payload_constructor_t)(void *payload_descriptor, uint8_t *buffer, uint32_t *len)
Payload constructor type.
Definition: record.h:57
nfc_ndef_record_tnf
Type Name Format (TNF) Field Values.
Definition: record.h:65
@ TNF_UNKNOWN_TYPE
Definition: record.h:81
@ TNF_ABSOLUTE_URI
Definition: record.h:75
@ TNF_RESERVED
Definition: record.h:85
@ TNF_EMPTY
Definition: record.h:69
@ TNF_MEDIA_TYPE
Definition: record.h:73
@ TNF_UNCHANGED
Definition: record.h:83
@ TNF_WELL_KNOWN
Definition: record.h:71
@ TNF_EXTERNAL_TYPE
Definition: record.h:77
int nfc_ndef_bin_payload_memcopy(struct nfc_ndef_bin_payload_desc *payload_descriptor, uint8_t *buffer, uint32_t *len)
Construct the payload for an NFC NDEF record from binary data.
nfc_ndef_record_location
Record position within the NDEF message.
Definition: record.h:115
@ NDEF_LONE_RECORD
Definition: record.h:119
@ NDEF_FIRST_RECORD
Definition: record.h:116
@ NDEF_MIDDLE_RECORD
Definition: record.h:117
@ NDEF_LAST_RECORD
Definition: record.h:118
int nfc_ndef_record_encode(struct nfc_ndef_record_desc const *ndef_record_desc, enum nfc_ndef_record_location const record_location, uint8_t *record_buffer, uint32_t *record_len)
Encode an NDEF record.
uint32_t payload_length
Definition: record.h:130
uint8_t const * payload
Definition: record.h:129
Binary data descriptor containing the payload for the record.
Definition: record.h:128
uint8_t type_length
Definition: record.h:101
void * payload_descriptor
Definition: record.h:107
uint8_t const * id
Definition: record.h:99
payload_constructor_t payload_constructor
Definition: record.h:105
uint8_t const * type
Definition: record.h:103
enum nfc_ndef_record_tnf tnf
Definition: record.h:93
uint8_t id_length
Definition: record.h:97
NDEF record descriptor.
Definition: record.h:91