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

161 lines
5.2 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
2021-04-15 09:46:28 +02:00
#define _ARG(param, name) name
2021-04-13 20:29:55 +02:00
#else
2021-04-15 09:46:28 +02:00
#define _ARG(param, name) param
2021-04-13 20:29:55 +02:00
#endif
#ifdef __cplusplus
2021-03-16 21:36:13 +01:00
#include <string>
2021-04-15 09:46:28 +02:00
#define STRING_IN(param, name) const std::string& _ARG(param, name)
#define STRING_OUT(param, name) std::string& _ARG(param, name)
#define BOOL_IN(param, name) const bool _ARG(param, name)
#define BOOL_OUT(param, name) bool& _ARG(param, name)
#define INT_OUT(param, name) int& _ARG(param, name)
2021-03-30 08:25:16 +02:00
2021-03-24 21:06:27 +01:00
#define STRUCT_OUT(struct_name, x) struct_name& x
#else
2021-04-15 09:46:28 +02:00
#define STRING_IN(param, name) const char* _ARG(param, name)
#define STRING_OUT(param, name) char* _ARG(param, name)
#define BOOL_IN(param, name) const bool _ARG(param, name)
#define BOOL_OUT(param, name) bool* _ARG(param, name)
#define INT_OUT(param, name) int* _ARG(param, name)
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-15 09:46:28 +02:00
ESP_MODEM_DECLARE_DCE_COMMAND(set_pin, command_result, 1, MUX_ARG, STRING_IN(x, pin)) \
2021-04-13 20:29:55 +02:00
\
\
/**
* @brief Checks if the SIM needs a PIN
*
* @param[out] pin_ok Pin
*/ \
2021-04-15 09:46:28 +02:00
ESP_MODEM_DECLARE_DCE_COMMAND(read_pin, command_result, 1, MUX_ARG, BOOL_OUT(x, pin_ok)) \
\
2021-04-13 20:29:55 +02:00
/**
* @brief Reads the module name
*
* @param[out] name module name
*/ \
2021-04-15 09:46:28 +02:00
ESP_MODEM_DECLARE_DCE_COMMAND(set_echo, command_result, 1, MUX_ARG, BOOL_IN(x, echo_on)) \
ESP_MODEM_DECLARE_DCE_COMMAND(sms_txt_mode, command_result, 1, MUX_ARG, BOOL_IN(x, txt)) \
ESP_MODEM_DECLARE_DCE_COMMAND(sms_character_set, command_result, 0, MUX_ARG) \
ESP_MODEM_DECLARE_DCE_COMMAND(send_sms, command_result, 2, MUX_ARG, STRING_IN(x, number), STRING_IN(y, message)) \
\
\
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-04-15 09:46:28 +02:00
ESP_MODEM_DECLARE_DCE_COMMAND(get_imsi, command_result, 1, MUX_ARG, STRING_OUT(x, imsi)) \
\
2021-04-13 20:29:55 +02:00
/**
* @brief Reads the module name
*
* @param[out] name module name
*/ \
2021-04-15 09:46:28 +02:00
ESP_MODEM_DECLARE_DCE_COMMAND(get_imei, command_result, 1, MUX_ARG, STRING_OUT(x, name)) \
\
/**
* @brief Reads the module name
*
2021-04-13 20:29:55 +02:00
* @param[out] name module name
*/ \
2021-04-15 09:46:28 +02:00
ESP_MODEM_DECLARE_DCE_COMMAND(get_module_name, command_result, 1, MUX_ARG, STRING_OUT(x, 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
*
*/ \
2021-04-15 09:46:28 +02:00
ESP_MODEM_DECLARE_DCE_COMMAND(get_signal_quality, command_result, 2, MUX_ARG, INT_OUT(x, rssi), INT_OUT(y, ber))
#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_