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 void (*tx)(const uint8_t* buffer, size_t size);
32 void (*tx_stdout)(const char* data, size_t size);
33 bool (*is_connected)(void);
34};
35
36BPTREE_DEF2(
37 CliCommandTree,
38 CLI_COMMANDS_TREE_RANK,
42 M_POD_OPLIST)
43
44#define M_OPL_CliCommandTree_t() BPTREE_OPLIST(CliCommandTree, M_POD_OPLIST)
45
46struct Cli {
47 CliCommandTree_t commands;
48 FuriMutex* mutex;
49 FuriSemaphore* idle_sem;
50 FuriString* last_line;
51 FuriString* line;
52 CliSession* session;
53
54 size_t cursor_position;
55};
56
57Cli* cli_alloc(void);
58
59void cli_reset(Cli* cli);
60
61void cli_putc(Cli* cli, char c);
62
63void cli_stdout_callback(void* _cookie, const char* data, size_t size);
64
65#ifdef __cplusplus
66}
67#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