mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-16 12:02:11 +02:00
Merge pull request #131 from tore-espressif/feature/esp_modem/err_cb
esp_modem: Expose set_error_cb method
This commit is contained in:
@ -47,5 +47,3 @@ if(${target} STREQUAL "linux")
|
|||||||
# This is needed for ESP_LOGx() macros, as integer formats differ on ESP32(..) and x64
|
# 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)
|
set_target_properties(${COMPONENT_LIB} PROPERTIES COMPILE_FLAGS -Wno-format)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
version: "0.1.19"
|
version: "0.1.20"
|
||||||
description: esp modem
|
description: esp modem
|
||||||
url: https://github.com/espressif/esp-protocols/tree/master/components/esp_modem
|
url: https://github.com/espressif/esp-protocols/tree/master/components/esp_modem
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -75,6 +75,12 @@ public:
|
|||||||
*/
|
*/
|
||||||
void set_read_cb(std::function<bool(uint8_t *data, size_t len)> f);
|
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)
|
* @brief Sets the DTE to desired mode (Command/Data/Cmux)
|
||||||
* @param m Desired operation mode
|
* @param m Desired operation mode
|
||||||
|
@ -41,6 +41,7 @@ enum class terminal_error {
|
|||||||
BUFFER_OVERFLOW,
|
BUFFER_OVERFLOW,
|
||||||
CHECKSUM_ERROR,
|
CHECKSUM_ERROR,
|
||||||
UNEXPECTED_CONTROL_FLOW,
|
UNEXPECTED_CONTROL_FLOW,
|
||||||
|
DEVICE_GONE,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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)
|
int DTE::read(uint8_t **d, size_t len)
|
||||||
{
|
{
|
||||||
auto data_to_read = std::min(len, buffer.size);
|
auto data_to_read = std::min(len, buffer.size);
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
#include <esp_event.h>
|
#include <esp_event.h>
|
||||||
#include "cxx_include/esp_modem_netif.hpp"
|
#include "cxx_include/esp_modem_netif.hpp"
|
||||||
@ -28,7 +29,7 @@ void Netif::on_ppp_changed(void *arg, esp_event_base_t event_base,
|
|||||||
{
|
{
|
||||||
auto *ppp = static_cast<Netif *>(arg);
|
auto *ppp = static_cast<Netif *>(arg);
|
||||||
if (event_id < NETIF_PP_PHASE_OFFSET) {
|
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
|
// only notify the modem on state/error events, ignoring phase transitions
|
||||||
ppp->signal.set(PPP_EXIT);
|
ppp->signal.set(PPP_EXIT);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user