~aleteoryx/muditaos

ref: 8204cba1ab2566d53736e729b3929df59f0889cd muditaos/module-apps/application-settings-new/models/ApnSettingsModel.cpp -rw-r--r-- 1.2 KiB
8204cba1 — Wojtek Rzepecki [EGD-5575] Add battery file test 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// 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()
{
    sys::Bus::SendUnicast(std::make_shared<CellularGetAPNMessage>(), ServiceCellular::serviceName, application);
}

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;
    sys::Bus::SendUnicast(std::make_shared<CellularSetAPNMessage>(apn), ServiceCellular::serviceName, application);
}