~aleteoryx/muditaos

ref: 228fca4b83060df4dc3eb84a0dcb290c8a572057 muditaos/module-apps/application-settings/models/network/ApnSettingsModel.cpp -rw-r--r-- 1.1 KiB
228fca4b — Bartosz Cichocki [MOS-463] Unify cellular namespace 3 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
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ApnSettingsModel.hpp"
#include <service-cellular/ServiceCellular.hpp>

ApnSettingsModel::ApnSettingsModel(app::ApplicationCommon *application) : application{application}
{}

void ApnSettingsModel::requestAPNList()
{
    application->bus.sendUnicast(std::make_shared<cellular::GetAPNMessage>(), ServiceCellular::serviceName);
}

void ApnSettingsModel::saveAPN(const 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(const std::shared_ptr<packet_data::APN::Config> &apn)
{
    CellularServiceAPI::DeleteAPN(application, apn->contextId);
}

void ApnSettingsModel::setAsDefaultAPN(const std::shared_ptr<packet_data::APN::Config> &apn)
{
    apn->apnType = packet_data::APN::APNType::Default;
    application->bus.sendUnicast(std::make_shared<cellular::SetAPNMessage>(apn), ServiceCellular::serviceName);
}