mirror of
https://github.com/cesanta/mongoose.git
synced 2025-01-15 02:08:08 +08:00
Fix for new mg_iobuf API
This commit is contained in:
parent
bd7ee0d1e8
commit
70683fc8e7
@ -16,7 +16,7 @@ flash: CMD = flash
|
|||||||
flash: DA = --device $(PORT)
|
flash: DA = --device $(PORT)
|
||||||
flash: build
|
flash: build
|
||||||
|
|
||||||
.PHONY: flash
|
.PHONY: build
|
||||||
|
|
||||||
bridge.hex: build
|
bridge.hex: build
|
||||||
esputil mkhex \
|
esputil mkhex \
|
||||||
|
@ -44,12 +44,12 @@ static void cli_rm(const char *fname) {
|
|||||||
remove(path);
|
remove(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cli(uint8_t input_byte) {
|
static struct mg_iobuf in;
|
||||||
static struct mg_iobuf in;
|
|
||||||
|
|
||||||
|
void cli(uint8_t input_byte) {
|
||||||
if (input_byte == 0 || input_byte == 0xff) return;
|
if (input_byte == 0 || input_byte == 0xff) return;
|
||||||
if (in.len >= 128) in.len = 0;
|
if (in.len >= 128) in.len = 0;
|
||||||
mg_iobuf_add(&in, in.len, &input_byte, sizeof(input_byte), 32);
|
mg_iobuf_add(&in, in.len, &input_byte, sizeof(input_byte));
|
||||||
|
|
||||||
if (input_byte == '\n') {
|
if (input_byte == '\n') {
|
||||||
const char *arrow = "---";
|
const char *arrow = "---";
|
||||||
@ -87,3 +87,7 @@ void cli(uint8_t input_byte) {
|
|||||||
in.len = 0;
|
in.len = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cli_init(void) {
|
||||||
|
mg_iobuf_init(&in, 0, 32);
|
||||||
|
}
|
||||||
|
@ -32,6 +32,7 @@ void app_main(void) {
|
|||||||
} else {
|
} else {
|
||||||
// If WiFi is not configured, run CLI until configured
|
// If WiFi is not configured, run CLI until configured
|
||||||
MG_INFO(("WiFi is not configured, running CLI. Press enter"));
|
MG_INFO(("WiFi is not configured, running CLI. Press enter"));
|
||||||
|
cli_init();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
uint8_t ch = getchar();
|
uint8_t ch = getchar();
|
||||||
cli(ch);
|
cli(ch);
|
||||||
|
@ -15,3 +15,4 @@ void uart_bridge_fn(struct mg_connection *, int, void *, void *);
|
|||||||
int uart_read(void *buf, size_t len);
|
int uart_read(void *buf, size_t len);
|
||||||
bool wifi_init(const char *ssid, const char *pass);
|
bool wifi_init(const char *ssid, const char *pass);
|
||||||
void cli(uint8_t ch);
|
void cli(uint8_t ch);
|
||||||
|
void cli_init(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user