16
16
*/
17
17
18
18
#include " matter_shell.h"
19
+ #include " sl_component_catalog.h"
19
20
#include < ChipShellCollection.h>
20
21
#include < cmsis_os2.h>
21
22
#include < lib/core/CHIPCore.h>
22
23
#include < lib/shell/Engine.h>
23
24
#include < sl_cmsis_os2_common.h>
25
+ #ifdef SL_CATALOG_CLI_PRESENT
26
+ #include " sl_cli.h"
27
+ #include " sl_cli_config.h"
28
+ #include " sli_cli_io.h"
29
+ #endif
24
30
25
31
using namespace ::chip;
26
32
using chip::Shell::Engine;
@@ -60,6 +66,51 @@ void WaitForShellActivity()
60
66
osThreadFlagsWait (kShellProcessFlag , osFlagsWaitAny, osWaitForever);
61
67
}
62
68
69
+ #ifdef SL_CATALOG_CLI_PRESENT
70
+
71
+ CHIP_ERROR CmdSilabsDispatch (int argc, char ** argv)
72
+ {
73
+ CHIP_ERROR error = CHIP_NO_ERROR;
74
+
75
+ char buff[SL_CLI_INPUT_BUFFER_SIZE] = { 0 };
76
+ char * buff_ptr = buff;
77
+ int i = 0 ;
78
+
79
+ VerifyOrExit (argc > 0 , error = CHIP_ERROR_INVALID_ARGUMENT);
80
+
81
+ for (i = 0 ; i < argc; i++)
82
+ {
83
+ size_t arg_len = strlen (argv[i]);
84
+
85
+ /* Make sure that the next argument won't overflow the buffer */
86
+ VerifyOrExit (buff_ptr + arg_len < buff + kMaxLineLength , error = CHIP_ERROR_BUFFER_TOO_SMALL);
87
+
88
+ strncpy (buff_ptr, argv[i], arg_len);
89
+ buff_ptr += arg_len;
90
+
91
+ /* Make sure that there is enough buffer for a space char */
92
+ if (buff_ptr + sizeof (char ) < buff + kMaxLineLength )
93
+ {
94
+ strncpy (buff_ptr, " " , sizeof (char ));
95
+ buff_ptr++;
96
+ }
97
+ }
98
+ buff_ptr = 0 ;
99
+ sl_cli_handle_input (sl_cli_default_handle, buff);
100
+ exit :
101
+ return error;
102
+ }
103
+
104
+ static const Shell::shell_command_t cmds_silabs_root = { &CmdSilabsDispatch, " silabs" , " Dispatch Silicon Labs CLI command" };
105
+
106
+ void cmdSilabsInit ()
107
+ {
108
+ // Register the root otcli command with the top-level shell.
109
+ Engine::Root ().RegisterCommands (&cmds_silabs_root, 1 );
110
+ }
111
+
112
+ #endif // SL_CATALOG_CLI_PRESENT
113
+
63
114
void startShellTask ()
64
115
{
65
116
int status = chip::Shell::Engine::Root ().Init ();
@@ -68,7 +119,13 @@ void startShellTask()
68
119
// For now also register commands from shell_common (shell app).
69
120
// TODO move at least OTCLI to default commands in lib/shell/commands
70
121
cmd_misc_init ();
122
+ #ifndef SL_WIFI
71
123
cmd_otcli_init ();
124
+ #endif
125
+
126
+ #ifdef SL_CATALOG_CLI_PRESENT
127
+ cmdSilabsInit ();
128
+ #endif
72
129
73
130
shellTaskHandle = osThreadNew (MatterShellTask, nullptr , &kShellTaskAttr );
74
131
VerifyOrDie (shellTaskHandle);
0 commit comments