Skip to content

File wsh_shell_session.h

FileList > src > wsh_shell_session.h

Go to the source code of this file

Persistent login session across reboots. More...

  • #include "wsh_shell_cfg.h"
  • #include "wsh_shell_misc.h"
  • #include "wsh_shell_types.h"

Classes

Type Name
struct WshShellSessionIO_t
Function pointers for session persistence I/O.
struct WshShellSession_t
Persisted session descriptor with an integrity hash.

Public Types

Type Name
typedef WshShellSession_t(* WshShellSession_ReadHandler_t
Read the persisted session descriptor.
typedef void(* WshShellSession_WriteHandler_t
Persist the session descriptor.

Public Functions

Type Name
void WshShellSession_Clear (WshShellSessionIO_t * pSessIO)
Drop any persisted session.
void WshShellSession_Init (WshShellSessionIO_t * pSessIO, WshShellSession_ReadHandler_t readFn, WshShellSession_WriteHandler_t writeFn)
Initialise the session system with custom I/O handlers.
WshShell_Bool_t WshShellSession_IsValid (const WshShellSession_t * pcSession)
Check whether a descriptor is a valid, active keep request.
WshShellSession_t WshShellSession_Read (WshShellSessionIO_t * pSessIO)
Read the persisted descriptor.
void WshShellSession_Store (WshShellSessionIO_t * pSessIO, WshShellSession_t session)
Persist a descriptor, computing its integrity hash first.

Detailed Description

Lets the host keep the current login valid across a bounded number of reboots, so a device that reboots mid-session (firmware bug, watchdog) does not force a re-login. The budget is a plain reboot counter — no wall-clock/RTC is needed: each restore consumes one reboot from the budget.

Storage is delegated to the integrator through read/write handlers (same pattern as the command history), so the shell core stays storage-agnostic. A no-init RAM region is the natural backing store: it survives a warm reboot but is lost on real power removal.

Author:

Whoosh Embedded Team

Copyright:

Copyright (c) 2025

Public Types Documentation

typedef WshShellSession_ReadHandler_t

Read the persisted session descriptor.

typedef WshShellSession_t(* WshShellSession_ReadHandler_t) (void);


typedef WshShellSession_WriteHandler_t

Persist the session descriptor.

typedef void(* WshShellSession_WriteHandler_t) (WshShellSession_t);


Public Functions Documentation

function WshShellSession_Clear

Drop any persisted session.

1
2
3
void WshShellSession_Clear (
    WshShellSessionIO_t * pSessIO
) 

Parameters:

  • pSessIO Pointer to the I/O structure.

function WshShellSession_Init

Initialise the session system with custom I/O handlers.

1
2
3
4
5
void WshShellSession_Init (
    WshShellSessionIO_t * pSessIO,
    WshShellSession_ReadHandler_t readFn,
    WshShellSession_WriteHandler_t writeFn
) 

Installs the handlers and normalises the backing store: any invalid descriptor (e.g. random RAM after a cold boot) is cleared so it will not be restored.

Parameters:

  • pSessIO Pointer to the I/O structure.
  • readFn Callback to read the saved descriptor.
  • writeFn Callback to persist the descriptor.

function WshShellSession_IsValid

Check whether a descriptor is a valid, active keep request.

1
2
3
WshShell_Bool_t WshShellSession_IsValid (
    const WshShellSession_t * pcSession
) 

Parameters:

  • pcSession Descriptor to validate.

Return value:

  • true Hash matches and RebootsLeft > 0.
  • false Corrupt/uninitialised, or budget exhausted.

function WshShellSession_Read

Read the persisted descriptor.

1
2
3
WshShellSession_t WshShellSession_Read (
    WshShellSessionIO_t * pSessIO
) 

Parameters:

  • pSessIO Pointer to the I/O structure.

Returns:

The stored descriptor (may be invalid — check with WshShellSession_IsValid()).


function WshShellSession_Store

Persist a descriptor, computing its integrity hash first.

1
2
3
4
void WshShellSession_Store (
    WshShellSessionIO_t * pSessIO,
    WshShellSession_t session
) 

Parameters:

  • pSessIO Pointer to the I/O structure.
  • session Descriptor to store (its Hash field is filled in).


The documentation for this class was generated from the following file src/wsh_shell_session.h