added scope lock

This commit is contained in:
David Cermak committed 2021-10-04 11:32:54 +02:00
1 parent fdfca36919
commit 031bbc14ff
6 files changed
+47 -44

No files matched your search

+7 -9
View File
@@ -94,13 +94,6 @@ bool CMUXedTerminal::process_cmux_recv(size_t len)
return false;
}
static CMUXedTerminal * s_cmux;
bool CMUXedTerminal::s_on_cmux(size_t len)
{
s_cmux->on_cmux(len);
return false;
}
bool output(uint8_t *data, size_t len, std::string message)
{
printf("OUTPUT: %s len=%d \n", message.c_str(), len);
@@ -130,6 +123,9 @@ bool CMUXedTerminal::on_cmux(size_t len)
size_t footer_offset = 0;
while (available_len > 0) {
switch (state) {
case cmux_state::RECOVER:
// TODO: Implement recovery, looking for SOF_MARKER's
break;
case cmux_state::INIT:
if (frame[0] != SOF_MARKER) {
ESP_LOGW("CMUX", "TODO: Recover!");
@@ -199,10 +195,12 @@ bool CMUXedTerminal::on_cmux(size_t len)
}
void CMUXedTerminal::setup_cmux()
{
s_cmux = this;
frame_header_offset = 0;
state = cmux_state::INIT;
term->set_data_cb(s_on_cmux);
term->set_data_cb([this](size_t len){
this->on_cmux(len);
return false;
});
for (size_t i = 0; i < 3; i++)
{
+1
View File
@@ -9,6 +9,7 @@ DTE::DTE(std::unique_ptr<Terminal> terminal):
command_result DTE::command(const std::string& command, got_line_cb got_line, uint32_t time_ms)
{
Scoped<Lock> l(lock);
command_result res = command_result::TIMEOUT;
term->write((uint8_t *)command.c_str(), command.length());
term->set_data_cb([&](size_t len){
+1 -1
View File
@@ -88,7 +88,7 @@ PPP::PPP(std::shared_ptr<DTE> e, esp_netif_t *ppp_netif):
void PPP::start()
{
ppp_dte->set_data_cb([&](size_t len) -> bool {
ppp_dte->set_data_cb([this](size_t len) -> bool {
uint8_t *data;
auto actual_len = ppp_dte->read(&data, len);
receive(data, actual_len);