openaliro
Aliro reader: UWB/CCC core and ESP32-S3/C5/C6 port
Loading...
Searching...
No Matches
aliro_shell.c File Reference

— `aliro` UART shell command: colored console over the UWB engine. More...

#include <stdint.h>
#include <string.h>
#include <zephyr/kernel.h>
#include <zephyr/shell/shell.h>
#include "aliro_shell.h"
#include "ccc_shim.h"
#include "fira_session.h"
#include "flight_recorder.h"
#include "uwb_cirdiag.h"
#include "uwb_min.h"
#include "uwb_rxdiag.h"
Include dependency graph for aliro_shell.c:

Functions

static void hdr (const struct shell *sh, const char *title)
 Section header: green "aliro · <title>" over a dim rule.
 
static int cmd_chip (const struct shell *sh, size_t argc, char **argv)
 Read and display the DW3110 DEV_ID register; verify chip identification.
 
static int cmd_rx (const struct shell *sh, size_t argc, char **argv)
 Display RX/TX frame tally and error counters.
 
static int cmd_range (const struct shell *sh, size_t argc, char **argv)
 Display the last valid DS-TWR distance measurement and metadata.
 
static int cmd_selftest (const struct shell *sh, size_t argc, char **argv)
 Run radio TX/RX self-test and display results.
 
static int cmd_log (const struct shell *sh, size_t argc, char **argv)
 Enable, disable, or query the ranging heartbeat log output stream.
 
static int cmd_frames (const struct shell *sh, size_t argc, char **argv)
 Enable, disable, or query the per-block distance stream output.
 
void aliro_shell_set_factory_reset (void(*fn)(void))
 Supply the handler that aliro factoryreset yes invokes.
 
static int cmd_factoryreset (const struct shell *sh, size_t argc, char **argv)
 Erase every stored credential and reboot, but only on an explicit "yes".
 
static int cmd_version (const struct shell *sh, size_t argc, char **argv)
 Display the build commit SHA.
 
static int cmd_status (const struct shell *sh, size_t argc, char **argv)
 Display all system status: chip ID, CCC bind state, URSK provisioning, last range, RX tally, and stream state.
 
static int cmd_aliro (const struct shell *sh, size_t argc, char **argv)
 Print aliro shell command help and list all available subcommands.
 

Detailed Description

— `aliro` UART shell command: colored console over the UWB engine.

Function Documentation

◆ aliro_shell_set_factory_reset()

void aliro_shell_set_factory_reset ( void(*)(void)  fn)

Supply the handler that aliro factoryreset yes invokes.

A factory reset is a Matter/CHIP operation, and CHIP is C++. This file's module is pure C and has no CHIP include paths, so the application registers the call instead of this layer reaching up for it. Pass NULL to unregister.

The handler is expected to erase provisioning and reboot; it may not return. Left unregistered (host tests, a build without the application) the command refuses with -ENOTSUP rather than pretending to have done anything.

Parameters
fnReset handler, or NULL.

◆ cmd_aliro()

static int cmd_aliro ( const struct shell *  sh,
size_t  argc,
char **  argv 
)
static

Print aliro shell command help and list all available subcommands.

Parameters
shShell context.
argcArgument count; if >1, returns error for unknown subcommand.
argvArgument vector; argv[1] if present must be empty or help request.
Returns
0 on success; -EINVAL if argc >1.

◆ cmd_chip()

static int cmd_chip ( const struct shell *  sh,
size_t  argc,
char **  argv 
)
static

Read and display the DW3110 DEV_ID register; verify chip identification.

Parameters
shShell context.
argcArgument count (unused).
argvArgument vector (unused).
Returns
0 on success; nonzero SPI error code on read failure.

◆ cmd_factoryreset()

static int cmd_factoryreset ( const struct shell *  sh,
size_t  argc,
char **  argv 
)
static

Erase every stored credential and reboot, but only on an explicit "yes".

The confirm word is the whole safety mechanism: this is reachable over a bare UART with no undo, and aliro fa<TAB> completes to something that would otherwise unpair the lock on Enter. Without it the command only explains what it would destroy.

Parameters
shShell context.
argcArgument count; argv[1] must be the literal "yes" to proceed.
argvCommand arguments.
Returns
0 once the reset is scheduled; -EINVAL when unconfirmed; -ENOTSUP when the application never registered a handler.

◆ cmd_frames()

static int cmd_frames ( const struct shell *  sh,
size_t  argc,
char **  argv 
)
static

Enable, disable, or query the per-block distance stream output.

Parameters
shShell context.
argcArgument count; if ≥2, argv[1] must be "on" or "off".
argvCommand arguments; argv[1] optionally specifies "on" or "off".
Returns
0 on success; -EINVAL if argv[1] is neither "on" nor "off".

◆ cmd_log()

static int cmd_log ( const struct shell *  sh,
size_t  argc,
char **  argv 
)
static

Enable, disable, or query the ranging heartbeat log output stream.

Parameters
shShell context.
argcArgument count; if ≥2, argv[1] must be "on" or "off".
argvCommand arguments; argv[1] optionally specifies "on" or "off".
Returns
0 on success; -EINVAL if argv[1] is neither "on" nor "off".

◆ cmd_range()

static int cmd_range ( const struct shell *  sh,
size_t  argc,
char **  argv 
)
static

Display the last valid DS-TWR distance measurement and metadata.

Parameters
shShell context.
argcArgument count (unused).
argvArgument vector (unused).
Returns
0 on success.

◆ cmd_rx()

static int cmd_rx ( const struct shell *  sh,
size_t  argc,
char **  argv 
)
static

Display RX/TX frame tally and error counters.

Parameters
shShell context.
argcArgument count (unused).
argvArgument vector (unused).
Returns
0 on success.

◆ cmd_selftest()

static int cmd_selftest ( const struct shell *  sh,
size_t  argc,
char **  argv 
)
static

Run radio TX/RX self-test and display results.

Parameters
shShell context.
argcArgument count (unused).
argvArgument vector (unused).
Returns
0 on success; nonzero error code if self-test fails.

◆ cmd_status()

static int cmd_status ( const struct shell *  sh,
size_t  argc,
char **  argv 
)
static

Display all system status: chip ID, CCC bind state, URSK provisioning, last range, RX tally, and stream state.

Parameters
shShell context.
argcArgument count (unused).
argvArgument vector (unused).
Returns
0 on success.

◆ cmd_version()

static int cmd_version ( const struct shell *  sh,
size_t  argc,
char **  argv 
)
static

Display the build commit SHA.

Parameters
shShell context.
argcArgument count (unused).
argvArgument vector (unused).
Returns
0 on success.