mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-28 17:57:31 +02:00
Compare commits
10 Commits
mdns-v1.0.
...
modem-v0.1
Author | SHA1 | Date | |
---|---|---|---|
d07237b2ce | |||
3c65fde2a7 | |||
35833d2730 | |||
bbb4b7e686 | |||
64e31dae48 | |||
63ce3a5d59 | |||
5dd138c883 | |||
98bf3efeb6 | |||
ae8479c77e | |||
656ab21c9b |
19
.github/workflows/target-test.yml
vendored
19
.github/workflows/target-test.yml
vendored
@ -56,16 +56,23 @@ jobs:
|
||||
run: |
|
||||
. ${IDF_PATH}/export.sh
|
||||
cd $GITHUB_WORKSPACE/esp-protocols/components/mdns/examples/
|
||||
idf.py set-target ${{ matrix.idf_target }}
|
||||
idf.py set-target ${{ matrix.idf_target }}
|
||||
echo "Building for default configuration"
|
||||
idf.py build
|
||||
rm sdkconfig
|
||||
echo "Building for sdkconfig.ci.eth_def"
|
||||
cat sdkconfig.ci.eth_def >> sdkconfig.defaults
|
||||
idf.py build
|
||||
rm sdkconfig.defaults
|
||||
rm sdkconfig sdkconfig.defaults
|
||||
echo "Building for sdkconfig.ci.eth_custom_netif"
|
||||
cat sdkconfig.ci.eth_custom_netif >> sdkconfig.defaults
|
||||
idf.py build
|
||||
rm sdkconfig.defaults
|
||||
rm sdkconfig sdkconfig.defaults
|
||||
echo "Building for sdkconfig.ci.eth_socket"
|
||||
cat sdkconfig.ci.eth_socket >> sdkconfig.defaults
|
||||
idf.py build
|
||||
rm sdkconfig.defaults
|
||||
rm sdkconfig sdkconfig.defaults
|
||||
echo "Building for sdkconfig.ci.eth_no_ipv6"
|
||||
cat sdkconfig.ci.eth_no_ipv6 >> sdkconfig.defaults
|
||||
idf.py build
|
||||
cd $GITHUB_WORKSPACE/esp-protocols/components/mdns/tests/test_apps/
|
||||
@ -154,10 +161,8 @@ jobs:
|
||||
name: examples_app_bin_${{ matrix.idf_target }}_${{ matrix.idf_ver }}
|
||||
path: components/esp_websocket_client/examples/build/
|
||||
- name: Install Python packages
|
||||
env:
|
||||
PIP_EXTRA_INDEX_URL: "https://www.piwheels.org/simple"
|
||||
run: |
|
||||
pip install -r $GITHUB_WORKSPACE/components/esp_websocket_client/examples/requirements.txt
|
||||
pip install --only-binary cryptography --extra-index-url https://dl.espressif.com/pypi/ -r $GITHUB_WORKSPACE/components/esp_websocket_client/examples/requirements.txt
|
||||
- name: Download Example Test to target
|
||||
run: python -m esptool --chip ${{ matrix.idf_target }} write_flash 0x0 components/esp_websocket_client/examples/build/flash_image.bin
|
||||
- name: Run Example Test on target
|
||||
|
@ -396,7 +396,9 @@ static esp_netif_t *eth_start(void)
|
||||
#endif
|
||||
#elif CONFIG_EXAMPLE_USE_SPI_ETHERNET
|
||||
gpio_install_isr_service(0);
|
||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
spi_device_handle_t spi_handle = NULL;
|
||||
#endif
|
||||
spi_bus_config_t buscfg = {
|
||||
.miso_io_num = CONFIG_EXAMPLE_ETH_SPI_MISO_GPIO,
|
||||
.mosi_io_num = CONFIG_EXAMPLE_ETH_SPI_MOSI_GPIO,
|
||||
@ -414,9 +416,14 @@ static esp_netif_t *eth_start(void)
|
||||
.spics_io_num = CONFIG_EXAMPLE_ETH_SPI_CS_GPIO,
|
||||
.queue_size = 20
|
||||
};
|
||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
ESP_ERROR_CHECK(spi_bus_add_device(CONFIG_EXAMPLE_ETH_SPI_HOST, &devcfg, &spi_handle));
|
||||
/* dm9051 ethernet driver is based on spi driver */
|
||||
eth_dm9051_config_t dm9051_config = ETH_DM9051_DEFAULT_CONFIG(spi_handle);
|
||||
#else
|
||||
eth_dm9051_config_t dm9051_config = ETH_DM9051_DEFAULT_CONFIG(CONFIG_EXAMPLE_ETH_SPI_HOST, &devcfg);
|
||||
#endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
|
||||
dm9051_config.int_gpio_num = CONFIG_EXAMPLE_ETH_SPI_INT_GPIO;
|
||||
s_mac = esp_eth_mac_new_dm9051(&dm9051_config, &mac_config);
|
||||
s_phy = esp_eth_phy_new_dm9051(&phy_config);
|
||||
@ -429,9 +436,13 @@ static esp_netif_t *eth_start(void)
|
||||
.spics_io_num = CONFIG_EXAMPLE_ETH_SPI_CS_GPIO,
|
||||
.queue_size = 20
|
||||
};
|
||||
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
ESP_ERROR_CHECK(spi_bus_add_device(CONFIG_EXAMPLE_ETH_SPI_HOST, &devcfg, &spi_handle));
|
||||
/* w5500 ethernet driver is based on spi driver */
|
||||
eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(spi_handle);
|
||||
#else
|
||||
eth_w5500_config_t w5500_config = ETH_W5500_DEFAULT_CONFIG(CONFIG_EXAMPLE_ETH_SPI_HOST, &devcfg);
|
||||
#endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
w5500_config.int_gpio_num = CONFIG_EXAMPLE_ETH_SPI_INT_GPIO;
|
||||
s_mac = esp_eth_mac_new_w5500(&w5500_config, &mac_config);
|
||||
s_phy = esp_eth_phy_new_w5500(&phy_config);
|
||||
|
@ -47,5 +47,3 @@ if(${target} STREQUAL "linux")
|
||||
# This is needed for ESP_LOGx() macros, as integer formats differ on ESP32(..) and x64
|
||||
set_target_properties(${COMPONENT_LIB} PROPERTIES COMPILE_FLAGS -Wno-format)
|
||||
endif()
|
||||
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
|
@ -11,12 +11,13 @@
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_idf_version.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "lwip/lwip_napt.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/event_groups.h"
|
||||
#include "network_dce.h"
|
||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0)
|
||||
#include "esp_mac.h"
|
||||
#include "dhcpserver/dhcpserver.h"
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
version: "0.1.19"
|
||||
version: "0.1.21"
|
||||
description: esp modem
|
||||
url: https://github.com/espressif/esp-protocols/tree/master/components/esp_modem
|
||||
dependencies:
|
||||
|
@ -75,6 +75,12 @@ public:
|
||||
*/
|
||||
void set_read_cb(std::function<bool(uint8_t *data, size_t len)> f);
|
||||
|
||||
/**
|
||||
* @brief Sets DTE error callback
|
||||
* @param f Function to be called on DTE error
|
||||
*/
|
||||
void set_error_cb(std::function<void(terminal_error err)> f);
|
||||
|
||||
/**
|
||||
* @brief Sets the DTE to desired mode (Command/Data/Cmux)
|
||||
* @param m Desired operation mode
|
||||
|
@ -41,6 +41,7 @@ enum class terminal_error {
|
||||
BUFFER_OVERFLOW,
|
||||
CHECKSUM_ERROR,
|
||||
UNEXPECTED_CONTROL_FLOW,
|
||||
DEVICE_GONE,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -15,6 +15,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_idf_version.h"
|
||||
#include "driver/uart.h"
|
||||
|
||||
/**
|
||||
@ -23,7 +24,7 @@
|
||||
*/
|
||||
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
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 3, 0)
|
||||
const void *data = src;
|
||||
#else
|
||||
auto *data = reinterpret_cast<const char*>(src);
|
||||
|
@ -155,6 +155,12 @@ void DTE::set_read_cb(std::function<bool(uint8_t *, size_t)> f)
|
||||
});
|
||||
}
|
||||
|
||||
void DTE::set_error_cb(std::function<void(terminal_error err)> f)
|
||||
{
|
||||
data_term->set_error_cb(f);
|
||||
command_term->set_error_cb(f);
|
||||
}
|
||||
|
||||
int DTE::read(uint8_t **d, size_t len)
|
||||
{
|
||||
auto data_to_read = std::min(len, buffer.size);
|
||||
|
@ -14,8 +14,10 @@
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <inttypes.h>
|
||||
#include <esp_log.h>
|
||||
#include <esp_event.h>
|
||||
#include "esp_idf_version.h"
|
||||
#include "cxx_include/esp_modem_netif.hpp"
|
||||
#include "cxx_include/esp_modem_dte.hpp"
|
||||
#include "esp_netif_ppp.h"
|
||||
@ -28,7 +30,7 @@ void Netif::on_ppp_changed(void *arg, esp_event_base_t event_base,
|
||||
{
|
||||
auto *ppp = static_cast<Netif *>(arg);
|
||||
if (event_id < NETIF_PP_PHASE_OFFSET) {
|
||||
ESP_LOGI("esp_modem_netif", "PPP state changed event %d", event_id);
|
||||
ESP_LOGI("esp_modem_netif", "PPP state changed event %" PRId32, event_id);
|
||||
// only notify the modem on state/error events, ignoring phase transitions
|
||||
ppp->signal.set(PPP_EXIT);
|
||||
}
|
||||
@ -58,7 +60,7 @@ esp_err_t Netif::esp_modem_post_attach(esp_netif_t *esp_netif, void *args)
|
||||
esp_netif_ppp_config_t ppp_config = { .ppp_phase_event_enabled = true, // assuming phase enabled, as earlier IDFs
|
||||
.ppp_error_event_enabled = false
|
||||
}; // don't provide cfg getters so we enable both events
|
||||
#if ESP_IDF_VERSION_MAJOR >= 4 && ESP_IDF_VERSION_MINOR >= 4
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0)
|
||||
esp_netif_ppp_get_params(esp_netif, &ppp_config);
|
||||
#endif // ESP-IDF >= v4.4
|
||||
if (!ppp_config.ppp_error_event_enabled) {
|
||||
|
@ -232,7 +232,7 @@ static char * _mdns_mangle_name(char* in) {
|
||||
static bool _mdns_service_match(const mdns_service_t * srv, const char * service, const char * proto,
|
||||
const char * hostname)
|
||||
{
|
||||
if (!service || !proto) {
|
||||
if (!service || !proto || !srv->hostname) {
|
||||
return false;
|
||||
}
|
||||
return !strcasecmp(srv->service, service) && !strcasecmp(srv->proto, proto) &&
|
||||
@ -4558,7 +4558,8 @@ static void _mdns_remap_self_service_hostname(const char * old_hostname, const c
|
||||
mdns_srv_item_t * service = _mdns_server->services;
|
||||
|
||||
while (service) {
|
||||
if (strcmp(service->service->hostname, old_hostname) == 0) {
|
||||
if (service->service->hostname &&
|
||||
strcmp(service->service->hostname, old_hostname) == 0) {
|
||||
free((char *)service->service->hostname);
|
||||
service->service->hostname = strdup(new_hostname);
|
||||
}
|
||||
@ -5430,7 +5431,7 @@ esp_err_t mdns_instance_name_set(const char * instance)
|
||||
esp_err_t mdns_service_add_for_host(const char * instance, const char * service, const char * proto, const char * hostname,
|
||||
uint16_t port, mdns_txt_item_t txt[], size_t num_items)
|
||||
{
|
||||
if (!_mdns_server || _str_null_or_empty(service) || _str_null_or_empty(proto) || !port) {
|
||||
if (!_mdns_server || _str_null_or_empty(service) || _str_null_or_empty(proto) || !port || !hostname) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user