Files
esp-protocols/esp_modem/include/generate/esp_modem_command_declare.inc

157 lines
4.6 KiB
PHP
Raw Normal View History

2021-03-29 19:34:45 +02:00
// Copyright 2021 Espressif Systems (Shanghai) PTE LTD
//
2021-03-29 19:34:45 +02:00
// 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
//
2021-03-29 19:34:45 +02:00
// 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.
2021-03-29 19:34:45 +02:00
#ifndef _ESP_MODEM_COMMAND_DECLARE_INC_
#define _ESP_MODEM_COMMAND_DECLARE_INC_
2021-04-13 20:29:55 +02:00
#if GENERATE_DOCS
#define _ARG(arg) arg
#else
#define _ARG(arg) x
#endif
#ifdef __cplusplus
2021-03-16 21:36:13 +01:00
#include <string>
2021-04-13 20:29:55 +02:00
#define STRING_IN(x) const std::string& _ARG(x)
#define STRING_OUT(x) std::string& _ARG(x)
2021-03-24 21:06:27 +01:00
#define BOOL_IN(x) const bool x
2021-04-13 20:29:55 +02:00
#define BOOL_OUT(x) bool& _ARG(x)
2021-03-30 08:25:16 +02:00
#define INT_OUT(x) int& x
2021-03-24 21:06:27 +01:00
#define STRUCT_OUT(struct_name, x) struct_name& x
#else
2021-03-24 21:06:27 +01:00
#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
2021-03-30 08:25:16 +02:00
#define INT_OUT(x) int* x
2021-03-24 21:06:27 +01:00
#define STRUCT_OUT(struct_name, x) struct struct_name* x
#endif
2021-03-29 19:34:45 +02:00
#define _ESP_MODEM_COMMAND_DECLARE_INC_
#define ESP_MODEM_DEFINE_DCE_COMMAND(...) ESP_MODEM_DECLARE_DCE_COMMAND(##__VA_ARGS__)
#define DEFINE_ALL_COMMAND_APIS() DECLARE_ALL_COMMAND_APIS()
#define DECLARE_ALL_COMMAND_APIS(...) \
/**
* @brief Sends the supplied PIN code
*
* @param pin Pin
2021-04-13 20:29:55 +02:00
*
*/ \
\
2021-04-13 20:29:55 +02:00
ESP_MODEM_DECLARE_DCE_COMMAND(set_pin, command_result, 1, MUX_ARG, STRING_IN(pin)) \
\
\
/**
* @brief Checks if the SIM needs a PIN
*
* @param[out] pin_ok Pin
*/ \
2021-04-13 20:29:55 +02:00
ESP_MODEM_DECLARE_DCE_COMMAND(read_pin, command_result, 1, MUX_ARG, BOOL_OUT(pin_ok)) \
\
2021-04-13 20:29:55 +02:00
/**
* @brief Reads the module name
*
* @param[out] name module name
*/ \
2021-03-24 21:06:27 +01:00
ESP_MODEM_DECLARE_DCE_COMMAND(set_echo, command_result, 1, MUX_ARG, BOOL_IN(x)) \
\
2021-04-13 20:29:55 +02:00
/**
* @brief Reads the module name
*
* @param[out] name module name
*/ \
2021-03-24 21:06:27 +01:00
ESP_MODEM_DECLARE_DCE_COMMAND(resume_data_mode, command_result, 0, MUX_ARG) \
\
2021-04-13 20:29:55 +02:00
/**
* @brief Reads the module name
*
* @param[out] name module name
*/ \
2021-03-24 21:06:27 +01:00
ESP_MODEM_DECLARE_DCE_COMMAND(set_pdp_context, command_result, 1, MUX_ARG, STRUCT_OUT(PdpContext, x)) \
\
2021-04-13 20:29:55 +02:00
/**
* @brief Reads the module name
*
* @param[out] name module name
*/ \
2021-03-24 21:06:27 +01:00
ESP_MODEM_DECLARE_DCE_COMMAND(set_command_mode, command_result, 0, MUX_ARG) \
\
2021-04-13 20:29:55 +02:00
/**
* @brief Reads the module name
*
* @param[out] name module name
*/ \
2021-03-24 21:06:27 +01:00
ESP_MODEM_DECLARE_DCE_COMMAND(set_cmux, command_result, 0, MUX_ARG) \
\
2021-04-13 20:29:55 +02:00
/**
* @brief Reads the module name
*
* @param[out] name module name
*/ \
2021-03-24 21:06:27 +01:00
ESP_MODEM_DECLARE_DCE_COMMAND(get_imsi, command_result, 1, MUX_ARG, STRING_OUT(x)) \
\
2021-04-13 20:29:55 +02:00
/**
* @brief Reads the module name
*
* @param[out] name module name
*/ \
2021-03-24 21:06:27 +01:00
ESP_MODEM_DECLARE_DCE_COMMAND(get_imei, command_result, 1, MUX_ARG, STRING_OUT(x)) \
\
/**
* @brief Reads the module name
*
2021-04-13 20:29:55 +02:00
* @param[out] name module name
*/ \
2021-04-13 20:29:55 +02:00
ESP_MODEM_DECLARE_DCE_COMMAND(get_module_name, command_result, 1, MUX_ARG, STRING_OUT(name)) \
\
/**
* @brief Sets the modem to data mode
*
*/ \
2021-03-30 08:25:16 +02:00
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))
#ifdef GENERATE_DOCS
2021-04-13 20:29:55 +02:00
// cat ../include/generate/esp_modem_command_declare.inc | clang++ -E -P -CC -xc++ -I../include -DGENERATE_DOCS - | sed -n '1,/DCE command documentation/!p'
// cat ../include/generate/esp_modem_command_declare.inc | clang -E -P -CC -xc -I../include -DGENERATE_DOCS - | sed -n '1,/DCE command documentation/!p' > c_api.h
2021-04-14 17:57:42 +02:00
// cat ../include/generate/esp_modem_command_declare.inc | clang -E -P -xc -I../include -DGENERATE_DOCS -DGENERATE_RST_LINKS - | sed 's/NL/\n/g' > cxx_api_links.rst
2021-04-13 20:29:55 +02:00
// --- DCE command documentation starts here ---
#ifdef __cplusplus
2021-04-14 17:57:42 +02:00
class esp_modem::DCE: public DCE_T<GenericModule> {
2021-04-13 20:29:55 +02:00
public:
using DCE_T<GenericModule>::DCE_T;
#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, TEMPLATE_ARG, MUX_ARG, ...) return_type name (__VA_ARGS__);
2021-04-14 17:57:42 +02:00
#elif defined(GENERATE_RST_LINKS)
#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, TEMPLATE_ARG, MUX_ARG, ...) NL- :cpp:func:`esp_modem::DCE::name`
2021-04-13 20:29:55 +02:00
#else
#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, TEMPLATE_ARG, MUX_ARG, ...) return_type esp_modem_ ## name (__VA_ARGS__);
#endif
DECLARE_ALL_COMMAND_APIS()
2021-04-13 20:29:55 +02:00
#ifdef __cplusplus
};
#endif
2021-04-13 20:29:55 +02:00
#endif
2021-03-29 19:34:45 +02:00
#endif // _ESP_MODEM_COMMAND_DECLARE_INC_