This guide describes how to integrate Whoosh Shell into your project.
The integration consists of a few simple steps: adding users, registering commands, setting up callbacks, initializing the shell, and using it for interaction.
constWshShellCmd_tShell_LedCmd={.Groups=WSH_SHELL_CMD_GROUP_ADMIN,.Name="led",.Descr="PC13 LED pin management",.Options=LedOptArr,.OptNum=CMD_LED_OPT_ENUM_SIZE,.Handler=shell_cmd_led,};
4. Define users
Add at least one user with credentials, groups, and rights
Optional (WSH_SHELL_SESSION). Lets wsh --keep N hold the login across N
reboots. A no-init RAM region is the natural backing store — it survives a warm
reboot and dies with the power:
boolShell_Init(constchar*pcHostName){if(WshShell_Init(&Shell,pcHostName,NULL,&Shell_Callbacks)!=WSH_SHELL_RET_STATE_SUCCESS){returnfalse;}if(WshShellUser_Attach(&(Shell.Users),Shell_UserTable,WSH_SHELL_ARR_LEN(Shell_UserTable))!=WSH_SHELL_RET_STATE_SUCCESS){returnfalse;}WshShellHistory_Init(&Shell.HistoryIO,Shell_HistoryRead,Shell_HistoryWrite);WshShellSession_Init(&Shell.SessionIO,Shell_SessionRead,Shell_SessionWrite);if(WshShellCmd_Attach(&(Shell.Commands),Shell_CmdTable,WSH_SHELL_ARR_LEN(Shell_CmdTable))!=WSH_SHELL_RET_STATE_SUCCESS){returnfalse;}// Restore a login the operator asked to keep across reboots (no-op without one)WshShell_SessionRestore(&Shell);// Optional: auto-login for development/testing// WshShell_Auth(&Shell, "admin", "1234");returntrue;}
9. Feeding input into the shell
Each received character (e.g., from UART, USB CDC, ...) should be passed to the shell: