Files
esp-protocols/components/esp_modem/src/esp_modem_modules.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

86 lines
2.2 KiB
C++
Raw Normal View History

2021-03-29 19:34:45 +02:00
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
2021-03-29 19:34:45 +02:00
* SPDX-License-Identifier: Apache-2.0
*/
2021-03-29 19:34:45 +02:00
#include "cxx_include/esp_modem_api.hpp"
#include "cxx_include/esp_modem_dce_module.hpp"
2021-03-24 21:06:27 +01:00
#include "generate/esp_modem_command_declare.inc"
2021-03-29 19:34:45 +02:00
namespace esp_modem {
GenericModule::GenericModule(std::shared_ptr<DTE> dte, const dce_config *config) :
2021-06-01 10:21:51 +02:00
dte(std::move(dte)), pdp(std::make_unique<PdpContext>(config->apn)) {}
2021-03-28 13:38:20 +02:00
2021-04-19 11:28:53 +02:00
//
// Define preprocessor's forwarding to dce_commands definitions
//
2021-03-28 13:38:20 +02:00
2021-04-19 11:28:53 +02:00
// Helper macros to handle multiple arguments of declared API
2021-03-24 21:06:27 +01:00
#define ARGS0
#define ARGS1 , p1
#define ARGS2 , p1 , p2
#define ARGS3 , p1 , p2 , p3
#define ARGS4 , p1 , p2 , p3, p4
#define ARGS5 , p1 , p2 , p3, p4, p5
#define ARGS6 , p1 , p2 , p3, p4, p5, p6
2021-03-24 21:06:27 +01:00
#define _ARGS(x) ARGS ## x
#define ARGS(x) _ARGS(x)
2021-04-19 11:28:53 +02:00
//
// Repeat all declarations and forward to the AT commands defined in esp_modem::dce_commands:: namespace
//
2021-04-15 14:59:30 +02:00
#define ESP_MODEM_DECLARE_DCE_COMMAND(name, return_type, arg_nr, ...) \
2021-03-24 21:06:27 +01:00
return_type GenericModule::name(__VA_ARGS__) { return esp_modem::dce_commands::name(dte.get() ARGS(arg_nr) ); }
2021-04-19 11:28:53 +02:00
DECLARE_ALL_COMMAND_APIS(return_type name(...) )
2021-03-24 21:06:27 +01:00
#undef ESP_MODEM_DECLARE_DCE_COMMAND
2021-04-19 11:28:53 +02:00
//
// Handle specific commands for specific supported modems
//
2021-06-01 10:21:51 +02:00
command_result SIM7600::get_battery_status(int &voltage, int &bcs, int &bcl)
{
2021-04-19 11:28:53 +02:00
return dce_commands::get_battery_status_sim7xxx(dte.get(), voltage, bcs, bcl);
}
command_result SIM7600::set_network_bands(const std::string &mode, const int *bands, int size)
2021-06-01 10:21:51 +02:00
{
return dce_commands::set_network_bands_sim76xx(dte.get(), mode, bands, size);
2022-04-13 13:42:57 +02:00
}
command_result SIM7600::set_gnss_power_mode(int mode)
2022-04-19 16:23:22 +02:00
{
return dce_commands::set_gnss_power_mode_sim76xx(dte.get(), mode);
2022-04-19 16:23:22 +02:00
}
command_result SIM7600::power_down()
{
return dce_commands::power_down_sim76xx(dte.get());
}
2022-04-13 13:42:57 +02:00
command_result SIM7070::power_down()
{
2022-04-13 15:36:15 +02:00
return dce_commands::power_down_sim70xx(dte.get());
}
command_result SIM7000::power_down()
{
return dce_commands::power_down_sim70xx(dte.get());
2021-04-19 11:28:53 +02:00
}
2021-06-01 10:21:51 +02:00
command_result SIM800::power_down()
{
2021-04-19 11:28:53 +02:00
return dce_commands::power_down_sim8xx(dte.get());
}
2021-06-01 10:21:51 +02:00
command_result SIM800::set_data_mode()
{
2021-04-19 11:28:53 +02:00
return dce_commands::set_data_mode_sim8xx(dte.get());
}
2021-03-29 19:34:45 +02:00
}