Move btshell.h out of samples into include/misc and rename to shell.h Move btshell.c into driver/console and rename to console_handler_shell.c as an shell implementation based on new config CONFIG_CONSOLE_HANDLER_SHELL. Add shell_register_app_cmd_handler for an to app to optionally call so that it can receive cmdlines not handled by the cmds registered with shell_init Change-Id: I5c1585e62ff7a0ee923c6c92833cc762cf912bad Signed-off-by: Thomas Heeley <thomas.heeley@intel.com> Signed-off-by: Anas Nashif <anas.nashif@intel.com>
45 lines
1.4 KiB
C
45 lines
1.4 KiB
C
/* shell.h - Shell header */
|
|
|
|
/*
|
|
* Copyright (c) 2015 Intel Corporation
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
/** @brief Callback called when command is entered.
|
|
*
|
|
* @param argc Number of parameters passed.
|
|
* @param argv Array of option strings. First option is always command name.
|
|
*/
|
|
typedef void (*cmd_function_t)(int argc, char *argv[]);
|
|
|
|
struct shell_cmd {
|
|
const char *cmd_name;
|
|
cmd_function_t cb;
|
|
};
|
|
|
|
/** @brief Initialize shell with optional prompt, NULL in case no prompt is
|
|
* needed.
|
|
*
|
|
* @param prompt Prompt to be printed on serial console.
|
|
* @param cmds Commands to register
|
|
*/
|
|
void shell_init(const char *prompt, struct shell_cmd *cmds);
|
|
|
|
/** @brief Optionally register an app default cmd handler.
|
|
*
|
|
* @param handler To be called if no cmd found in cmds registered with shell_init.
|
|
*/
|
|
void shell_register_app_cmd_handler(cmd_function_t handler);
|
|
|