Skip to content

Commit 20449d9

Browse files
KAGA164nordicjm
authored andcommitted
shell: Add NFC T4T shell backend
This adds the new NFC T4T shell backend. The transport interface uses raw ISO-DEP protocol to exchange data with a reader device. NCSDK-22428 Signed-off-by: Kamil Gawor <Kamil.Gawor@nordicsemi.no>
1 parent ee3cd0a commit 20449d9

File tree

5 files changed

+490
-1
lines changed

5 files changed

+490
-1
lines changed

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

+4-1
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,10 @@ Common Application Framework (CAF)
631631
Shell libraries
632632
---------------
633633

634-
|no_changes_yet_note|
634+
* Added:
635+
636+
* The :ref:`shell_nfc_readme` library.
637+
It adds shell backend using the NFC T4T ISO-DEP protocol for data exchange.
635638

636639
Libraries for Zigbee
637640
--------------------

include/shell/shell_nfc.h

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2023 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#ifndef SHELL_NFC_H_
8+
#define SHELL_NFC_H_
9+
10+
#include <zephyr/shell/shell.h>
11+
12+
/**
13+
* @file
14+
* @defgroup shell_nfc NFC shell transport
15+
* @{
16+
* @brief NFC shell transport API.
17+
*/
18+
19+
#ifdef __cplusplus
20+
extern "C" {
21+
#endif
22+
23+
/**
24+
* @brief This function provides a pointer to the shell NFC backend instance.
25+
*
26+
* The function returns a pointer to the shell NFC instance. This instance can then be
27+
* used with the shell_execute_cmd function to test the behavior of the command.
28+
*
29+
* @returns Pointer to the shell instance.
30+
*/
31+
const struct shell *shell_backend_nfc_get_ptr(void);
32+
33+
#ifdef __cplusplus
34+
}
35+
#endif
36+
37+
/**
38+
*@}
39+
*/
40+
41+
#endif /* SHELL_NFC_H_ */

subsys/shell/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66

77
zephyr_sources_ifdef(CONFIG_SHELL_BT_NUS shell_bt_nus.c)
88
zephyr_sources_ifdef(CONFIG_SHELL_IPC shell_ipc.c)
9+
zephyr_sources_ifdef(CONFIG_SHELL_NFC shell_nfc.c)

subsys/shell/Kconfig

+88
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,91 @@ default-size = 10
153153
source "${ZEPHYR_BASE}/subsys/shell/Kconfig.template.shell_log_queue_size"
154154

155155
endif #SHELL_IPC
156+
157+
menuconfig SHELL_NFC
158+
bool "Shell NFC transport"
159+
depends on NFC_T4T_NRFXLIB
160+
help
161+
Enable NFC T4T ISO-DEP transport layer for shell interface.
162+
163+
if SHELL_NFC
164+
165+
config SHELL_NFC_INIT_PRIORITY
166+
int "Initialization priority"
167+
default 0
168+
range 0 99
169+
help
170+
Initialization priority for NFC backend.
171+
172+
config SHELL_NFC_BACKEND_TX_BUFFER
173+
int "NFC Tx buffer size"
174+
default 255
175+
help
176+
Set the NFC ISO-DEP response buffer size. The response buffer size might vary on the
177+
NFC Reader device maximum supported frame size. Its size can be
178+
SHELL_NFC_BACKEND_TX_RING_BUFFER_SIZE + 1. One byte is used for a packet header.
179+
180+
config SHELL_NFC_BACKEND_TX_RING_BUFFER_SIZE
181+
int "Shell Tx ring buffer size"
182+
default 254
183+
help
184+
Set the shell Tx ring buffer size. It collects data from the shell and passes it to the
185+
transport interface. It can be increased to transfer data in bigger chunks. To achieve the
186+
higher data throughput, the SHELL_NFC_BACKEND_TX_BUFFER Kconfig option must be increased
187+
together with it.
188+
189+
config SHELL_NFC_BACKEND_RX_RING_BUFFER_SIZE
190+
int "Shell Rx ring buffer size"
191+
default 32
192+
help
193+
RX ring buffer size impacts accepted latency of handling incoming
194+
bytes by shell. If shell input is coming from the keyboard then it is
195+
usually enough if ring buffer is few bytes (more than one due to
196+
escape sequences). However, if bulk data is transferred it may be
197+
required to increase it.
198+
199+
choice
200+
prompt "Initial log level limit"
201+
default SHELL_NFC_INIT_LOG_LEVEL_NONE
202+
203+
config SHELL_NFC_INIT_LOG_LEVEL_DEFAULT
204+
bool "System limit (LOG_MAX_LEVEL)"
205+
206+
config SHELL_NFC_INIT_LOG_LEVEL_DBG
207+
bool "Debug"
208+
209+
config SHELL_NFC_INIT_LOG_LEVEL_INF
210+
bool "Info"
211+
212+
config SHELL_NFC_INIT_LOG_LEVEL_WRN
213+
bool "Warning"
214+
215+
config SHELL_NFC_INIT_LOG_LEVEL_ERR
216+
bool "Error"
217+
218+
config SHELL_NFC_INIT_LOG_LEVEL_NONE
219+
bool "None"
220+
221+
endchoice
222+
223+
config SHELL_NFC_INIT_LOG_LEVEL
224+
int
225+
default 0 if SHELL_NFC_INIT_LOG_LEVEL_NONE
226+
default 1 if SHELL_NFC_INIT_LOG_LEVEL_ERR
227+
default 2 if SHELL_NFC_INIT_LOG_LEVEL_WRN
228+
default 3 if SHELL_NFC_INIT_LOG_LEVEL_INF
229+
default 4 if SHELL_NFC_INIT_LOG_LEVEL_DBG
230+
default 5 if SHELL_NFC_INIT_LOG_LEVEL_DEFAULT
231+
232+
module = SHELL_NFC
233+
module-str = Shell over the NFC T4T ISO-DEP
234+
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"
235+
236+
default-timeout = 100
237+
source "${ZEPHYR_BASE}/subsys/shell/Kconfig.template.shell_log_queue_timeout"
238+
239+
default-size = 10
240+
source "${ZEPHYR_BASE}/subsys/shell/Kconfig.template.shell_log_queue_size"
241+
242+
243+
endif # SHELL_NFC

0 commit comments

Comments
 (0)