mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-06-26 09:51:34 +02:00
CI: fixing the files to be complient with pre-commit hooks
This commit is contained in:
5
.flake8
5
.flake8
@ -136,6 +136,5 @@ show_source = True
|
|||||||
|
|
||||||
statistics = True
|
statistics = True
|
||||||
|
|
||||||
per-file-ignores =
|
exclude =
|
||||||
# Sphinx conf.py files use star imports to setup config variables
|
components/asio/docs/conf_common.py
|
||||||
docs/conf_common.py: F405
|
|
||||||
|
2
.git-blame-ignore-revs
Normal file
2
.git-blame-ignore-revs
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Formating according pre-commit hooks
|
||||||
|
3e1c3cc647b6f6d4da20b3ab979879f60229bfee
|
26
.mypy.ini
Normal file
26
.mypy.ini
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[mypy]
|
||||||
|
|
||||||
|
# Specifies the Python version used to parse and check the target program
|
||||||
|
python_version = 3.9
|
||||||
|
|
||||||
|
# Disallows defining functions without type annotations or with incomplete type annotations
|
||||||
|
# True => enforce type annotation in all function definitions
|
||||||
|
disallow_untyped_defs = True
|
||||||
|
|
||||||
|
# Shows a warning when returning a value with type Any from a function declared with a non- Any return type
|
||||||
|
warn_return_any = True
|
||||||
|
|
||||||
|
# Shows errors for missing return statements on some execution paths
|
||||||
|
warn_no_return = True
|
||||||
|
|
||||||
|
# Suppress error messages about imports that cannot be resolved
|
||||||
|
# True => ignore all import errors
|
||||||
|
ignore_missing_imports = True
|
||||||
|
|
||||||
|
# Disallows defining functions with incomplete type annotations
|
||||||
|
disallow_incomplete_defs = False
|
||||||
|
|
||||||
|
# Directs what to do with imports when the imported module is found as a .py file and not part of the files,
|
||||||
|
# modules and packages provided on the command line.
|
||||||
|
# SKIP -> mypy checks only single file, not included imports
|
||||||
|
follow_imports = skip
|
@ -20,6 +20,10 @@ repos:
|
|||||||
rev: v0.981
|
rev: v0.981
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
|
exclude: >
|
||||||
|
(?x)^(
|
||||||
|
.*.py
|
||||||
|
)$
|
||||||
- repo: https://github.com/myint/unify
|
- repo: https://github.com/myint/unify
|
||||||
rev: v0.5
|
rev: v0.5
|
||||||
hooks:
|
hooks:
|
||||||
|
@ -46,9 +46,19 @@ asio_component:
|
|||||||
- Apache-2.0
|
- Apache-2.0
|
||||||
- BSL-1.0
|
- BSL-1.0
|
||||||
|
|
||||||
|
slim_modem_examples:
|
||||||
|
include:
|
||||||
|
- 'examples/esp_netif/slip_custom_netif/**'
|
||||||
|
allowed_licenses:
|
||||||
|
- Apache-2.0
|
||||||
|
- Unlicense
|
||||||
|
- CC0-1.0
|
||||||
|
|
||||||
ignore:
|
ignore:
|
||||||
perform_check: no
|
perform_check: no
|
||||||
include:
|
include:
|
||||||
- 'components/**/docs/**'
|
- 'components/**/docs/**'
|
||||||
- 'components/esp_modem/port/linux/**'
|
- 'components/esp_modem/port/linux/**'
|
||||||
- 'components/asio/examples/asio_chat/main/*'
|
- 'components/asio/examples/**'
|
||||||
|
- 'components/mdns/**/esp_system_protocols_linux/**'
|
||||||
|
- 'common_components/protocol_examples_common/**'
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* Common functions for protocol examples, to establish Wi-Fi or Ethernet connection.
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* Common functions for protocol examples, to establish Wi-Fi or Ethernet connection.
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -1,13 +1,14 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
/* Common utilities for socket address input interface:
|
/* Common utilities for socket address input interface:
|
||||||
The API get_addr_from_stdin() is mainly used by socket client examples which read IP address from stdin (if configured).
|
The API get_addr_from_stdin() is mainly used by socket client examples which read IP address from stdin (if configured).
|
||||||
This option is typically used in the CI, but could be enabled in the project configuration.
|
This option is typically used in the CI, but could be enabled in the project configuration.
|
||||||
In that case this component is used to receive a string that is evaluated and processed to output
|
In that case this component is used to receive a string that is evaluated and processed to output
|
||||||
socket structures to open a connectio
|
socket structures to open a connectio
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* Common functions for protocol examples, to establish Wi-Fi or Ethernet connection.
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* Common functions for protocol examples, to establish Wi-Fi or Ethernet connection.
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* Common functions for protocol examples, to configure stdin and stdout.
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* Common functions for protocol examples, to configure stdin and stdout.
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "protocol_examples_common.h"
|
#include "protocol_examples_common.h"
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
from esp_docs.conf_docs import * # noqa: F403,F401
|
from esp_docs.conf_docs import * # noqa: F403,F401
|
||||||
|
|
||||||
extensions += ['sphinx_copybutton',
|
extensions += [
|
||||||
|
'sphinx_copybutton',
|
||||||
# Needed as a trigger for running doxygen
|
# Needed as a trigger for running doxygen
|
||||||
'esp_docs.esp_extensions.dummy_build_system',
|
'esp_docs.esp_extensions.dummy_build_system',
|
||||||
'esp_docs.esp_extensions.run_doxygen',
|
'esp_docs.esp_extensions.run_doxygen',
|
||||||
|
@ -24,4 +24,3 @@ window.onload =(function() {
|
|||||||
|
|
||||||
})();
|
})();
|
||||||
</script>" >> html/index.html
|
</script>" >> html/index.html
|
||||||
|
|
||||||
|
@ -53,14 +53,15 @@ void start_client(void)
|
|||||||
#ifdef CONFIG_EXAMPLE_CHAT_SERVER
|
#ifdef CONFIG_EXAMPLE_CHAT_SERVER
|
||||||
std::lock_guard<std::mutex> guard(server_ready);
|
std::lock_guard<std::mutex> guard(server_ready);
|
||||||
#endif
|
#endif
|
||||||
std::thread t([&io_context]() { try {
|
std::thread t([&io_context]() {
|
||||||
|
try {
|
||||||
io_context.run();
|
io_context.run();
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
ESP_LOGE(TAG, "Exception occured during client thread execution %s", e.what());
|
ESP_LOGE(TAG, "Exception occured during client thread execution %s", e.what());
|
||||||
}
|
} catch (...) {
|
||||||
catch (...) {
|
|
||||||
ESP_LOGE(TAG, "Unknown exception");
|
ESP_LOGE(TAG, "Unknown exception");
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
do {
|
do {
|
||||||
ESP_LOGI(TAG, "CLIENT: Waiting for input");
|
ESP_LOGI(TAG, "CLIENT: Waiting for input");
|
||||||
get_string(line, sizeof(line));
|
get_string(line, sizeof(line));
|
||||||
@ -99,10 +100,10 @@ extern "C" void app_main(void)
|
|||||||
io_context.run();
|
io_context.run();
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
ESP_LOGE(TAG, "Exception occured during server thread execution %s", e.what());
|
ESP_LOGE(TAG, "Exception occured during server thread execution %s", e.what());
|
||||||
}
|
} catch (...) {
|
||||||
catch (...) {
|
|
||||||
ESP_LOGE(TAG, "Unknown exception");
|
ESP_LOGE(TAG, "Unknown exception");
|
||||||
}});;
|
}
|
||||||
|
});;
|
||||||
#endif
|
#endif
|
||||||
#ifdef CONFIG_EXAMPLE_CHAT_CLIENT
|
#ifdef CONFIG_EXAMPLE_CHAT_CLIENT
|
||||||
start_client();
|
start_client();
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
class chat_message
|
class chat_message {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
static constexpr std::size_t header_length = 4;
|
static constexpr std::size_t header_length = 4;
|
||||||
static constexpr std::size_t max_body_length = 512;
|
static constexpr std::size_t max_body_length = 512;
|
||||||
@ -59,17 +58,17 @@ public:
|
|||||||
void body_length(std::size_t new_length)
|
void body_length(std::size_t new_length)
|
||||||
{
|
{
|
||||||
body_length_ = new_length;
|
body_length_ = new_length;
|
||||||
if (body_length_ > max_body_length)
|
if (body_length_ > max_body_length) {
|
||||||
body_length_ = max_body_length;
|
body_length_ = max_body_length;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool decode_header()
|
bool decode_header()
|
||||||
{
|
{
|
||||||
char header[header_length + 1] = "";
|
char header[header_length + 1] = "";
|
||||||
std::strncat(header, data_, header_length);
|
std::strncat(header, data_, header_length);
|
||||||
body_length_ = std::atoi(header);
|
body_length_ = std::atoi(header);
|
||||||
if (body_length_ > max_body_length)
|
if (body_length_ > max_body_length) {
|
||||||
{
|
|
||||||
body_length_ = 0;
|
body_length_ = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,7 @@
|
|||||||
|
|
||||||
typedef std::deque<chat_message> chat_message_queue;
|
typedef std::deque<chat_message> chat_message_queue;
|
||||||
|
|
||||||
class chat_client
|
class chat_client {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
chat_client(asio::io_context &io_context,
|
chat_client(asio::io_context &io_context,
|
||||||
const asio::ip::tcp::resolver::results_type &endpoints)
|
const asio::ip::tcp::resolver::results_type &endpoints)
|
||||||
@ -31,12 +30,10 @@ public:
|
|||||||
void write(const chat_message &msg)
|
void write(const chat_message &msg)
|
||||||
{
|
{
|
||||||
asio::post(io_context_,
|
asio::post(io_context_,
|
||||||
[this, msg]()
|
[this, msg]() {
|
||||||
{
|
|
||||||
bool write_in_progress = !write_msgs_.empty();
|
bool write_in_progress = !write_msgs_.empty();
|
||||||
write_msgs_.push_back(msg);
|
write_msgs_.push_back(msg);
|
||||||
if (!write_in_progress)
|
if (!write_in_progress) {
|
||||||
{
|
|
||||||
do_write();
|
do_write();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -44,17 +41,17 @@ public:
|
|||||||
|
|
||||||
void close()
|
void close()
|
||||||
{
|
{
|
||||||
asio::post(io_context_, [this]() { socket_.close(); });
|
asio::post(io_context_, [this]() {
|
||||||
|
socket_.close();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void do_connect(const asio::ip::tcp::resolver::results_type &endpoints)
|
void do_connect(const asio::ip::tcp::resolver::results_type &endpoints)
|
||||||
{
|
{
|
||||||
asio::async_connect(socket_, endpoints,
|
asio::async_connect(socket_, endpoints,
|
||||||
[this](std::error_code ec, asio::ip::tcp::endpoint)
|
[this](std::error_code ec, asio::ip::tcp::endpoint) {
|
||||||
{
|
if (!ec) {
|
||||||
if (!ec)
|
|
||||||
{
|
|
||||||
do_read_header();
|
do_read_header();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -64,14 +61,10 @@ void do_connect(const asio::ip::tcp::resolver::results_type& endpoints)
|
|||||||
{
|
{
|
||||||
asio::async_read(socket_,
|
asio::async_read(socket_,
|
||||||
asio::buffer(read_msg_.data(), chat_message::header_length),
|
asio::buffer(read_msg_.data(), chat_message::header_length),
|
||||||
[this](std::error_code ec, std::size_t /*length*/)
|
[this](std::error_code ec, std::size_t /*length*/) {
|
||||||
{
|
if (!ec && read_msg_.decode_header()) {
|
||||||
if (!ec && read_msg_.decode_header())
|
|
||||||
{
|
|
||||||
do_read_body();
|
do_read_body();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
socket_.close();
|
socket_.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -81,14 +74,10 @@ void do_connect(const asio::ip::tcp::resolver::results_type& endpoints)
|
|||||||
{
|
{
|
||||||
asio::async_read(socket_,
|
asio::async_read(socket_,
|
||||||
asio::buffer(read_msg_.body(), read_msg_.body_length()),
|
asio::buffer(read_msg_.body(), read_msg_.body_length()),
|
||||||
[this](std::error_code ec, std::size_t /*length*/)
|
[this](std::error_code ec, std::size_t /*length*/) {
|
||||||
{
|
if (!ec) {
|
||||||
if (!ec)
|
|
||||||
{
|
|
||||||
do_read_header();
|
do_read_header();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
socket_.close();
|
socket_.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -99,18 +88,13 @@ void do_connect(const asio::ip::tcp::resolver::results_type& endpoints)
|
|||||||
asio::async_write(socket_,
|
asio::async_write(socket_,
|
||||||
asio::buffer(write_msgs_.front().data(),
|
asio::buffer(write_msgs_.front().data(),
|
||||||
write_msgs_.front().length()),
|
write_msgs_.front().length()),
|
||||||
[this](std::error_code ec, std::size_t /*length*/)
|
[this](std::error_code ec, std::size_t /*length*/) {
|
||||||
{
|
if (!ec) {
|
||||||
if (!ec)
|
|
||||||
{
|
|
||||||
write_msgs_.pop_front();
|
write_msgs_.pop_front();
|
||||||
if (!write_msgs_.empty())
|
if (!write_msgs_.empty()) {
|
||||||
{
|
|
||||||
do_write();
|
do_write();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
socket_.close();
|
socket_.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -27,8 +27,7 @@ extern std::mutex server_ready;
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
class chat_participant
|
class chat_participant {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
virtual ~chat_participant() {}
|
virtual ~chat_participant() {}
|
||||||
virtual void deliver(const chat_message &msg) = 0;
|
virtual void deliver(const chat_message &msg) = 0;
|
||||||
@ -38,15 +37,15 @@ typedef std::shared_ptr<chat_participant> chat_participant_ptr;
|
|||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
class chat_room
|
class chat_room {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
void join(chat_participant_ptr participant)
|
void join(chat_participant_ptr participant)
|
||||||
{
|
{
|
||||||
participants_.insert(participant);
|
participants_.insert(participant);
|
||||||
for (auto msg: recent_msgs_)
|
for (auto msg : recent_msgs_) {
|
||||||
participant->deliver(msg);
|
participant->deliver(msg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void leave(chat_participant_ptr participant)
|
void leave(chat_participant_ptr participant)
|
||||||
{
|
{
|
||||||
@ -56,12 +55,14 @@ public:
|
|||||||
void deliver(const chat_message &msg)
|
void deliver(const chat_message &msg)
|
||||||
{
|
{
|
||||||
recent_msgs_.push_back(msg);
|
recent_msgs_.push_back(msg);
|
||||||
while (recent_msgs_.size() > max_recent_msgs)
|
while (recent_msgs_.size() > max_recent_msgs) {
|
||||||
recent_msgs_.pop_front();
|
recent_msgs_.pop_front();
|
||||||
|
}
|
||||||
|
|
||||||
for (auto participant: participants_)
|
for (auto participant : participants_) {
|
||||||
participant->deliver(msg);
|
participant->deliver(msg);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::set<chat_participant_ptr> participants_;
|
std::set<chat_participant_ptr> participants_;
|
||||||
@ -74,8 +75,7 @@ private:
|
|||||||
|
|
||||||
class chat_session
|
class chat_session
|
||||||
: public chat_participant,
|
: public chat_participant,
|
||||||
public std::enable_shared_from_this<chat_session>
|
public std::enable_shared_from_this<chat_session> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
chat_session(asio::ip::tcp::socket socket, chat_room &room)
|
chat_session(asio::ip::tcp::socket socket, chat_room &room)
|
||||||
: socket_(std::move(socket)),
|
: socket_(std::move(socket)),
|
||||||
@ -93,8 +93,7 @@ public:
|
|||||||
{
|
{
|
||||||
bool write_in_progress = !write_msgs_.empty();
|
bool write_in_progress = !write_msgs_.empty();
|
||||||
write_msgs_.push_back(msg);
|
write_msgs_.push_back(msg);
|
||||||
if (!write_in_progress)
|
if (!write_in_progress) {
|
||||||
{
|
|
||||||
do_write();
|
do_write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,14 +104,10 @@ private:
|
|||||||
auto self(shared_from_this());
|
auto self(shared_from_this());
|
||||||
asio::async_read(socket_,
|
asio::async_read(socket_,
|
||||||
asio::buffer(read_msg_.data(), chat_message::header_length),
|
asio::buffer(read_msg_.data(), chat_message::header_length),
|
||||||
[this, self](std::error_code ec, std::size_t /*length*/)
|
[this, self](std::error_code ec, std::size_t /*length*/) {
|
||||||
{
|
if (!ec && read_msg_.decode_header()) {
|
||||||
if (!ec && read_msg_.decode_header())
|
|
||||||
{
|
|
||||||
do_read_body();
|
do_read_body();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
room_.leave(shared_from_this());
|
room_.leave(shared_from_this());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -123,16 +118,12 @@ private:
|
|||||||
auto self(shared_from_this());
|
auto self(shared_from_this());
|
||||||
asio::async_read(socket_,
|
asio::async_read(socket_,
|
||||||
asio::buffer(read_msg_.body(), read_msg_.body_length()),
|
asio::buffer(read_msg_.body(), read_msg_.body_length()),
|
||||||
[this, self](std::error_code ec, std::size_t /*length*/)
|
[this, self](std::error_code ec, std::size_t /*length*/) {
|
||||||
{
|
if (!ec) {
|
||||||
if (!ec)
|
|
||||||
{
|
|
||||||
ESP_LOGD("asio-chat:", "%s", read_msg_.body());
|
ESP_LOGD("asio-chat:", "%s", read_msg_.body());
|
||||||
room_.deliver(read_msg_);
|
room_.deliver(read_msg_);
|
||||||
do_read_header();
|
do_read_header();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
room_.leave(shared_from_this());
|
room_.leave(shared_from_this());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -144,18 +135,13 @@ private:
|
|||||||
asio::async_write(socket_,
|
asio::async_write(socket_,
|
||||||
asio::buffer(write_msgs_.front().data(),
|
asio::buffer(write_msgs_.front().data(),
|
||||||
write_msgs_.front().length()),
|
write_msgs_.front().length()),
|
||||||
[this, self](std::error_code ec, std::size_t /*length*/)
|
[this, self](std::error_code ec, std::size_t /*length*/) {
|
||||||
{
|
if (!ec) {
|
||||||
if (!ec)
|
|
||||||
{
|
|
||||||
write_msgs_.pop_front();
|
write_msgs_.pop_front();
|
||||||
if (!write_msgs_.empty())
|
if (!write_msgs_.empty()) {
|
||||||
{
|
|
||||||
do_write();
|
do_write();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
room_.leave(shared_from_this());
|
room_.leave(shared_from_this());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -169,8 +155,7 @@ private:
|
|||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
|
|
||||||
class chat_server
|
class chat_server {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
chat_server(asio::io_context &io_context,
|
chat_server(asio::io_context &io_context,
|
||||||
const asio::ip::tcp::endpoint &endpoint)
|
const asio::ip::tcp::endpoint &endpoint)
|
||||||
@ -184,10 +169,8 @@ private:
|
|||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> guard(server_ready);
|
std::lock_guard<std::mutex> guard(server_ready);
|
||||||
acceptor_.async_accept(
|
acceptor_.async_accept(
|
||||||
[this](std::error_code ec, asio::ip::tcp::socket socket)
|
[this](std::error_code ec, asio::ip::tcp::socket socket) {
|
||||||
{
|
if (!ec) {
|
||||||
if (!ec)
|
|
||||||
{
|
|
||||||
std::make_shared<chat_session>(std::move(socket), room_)->start();
|
std::make_shared<chat_session>(std::move(socket), room_)->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,9 @@
|
|||||||
# This example code is in the Public Domain (or CC0 licensed, at your option.)
|
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
# Unless required by applicable law or agreed to in writing, this
|
|
||||||
# software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
# CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import pytest
|
|
||||||
from pytest_embedded import Dut
|
|
||||||
|
|
||||||
|
|
||||||
def test_examples_asio_chat(dut):
|
def test_examples_asio_chat(dut):
|
@ -70,4 +70,3 @@ ssh -N -v -D 0.0.0.0:1080 localhost
|
|||||||
# Async operations composition and automatic lifetime control
|
# Async operations composition and automatic lifetime control
|
||||||
|
|
||||||
For documentation about the structure of this example look into [async\_request README](../async_request/README.md).
|
For documentation about the structure of this example look into [async\_request README](../async_request/README.md).
|
||||||
|
|
||||||
|
@ -20,11 +20,9 @@ namespace socks4 {
|
|||||||
|
|
||||||
const unsigned char version = 0x04;
|
const unsigned char version = 0x04;
|
||||||
|
|
||||||
class request
|
class request {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
enum command_type
|
enum command_type {
|
||||||
{
|
|
||||||
connect = 0x01,
|
connect = 0x01,
|
||||||
bind = 0x02
|
bind = 0x02
|
||||||
};
|
};
|
||||||
@ -37,8 +35,7 @@ public:
|
|||||||
null_byte_(0)
|
null_byte_(0)
|
||||||
{
|
{
|
||||||
// Only IPv4 is supported by the SOCKS 4 protocol.
|
// Only IPv4 is supported by the SOCKS 4 protocol.
|
||||||
if (endpoint.protocol() != asio::ip::tcp::v4())
|
if (endpoint.protocol() != asio::ip::tcp::v4()) {
|
||||||
{
|
|
||||||
throw asio::system_error(
|
throw asio::system_error(
|
||||||
asio::error::address_family_not_supported);
|
asio::error::address_family_not_supported);
|
||||||
}
|
}
|
||||||
@ -54,8 +51,7 @@ public:
|
|||||||
|
|
||||||
std::array<asio::const_buffer, 7> buffers() const
|
std::array<asio::const_buffer, 7> buffers() const
|
||||||
{
|
{
|
||||||
return
|
return {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
asio::buffer(&version_, 1),
|
asio::buffer(&version_, 1),
|
||||||
asio::buffer(&command_, 1),
|
asio::buffer(&command_, 1),
|
||||||
@ -78,11 +74,9 @@ private:
|
|||||||
unsigned char null_byte_;
|
unsigned char null_byte_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class reply
|
class reply {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
enum status_type
|
enum status_type {
|
||||||
{
|
|
||||||
request_granted = 0x5a,
|
request_granted = 0x5a,
|
||||||
request_failed = 0x5b,
|
request_failed = 0x5b,
|
||||||
request_failed_no_identd = 0x5c,
|
request_failed_no_identd = 0x5c,
|
||||||
@ -97,8 +91,7 @@ public:
|
|||||||
|
|
||||||
std::array<asio::mutable_buffer, 5> buffers()
|
std::array<asio::mutable_buffer, 5> buffers()
|
||||||
{
|
{
|
||||||
return
|
return {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
asio::buffer(&null_byte_, 1),
|
asio::buffer(&null_byte_, 1),
|
||||||
asio::buffer(&status_, 1),
|
asio::buffer(&status_, 1),
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
|
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import pytest
|
|
||||||
from pytest_embedded import Dut
|
|
||||||
|
|
||||||
|
|
||||||
def test_examples_asio_ssl(dut):
|
def test_examples_asio_ssl(dut):
|
||||||
dut.expect('Reply: GET / HTTP/1.1')
|
dut.expect('Reply: GET / HTTP/1.1')
|
@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
#include "asio.hpp"
|
#include "asio.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -8,8 +13,7 @@
|
|||||||
using asio::ip::tcp;
|
using asio::ip::tcp;
|
||||||
|
|
||||||
class session
|
class session
|
||||||
: public std::enable_shared_from_this<session>
|
: public std::enable_shared_from_this<session> {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
session(tcp::socket socket)
|
session(tcp::socket socket)
|
||||||
: socket_(std::move(socket))
|
: socket_(std::move(socket))
|
||||||
@ -26,10 +30,8 @@ private:
|
|||||||
{
|
{
|
||||||
auto self(shared_from_this());
|
auto self(shared_from_this());
|
||||||
socket_.async_read_some(asio::buffer(data_, max_length),
|
socket_.async_read_some(asio::buffer(data_, max_length),
|
||||||
[this, self](std::error_code ec, std::size_t length)
|
[this, self](std::error_code ec, std::size_t length) {
|
||||||
{
|
if (!ec) {
|
||||||
if (!ec)
|
|
||||||
{
|
|
||||||
data_[length] = 0;
|
data_[length] = 0;
|
||||||
std::cout << data_ << std::endl;
|
std::cout << data_ << std::endl;
|
||||||
do_write(length);
|
do_write(length);
|
||||||
@ -41,10 +43,8 @@ private:
|
|||||||
{
|
{
|
||||||
auto self(shared_from_this());
|
auto self(shared_from_this());
|
||||||
asio::async_write(socket_, asio::buffer(data_, length),
|
asio::async_write(socket_, asio::buffer(data_, length),
|
||||||
[this, self](std::error_code ec, std::size_t length)
|
[this, self](std::error_code ec, std::size_t length) {
|
||||||
{
|
if (!ec) {
|
||||||
if (!ec)
|
|
||||||
{
|
|
||||||
do_read();
|
do_read();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -55,8 +55,7 @@ private:
|
|||||||
char data_[max_length];
|
char data_[max_length];
|
||||||
};
|
};
|
||||||
|
|
||||||
class server
|
class server {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
server(asio::io_context &io_context, short port)
|
server(asio::io_context &io_context, short port)
|
||||||
: acceptor_(io_context, tcp::endpoint(tcp::v4(), port))
|
: acceptor_(io_context, tcp::endpoint(tcp::v4(), port))
|
||||||
@ -68,10 +67,8 @@ private:
|
|||||||
void do_accept()
|
void do_accept()
|
||||||
{
|
{
|
||||||
acceptor_.async_accept(
|
acceptor_.async_accept(
|
||||||
[this](std::error_code ec, tcp::socket socket)
|
[this](std::error_code ec, tcp::socket socket) {
|
||||||
{
|
if (!ec) {
|
||||||
if (!ec)
|
|
||||||
{
|
|
||||||
std::make_shared<session>(std::move(socket))->start();
|
std::make_shared<session>(std::move(socket))->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import os
|
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
from pytest_embedded import Dut
|
|
||||||
|
|
||||||
|
|
||||||
def test_examples_protocol_asio_tcp_server(dut):
|
def test_examples_protocol_asio_tcp_server(dut):
|
||||||
@ -15,7 +15,10 @@ def test_examples_protocol_asio_tcp_server(dut):
|
|||||||
"""
|
"""
|
||||||
test_msg = b'echo message from client to server'
|
test_msg = b'echo message from client to server'
|
||||||
# 2. get the server IP address
|
# 2. get the server IP address
|
||||||
data = dut.expect(re.compile(b' IPv4 address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)'), timeout=30).group(1).decode()
|
data = dut.expect(
|
||||||
|
re.compile(
|
||||||
|
b' IPv4 address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)'), # noqa: W605
|
||||||
|
timeout=30).group(1).decode()
|
||||||
# 3. create tcp client and connect to server
|
# 3. create tcp client and connect to server
|
||||||
dut.expect('ASIO engine is up and running', timeout=1)
|
dut.expect('ASIO engine is up and running', timeout=1)
|
||||||
cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
cli = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
@ -29,7 +32,8 @@ def test_examples_protocol_asio_tcp_server(dut):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
print('Failure!')
|
print('Failure!')
|
||||||
raise ValueError('Wrong data received from asi tcp server: {} (expected:{})'.format(data, test_msg))
|
raise ValueError(
|
||||||
|
'Wrong data received from asi tcp server: {} (expected:{})'.format(
|
||||||
|
data, test_msg))
|
||||||
# 5. check the client message appears also on server terminal
|
# 5. check the client message appears also on server terminal
|
||||||
dut.expect(test_msg.decode())
|
dut.expect(test_msg.decode())
|
||||||
|
|
||||||
|
@ -20,8 +20,7 @@
|
|||||||
|
|
||||||
using asio::ip::udp;
|
using asio::ip::udp;
|
||||||
|
|
||||||
class server
|
class server {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
server(asio::io_context &io_context, short port)
|
server(asio::io_context &io_context, short port)
|
||||||
: socket_(io_context, udp::endpoint(udp::v4(), port))
|
: socket_(io_context, udp::endpoint(udp::v4(), port))
|
||||||
@ -33,16 +32,12 @@ public:
|
|||||||
{
|
{
|
||||||
socket_.async_receive_from(
|
socket_.async_receive_from(
|
||||||
asio::buffer(data_, max_length), sender_endpoint_,
|
asio::buffer(data_, max_length), sender_endpoint_,
|
||||||
[this](std::error_code ec, std::size_t bytes_recvd)
|
[this](std::error_code ec, std::size_t bytes_recvd) {
|
||||||
{
|
if (!ec && bytes_recvd > 0) {
|
||||||
if (!ec && bytes_recvd > 0)
|
|
||||||
{
|
|
||||||
data_[bytes_recvd] = 0;
|
data_[bytes_recvd] = 0;
|
||||||
std::cout << data_ << std::endl;
|
std::cout << data_ << std::endl;
|
||||||
do_send(bytes_recvd);
|
do_send(bytes_recvd);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
do_receive();
|
do_receive();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -52,8 +47,7 @@ public:
|
|||||||
{
|
{
|
||||||
socket_.async_send_to(
|
socket_.async_send_to(
|
||||||
asio::buffer(data_, length), sender_endpoint_,
|
asio::buffer(data_, length), sender_endpoint_,
|
||||||
[this](std::error_code /*ec*/, std::size_t bytes /*bytes_sent*/)
|
[this](std::error_code /*ec*/, std::size_t bytes /*bytes_sent*/) {
|
||||||
{
|
|
||||||
do_receive();
|
do_receive();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
import os
|
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
# SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
import pytest
|
|
||||||
from pytest_embedded import Dut
|
|
||||||
|
|
||||||
def test_examples_protocol_asio_udp_server(dut):
|
def test_examples_protocol_asio_udp_server(dut):
|
||||||
"""
|
"""
|
||||||
@ -15,7 +14,10 @@ def test_examples_protocol_asio_udp_server(dut):
|
|||||||
5. Test evaluates received test message on server stdout
|
5. Test evaluates received test message on server stdout
|
||||||
"""
|
"""
|
||||||
test_msg = b'echo message from client to server'
|
test_msg = b'echo message from client to server'
|
||||||
data = dut.expect(re.compile(b' IPv4 address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)'), timeout=30).group(1).decode()
|
data = dut.expect(
|
||||||
|
re.compile(
|
||||||
|
b' IPv4 address: ([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)'), # noqa: W605
|
||||||
|
timeout=30).group(1).decode()
|
||||||
dut.expect('ASIO engine is up and running', timeout=1)
|
dut.expect('ASIO engine is up and running', timeout=1)
|
||||||
cli = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
cli = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
cli.settimeout(30)
|
cli.settimeout(30)
|
||||||
@ -28,6 +30,8 @@ def test_examples_protocol_asio_udp_server(dut):
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
print('Failure!')
|
print('Failure!')
|
||||||
raise ValueError('Wrong data received from asio udp server: {} (expected:{})'.format(data, test_msg))
|
raise ValueError(
|
||||||
|
'Wrong data received from asio udp server: {} (expected:{})'.
|
||||||
|
format(data, test_msg))
|
||||||
# 5. check the client message appears also on server terminal
|
# 5. check the client message appears also on server terminal
|
||||||
dut.expect(test_msg.decode())
|
dut.expect(test_msg.decode())
|
||||||
|
@ -24,7 +24,8 @@ void throw_exception(const Exception& e)
|
|||||||
ESP_LOGE("esp32_asio_exception", "Caught exception: %s!", e.what());
|
ESP_LOGE("esp32_asio_exception", "Caught exception: %s!", e.what());
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
#endif // CONFIG_COMPILER_CXX_EXCEPTIONS==1 && defined (ASIO_NO_EXCEPTIONS)
|
#endif // CONFIG_COMPILER_CXX_EXCEPTIONS==1 && defined (ASIO_NO_EXCEPTIONS)
|
||||||
|
|
||||||
#endif // _ESP_EXCEPTION_H_
|
#endif // _ESP_EXCEPTION_H_
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
// SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
//
|
//
|
||||||
@ -35,7 +35,9 @@ namespace mbedtls {
|
|||||||
class engine;
|
class engine;
|
||||||
class bio;
|
class bio;
|
||||||
class shared_ctx;
|
class shared_ctx;
|
||||||
} } } // namespace asio::ssl::mbedtls
|
}
|
||||||
|
}
|
||||||
|
} // namespace asio::ssl::mbedtls
|
||||||
|
|
||||||
//
|
//
|
||||||
// Supply OpenSSL types as aliases to mbedtls classes
|
// Supply OpenSSL types as aliases to mbedtls classes
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
// SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
//
|
//
|
||||||
@ -110,4 +110,6 @@ private:
|
|||||||
size_t flags_ {0};
|
size_t flags_ {0};
|
||||||
};
|
};
|
||||||
|
|
||||||
} } } // namespace asio::ssl::mbedtls
|
}
|
||||||
|
}
|
||||||
|
} // namespace asio::ssl::mbedtls
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
// SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
//
|
//
|
||||||
@ -29,8 +29,7 @@ template <typename T, typename... Args>
|
|||||||
inline T *create(const char *location, Args &&... args)
|
inline T *create(const char *location, Args &&... args)
|
||||||
{
|
{
|
||||||
T *t = new (std::nothrow) T(std::forward<Args>(args)...);
|
T *t = new (std::nothrow) T(std::forward<Args>(args)...);
|
||||||
if (t == nullptr)
|
if (t == nullptr) {
|
||||||
{
|
|
||||||
throw_alloc_failure(location);
|
throw_alloc_failure(location);
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
@ -83,8 +82,7 @@ public:
|
|||||||
static SSL_CTX *create(const char *location, context_base::method m)
|
static SSL_CTX *create(const char *location, context_base::method m)
|
||||||
{
|
{
|
||||||
auto wrapped = asio::ssl::mbedtls::create<shared_ctx>(location, m);
|
auto wrapped = asio::ssl::mbedtls::create<shared_ctx>(location, m);
|
||||||
if (wrapped->ctx_ == nullptr)
|
if (wrapped->ctx_ == nullptr) {
|
||||||
{
|
|
||||||
throw_alloc_failure(location);
|
throw_alloc_failure(location);
|
||||||
}
|
}
|
||||||
return wrapped;
|
return wrapped;
|
||||||
@ -102,4 +100,6 @@ private:
|
|||||||
std::shared_ptr<mbedtls::context> ctx_;
|
std::shared_ptr<mbedtls::context> ctx_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} } } // namespace asio::ssl::mbedtls
|
}
|
||||||
|
}
|
||||||
|
} // namespace asio::ssl::mbedtls
|
||||||
|
@ -163,18 +163,20 @@ private:
|
|||||||
{
|
{
|
||||||
int mode = MBEDTLS_SSL_VERIFY_UNSET;
|
int mode = MBEDTLS_SSL_VERIFY_UNSET;
|
||||||
if (is_client_not_server) {
|
if (is_client_not_server) {
|
||||||
if (verify_mode_ & SSL_VERIFY_PEER)
|
if (verify_mode_ & SSL_VERIFY_PEER) {
|
||||||
mode = MBEDTLS_SSL_VERIFY_REQUIRED;
|
mode = MBEDTLS_SSL_VERIFY_REQUIRED;
|
||||||
else if (verify_mode_ == SSL_VERIFY_NONE)
|
} else if (verify_mode_ == SSL_VERIFY_NONE) {
|
||||||
mode = MBEDTLS_SSL_VERIFY_NONE;
|
mode = MBEDTLS_SSL_VERIFY_NONE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (verify_mode_ & SSL_VERIFY_FAIL_IF_NO_PEER_CERT)
|
if (verify_mode_ & SSL_VERIFY_FAIL_IF_NO_PEER_CERT) {
|
||||||
mode = MBEDTLS_SSL_VERIFY_REQUIRED;
|
mode = MBEDTLS_SSL_VERIFY_REQUIRED;
|
||||||
else if (verify_mode_ & SSL_VERIFY_PEER)
|
} else if (verify_mode_ & SSL_VERIFY_PEER) {
|
||||||
mode = MBEDTLS_SSL_VERIFY_OPTIONAL;
|
mode = MBEDTLS_SSL_VERIFY_OPTIONAL;
|
||||||
else if (verify_mode_ == SSL_VERIFY_NONE)
|
} else if (verify_mode_ == SSL_VERIFY_NONE) {
|
||||||
mode = MBEDTLS_SSL_VERIFY_NONE;
|
mode = MBEDTLS_SSL_VERIFY_NONE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return mode;
|
return mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,4 +292,6 @@ private:
|
|||||||
asio::ssl::verify_mode verify_mode_;
|
asio::ssl::verify_mode verify_mode_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} } } // namespace asio::ssl::mbedtls
|
}
|
||||||
|
}
|
||||||
|
} // namespace asio::ssl::mbedtls
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
// SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
//
|
//
|
||||||
@ -14,8 +14,7 @@ namespace asio {
|
|||||||
namespace error {
|
namespace error {
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
class mbedtls_category : public asio::error_category
|
class mbedtls_category : public asio::error_category {
|
||||||
{
|
|
||||||
public:
|
public:
|
||||||
const char *name() const ASIO_ERROR_CATEGORY_NOEXCEPT
|
const char *name() const ASIO_ERROR_CATEGORY_NOEXCEPT
|
||||||
{
|
{
|
||||||
@ -52,4 +51,6 @@ const asio::error_category& get_stream_category()
|
|||||||
return asio::error::get_mbedtls_category();
|
return asio::error::get_mbedtls_category();
|
||||||
}
|
}
|
||||||
|
|
||||||
} } } // namespace asio::ssl::error
|
}
|
||||||
|
}
|
||||||
|
} // namespace asio::ssl::error
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
// SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
//
|
//
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
// SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
//
|
//
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
// SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
//
|
//
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
// SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
//
|
//
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
// SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
//
|
//
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
// SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
//
|
//
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
//
|
//
|
||||||
// SPDX-FileContributor: 2021 Espressif Systems (Shanghai) CO LTD
|
// SPDX-FileContributor: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "asio/detail/config.hpp"
|
#include "asio/detail/config.hpp"
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
//
|
//
|
||||||
// SPDX-FileContributor: 2021 Espressif Systems (Shanghai) CO LTD
|
// SPDX-FileContributor: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "asio/detail/config.hpp"
|
#include "asio/detail/config.hpp"
|
||||||
@ -62,8 +62,7 @@ engine::want engine::shutdown(asio::error_code& ec)
|
|||||||
engine::want engine::write(const asio::const_buffer &data,
|
engine::want engine::write(const asio::const_buffer &data,
|
||||||
asio::error_code &ec, std::size_t &bytes_transferred)
|
asio::error_code &ec, std::size_t &bytes_transferred)
|
||||||
{
|
{
|
||||||
if (data.size() == 0)
|
if (data.size() == 0) {
|
||||||
{
|
|
||||||
ec = asio::error_code();
|
ec = asio::error_code();
|
||||||
return engine::want_nothing;
|
return engine::want_nothing;
|
||||||
}
|
}
|
||||||
@ -76,8 +75,7 @@ engine::want engine::write(const asio::const_buffer& data,
|
|||||||
engine::want engine::read(const asio::mutable_buffer &data,
|
engine::want engine::read(const asio::mutable_buffer &data,
|
||||||
asio::error_code &ec, std::size_t &bytes_transferred)
|
asio::error_code &ec, std::size_t &bytes_transferred)
|
||||||
{
|
{
|
||||||
if (data.size() == 0)
|
if (data.size() == 0) {
|
||||||
{
|
|
||||||
ec = asio::error_code();
|
ec = asio::error_code();
|
||||||
return engine::want_nothing;
|
return engine::want_nothing;
|
||||||
}
|
}
|
||||||
@ -108,19 +106,18 @@ const asio::error_code& engine::map_error_code(
|
|||||||
asio::error_code &ec) const
|
asio::error_code &ec) const
|
||||||
{
|
{
|
||||||
// We only want to map the error::eof code.
|
// We only want to map the error::eof code.
|
||||||
if (ec != asio::error::eof)
|
if (ec != asio::error::eof) {
|
||||||
return ec;
|
return ec;
|
||||||
|
}
|
||||||
|
|
||||||
// If there's data yet to be read, it's an error.
|
// If there's data yet to be read, it's an error.
|
||||||
if (ssl_->ext_bio()->wpending())
|
if (ssl_->ext_bio()->wpending()) {
|
||||||
{
|
|
||||||
ec = asio::ssl::error::stream_truncated;
|
ec = asio::ssl::error::stream_truncated;
|
||||||
return ec;
|
return ec;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, the peer should have negotiated a proper shutdown.
|
// Otherwise, the peer should have negotiated a proper shutdown.
|
||||||
if (ssl_->shutdown() != 0)
|
if (ssl_->shutdown() != 0) {
|
||||||
{
|
|
||||||
ec = asio::ssl::error::stream_truncated;
|
ec = asio::ssl::error::stream_truncated;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,38 +135,30 @@ engine::want engine::perform(int (engine::* op)(void*, std::size_t),
|
|||||||
|
|
||||||
std::size_t pending_output_after = ssl_->ext_bio()->ctrl_pending();
|
std::size_t pending_output_after = ssl_->ext_bio()->ctrl_pending();
|
||||||
|
|
||||||
if (mbedtls::error_codes::is_error(result))
|
if (mbedtls::error_codes::is_error(result)) {
|
||||||
{
|
|
||||||
ec = asio::error_code(result, asio::error::get_mbedtls_category());
|
ec = asio::error_code(result, asio::error::get_mbedtls_category());
|
||||||
return pending_output_after > pending_output_before ? want_output : want_nothing;
|
return pending_output_after > pending_output_before ? want_output : want_nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == 0)
|
if (result == 0) {
|
||||||
{
|
|
||||||
return pending_output_after > pending_output_before
|
return pending_output_after > pending_output_before
|
||||||
? want_output : want_nothing;
|
? want_output : want_nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result > 0 && bytes_transferred)
|
if (result > 0 && bytes_transferred) {
|
||||||
*bytes_transferred = static_cast<std::size_t>(result);
|
*bytes_transferred = static_cast<std::size_t>(result);
|
||||||
|
}
|
||||||
|
|
||||||
if (mbedtls::error_codes::want_write(result))
|
if (mbedtls::error_codes::want_write(result)) {
|
||||||
{
|
|
||||||
ec = asio::error_code();
|
ec = asio::error_code();
|
||||||
return want_output_and_retry;
|
return want_output_and_retry;
|
||||||
}
|
} else if (pending_output_after > pending_output_before) {
|
||||||
else if (pending_output_after > pending_output_before)
|
|
||||||
{
|
|
||||||
ec = asio::error_code();
|
ec = asio::error_code();
|
||||||
return result > 0 ? want_output : want_output_and_retry;
|
return result > 0 ? want_output : want_output_and_retry;
|
||||||
}
|
} else if (mbedtls::error_codes::want_read(result)) {
|
||||||
else if (mbedtls::error_codes::want_read(result))
|
|
||||||
{
|
|
||||||
ec = asio::error_code();
|
ec = asio::error_code();
|
||||||
return want_input_and_retry;
|
return want_input_and_retry;
|
||||||
}
|
} else if (ssl_->get_state() == mbedtls::CLOSED) {
|
||||||
else if (ssl_->get_state() == mbedtls::CLOSED)
|
|
||||||
{
|
|
||||||
ec = asio::error::eof;
|
ec = asio::error::eof;
|
||||||
return want_nothing;
|
return want_nothing;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
|
// SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
//
|
//
|
||||||
@ -17,4 +17,6 @@ asio::detail::shared_ptr<openssl_init_base::do_init> openssl_init_base::instance
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} } } // namespace asio::ssl::detail
|
}
|
||||||
|
}
|
||||||
|
} // namespace asio::ssl::detail
|
||||||
|
@ -2522,4 +2522,3 @@ DOT_CLEANUP = YES
|
|||||||
#DOT_GRAPH_MAX_NODES = 100
|
#DOT_GRAPH_MAX_NODES = 100
|
||||||
#MAX_DOT_GRAPH_DEPTH = 0
|
#MAX_DOT_GRAPH_DEPTH = 0
|
||||||
#DOT_TRANSPARENT = YES
|
#DOT_TRANSPARENT = YES
|
||||||
|
|
||||||
|
@ -46,4 +46,3 @@ a custom DTE object and supply it into :ref:`the DCE factory<dce_factory>`. The
|
|||||||
- Create the DTE which uses the custom Terminal
|
- Create the DTE which uses the custom Terminal
|
||||||
|
|
||||||
Please refer to the implementation of the existing UART DTE.
|
Please refer to the implementation of the existing UART DTE.
|
||||||
|
|
||||||
|
@ -2,11 +2,6 @@
|
|||||||
#
|
#
|
||||||
# English Language RTD & Sphinx config file
|
# English Language RTD & Sphinx config file
|
||||||
#
|
#
|
||||||
import os
|
|
||||||
import os.path
|
|
||||||
import re
|
|
||||||
import subprocess
|
|
||||||
import sys
|
|
||||||
|
|
||||||
# General information about the project.
|
# General information about the project.
|
||||||
project = u'esp-modem'
|
project = u'esp-modem'
|
||||||
@ -18,11 +13,12 @@ language = 'en'
|
|||||||
|
|
||||||
extensions = ['breathe', 'recommonmark']
|
extensions = ['breathe', 'recommonmark']
|
||||||
|
|
||||||
|
|
||||||
breathe_projects = {'esp_modem': 'xml'}
|
breathe_projects = {'esp_modem': 'xml'}
|
||||||
|
|
||||||
breathe_default_project = "esp_modem"
|
breathe_default_project = 'esp_modem'
|
||||||
|
|
||||||
source_suffix = ['.rst', '.md']
|
source_suffix = ['.rst', '.md']
|
||||||
|
|
||||||
source_parsers = {'.md': 'recommonmark.parser.CommonMarkParser', }
|
source_parsers = {
|
||||||
|
'.md': 'recommonmark.parser.CommonMarkParser',
|
||||||
|
}
|
||||||
|
@ -115,8 +115,3 @@ Modem types
|
|||||||
|
|
||||||
.. doxygengroup:: ESP_MODEM_TYPES
|
.. doxygengroup:: ESP_MODEM_TYPES
|
||||||
:members:
|
:members:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* softAP to PPPoS Example
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* softAP to PPPoS Example
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* softAP to PPPoS Example (network_dce)
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* softAP to PPPoS Example (network_dce)
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* softAP to PPPoS Example (network_dce)
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* softAP to PPPoS Example (network_dce)
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "cxx_include/esp_modem_dte.hpp"
|
#include "cxx_include/esp_modem_dte.hpp"
|
||||||
@ -92,8 +93,9 @@ public:
|
|||||||
bool check_signal()
|
bool check_signal()
|
||||||
{
|
{
|
||||||
int rssi, ber;
|
int rssi, ber;
|
||||||
if (dce_commands::get_signal_quality(dte.get(), rssi, ber) != command_result::OK)
|
if (dce_commands::get_signal_quality(dte.get(), rssi, ber) != command_result::OK) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
return rssi != 99 && rssi > 5;
|
return rssi != 99 && rssi > 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* softAP to PPPoS Example (network_dce)
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* softAP to PPPoS Example (network_dce)
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -8,4 +8,3 @@ PROJECT_NAME := modem-console
|
|||||||
EXTRA_COMPONENT_DIRS = $(IDF_PATH)/examples/common_components/protocol_examples_common
|
EXTRA_COMPONENT_DIRS = $(IDF_PATH)/examples/common_components/protocol_examples_common
|
||||||
|
|
||||||
include $(IDF_PATH)/make/project.mk
|
include $(IDF_PATH)/make/project.mk
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* Modem console example
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* Modem console example
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "console_helper.hpp"
|
#include "console_helper.hpp"
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* Modem console example
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* Modem console example
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
/* Modem console example
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* Modem console example
|
||||||
Unless required by applicable law or agreed to in writing, this
|
*
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* Modem console example
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* Modem console example
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* Modem console example: Custom DCE
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* Modem console example: Custom DCE
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
/* Ping handle example
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
Unless required by applicable law or agreed to in writing, this
|
*/
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
/*
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
* Ping handle example
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -6,5 +6,3 @@ set(EXTRA_COMPONENT_DIRS "../..")
|
|||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
project(pppos_client)
|
project(pppos_client)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
/* PPPoS Client Example
|
/* PPPoS Client Example
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||||
|
@ -6,5 +6,3 @@ set(EXTRA_COMPONENT_DIRS "../.." $ENV{IDF_PATH}/examples/cxx/experimental/experi
|
|||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
project(simple_cmux_client)
|
project(simple_cmux_client)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
/* PPPoS Client Example
|
/* PPPoS Client Example
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
||||||
@ -96,8 +101,7 @@ extern "C" void app_main(void)
|
|||||||
#endif
|
#endif
|
||||||
assert(dce);
|
assert(dce);
|
||||||
|
|
||||||
if(dte_config.uart_config.flow_control == ESP_MODEM_FLOW_CONTROL_HW)
|
if (dte_config.uart_config.flow_control == ESP_MODEM_FLOW_CONTROL_HW) {
|
||||||
{
|
|
||||||
if (command_result::OK != dce->set_flow_control(2, 2)) {
|
if (command_result::OK != dce->set_flow_control(2, 2)) {
|
||||||
ESP_LOGE(TAG, "Failed to set the set_flow_control mode");
|
ESP_LOGE(TAG, "Failed to set the set_flow_control mode");
|
||||||
return;
|
return;
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* PPPoS Client Example
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* PPPoS Client Example
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
/* PPPoS Client Example
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
||||||
|
*/
|
||||||
|
|
||||||
This example code is in the Public Domain (or CC0 licensed, at your option.)
|
/*
|
||||||
|
* PPPoS Client Example
|
||||||
Unless required by applicable law or agreed to in writing, this
|
|
||||||
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
|
||||||
CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2022 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -40,7 +32,10 @@ struct unique_buffer {
|
|||||||
consumed = 0;
|
consumed = 0;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
[[nodiscard]] uint8_t *get() const { return data.get(); }
|
[[nodiscard]] uint8_t *get() const
|
||||||
|
{
|
||||||
|
return data.get();
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<uint8_t[]> data;
|
std::unique_ptr<uint8_t[]> data;
|
||||||
size_t size{};
|
size_t size{};
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -82,11 +74,13 @@ public:
|
|||||||
Task::Delay(1000); // Mandatory 1s pause before
|
Task::Delay(1000); // Mandatory 1s pause before
|
||||||
int retry = 0;
|
int retry = 0;
|
||||||
while (retry++ < 3) {
|
while (retry++ < 3) {
|
||||||
if (set_command_mode() == command_result::OK)
|
if (set_command_mode() == command_result::OK) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
Task::Delay(1000); // Mandatory 1s pause after escape
|
Task::Delay(1000); // Mandatory 1s pause after escape
|
||||||
if (sync() == command_result::OK)
|
if (sync() == command_result::OK) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
Task::Delay(1000); // Mandatory 1s pause before escape
|
Task::Delay(1000); // Mandatory 1s pause before escape
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -106,8 +98,14 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* @brief Allows for locking the DTE
|
* @brief Allows for locking the DTE
|
||||||
*/
|
*/
|
||||||
void lock() { internal_lock.lock(); }
|
void lock()
|
||||||
void unlock() { internal_lock.unlock(); }
|
{
|
||||||
|
internal_lock.lock();
|
||||||
|
}
|
||||||
|
void unlock()
|
||||||
|
{
|
||||||
|
internal_lock.unlock();
|
||||||
|
}
|
||||||
friend class Scoped<DTE>; /*!< Declaring "Scoped<DTE> lock(dte)" locks this instance */
|
friend class Scoped<DTE>; /*!< Declaring "Scoped<DTE> lock(dte)" locks this instance */
|
||||||
private:
|
private:
|
||||||
static const size_t GOT_LINE = SignalGroup::bit0; /*!< Bit indicating response available */
|
static const size_t GOT_LINE = SignalGroup::bit0; /*!< Bit indicating response available */
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -51,10 +43,19 @@ private:
|
|||||||
#define ESP_MODEM_THROW(exception) do { exception; abort(); } while(0)
|
#define ESP_MODEM_THROW(exception) do { exception; abort(); } while(0)
|
||||||
|
|
||||||
class esp_err_exception {
|
class esp_err_exception {
|
||||||
void print(std::string msg) { ESP_LOGE("ESP_MODEM_THROW", "%s\n", msg.c_str()); }
|
void print(std::string msg)
|
||||||
|
{
|
||||||
|
ESP_LOGE("ESP_MODEM_THROW", "%s\n", msg.c_str());
|
||||||
|
}
|
||||||
public:
|
public:
|
||||||
explicit esp_err_exception(std::string msg) { print(std::move(msg)); }
|
explicit esp_err_exception(std::string msg)
|
||||||
explicit esp_err_exception(std::string msg, esp_err_t err) { print(std::move(msg)); }
|
{
|
||||||
|
print(std::move(msg));
|
||||||
|
}
|
||||||
|
explicit esp_err_exception(std::string msg, esp_err_t err)
|
||||||
|
{
|
||||||
|
print(std::move(msg));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -40,8 +32,7 @@ typedef struct esp_modem_PdpContext_t {
|
|||||||
/**
|
/**
|
||||||
* @brief DCE mode: This enum is used to set desired operation mode of the DCE
|
* @brief DCE mode: This enum is used to set desired operation mode of the DCE
|
||||||
*/
|
*/
|
||||||
typedef enum esp_modem_dce_mode
|
typedef enum esp_modem_dce_mode {
|
||||||
{
|
|
||||||
ESP_MODEM_MODE_COMMAND, /**< Default mode after modem startup, used for sending AT commands */
|
ESP_MODEM_MODE_COMMAND, /**< Default mode after modem startup, used for sending AT commands */
|
||||||
ESP_MODEM_MODE_DATA, /**< Used for switching to PPP mode for the modem to connect to a network */
|
ESP_MODEM_MODE_DATA, /**< Used for switching to PPP mode for the modem to connect to a network */
|
||||||
ESP_MODEM_MODE_CMUX, /**< Multiplexed terminal mode */
|
ESP_MODEM_MODE_CMUX, /**< Multiplexed terminal mode */
|
||||||
@ -50,8 +41,7 @@ typedef enum esp_modem_dce_mode
|
|||||||
/**
|
/**
|
||||||
* @brief DCE devices: Enum list of supported devices
|
* @brief DCE devices: Enum list of supported devices
|
||||||
*/
|
*/
|
||||||
typedef enum esp_modem_dce_device
|
typedef enum esp_modem_dce_device {
|
||||||
{
|
|
||||||
ESP_MODEM_DCE_GENETIC, /**< The most generic device */
|
ESP_MODEM_DCE_GENETIC, /**< The most generic device */
|
||||||
ESP_MODEM_DCE_SIM7600,
|
ESP_MODEM_DCE_SIM7600,
|
||||||
ESP_MODEM_DCE_SIM7070,
|
ESP_MODEM_DCE_SIM7070,
|
||||||
@ -63,8 +53,7 @@ typedef enum esp_modem_dce_device
|
|||||||
/**
|
/**
|
||||||
* @brief Terminal errors
|
* @brief Terminal errors
|
||||||
*/
|
*/
|
||||||
typedef enum esp_modem_terminal_error
|
typedef enum esp_modem_terminal_error {
|
||||||
{
|
|
||||||
ESP_MODEM_TERMINAL_BUFFER_OVERFLOW,
|
ESP_MODEM_TERMINAL_BUFFER_OVERFLOW,
|
||||||
ESP_MODEM_TERMINAL_CHECKSUM_ERROR,
|
ESP_MODEM_TERMINAL_CHECKSUM_ERROR,
|
||||||
ESP_MODEM_TERMINAL_UNEXPECTED_CONTROL_FLOW,
|
ESP_MODEM_TERMINAL_UNEXPECTED_CONTROL_FLOW,
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2022 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file c_api_wrapper.hpp
|
* @file c_api_wrapper.hpp
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -23,4 +23,3 @@ typedef enum {
|
|||||||
} mdns_used_event_t;
|
} mdns_used_event_t;
|
||||||
|
|
||||||
typedef void *esp_event_base_t;
|
typedef void *esp_event_base_t;
|
||||||
|
|
||||||
|
@ -20,4 +20,3 @@ idf_component_register(SRCS esp_netif_linux.cpp tun_io.c ip4_stub.c ip6_stub.c $
|
|||||||
INCLUDE_DIRS include ${LWIP_INCLUDE_DIRS}
|
INCLUDE_DIRS include ${LWIP_INCLUDE_DIRS}
|
||||||
PRIV_INCLUDE_DIRS .
|
PRIV_INCLUDE_DIRS .
|
||||||
REQUIRES esp_system_protocols_linux)
|
REQUIRES esp_system_protocols_linux)
|
||||||
|
|
||||||
|
@ -4,14 +4,20 @@ err_t
|
|||||||
ip4_output_if(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
ip4_output_if(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||||
u8_t ttl, u8_t tos,
|
u8_t ttl, u8_t tos,
|
||||||
u8_t proto, struct netif *netif)
|
u8_t proto, struct netif *netif)
|
||||||
{ return ERR_OK; }
|
{
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
struct netif *
|
struct netif *
|
||||||
ip4_route(const ip4_addr_t *dest)
|
ip4_route(const ip4_addr_t *dest)
|
||||||
{ return NULL; }
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
err_t
|
err_t
|
||||||
ip4_output_if_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
ip4_output_if_src(struct pbuf *p, const ip4_addr_t *src, const ip4_addr_t *dest,
|
||||||
u8_t ttl, u8_t tos,
|
u8_t ttl, u8_t tos,
|
||||||
u8_t proto, struct netif *netif)
|
u8_t proto, struct netif *netif)
|
||||||
{ return ERR_OK; }
|
{
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
@ -4,22 +4,32 @@ err_t
|
|||||||
ip6_output_if(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
|
ip6_output_if(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
|
||||||
u8_t hl, u8_t tc,
|
u8_t hl, u8_t tc,
|
||||||
u8_t nexth, struct netif *netif)
|
u8_t nexth, struct netif *netif)
|
||||||
{ return ERR_OK; }
|
{
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
struct netif *
|
struct netif *
|
||||||
ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
|
ip6_route(const ip6_addr_t *src, const ip6_addr_t *dest)
|
||||||
{ return NULL; }
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
err_t
|
err_t
|
||||||
ip6_output_if_src(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
|
ip6_output_if_src(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
|
||||||
u8_t hl, u8_t tc,
|
u8_t hl, u8_t tc,
|
||||||
u8_t nexth, struct netif *netif)
|
u8_t nexth, struct netif *netif)
|
||||||
{ return ERR_OK; }
|
{
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
const ip_addr_t *
|
const ip_addr_t *
|
||||||
ip6_select_source_address(struct netif *netif, const ip6_addr_t *dest)
|
ip6_select_source_address(struct netif *netif, const ip6_addr_t *dest)
|
||||||
{ return NULL; }
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
err_t
|
err_t
|
||||||
ip6_options_add_hbh_ra(struct pbuf *p, u8_t nexth, u8_t value)
|
ip6_options_add_hbh_ra(struct pbuf *p, u8_t nexth, u8_t value)
|
||||||
{ return ERR_OK; }
|
{
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
@ -24,8 +24,7 @@ static void ppp_link_status_cb(ppp_pcb *pcb, int err_code, void *ctx)
|
|||||||
LWIP_UNUSED_ARG(ctx);
|
LWIP_UNUSED_ARG(ctx);
|
||||||
|
|
||||||
switch (err_code) {
|
switch (err_code) {
|
||||||
case PPPERR_NONE: /* No error. */
|
case PPPERR_NONE: { /* No error. */
|
||||||
{
|
|
||||||
#if LWIP_DNS
|
#if LWIP_DNS
|
||||||
const ip_addr_t *ns;
|
const ip_addr_t *ns;
|
||||||
#endif /* LWIP_DNS */
|
#endif /* LWIP_DNS */
|
||||||
@ -108,8 +107,9 @@ static void ppp_link_status_cb(ppp_pcb *pcb, int err_code, void *ctx)
|
|||||||
static u32_t ppp_output_cb(struct ppp_pcb_s *pcb, const void *data, u32_t len, void *ctx)
|
static u32_t ppp_output_cb(struct ppp_pcb_s *pcb, const void *data, u32_t len, void *ctx)
|
||||||
{
|
{
|
||||||
esp_netif_t *netif = (esp_netif_t *)ctx;
|
esp_netif_t *netif = (esp_netif_t *)ctx;
|
||||||
if (netif->transmit)
|
if (netif->transmit) {
|
||||||
return netif->transmit(netif->ctx, (uint8_t *)data, len);
|
return netif->transmit(netif->ctx, (uint8_t *)data, len);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,4 +44,3 @@ printf(LOG_COLOR_I); printf("(%s) ", TAG); printf(__VA_ARGS__); printf(LOG_RESET
|
|||||||
printf(LOG_COLOR_D); printf("(%s) ", TAG); printf(__VA_ARGS__); printf(LOG_RESET_COLOR "\n"); } while(0)
|
printf(LOG_COLOR_D); printf("(%s) ", TAG); printf(__VA_ARGS__); printf(LOG_RESET_COLOR "\n"); } while(0)
|
||||||
#define ESP_LOGV(TAG, ...) do { \
|
#define ESP_LOGV(TAG, ...) do { \
|
||||||
printf(LOG_COLOR_V); printf("(%s) ", TAG); printf(__VA_ARGS__); printf(LOG_RESET_COLOR "\n"); } while(0)
|
printf(LOG_COLOR_V); printf("(%s) ", TAG); printf(__VA_ARGS__); printf(LOG_RESET_COLOR "\n"); } while(0)
|
||||||
|
|
||||||
|
@ -14,4 +14,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include_next "endian.h"
|
#include_next "endian.h"
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
@ -23,4 +15,3 @@ namespace esp_modem {
|
|||||||
std::unique_ptr<Terminal> create_uart_terminal(const esp_modem_dte_config *config);
|
std::unique_ptr<Terminal> create_uart_terminal(const esp_modem_dte_config *config);
|
||||||
|
|
||||||
} // namespace esp_modem
|
} // namespace esp_modem
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "cxx_include/esp_modem_dte.hpp"
|
#include "cxx_include/esp_modem_dte.hpp"
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -85,11 +77,13 @@ void CMux::send_disconnect(size_t i)
|
|||||||
{
|
{
|
||||||
if (i == 0) { // control terminal
|
if (i == 0) { // control terminal
|
||||||
uint8_t frame[] = {
|
uint8_t frame[] = {
|
||||||
SOF_MARKER, 0x3, 0xEF, 0x5, 0xC3, 0x1, 0xF2, SOF_MARKER };
|
SOF_MARKER, 0x3, 0xEF, 0x5, 0xC3, 0x1, 0xF2, SOF_MARKER
|
||||||
|
};
|
||||||
term->write(frame, 8);
|
term->write(frame, 8);
|
||||||
} else { // separate virtual terminal
|
} else { // separate virtual terminal
|
||||||
uint8_t frame[] = {
|
uint8_t frame[] = {
|
||||||
SOF_MARKER, 0x3, FT_DISC | PF, 0x1, 0, SOF_MARKER };
|
SOF_MARKER, 0x3, FT_DISC | PF, 0x1, 0, SOF_MARKER
|
||||||
|
};
|
||||||
frame[1] |= i << 2;
|
frame[1] |= i << 2;
|
||||||
frame[4] = 0xFF - fcs_crc(frame);
|
frame[4] = 0xFF - fcs_crc(frame);
|
||||||
term->write(frame, sizeof(frame));
|
term->write(frame, sizeof(frame));
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <charconv>
|
#include <charconv>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -44,8 +36,7 @@ bool DCE_Mode::set_unsafe(DTE *dte, ModuleIf *device, Netif &netif, modem_mode m
|
|||||||
switch (m) {
|
switch (m) {
|
||||||
case modem_mode::UNDEF:
|
case modem_mode::UNDEF:
|
||||||
break;
|
break;
|
||||||
case modem_mode::COMMAND_MODE:
|
case modem_mode::COMMAND_MODE: {
|
||||||
{
|
|
||||||
if (mode == modem_mode::COMMAND_MODE) {
|
if (mode == modem_mode::COMMAND_MODE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -62,14 +53,16 @@ bool DCE_Mode::set_unsafe(DTE *dte, ModuleIf *device, Netif &netif, modem_mode m
|
|||||||
auto signal = std::make_shared<SignalGroup>();
|
auto signal = std::make_shared<SignalGroup>();
|
||||||
std::weak_ptr<SignalGroup> weak_signal = signal;
|
std::weak_ptr<SignalGroup> weak_signal = signal;
|
||||||
dte->set_read_cb([weak_signal](uint8_t *data, size_t len) -> bool {
|
dte->set_read_cb([weak_signal](uint8_t *data, size_t len) -> bool {
|
||||||
if (memchr(data, '\n', len)) {
|
if (memchr(data, '\n', len))
|
||||||
|
{
|
||||||
ESP_LOG_BUFFER_HEXDUMP("esp-modem: debug_data", data, len, ESP_LOG_DEBUG);
|
ESP_LOG_BUFFER_HEXDUMP("esp-modem: debug_data", data, len, ESP_LOG_DEBUG);
|
||||||
const auto pass = std::list<std::string_view>({"NO CARRIER", "DISCONNECTED"});
|
const auto pass = std::list<std::string_view>({"NO CARRIER", "DISCONNECTED"});
|
||||||
std::string_view response((char *) data, len);
|
std::string_view response((char *) data, len);
|
||||||
for (auto &it : pass)
|
for (auto &it : pass)
|
||||||
if (response.find(it) != std::string::npos) {
|
if (response.find(it) != std::string::npos) {
|
||||||
if (auto signal = weak_signal.lock())
|
if (auto signal = weak_signal.lock()) {
|
||||||
signal->set(1);
|
signal->set(1);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "cxx_include/esp_modem_types.hpp"
|
#include "cxx_include/esp_modem_types.hpp"
|
||||||
|
@ -1,16 +1,8 @@
|
|||||||
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
|
/*
|
||||||
//
|
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
*
|
||||||
// you may not use this file except in compliance with the License.
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
// You may obtain a copy of the License at
|
*/
|
||||||
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
#include "cxx_include/esp_modem_api.hpp"
|
#include "cxx_include/esp_modem_api.hpp"
|
||||||
#include "cxx_include/esp_modem_dce_module.hpp"
|
#include "cxx_include/esp_modem_dce_module.hpp"
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user