Loading...
Searching...
No Matches
cli_i.h
1#pragma once
2
3#include "cli.h"
4
5#include <furi.h>
6#include <furi_hal.h>
7
8#include <m-dict.h>
9#include <m-bptree.h>
10#include <m-array.h>
11
12#include "cli_vcp.h"
13
14#define CLI_LINE_SIZE_MAX
15#define CLI_COMMANDS_TREE_RANK 4
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21typedef struct {
22 CliCallback callback;
23 void* context;
24 uint32_t flags;
26
27struct CliSession {
28 void (*init)(void);
29 void (*deinit)(void);
30 size_t (*rx)(uint8_t* buffer, size_t size, uint32_t timeout);
31 size_t (*rx_stdin)(uint8_t* buffer, size_t size, uint32_t timeout, void* context);
32 void (*tx)(const uint8_t* buffer, size_t size);
33 void (*tx_stdout)(const char* data, size_t size, void* context);
34 bool (*is_connected)(void);
35};
36
37BPTREE_DEF2(
38 CliCommandTree,
39 CLI_COMMANDS_TREE_RANK,
43 M_POD_OPLIST)
44
45#define M_OPL_CliCommandTree_t() BPTREE_OPLIST(CliCommandTree, M_POD_OPLIST)
46
47struct Cli {
48 CliCommandTree_t commands;
49 FuriMutex* mutex;
50 FuriSemaphore* idle_sem;
51 FuriString* last_line;
52 FuriString* line;
53 CliSession* session;
54
55 size_t cursor_position;
56};
57
58Cli* cli_alloc(void);
59
60void cli_reset(Cli* cli);
61
62void cli_putc(Cli* cli, char c);
63
64void cli_stdout_callback(void* _cookie, const char* data, size_t size);
65
66#ifdef __cplusplus
67}
68#endif
Cli API.
struct Cli Cli
Cli type anonymous structure.
Definition cli.h:38
void(* CliCallback)(Cli *cli, FuriString *args, void *context)
Cli callback function pointer.
Definition cli.h:45
VCP HAL API.
Furi HAL API.
#define FURI_STRING_OPLIST
OPLIST for FuriString.
Definition string.h:778
Definition cli_i.h:21
Definition cli_i.h:27
Definition mutex.c:13
Definition semaphore.c:15
Definition string.c:4