@@ -99,6 +99,11 @@ static int ot_cli_output_callback(void *context, const char *format, va_list arg
99
99
for (int i = 0 ; i < ret; i++) {
100
100
xQueueSend (rx_queue, &buf[i], 0 );
101
101
}
102
+ // if there is a user callback function in place, it shall have the priority
103
+ // to process/consume the Stream data received from OpenThread CLI, which is available in its RX Buffer
104
+ if (otConsole.responseCallBack != NULL ) {
105
+ otConsole.responseCallBack ();
106
+ }
102
107
}
103
108
}
104
109
}
@@ -144,13 +149,8 @@ static void ot_cli_console_worker(void *context) {
144
149
if (c == ' \n ' && lastReadChar != ' \n ' ) {
145
150
// wait for the OpenThread CLI to finish processing the command
146
151
xTaskNotifyWait (0 , 0 , NULL , portMAX_DELAY);
147
- // if there is a user callback function in place, it shall have the priority
148
- // to process/consume the Stream data received from OpenThread CLI, which is available in its RX Buffer
149
- if (cli->responseCallBack != NULL ) {
150
- cli->responseCallBack ();
151
- }
152
152
// read response from OpenThread CLI and send it to the Stream
153
- while (OThreadCLI.available ()) {
153
+ while (OThreadCLI.available () > 0 ) {
154
154
char c = OThreadCLI.read ();
155
155
// echo it back to the console
156
156
if (cli->echoback ) {
@@ -182,7 +182,7 @@ void OpenThreadCLI::setStream(Stream& otStream) {
182
182
otConsole.cliStream = &otStream;
183
183
}
184
184
185
- void onReceive (OnReceiveCb_t func) {
185
+ void OpenThreadCLI:: onReceive (OnReceiveCb_t func) {
186
186
otConsole.responseCallBack = func; // NULL will set it off
187
187
}
188
188
0 commit comments