nRF Connect SDK API 3.3.99
Loading...
Searching...
No Matches
tag.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef NFC_TNEP_TAG_H_
8#define NFC_TNEP_TAG_H_
9
17#include <nfc/tnep/base.h>
18#include <zephyr/kernel.h>
19
21#define NFC_TNEP_EVENTS_NUMBER 2
22
24#define NFC_TNEP_TAG_MAX_WAIT_TIME 63
25
27#define NFC_TNEP_TAG_MAX_N_WAIT_TIME 15
28
39#define NFC_TNEP_TAG_APP_MSG_DEF(_name, _max_record_cnt) \
40 NFC_NDEF_MSG_DEF(_name, (_max_record_cnt + 1))
41
44 void (*selected)(void);
45
47 void (*deselected)(void);
48
55 void (*message_received)(const uint8_t *data, size_t len);
56
62 void (*error_detected)(int err);
63};
64
82
119#define NFC_TNEP_TAG_SERVICE_DEF(_name, _uri, _uri_length, \
120 _mode, _t_wait, _n_wait, \
121 _max_msg_size, \
122 _select_cb, \
123 _deselect_cb, \
124 _message_cb, \
125 _error_cb) \
126 \
127 BUILD_ASSERT(_t_wait <= NFC_TNEP_TAG_MAX_WAIT_TIME, \
128 "The Waiting time has to be equal or smaller than 63"); \
129 BUILD_ASSERT(_n_wait <= NFC_TNEP_TAG_MAX_N_WAIT_TIME, \
130 "The Waiting time extension count has to be equal or smaller than 15"); \
131 \
132 NFC_TNEP_SERVICE_PARAM_RECORD_DESC_DEF(_name, NFC_TNEP_VERSION, \
133 _uri_length, _uri, \
134 _mode, _t_wait, _n_wait, \
135 _max_msg_size); \
136 static const struct nfc_tnep_tag_service_cb _name##_cb = { \
137 .selected = _select_cb, \
138 .deselected = _deselect_cb, \
139 .message_received = _message_cb, \
140 .error_detected = _error_cb, \
141 }; \
142 \
143 const STRUCT_SECTION_ITERABLE(nfc_tnep_tag_service, _name##_svc) = \
144 NFC_TNEP_TAG_SERVICE(_name)
145
149#define NFC_TNEP_TAG_SERVICE(_name) \
150 { \
151 &_name, \
152 &NFC_NDEF_TNEP_RECORD_DESC(_name), \
153 &_name##_cb, \
154 }
155
156
157typedef int (*nfc_payload_set_t)(uint8_t *, size_t);
158
170typedef int (*initial_msg_encode_t)(struct nfc_ndef_msg_desc *msg);
171
186 uint8_t *tx_swap_buff,
187 size_t len);
202int nfc_tnep_tag_init(struct k_poll_event *events, uint8_t event_cnt,
203 nfc_payload_set_t payload_set);
204
224int nfc_tnep_tag_initial_msg_create(size_t max_record_cnt,
225 initial_msg_encode_t msg_encode_cb);
226
246 const struct nfc_ndef_record_desc *records,
247 size_t records_cnt);
248
258
272void nfc_tnep_tag_rx_msg_indicate(const uint8_t *rx_buffer, size_t len);
273
295 enum nfc_tnep_status_value status);
296
310
318
325
330#endif
nfc_tnep_status_value
Service status - payload in TNEP Status Record.
Definition base.h:36
void nfc_tnep_tag_on_selected(void)
Handle NFC Tag selected event.
void nfc_tnep_tag_rx_msg_indicate(const uint8_t *rx_buffer, size_t len)
Indicate about new TNEP message available in buffer.
int nfc_tnep_initial_msg_encode(struct nfc_ndef_msg_desc *msg, const struct nfc_ndef_record_desc *records, size_t records_cnt)
Encode the Initial NDEF message.
int nfc_tnep_tag_init(struct k_poll_event *events, uint8_t event_cnt, nfc_payload_set_t payload_set)
Start communication using TNEP.
int nfc_tnep_tag_tx_msg_buffer_register(uint8_t *tx_buff, uint8_t *tx_swap_buff, size_t len)
Register TNEP message buffer.
int(* initial_msg_encode_t)(struct nfc_ndef_msg_desc *msg)
Callback type for encoding the Initial TNEP NDEF message.
Definition tag.h:170
int(* nfc_payload_set_t)(uint8_t *, size_t)
Definition tag.h:157
void nfc_tnep_tag_process(void)
Waiting for a signal to execute protocol logic.
int nfc_tnep_tag_tx_msg_app_data(struct nfc_ndef_msg_desc *msg, enum nfc_tnep_status_value status)
Add application data record to next message.
int nfc_tnep_tag_tx_msg_no_app_data(void)
Respond with no more application data.
size_t nfc_tnep_tag_svc_count_get(void)
Get the NFC Tag TNEP service count.
int nfc_tnep_tag_initial_msg_create(size_t max_record_cnt, initial_msg_encode_t msg_encode_cb)
Create the Initial TNEP NDEF message.
NDEF message descriptor.
Definition msg.h:29
NDEF record descriptor.
Definition record.h:89
Service Parameters in the TNEP's Initial NDEF message.
Definition tnep_rec.h:51
void(* selected)(void)
Function called when service was selected.
Definition tag.h:44
void(* message_received)(const uint8_t *data, size_t len)
Function called when new message was received.
Definition tag.h:55
void(* deselected)(void)
Function called when service deselected.
Definition tag.h:47
void(* error_detected)(int err)
Function called when an internal error in TNEP detected.
Definition tag.h:62
Definition tag.h:42
const struct nfc_tnep_tag_service_cb * callbacks
Definition tag.h:80
struct nfc_ndef_record_desc * ndef_record
Definition tag.h:77
struct nfc_ndef_tnep_rec_svc_param * parameters
Definition tag.h:74
Service structure.
Definition tag.h:72