nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
ch.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef NFC_NDEF_CH_H_
8#define NFC_NDEF_CH_H_
9
19#include <stdint.h>
20#include <string.h>
21#include <zephyr/types.h>
22#include <nfc/ndef/record.h>
23#include <nfc/ndef/msg.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
34#define NFC_NDEF_CH_REC_TYPE_LENGTH 2
35
48
50 struct {
52 uint8_t type_len;
53
58 const uint8_t *type;
59
61 uint8_t data_len;
62
67 uint8_t *data;
69};
70
79
82
85
88};
89
91#define NFC_NDEF_CH_AC_CPS_MASK (NFC_AC_CPS_UNKNOWN)
92
98 uint8_t length;
99
103 const uint8_t *data;
104};
105
112
115
117 const uint8_t max_aux_data_ref_cnt;
118
121
124};
125
131 uint16_t random;
132};
133
142
147
150};
151
167 uint8_t *buf, uint32_t *len);
168
190#define NFC_NDEF_CH_RECORD_DESC_DEF(_name, \
191 _rec_type_field, \
192 _major_version, \
193 _minor_version, \
194 _max_records) \
195 NFC_NDEF_MSG_DEF(_name, _max_records); \
196 struct nfc_ndef_ch_rec _name##_nfc_ch_rec = { \
197 .major_version = _major_version, \
198 .minor_version = _minor_version, \
199 .local_records = &NFC_NDEF_MSG(_name) \
200 }; \
201 NFC_NDEF_GENERIC_RECORD_DESC_DEF(_name, \
202 TNF_WELL_KNOWN, \
203 0, \
204 0, \
205 _rec_type_field, \
206 NFC_NDEF_CH_REC_TYPE_LENGTH, \
207 nfc_ndef_ch_rec_payload_encode, \
208 &(_name##_nfc_ch_rec))
209
230#define NFC_NDEF_CH_HS_RECORD_DESC_DEF(_name, \
231 _major_version, \
232 _minor_version, \
233 _max_records) \
234 NFC_NDEF_CH_RECORD_DESC_DEF(_name, \
235 nfc_ndef_ch_hs_rec_type_field, \
236 _major_version, \
237 _minor_version, \
238 _max_records)
239
260#define NFC_NDEF_CH_HR_RECORD_DESC_DEF(_name, \
261 _major_version, \
262 _minor_version, \
263 _max_records) \
264 NFC_NDEF_CH_RECORD_DESC_DEF(_name, \
265 nfc_ndef_ch_hr_rec_type_field, \
266 _major_version, \
267 _minor_version, \
268 _max_records)
269
290#define NFC_NDEF_CH_HM_RECORD_DESC_DEF(_name, \
291 _major_version, \
292 _minor_version, \
293 _max_records) \
294 NFC_NDEF_CH_RECORD_DESC_DEF(_name, \
295 nfc_ndef_ch_hm_rec_type_field, \
296 _major_version, \
297 _minor_version, \
298 _max_records)
299
317#define NFC_NDEF_CH_HI_RECORD_DESC_DEF(_name, \
318 _major_version, \
319 _minor_version, \
320 _max_records) \
321 NFC_NDEF_CH_RECORD_DESC_DEF(_name, \
322 nfc_ndef_ch_hi_rec_type_field, \
323 _major_version, \
324 _minor_version, \
325 _max_records)
326
331#define NFC_NDEF_CH_RECORD_DESC(_name) NFC_NDEF_GENERIC_RECORD_DESC(_name)
332
342
354 const struct nfc_ndef_record_desc *local_rec);
355
371 uint8_t *buf, uint32_t *len);
372
390#define NFC_NDEF_CH_HC_RECORD_DESC_DEF(_name, \
391 _payload_id, \
392 _payload_id_length, \
393 _payload_desc) \
394 \
395 NFC_NDEF_GENERIC_RECORD_DESC_DEF(_name, \
396 TNF_WELL_KNOWN, \
397 _payload_id, \
398 _payload_id_length, \
399 nfc_ndef_ch_hc_rec_type_field, \
400 NFC_NDEF_CH_REC_TYPE_LENGTH, \
401 nfc_ndef_ch_hc_rec_payload_encode, \
402 (_payload_desc))
403
408#define NFC_NDEF_CH_HC_RECORD_DESC(_name) NFC_NDEF_GENERIC_RECORD_DESC(_name)
409
425 uint8_t *buf, uint32_t *len);
426
446#define NFC_NDEF_CH_AC_RECORD_DESC_DEF(_name, \
447 _cps, \
448 _carr_data_ref_len, \
449 _carr_data_ref, \
450 _max_aux_data_ref_cnt) \
451 struct nfc_ndef_ch_ac_rec_ref \
452 _name##nfc_ndef_ch_ac_rec_ref[_max_aux_data_ref_cnt]; \
453 struct nfc_ndef_ch_ac_rec \
454 _name##_nfc_ac_rec = { \
455 .cps = _cps, \
456 .carrier_data_ref = { _carr_data_ref_len, _carr_data_ref }, \
457 .max_aux_data_ref_cnt = _max_aux_data_ref_cnt, \
458 .aux_data_ref_cnt = 0, \
459 .aux_data_ref = _name##nfc_ndef_ch_ac_rec_ref \
460 }; \
461 NFC_NDEF_GENERIC_RECORD_DESC_DEF(_name, \
462 TNF_WELL_KNOWN, \
463 0, \
464 0, \
465 nfc_ndef_ch_ac_rec_type_field, \
466 NFC_NDEF_CH_REC_TYPE_LENGTH, \
467 nfc_ndef_ch_ac_rec_payload_encode, \
468 &(_name##_nfc_ac_rec))
469
474#define NFC_NDEF_CH_AC_RECORD_DESC(_name) NFC_NDEF_GENERIC_RECORD_DESC(_name)
475
486
499 const uint8_t *aux_data,
500 uint8_t aux_length);
501
517 uint8_t *buf, uint32_t *len);
518
535#define NFC_NDEF_CH_CR_RECORD_DESC_DEF(_name, \
536 _random_number) \
537 struct nfc_ndef_ch_cr_rec \
538 _name##_nfc_cr_rec = { \
539 .random = _random_number, \
540 }; \
541 NFC_NDEF_GENERIC_RECORD_DESC_DEF(_name, \
542 TNF_WELL_KNOWN, \
543 0, \
544 0, \
545 nfc_ndef_ch_cr_rec_type_field, \
546 NFC_NDEF_CH_REC_TYPE_LENGTH, \
547 nfc_ndef_ch_cr_rec_payload_encode, \
548 &(_name##_nfc_cr_rec))
549
554#define NFC_NDEF_CR_RECORD_DESC(_name) NFC_NDEF_GENERIC_RECORD_DESC(_name)
555
556#ifdef __cplusplus
557}
558#endif
559
564#endif /* NFC_NDEF_CH_H_ */
void nfc_ndef_ch_ac_rec_auxiliary_data_ref_clear(struct nfc_ndef_record_desc *ac_rec)
Function for clearing an Auxiliary Data Reference in an NFC NDEF Alternative Carrier record.
int nfc_ndef_ch_ac_rec_auxiliary_data_ref_add(struct nfc_ndef_record_desc *ac_rec, const uint8_t *aux_data, uint8_t aux_length)
Function for adding an Auxiliary Data Reference to an NFC NDEF Alternative Carrier record.
int nfc_ndef_ch_rec_payload_encode(const struct nfc_ndef_ch_rec *ch_rec, uint8_t *buf, uint32_t *len)
Constructor for an NFC Connection Handover generic record payload.
int nfc_ndef_ch_hc_rec_payload_encode(const struct nfc_ndef_ch_hc_rec *hc_rec, uint8_t *buf, uint32_t *len)
Constructor for an NFC Connection Handover Carrier Record payload.
int nfc_ndef_ch_ac_rec_payload_encode(const struct nfc_ndef_ch_ac_rec *nfc_rec_ac, uint8_t *buf, uint32_t *len)
Constructor for an NFC NDEF Alternative Carrier record payload.
nfc_ndef_ch_ac_rec_cps
Carrier Power State.
Definition: ch.h:76
@ NFC_AC_CPS_ACTIVE
Definition: ch.h:81
@ NFC_AC_CPS_ACTIVATING
Definition: ch.h:84
@ NFC_AC_CPS_UNKNOWN
Definition: ch.h:87
@ NFC_AC_CPS_INACTIVE
Definition: ch.h:78
void nfc_ndef_ch_rec_local_record_clear(struct nfc_ndef_record_desc *ch_rec)
Function for clearing local records in the NFC NDEF Connection Handover records.
int nfc_ndef_ch_cr_rec_payload_encode(const struct nfc_ndef_ch_cr_rec *nfc_rec_cr, uint8_t *buf, uint32_t *len)
Constructor for an NFC NDEF Collision Resolution record payload.
int nfc_ndef_ch_rec_local_record_add(struct nfc_ndef_record_desc *ch_rec, const struct nfc_ndef_record_desc *local_rec)
Function for adding a local record to an NFC NDEF Handover Select record.
nfc_ndef_record_tnf
Type Name Format (TNF) Field Values.
Definition: record.h:65
uint8_t length
Definition: ch.h:98
const uint8_t * data
Definition: ch.h:103
Carrier Data Reference and Auxiliary Data Reference descriptor.
Definition: ch.h:96
struct nfc_ndef_ch_ac_rec_ref * aux_data_ref
Definition: ch.h:123
uint8_t aux_data_ref_cnt
Definition: ch.h:120
enum nfc_ndef_ch_ac_rec_cps cps
Definition: ch.h:111
struct nfc_ndef_ch_ac_rec_ref carrier_data_ref
Definition: ch.h:114
const uint8_t max_aux_data_ref_cnt
Definition: ch.h:117
Alternative Carrier record payload descriptor.
Definition: ch.h:109
uint16_t random
Definition: ch.h:131
Collision Resolution record payload descriptor.
Definition: ch.h:129
enum nfc_ndef_record_tnf ctf
Definition: ch.h:47
uint8_t * data
Definition: ch.h:67
uint8_t type_len
Definition: ch.h:52
uint8_t data_len
Definition: ch.h:61
struct nfc_ndef_ch_hc_rec::@213 carrier
const uint8_t * type
Definition: ch.h:58
Handover Carrier record payload descriptor.
Definition: ch.h:39
struct nfc_ndef_msg_desc * local_records
Definition: ch.h:149
uint8_t major_version
Definition: ch.h:141
uint8_t minor_version
Definition: ch.h:146
Handover Select record payload descriptor.
Definition: ch.h:137
NDEF message descriptor.
Definition: msg.h:30
NDEF record descriptor.
Definition: record.h:91