Files
MuditaOS/module-apps/application-settings-new/models/ApnSettingsModel.cpp
Piotr Tański bc4d32c7d8 [EGD-5158] Change access to the bus methods
The bus is now accessible only via Service object.
2021-02-08 16:56:42 +01:00

36 lines
1.2 KiB
C++

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "ApnSettingsModel.hpp"
#include <service-cellular/PacketDataCellularMessage.hpp>
#include <service-cellular/ServiceCellular.hpp>
ApnSettingsModel::ApnSettingsModel(app::Application *application) : application{application}
{}
void ApnSettingsModel::requestAPNList()
{
application->bus.sendUnicast(std::make_shared<CellularGetAPNMessage>(), ServiceCellular::serviceName);
}
void ApnSettingsModel::saveAPN(std::shared_ptr<packet_data::APN::Config> apn)
{
if (apn->contextId != packet_data::EmptyContextId) {
CellularServiceAPI::SetAPN(application, *apn);
}
else {
CellularServiceAPI::NewAPN(application, *apn);
}
}
void ApnSettingsModel::removeAPN(std::shared_ptr<packet_data::APN::Config> apn)
{
CellularServiceAPI::DeleteAPN(application, apn->contextId);
}
void ApnSettingsModel::setAsDefaultAPN(std::shared_ptr<packet_data::APN::Config> apn)
{
apn->apnType = packet_data::APN::APNType::Default;
application->bus.sendUnicast(std::make_shared<CellularSetAPNMessage>(apn), ServiceCellular::serviceName);
}