Make the component compatible with IDFv4.1, v4.2, v4.3

This commit is contained in:
David Cermak
2021-05-21 16:05:37 +02:00
parent a67d74999e
commit 69ad3ea589
12 changed files with 72 additions and 8 deletions

View File

@ -15,3 +15,7 @@ By default, this example simply connects to the PPP server using a supported dev
This example however, doesn't rely on sending specific AT commands, just the bare minimum to setup the cellular network.
Thus, if the `EXAMPLE_USE_MINIMAL_DCE` option is enabled, we directly inherit from the `ModuleIf` and implement only the basic commands.
Also, to demonstrate the dce_factory functionality, a new `NetDCE_Factory` is implemented for creating the network module and the DCE.
### Supported IDF versions
This example is only supported from `v4.2`, since is uses NAPT feature.

View File

@ -17,3 +17,7 @@ over PPPoS, i.e. over the modem serial line.
* Experiment with the network, after getting the IP from the modem device
- directly in the code
- in the system (need to set `tun` interface IP, dns servers, and routing the desired traffic over the tun interface)
### Supported IDF versions
This example (using the default CMake IDF build system) is only supported from `v4.4`, since is uses `idf.py`'s linux target.

View File

@ -15,3 +15,7 @@ To demonstrate creating custom modem devices, this example creates a DCE object
that sets up the DCE based on a custom module implemented in the `my_module_dce.hpp` file. The module class only overrides
`get_module_name()` method supplying a user defined name, but keeps all other commands the same as defined in the `GenericModule`
class.
### Supported IDF versions
This example is only supported from `v4.2`, due to support of the console repl mode.

View File

@ -8,3 +8,7 @@ This example shows how to act as a MQTT client after the PPPoS channel created b
## How to use this example
See the README.md file in the upper level `pppos` directory for more information about the PPPoS examples.
### Supported IDF versions
This example is only supported from `v4.1`, as this is the default dependency of `esp-modem` component.

View File

@ -15,3 +15,7 @@ The example uses the following configuration options to demonstrate basic esp-mo
## About the esp_modem
Please check the component [README](../../README.md)
### Supported IDF versions
This example is only supported from `v4.3`, since is uses an experimental `esp_event_cxx` component.

View File

@ -14,6 +14,8 @@
#ifndef _ESP_MODEM_PRIMITIVES_HPP_
#define _ESP_MODEM_PRIMITIVES_HPP_
#include "esp_event.h"
#include "esp_modem_exception.hpp"
#if defined(CONFIG_IDF_TARGET_LINUX)
@ -34,7 +36,7 @@ namespace esp_modem {
using TaskFunction_t = void (*)(void*);
#if !defined(CONFIG_IDF_TARGET_LINUX)
struct Lock {
using MutexT = QueueDefinition*;
using MutexT = QueueHandle_t;
explicit Lock();
~Lock();
void lock();

View File

@ -38,4 +38,6 @@ esp_err_t esp_event_handler_register(const char * event_base, int32_t event_id,
esp_err_t esp_event_handler_unregister(const char * event_base, int32_t event_id, void* event_handler);
typedef void * QueueHandle_t;
#endif //MDNS_HOST_ESP_EVENT_H

View File

@ -0,0 +1,35 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// 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 "esp_log.h"
#include "driver/uart.h"
#ifndef _UART_COMPAT_H_
#define _UART_COMPAT_H_
/**
* @brief This is a compatible header, which just takes care of different data ptr type
* across different IDF version in driver/uart
*/
static inline int uart_write_bytes_compat(uart_port_t uart_num, const void* src, size_t size)
{
#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 3
const void *data = src;
#else
auto *data = reinterpret_cast<const char*>(src);
#endif
return uart_write_bytes(uart_num, data, size);
}
#endif //_UART_COMPAT_H_

View File

@ -26,8 +26,10 @@ namespace esp_modem {
* @brief Uart Resource is a platform specific struct which is implemented separately for ESP_PLATFORM and linux target
*/
struct uart_resource {
explicit uart_resource(const esp_modem_dte_config *config, struct QueueDefinition** event_queue, int fd);
explicit uart_resource(const esp_modem_dte_config *config, QueueHandle_t* event_queue, int fd);
~uart_resource();
uart_port_t port{};
};

View File

@ -25,7 +25,7 @@ uart_resource::~uart_resource()
}
}
uart_resource::uart_resource(const esp_modem_dte_config *config, struct QueueDefinition** event_queue, int fd)
uart_resource::uart_resource(const esp_modem_dte_config *config, QueueHandle_t* event_queue, int fd)
:port(-1)
{
esp_err_t res;

View File

@ -17,6 +17,7 @@
#include "freertos/semphr.h"
#include "esp_log.h"
#include "driver/uart.h"
#include "uart_compat.h"
#include "esp_modem_config.h"
#include "exception_stub.hpp"
#include "cxx_include/esp_modem_dte.hpp"
@ -163,7 +164,8 @@ void UartTerminal::task() {
}
}
int UartTerminal::read(uint8_t *data, size_t len) {
int UartTerminal::read(uint8_t *data, size_t len)
{
size_t length = 0;
uart_get_buffered_data_len(uart.port, &length);
length = std::min(len, length);
@ -173,8 +175,9 @@ int UartTerminal::read(uint8_t *data, size_t len) {
return 0;
}
int UartTerminal::write(uint8_t *data, size_t len) {
return uart_write_bytes(uart.port, data, len);
int UartTerminal::write(uint8_t *data, size_t len)
{
return uart_write_bytes_compat(uart.port, data, len);
}
} // namespace esp_modem

View File

@ -23,7 +23,7 @@ namespace esp_modem {
constexpr const char *TAG = "uart_resource";
uart_resource::uart_resource(const esp_modem_dte_config *config, struct QueueDefinition** event_queue, int fd): port(-1)
uart_resource::uart_resource(const esp_modem_dte_config *config, QueueHandle_t* event_queue, int fd): port(-1)
{
ESP_LOGD(TAG, "Creating uart resource" );
struct termios tty = {};