Loading...
Searching...
No Matches
cli.h File Reference

Cli API. More...

#include <furi.h>

Go to the source code of this file.

Macros

#define RECORD_CLI   "cli"
 

Typedefs

typedef struct Cli Cli
 Cli type anonymous structure.
 
typedef void(* CliCallback) (Cli *cli, FuriString *args, void *context)
 Cli callback function pointer.
 

Enumerations

enum  CliSymbols {
  CliSymbolAsciiSOH = 0x01 , CliSymbolAsciiETX = 0x03 , CliSymbolAsciiEOT = 0x04 , CliSymbolAsciiBell = 0x07 ,
  CliSymbolAsciiBackspace = 0x08 , CliSymbolAsciiTab = 0x09 , CliSymbolAsciiLF = 0x0A , CliSymbolAsciiCR = 0x0D ,
  CliSymbolAsciiEsc = 0x1B , CliSymbolAsciiUS = 0x1F , CliSymbolAsciiSpace = 0x20 , CliSymbolAsciiDel = 0x7F
}
 
enum  CliCommandFlag { CliCommandFlagDefault = 0 , CliCommandFlagParallelSafe , CliCommandFlagInsomniaSafe = (1 << 1) }
 

Functions

void cli_add_command (Cli *cli, const char *name, CliCommandFlag flags, CliCallback callback, void *context)
 Add cli command Registers you command callback.
 
void cli_print_usage (const char *cmd, const char *usage, const char *arg)
 Print unified cmd usage tip.
 
void cli_delete_command (Cli *cli, const char *name)
 Delete cli command.
 
size_t cli_read (Cli *cli, uint8_t *buffer, size_t size)
 Read from terminal.
 
size_t cli_read_timeout (Cli *cli, uint8_t *buffer, size_t size, uint32_t timeout)
 Non-blocking read from terminal.
 
bool cli_cmd_interrupt_received (Cli *cli)
 Non-blocking check for interrupt command received.
 
void cli_write (Cli *cli, const uint8_t *buffer, size_t size)
 Write to terminal Do it only from inside of cli call.
 
char cli_getc (Cli *cli)
 Read character.
 
void cli_nl (Cli *cli)
 New line Send new ine sequence.
 
void cli_session_open (Cli *cli, void *session)
 
void cli_session_close (Cli *cli)
 
bool cli_is_connected (Cli *cli)
 

Detailed Description

Cli API.

Typedef Documentation

◆ CliCallback

typedef void(* CliCallback) (Cli *cli, FuriString *args, void *context)

Cli callback function pointer.

Implement this interface and use add_cli_command

Parameters
argsstring with what was passed after command
contextpointer to whatever you gave us on cli_add_command

Enumeration Type Documentation

◆ CliCommandFlag

Enumerator
CliCommandFlagDefault 

Default, loader lock is used.

CliCommandFlagParallelSafe 

Safe to run in parallel with other apps, loader lock is not used.

CliCommandFlagInsomniaSafe 

Safe to run with insomnia mode on.

Function Documentation

◆ cli_add_command()

void cli_add_command ( Cli * cli,
const char * name,
CliCommandFlag flags,
CliCallback callback,
void * context )

Add cli command Registers you command callback.

Parameters
clipointer to cli instance
namecommand name
flagsCliCommandFlag
callbackcallback function
contextpointer to whatever we need to pass to callback

◆ cli_cmd_interrupt_received()

bool cli_cmd_interrupt_received ( Cli * cli)

Non-blocking check for interrupt command received.

Parameters
cliCli instance
Returns
true if received

◆ cli_delete_command()

void cli_delete_command ( Cli * cli,
const char * name )

Delete cli command.

Parameters
clipointer to cli instance
namecommand name

◆ cli_getc()

char cli_getc ( Cli * cli)

Read character.

Parameters
cliCli instance
Returns
char

◆ cli_print_usage()

void cli_print_usage ( const char * cmd,
const char * usage,
const char * arg )

Print unified cmd usage tip.

Parameters
cmdcmd name
usageusage tip
argarg passed by user

◆ cli_read()

size_t cli_read ( Cli * cli,
uint8_t * buffer,
size_t size )

Read from terminal.

Parameters
cliCli instance
bufferpointer to buffer
sizesize of buffer in bytes
Returns
bytes read

◆ cli_read_timeout()

size_t cli_read_timeout ( Cli * cli,
uint8_t * buffer,
size_t size,
uint32_t timeout )

Non-blocking read from terminal.

Parameters
cliCli instance
bufferpointer to buffer
sizesize of buffer in bytes
timeouttimeout value in ms
Returns
bytes read

◆ cli_write()

void cli_write ( Cli * cli,
const uint8_t * buffer,
size_t size )

Write to terminal Do it only from inside of cli call.

Parameters
cliCli instance
bufferpointer to buffer
sizesize of buffer in bytes