-
Notifications
You must be signed in to change notification settings - Fork 7.6k
/
Copy pathOThreadCLI.h
60 lines (48 loc) · 1.73 KB
/
OThreadCLI.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#pragma once
#include "soc/soc_caps.h"
#include "sdkconfig.h"
#if SOC_IEEE802154_SUPPORTED
#if CONFIG_OPENTHREAD_ENABLED
#include "esp_openthread.h"
#include "esp_openthread_cli.h"
#include "esp_openthread_lock.h"
#include "esp_openthread_netif_glue.h"
#include "esp_openthread_types.h"
#include "openthread/cli.h"
#include "openthread/instance.h"
#include "openthread/logging.h"
#include "openthread/tasklet.h"
#include "openthread/dataset_ftd.h"
#include "Arduino.h"
typedef std::function<void(void)> OnReceiveCb_t;
class OpenThreadCLI : public Stream {
private:
static size_t setBuffer(QueueHandle_t &queue, size_t len);
bool otStarted = false;
public:
OpenThreadCLI();
~OpenThreadCLI();
// returns true if OpenThread CLI is running
operator bool() const;
// starts a task to read/write otStream. Default prompt is "ot> ". Set it to NULL to make it invisible.
void startConsole(Stream &otStream, bool echoback = true, const char *prompt = "ot> ");
void stopConsole();
void setPrompt(char *prompt); // changes the console prompt. NULL is an empty prompt.
void setEchoBack(bool echoback); // changes the console echoback option
void setStream(Stream &otStream); // changes the console Stream object
void onReceive(OnReceiveCb_t func); // called on a complete line of output from OT CLI, as OT Response
void begin(bool OThreadAutoStart = true);
void end();
// default size is 256 bytes
size_t setTxBufferSize(size_t tx_queue_len);
// default size is 1024 bytes
size_t setRxBufferSize(size_t rx_queue_len);
size_t write(uint8_t);
int available();
int read();
int peek();
void flush();
};
extern OpenThreadCLI OThreadCLI;
#endif /* CONFIG_OPENTHREAD_ENABLED */
#endif /* SOC_IEEE802154_SUPPORTED */