Merge pull request #72 from david-cermak/bugfix/modem_c_api_pdp_ctx

fix(esp-modem): Add missing set_pdp_context() to C-API
This commit is contained in:
david-cermak
2022-07-12 20:03:03 +02:00
committed by GitHub
3 changed files with 18 additions and 2 deletions

View File

@ -15,6 +15,7 @@
#pragma once
#include "esp_modem_config.h"
#include "esp_netif.h"
#ifdef __cplusplus
extern "C" {
@ -22,7 +23,11 @@ extern "C" {
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

View File

@ -38,7 +38,7 @@
#define BOOL_OUT(param, name) bool* _ARG(param, name)
#define INT_OUT(param, name) 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
#define DECLARE_ALL_COMMAND_APIS(...) \

View File

@ -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());
}
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));
}