feat(modem): DTE to support sending and receiving raw data

MAJOR CHANGE: Enable DTE to redefine on_read() and write(cmd) directly
This commit is contained in:
David Cermak
2023-03-16 19:17:53 +01:00
parent 574738b8d3
commit bf114d3624
6 changed files with 63 additions and 31 deletions

View File

@ -29,6 +29,13 @@ class CMux;
* @{
*/
struct DTE_Command {
DTE_Command(const std::string &cmd): data((uint8_t *)cmd.c_str()), len(cmd.length()) {}
uint8_t *data;
size_t len;
};
/**
* DTE (Data Terminal Equipment) class
*/
@ -54,7 +61,9 @@ public:
* @param len Data len to write
* @return number of bytes written
*/
int write(uint8_t *data, size_t len);
int write(uint8_t *data, size_t len) override;
int write(DTE_Command command);
/**
* @brief Reading from the underlying terminal
@ -70,6 +79,8 @@ public:
*/
void set_read_cb(std::function<bool(uint8_t *data, size_t len)> f);
void on_read(got_line_cb on_data) override;
/**
* @brief Sets DTE error callback
* @param f Function to be called on DTE error