esp_modem component updated
This commit is contained in:
parent
6cdede8e4b
commit
d21fed7fb2
|
|
@ -1,15 +1,15 @@
|
||||||
dependencies:
|
dependencies:
|
||||||
espressif/esp_modem:
|
espressif/esp_modem:
|
||||||
component_hash: a061d9aa884f571a992dddfe5ed2a5829f6b82194aa122de7f8c5dc3dbdad91a
|
component_hash: b11de8ecab6860719ab236cf353967c4f31d7f8e5e82dc6c224efeabbde00fcd
|
||||||
source:
|
source:
|
||||||
service_url: https://api.components.espressif.com/
|
service_url: https://api.components.espressif.com/
|
||||||
type: service
|
type: service
|
||||||
version: 0.1.18
|
version: 0.1.19
|
||||||
idf:
|
idf:
|
||||||
component_hash: null
|
component_hash: null
|
||||||
source:
|
source:
|
||||||
type: idf
|
type: idf
|
||||||
version: 4.4.2
|
version: 4.4.2
|
||||||
manifest_hash: 09fafd7cd74bc92f8e56b7f30ef1bc43b3a2700448a92ab1ac8b70e8f64c3ff6
|
manifest_hash: 76b850d9d6bd5811db1d008a4489ce72a36df494492de24194b352a7b1f08647
|
||||||
target: esp32
|
target: esp32
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
## IDF Component Manager Manifest File
|
## IDF Component Manager Manifest File
|
||||||
dependencies:
|
dependencies:
|
||||||
espressif/esp_modem: "==0.1.18"
|
espressif/esp_modem: "==0.1.19"
|
||||||
## Required IDF version
|
## Required IDF version
|
||||||
idf:
|
idf:
|
||||||
version: ">=4.1.0"
|
version: ">=4.1.0"
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
a061d9aa884f571a992dddfe5ed2a5829f6b82194aa122de7f8c5dc3dbdad91a
|
b11de8ecab6860719ab236cf353967c4f31d7f8e5e82dc6c224efeabbde00fcd
|
||||||
|
|
@ -11,9 +11,10 @@ else()
|
||||||
src/esp_modem_uart.cpp
|
src/esp_modem_uart.cpp
|
||||||
src/esp_modem_term_uart.cpp
|
src/esp_modem_term_uart.cpp
|
||||||
src/esp_modem_netif.cpp)
|
src/esp_modem_netif.cpp)
|
||||||
set(dependencies driver)
|
set(dependencies driver esp_event esp_netif)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
set(srcs ${platform_srcs}
|
set(srcs ${platform_srcs}
|
||||||
"src/esp_modem_dte.cpp"
|
"src/esp_modem_dte.cpp"
|
||||||
"src/esp_modem_dce.cpp"
|
"src/esp_modem_dce.cpp"
|
||||||
|
|
@ -34,12 +35,14 @@ idf_component_register(SRCS "${srcs}"
|
||||||
PRIV_INCLUDE_DIRS private_include
|
PRIV_INCLUDE_DIRS private_include
|
||||||
REQUIRES ${dependencies})
|
REQUIRES ${dependencies})
|
||||||
|
|
||||||
|
|
||||||
set_target_properties(${COMPONENT_LIB} PROPERTIES
|
set_target_properties(${COMPONENT_LIB} PROPERTIES
|
||||||
CXX_STANDARD 17
|
CXX_STANDARD 17
|
||||||
CXX_STANDARD_REQUIRED ON
|
CXX_STANDARD_REQUIRED ON
|
||||||
CXX_EXTENSIONS ON
|
CXX_EXTENSIONS ON
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if(${target} STREQUAL "linux")
|
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)
|
||||||
|
|
|
||||||
|
|
@ -3,4 +3,4 @@ dependencies:
|
||||||
version: '>=4.1'
|
version: '>=4.1'
|
||||||
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
|
||||||
version: 0.1.18
|
version: 0.1.19
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,15 @@ public:
|
||||||
pdp = std::move(new_pdp);
|
pdp = std::move(new_pdp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Simplified version of operator name (without the ACT, which is included in the command library)
|
||||||
|
*/
|
||||||
|
command_result get_operator_name(std::string& name)
|
||||||
|
{
|
||||||
|
int dummy_act;
|
||||||
|
return get_operator_name(name, dummy_act);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Common DCE commands generated from the API AT list
|
* @brief Common DCE commands generated from the API AT list
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "esp_modem_config.h"
|
#include "esp_modem_config.h"
|
||||||
|
#include "esp_netif.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
@ -22,7 +23,11 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct esp_modem_dce_wrap esp_modem_dce_t;
|
typedef struct esp_modem_dce_wrap esp_modem_dce_t;
|
||||||
|
|
||||||
struct PdpContext;
|
typedef struct esp_modem_PdpContext_t {
|
||||||
|
size_t context_id;
|
||||||
|
const char *protocol_type;
|
||||||
|
const char *apn;
|
||||||
|
} esp_modem_PdpContext_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup ESP_MODEM_C_API ESP_MODEM C API
|
* @defgroup ESP_MODEM_C_API ESP_MODEM C API
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
#define BOOL_OUT(param, name) bool* _ARG(param, name)
|
#define BOOL_OUT(param, name) bool* _ARG(param, name)
|
||||||
#define INT_OUT(param, name) int* _ARG(param, name)
|
#define INT_OUT(param, name) int* _ARG(param, name)
|
||||||
#define INTEGER_LIST_IN(param, name) const int* _ARG(param, name)
|
#define INTEGER_LIST_IN(param, name) const int* _ARG(param, name)
|
||||||
#define STRUCT_OUT(struct_name, p1) struct struct_name* p1
|
#define STRUCT_OUT(struct_name, p1) esp_modem_ ## struct_name ## _t* p1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DECLARE_ALL_COMMAND_APIS(...) \
|
#define DECLARE_ALL_COMMAND_APIS(...) \
|
||||||
|
|
@ -50,9 +50,10 @@ ESP_MODEM_DECLARE_DCE_COMMAND(sync, command_result, 0) \
|
||||||
/**
|
/**
|
||||||
* @brief Reads the operator name
|
* @brief Reads the operator name
|
||||||
* @param[out] operator name
|
* @param[out] operator name
|
||||||
|
* @param[out] access technology
|
||||||
* @return OK, FAIL or TIMEOUT
|
* @return OK, FAIL or TIMEOUT
|
||||||
*/ \
|
*/ \
|
||||||
ESP_MODEM_DECLARE_DCE_COMMAND(get_operator_name, command_result, 1, STRING_OUT(p1, name)) \
|
ESP_MODEM_DECLARE_DCE_COMMAND(get_operator_name, command_result, 2, STRING_OUT(p1, name), INT_OUT(p2, act)) \
|
||||||
\
|
\
|
||||||
/**
|
/**
|
||||||
* @brief Stores current user profile
|
* @brief Stores current user profile
|
||||||
|
|
@ -97,7 +98,7 @@ ESP_MODEM_DECLARE_DCE_COMMAND(set_echo, command_result, 1, BOOL_IN(p1, echo_on))
|
||||||
ESP_MODEM_DECLARE_DCE_COMMAND(sms_txt_mode, command_result, 1, BOOL_IN(p1, txt)) \
|
ESP_MODEM_DECLARE_DCE_COMMAND(sms_txt_mode, command_result, 1, BOOL_IN(p1, txt)) \
|
||||||
\
|
\
|
||||||
/**
|
/**
|
||||||
* @brief Sets the default (GSM) charater set
|
* @brief Sets the default (GSM) character set
|
||||||
* @return OK, FAIL or TIMEOUT
|
* @return OK, FAIL or TIMEOUT
|
||||||
*/ \
|
*/ \
|
||||||
ESP_MODEM_DECLARE_DCE_COMMAND(sms_character_set, command_result, 0) \
|
ESP_MODEM_DECLARE_DCE_COMMAND(sms_character_set, command_result, 0) \
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
idf_component_register(INCLUDE_DIRS include
|
idf_component_register(SRCS "esp_err_to_name.c"
|
||||||
|
INCLUDE_DIRS include
|
||||||
REQUIRES esp_netif_linux esp_event_mock)
|
REQUIRES esp_netif_linux esp_event_mock)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: Franz Hoepfinger
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static const char esp_unknown_msg[] = "ERROR";
|
||||||
|
|
||||||
|
const char *esp_err_to_name(int code)
|
||||||
|
{
|
||||||
|
return esp_unknown_msg;
|
||||||
|
}
|
||||||
|
|
@ -25,3 +25,11 @@ typedef int esp_err_t;
|
||||||
#define ESP_ERR_NOT_FOUND 0x105
|
#define ESP_ERR_NOT_FOUND 0x105
|
||||||
#define ESP_ERR_NOT_SUPPORTED 0x106
|
#define ESP_ERR_NOT_SUPPORTED 0x106
|
||||||
#define ESP_ERR_TIMEOUT 0x107
|
#define ESP_ERR_TIMEOUT 0x107
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
const char *esp_err_to_name(int code);
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
action; \
|
action; \
|
||||||
} catch (::esp_modem::esp_err_exception& e) { \
|
} catch (::esp_modem::esp_err_exception& e) { \
|
||||||
esp_err_t err = e.get_err_t(); \
|
esp_err_t err = e.get_err_t(); \
|
||||||
ESP_LOGE(TAG, "%s: Exception caught with ESP err_code=%d", __func__, err); \
|
ESP_LOGE(TAG, "%s: Exception caught with ESP err_code=%d %s", __func__, err, esp_err_to_name(err)); \
|
||||||
ESP_LOGE(TAG, "%s", e.what()); \
|
ESP_LOGE(TAG, "%s", e.what()); \
|
||||||
action; \
|
action; \
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -393,3 +393,14 @@ extern "C" esp_err_t esp_modem_reset(esp_modem_dce_t *dce_wrap)
|
||||||
{
|
{
|
||||||
return command_response_to_esp_err(dce_wrap->dce->reset());
|
return command_response_to_esp_err(dce_wrap->dce->reset());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" esp_err_t esp_modem_set_pdp_context(esp_modem_dce_t *dce_wrap, esp_modem_PdpContext_t *c_api_pdp)
|
||||||
|
{
|
||||||
|
if (dce_wrap == nullptr || dce_wrap->dce == nullptr) {
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
esp_modem::PdpContext pdp{c_api_pdp->apn};
|
||||||
|
pdp.context_id = c_api_pdp->context_id;
|
||||||
|
pdp.protocol_type = c_api_pdp->protocol_type;
|
||||||
|
return command_response_to_esp_err(dce_wrap->dce->set_pdp_context(pdp));
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,7 @@ command_result set_flow_control(CommandableIf *t, int dce_flow, int dte_flow)
|
||||||
return generic_command_common(t, "AT+IFC=" + std::to_string(dce_flow) + ", " + std::to_string(dte_flow) + "\r");
|
return generic_command_common(t, "AT+IFC=" + std::to_string(dce_flow) + ", " + std::to_string(dte_flow) + "\r");
|
||||||
}
|
}
|
||||||
|
|
||||||
command_result get_operator_name(CommandableIf *t, std::string &operator_name)
|
command_result get_operator_name(CommandableIf *t, std::string &operator_name, int &act)
|
||||||
{
|
{
|
||||||
ESP_LOGV(TAG, "%s", __func__ );
|
ESP_LOGV(TAG, "%s", __func__ );
|
||||||
std::string_view out;
|
std::string_view out;
|
||||||
|
|
@ -239,9 +239,19 @@ command_result get_operator_name(CommandableIf *t, std::string &operator_name)
|
||||||
auto pos = out.find("+COPS");
|
auto pos = out.find("+COPS");
|
||||||
auto property = 0;
|
auto property = 0;
|
||||||
while (pos != std::string::npos) {
|
while (pos != std::string::npos) {
|
||||||
// Looking for: +COPS: <mode>[, <format>[, <oper>]]
|
// Looking for: +COPS: <mode>[, <format>[, <oper>[, <act>]]]
|
||||||
if (property++ == 2) { // operator name is after second comma (as a 3rd property of COPS string)
|
if (property++ == 2) { // operator name is after second comma (as a 3rd property of COPS string)
|
||||||
operator_name = out.substr(++pos);
|
operator_name = out.substr(++pos);
|
||||||
|
auto additional_comma = operator_name.find(','); // check for the optional ACT
|
||||||
|
if (additional_comma != std::string::npos && std::from_chars(operator_name.data() + additional_comma + 1,operator_name.data() + operator_name.length(), act).ec != std::errc::invalid_argument) {
|
||||||
|
operator_name = operator_name.substr(0, additional_comma);
|
||||||
|
}
|
||||||
|
// and strip quotes if present
|
||||||
|
auto quote1 = operator_name.find('"');
|
||||||
|
auto quote2 = operator_name.rfind('"');
|
||||||
|
if (quote1 != std::string::npos && quote2 != std::string::npos) {
|
||||||
|
operator_name = operator_name.substr(quote1+1, quote2-1);
|
||||||
|
}
|
||||||
return command_result::OK;
|
return command_result::OK;
|
||||||
}
|
}
|
||||||
pos = out.find(',', ++pos);
|
pos = out.find(',', ++pos);
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,8 @@ int LoopbackTerm::write(uint8_t *data, size_t len)
|
||||||
response = "+CSQ: 123,456\n\r\nOK\r\n";
|
response = "+CSQ: 123,456\n\r\nOK\r\n";
|
||||||
} else if (command.find("AT+CGMM\r") != std::string::npos) {
|
} else if (command.find("AT+CGMM\r") != std::string::npos) {
|
||||||
response = "0G Dummy Model\n\r\nOK\r\n";
|
response = "0G Dummy Model\n\r\nOK\r\n";
|
||||||
|
} else if (command.find("AT+COPS?\r") != std::string::npos) {
|
||||||
|
response = "+COPS: 0,0,\"OperatorName\",5\n\r\nOK\r\n";
|
||||||
} else if (command.find("AT+CBC\r") != std::string::npos) {
|
} else if (command.find("AT+CBC\r") != std::string::npos) {
|
||||||
response = is_bg96 ? "+CBC: 1,20,123456\r\r\n\r\nOK\r\n\n\r\n" :
|
response = is_bg96 ? "+CBC: 1,20,123456\r\r\n\r\nOK\r\n\n\r\n" :
|
||||||
"+CBC: 123.456V\r\r\n\r\nOK\r\n\n\r\n";
|
"+CBC: 123.456V\r\r\n\r\nOK\r\n\n\r\n";
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,14 @@ TEST_CASE("DCE AT parser", "[esp_modem]")
|
||||||
std::string model;
|
std::string model;
|
||||||
CHECK(dce->get_module_name(model) == command_result::OK);
|
CHECK(dce->get_module_name(model) == command_result::OK);
|
||||||
CHECK(model == "0G Dummy Model");
|
CHECK(model == "0G Dummy Model");
|
||||||
|
|
||||||
|
std::string operator_name;
|
||||||
|
int act = 99;
|
||||||
|
CHECK(dce->get_operator_name(operator_name) == command_result::OK);
|
||||||
|
CHECK(operator_name == "OperatorName");
|
||||||
|
CHECK(dce->get_operator_name(operator_name, act) == command_result::OK);
|
||||||
|
CHECK(operator_name == "OperatorName");
|
||||||
|
CHECK(act == 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user