1 /*
2  * Copyright (c) 2024 Nordic Semiconductor ASA
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef __BT_SHELL_PRIVATE_H
8 #define __BT_SHELL_PRIVATE_H
9 
10 #include <zephyr/shell/shell.h>
11 
12 /**
13  * @brief printf-like function which sends formatted data stream to the shell.
14  * (Bluetooth context specific)
15  *
16  * This function can be used from the command handler or from threads, but not
17  * from an interrupt context.
18  *
19  * @param[in] color Printed text color.
20  * @param[in] fmt   Format string.
21  * @param[in] ...   List of parameters to print.
22  */
23 __printf_like(2, 3) void bt_shell_fprintf(enum shell_vt100_color color,
24 					  const char *fmt, ...);
25 
26 /**
27  * @brief printf-like function which sends formatted data stream to the shell.
28  * (Bluetooth context specific)
29  *
30  * This function can be used from the command handler or from threads, but not
31  * from an interrupt context.
32  *
33  * @param[in] fmt   Format string.
34  * @param[in] ...   List of parameters to print.
35  */
36 __printf_like(1, 2) void bt_shell_fprintf_info(const char *fmt, ...);
37 __printf_like(1, 2) void bt_shell_fprintf_print(const char *fmt, ...);
38 __printf_like(1, 2) void bt_shell_fprintf_warn(const char *fmt, ...);
39 __printf_like(1, 2) void bt_shell_fprintf_error(const char *fmt, ...);
40 
41 /**
42  * @brief Print data in hexadecimal format.
43  * (Bluetooth context specific)
44  *
45  * @param[in] data Pointer to data.
46  * @param[in] len  Length of data.
47  */
48 void bt_shell_hexdump(const uint8_t *data, size_t len);
49 
50 /**
51  * @brief Print info message to the shell.
52  * (Bluetooth context specific)
53  *
54  * @param[in] _ft Format string.
55  * @param[in] ... List of parameters to print.
56  */
57 #define bt_shell_info(_ft, ...) \
58 	bt_shell_fprintf_info(_ft "\n", ##__VA_ARGS__)
59 
60 /**
61  * @brief Print normal message to the shell.
62  * (Bluetooth context specific)
63  *
64  * @param[in] _ft Format string.
65  * @param[in] ... List of parameters to print.
66  */
67 #define bt_shell_print(_ft, ...) \
68 	bt_shell_fprintf_print(_ft "\n", ##__VA_ARGS__)
69 
70 /**
71  * @brief Print warning message to the shell.
72  * (Bluetooth context specific)
73  *
74  * @param[in] _ft Format string.
75  * @param[in] ... List of parameters to print.
76  */
77 #define bt_shell_warn(_ft, ...) \
78 	bt_shell_fprintf_warn(_ft "\n", ##__VA_ARGS__)
79 
80 /**
81  * @brief Print error message to the shell.
82  * (Bluetooth context specific)
83  *
84  * @param[in] _ft Format string.
85  * @param[in] ... List of parameters to print.
86  */
87 #define bt_shell_error(_ft, ...) \
88 	bt_shell_fprintf_error(_ft "\n", ##__VA_ARGS__)
89 
90 #endif /* __BT_SHELL_PRIVATE_H */
91