Add: Sim7600 extended support

This commit is contained in:
Sjur G. Wroldsen
2022-04-19 16:23:22 +02:00
parent 0733ea8ff4
commit 15ed885035
4 changed files with 36 additions and 0 deletions

View File

@ -44,8 +44,10 @@ DECLARE_ALL_COMMAND_APIS(declare name(Commandable *p, ...);)
* @brief Following commands that are different for some specific modules
*/
command_result get_battery_status_sim7xxx(CommandableIf *t, int &voltage, int &bcs, int &bcl);
command_result set_gnss_power_mode_sim76xx(CommandableIf *t, int mode);
command_result power_down_sim76xx(CommandableIf *t);
command_result power_down_sim70xx(CommandableIf *t);
command_result set_network_bands_sim76xx(CommandableIf *t, const std::string& mode, const int* bands, int size);
command_result power_down_sim8xx(CommandableIf *t);
command_result set_data_mode_sim8xx(CommandableIf *t);

View File

@ -121,6 +121,8 @@ class SIM7600: public GenericModule {
public:
command_result get_battery_status(int &voltage, int &bcs, int &bcl) override;
command_result power_down() override;
command_result set_gnss_power_mode(int mode) override;
command_result set_network_bands(const std::string& mode, const int* bands, int size) override;
};
/**

View File

@ -18,6 +18,7 @@
#include "cxx_include/esp_modem_dte.hpp"
#include "cxx_include/esp_modem_dce_module.hpp"
#include "cxx_include/esp_modem_command_library.hpp"
#include <iomanip>
namespace esp_modem::dce_commands {
@ -489,6 +490,21 @@ command_result set_network_bands(CommandableIf *t, const std::string& mode, cons
return generic_command_common(t, "AT+CBANDCFG=\"" + mode + "\"," + band_string + "\r");
}
command_result set_network_bands_sim76xx(CommandableIf *t, const std::string& mode, const int* bands, int size)
{
ESP_LOGV(TAG, "%s", __func__ );
std::string any_mode = "0xFFFFFFFF7FFFFFFF";
uint64_t band_bits = 0;
for (int i = 0; i<size; ++i) {
// OR-operation to add bands
band_bits |= 1 << bands[i];
}
std::stringstream stream;
stream << "0x" << std::setfill('0') << std::setw(16) << std::hex << band_bits;
std::string band_string = stream.str();
return generic_command_common(t, "AT+CNBP=" + any_mode + "," + band_string + "\r");
}
command_result get_network_system_mode(CommandableIf *t, int &mode)
{
ESP_LOGV(TAG, "%s", __func__ );
@ -517,4 +533,10 @@ command_result set_gnss_power_mode(CommandableIf *t, int mode)
return generic_command_common(t, "AT+CGNSPWR=" + std::to_string(mode) + "\r");
}
command_result set_gnss_power_mode_sim76xx(CommandableIf *t, int mode)
{
ESP_LOGV(TAG, "%s", __func__ );
return generic_command_common(t, "AT+CGPS=" + std::to_string(mode) + "\r");
}
} // esp_modem::dce_commands

View File

@ -60,6 +60,16 @@ command_result SIM7600::power_down()
return dce_commands::power_down_sim76xx(dte.get());
}
command_result SIM7600::set_network_bands(const std::string& mode, const int* bands, int size)
{
return dce_commands::set_network_bands_sim76xx(dte.get(), mode, bands, size);
}
command_result SIM7600::power_down()
{
return dce_commands::power_down_sim76xx(dte.get());
}
command_result SIM7070::power_down()
{
return dce_commands::power_down_sim70xx(dte.get());