Added C API example

This commit is contained in:
David Cermak
2021-10-04 11:32:54 +02:00
parent 246572d286
commit 031e41ddf2
10 changed files with 146 additions and 297 deletions
+1 -14
View File
@@ -16,25 +16,12 @@
#define _ESP_MODEM_API_H_
#include "generate/esp_modem_command_declare.inc"
#include "esp_modem_c_api_types.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct esp_modem_dce_wrap esp_modem_dce_t;
typedef struct esp_modem_dte_config esp_modem_dte_config_t;
struct PdpContext;
typedef enum esp_modem_dce_mode
{
ESP_MODEM_MODE_COMMAND,
ESP_MODEM_MODE_DATA,
} esp_modem_dce_mode_t;
esp_modem_dce_t *esp_modem_new(const esp_modem_dte_config_t *dte_config, const esp_modem_dce_config_t *dce_config, esp_netif_t *netif);
void esp_modem_destroy(esp_modem_dce_t * dce);
esp_err_t esp_modem_set_mode(esp_modem_dce_t * dce, esp_modem_dce_mode_t mode);
#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, TEMPLATE_ARG, MUX_ARG, ...) \
esp_err_t esp_modem_ ## name(esp_modem_dce_t *dce, ##__VA_ARGS__);
+43
View File
@@ -0,0 +1,43 @@
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef _ESP_MODEM_C_API_TYPES_H_
#define _ESP_MODEM_C_API_TYPES_H_
#include "esp_modem_config.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct esp_modem_dce_wrap esp_modem_dce_t;
struct PdpContext;
typedef enum esp_modem_dce_mode
{
ESP_MODEM_MODE_COMMAND,
ESP_MODEM_MODE_DATA,
} esp_modem_dce_mode_t;
esp_modem_dce_t *esp_modem_new(const esp_modem_dte_config_t *dte_config, const esp_modem_dce_config_t *dce_config, esp_netif_t *netif);
void esp_modem_destroy(esp_modem_dce_t * dce);
esp_err_t esp_modem_set_mode(esp_modem_dce_t * dce, esp_modem_dce_mode_t mode);
#ifdef __cplusplus
}
#endif
#endif //_ESP_MODEM_C_API_TYPES_H_
@@ -21,12 +21,15 @@
#define STRING_OUT(x) std::string& x
#define BOOL_IN(x) const bool x
#define BOOL_OUT(x) bool& x
#define INT_OUT(x) int& x
#define STRUCT_OUT(struct_name, x) struct_name& x
#else
#define STRING_IN(x) const char* x
#define STRING_OUT(x) char* x
#define BOOL_IN(x) const bool x
#define BOOL_OUT(x) bool* x
#define INT_OUT(x) int* x
#define STRUCT_OUT(struct_name, x) struct struct_name* x
#endif
@@ -74,7 +77,13 @@ ESP_MODEM_DECLARE_DCE_COMMAND(get_module_name, command_result, 1, MUX_ARG, STRIN
* @brief Sets the modem to data mode
*
*/ \
ESP_MODEM_DECLARE_DCE_COMMAND(set_data_mode, command_result, 0, MUX_ARG)
ESP_MODEM_DECLARE_DCE_COMMAND(set_data_mode, command_result, 0, MUX_ARG) \
\
/**
* @brief Get Signal quality
*
*/ \
ESP_MODEM_DECLARE_DCE_COMMAND(get_signal_quality, command_result, 2, MUX_ARG, INT_OUT(x), INT_OUT(y))
// --- DCE command documentation starts here ---
#ifdef GENERATE_DOCS