Air quality sensor
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
esp-airsensor/main/console/console_ioimpl.h

77 lines
1.8 KiB

/**
* TODO file description
*
* Created on 2020/04/09.
*/
#ifndef CSPEMU_CONSOLE_IOIMPL_H
#define CSPEMU_CONSOLE_IOIMPL_H
#include <freertos/FreeRTOS.h>
#include <freertos/ringbuf.h>
#include <socket_server.h>
#include <console/console.h>
/** Console ring buffer capacity */
#define CONSOLE_BUFSIZE 512
/** Enum for tagging ioimpl kind */
enum console_iokind {
CONSOLE_IO_FILES,
CONSOLE_IO_TELNET,
};
#define CONSOLE_IOIMPL_MAGIC 0x079fbf72
struct console_ioimpl {
/** This is a tag for the following union */
enum console_iokind kind;
union {
/** STDIO variant data */
struct {
/** STDIN */
FILE *inf;
/** STDOUT */
FILE *outf;
} files;
/** Telnet variant data */
struct {
/** TCP client handle */
TcpdClient_t tcpcli;
/** Received data ring buffer */
RingbufHandle_t console_stdin_ringbuf;
} telnet;
};
/** Console context */
console_ctx_t ctx;
uint32_t __magic;
};
/**
* Setup UART IO for console
*/
void console_setup_uart_stdio(void);
/**
* Start console for stdin/stdout (UART)
*
* @param pIo - pointer where the allocated struct will be stored
* @param hdl - handle to the created task, can be NULL if not used
* @return success
*/
esp_err_t console_start_stdio(struct console_ioimpl **pIo, TaskHandle_t * hdl);
/**
* Start console for a TCP client
*
* @param pIo - pointer where the allocated struct will be stored
* @param hdl - handle to the created task, can be NULL if not used
* @param client - TCP server client handle
* @return success
*/
esp_err_t console_start_tcp(struct console_ioimpl **pIo, TaskHandle_t * hdl, TcpdClient_t client);
#endif //CSPEMU_CONSOLE_IOIMPL_H