New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PdpContext is not declared (IDFGH-9350) #220
Comments
@rpirsc13 Could you please share more details on how to reproduce the problem? My guess is that you've just renamed the example's source By that renaming you have chosen C++ and you're trying to include the plain C API. This is unfortunately not possible. #include "cxx_include/esp_modem_api.hpp" |
@david-cermak Your guess is correct. I have used my test implementation from pppos_example.c. I was not aware that there are separate headers for cpp. Thank you for pointing that out. Everything works as expected now. |
Im also having this issue. I have included them. ../managed_components/espressif__esp_modem/include/generate/esp_modem_command_declare.inc:102:78: error: 'PdpContext' has not been declared
ESP_MODEM_DECLARE_DCE_COMMAND(set_pdp_context, command_result, 1, STRUCT_OUT(PdpContext, p1)) \
^~~~~~~~~~
../managed_components/espressif__esp_modem/include/generate/esp_modem_command_declare_helper.inc:17:38: note: in definition of macro 'STRUCT_OUT'
#define STRUCT_OUT(struct_name, p1) struct_name& p1
^~~~~~~~~~~
../managed_components/espressif__esp_modem/include/generate/esp_modem_command_declare.inc:102:1: note: in expansion of macro 'ESP_MODEM_DECLARE_DCE_COMMAND'
ESP_MODEM_DECLARE_DCE_COMMAND(set_pdp_context, command_result, 1, STRUCT_OUT(PdpContext, p1)) \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../managed_components/espressif__esp_modem/include/esp_modem_api.h:21:1: note: in expansion of macro 'DECLARE_ALL_COMMAND_APIS'
DECLARE_ALL_COMMAND_APIS(declares esp_modem_<API>(esp_modem_t *dce, ...);)
^~~~~~~~~~~~~~~~~~~~~~~~
#include "esp_modem_api.h"
static void setupPPP() {
//define the err
esp_err_t err;
/* Init and register system/core components */
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, &on_ip_event, NULL));
ESP_ERROR_CHECK(esp_event_handler_register(NETIF_PPP_STATUS, ESP_EVENT_ANY_ID, &on_ppp_changed, NULL));
/* Configure the PPP netif */
// create_generic_dce
esp_modem_dce_config dce_config = ESP_MODEM_DCE_DEFAULT_CONFIG(CONFIG_EXAMPLE_MODEM_PPP_APN);
esp_netif_config_t netif_ppp_config = ESP_NETIF_DEFAULT_PPP();
esp_netif_t *esp_netif = esp_netif_new(&netif_ppp_config);
assert(esp_netif);
//event_group = xEventGroupCreate();
//configure the dte
// create_uart_dte
esp_modem_dte_config_t dte_config = ESP_MODEM_DTE_DEFAULT_CONFIG();
/*
esp_modem_dte_config dte_config = {
.dte_buffer_size = 512, // Custom value
.task_stack_size = 4096, // Custom value
.task_priority = 5, // Custom value
.uart_config = {
.port_num = UART_NUM_1,
.data_bits = UART_DATA_8_BITS,
.stop_bits = UART_STOP_BITS_1,
.parity = UART_PARITY_DISABLE,
.flow_control = 0,
.source_clk = 0,
.baud_rate = 115200, // Custom value
.tx_io_num = TX_PIN, // Custom value
.rx_io_num = RX_PIN, // Custom value
.rts_io_num = 27, // Custom value
.cts_io_num = 23, // Custom value
.rx_buffer_size = 4096, // Custom value
.tx_buffer_size = 512, // Custom value
.event_queue_size = 30 // Custom value
}
};
*/
//setup UART specific configuration based on kconfig options
dte_config.uart_config.tx_io_num = TX_PIN;
dte_config.uart_config.rx_io_num = RX_PIN;
/*
dte_config.uart_config.rts_io_num = CONFIG_EXAMPLE_MODEM_UART_RTS_PIN;
dte_config.uart_config.cts_io_num = CONFIG_EXAMPLE_MODEM_UART_CTS_PIN;
dte_config.uart_config.flow_control = EXAMPLE_FLOW_CONTROL;
dte_config.uart_config.rx_buffer_size = CONFIG_EXAMPLE_MODEM_UART_RX_BUFFER_SIZE;
dte_config.uart_config.tx_buffer_size = CONFIG_EXAMPLE_MODEM_UART_TX_BUFFER_SIZE;
dte_config.uart_config.event_queue_size = CONFIG_EXAMPLE_MODEM_UART_EVENT_QUEUE_SIZE;
dte_config.task_stack_size = CONFIG_EXAMPLE_MODEM_UART_EVENT_TASK_STACK_SIZE;
dte_config.task_priority = CONFIG_EXAMPLE_MODEM_UART_EVENT_TASK_PRIORITY;
dte_config.dte_buffer_size = CONFIG_EXAMPLE_MODEM_UART_RX_BUFFER_SIZE / 2;
*/
ESP_LOGI(TAG, "Initializing esp_modem for a generic module...");
esp_modem_dce_t *dce = esp_modem_new(&dte_config, &dce_config, esp_netif);
int rssi, ber;
err = esp_modem_get_signal_quality(dce, rssi, ber);
if (err != ESP_OK) {
ESP_LOGE(TAG, "esp_modem_get_signal_quality failed with %d %s", err, esp_err_to_name(err));
return;
}
ESP_LOGI(TAG, "Signal quality: rssi=%d, ber=%d", rssi, ber);
err = esp_modem_set_mode(dce, ESP_MODEM_MODE_DATA);
if (err != ESP_OK) {
ESP_LOGE(TAG, "esp_modem_set_mode(ESP_MODEM_MODE_DATA) failed with %d", err);
return;
}
/* Wait for IP address */
ESP_LOGI(TAG, "Waiting for IP address");
xEventGroupWaitBits(event_group, CONNECT_BIT, pdFALSE, pdFALSE, portMAX_DELAY);
std::string imsi; // Declare imsi as a non-const string
err = esp_modem_get_imsi(dce, imsi); // Pass imsi to the function, assuming it expects a non-const reference
if (err != ESP_OK) {
ESP_LOGE(TAG, "esp_modem_get_imsi failed with %d", err);
return;
}
ESP_LOGI(TAG, "IMSI=%s", imsi.c_str());
// UART DTE clean-up
esp_modem_destroy(dce);
esp_netif_destroy(esp_netif);
}
|
@michaelboeding Have you tried the suggestion from #220 (comment) ? Are you compiling the snippet you shared above in C++? This library does not support using C-API from C++. |
Hi,I am having the following issue that I am unable to compile the example pppos_client
ESP-IDF: v5.0
esp_modem : v0.1.26
The text was updated successfully, but these errors were encountered: