~aleteoryx/muditaos

muditaos/module-services/service-cellular/NetworkSettings.hpp -rw-r--r-- 1.9 KiB
a405cad6Aleteoryx trim readme 6 days 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#pragma once

#include <string>
#include <vector>

#include "service-cellular/CellularMessage.hpp"
#include "service-cellular/CellularServiceAPI.hpp"
#include "service-cellular/ServiceCellular.hpp"
#include "response.hpp"

#include <at/cmd/QNWINFO.hpp>

/**
 * Internal (Mudita) VoLTE state, based on on a few
 * modem parameters
 */
enum class VoLTEState
{
    On,
    Off,
    Unknown
};

/**
 * Enum for voice domain preference
 * between circuit-switched (CS) and
 * packet-switched (PS)
 */
enum class VoiceDomainPreference : std::uint8_t
{
    CSOnly      = 0x00,
    PSOnly      = 0x01,
    CSPreferred = 0x02,
    PSPreferred = 0x03
};

enum class SMSDomainPreference : std::uint8_t
{
    PSNotAllowed = 0x00,
    PSPreferred  = 0x01
};

class NetworkSettings
{

  public:
    explicit NetworkSettings(ServiceCellular &cellularService) : cellularService(cellularService)
    {}
    /**
     * Scan for operator, return string list see param fullInfoList
     * @param fullInfoList for tru scan wit details (as space separated) in case of false scan only
     * for full names without duplicates
     * @return
     */
    std::vector<std::string> scanOperators(bool fullInfoList = false);

    bool setOperatorAutoSelect();
    std::string getCurrentOperatorName() const;
    std::optional<at::response::cops::Operator> getCurrentOperator() const;
    bool setOperator(at::response::cops::CopsMode mode, at::response::cops::NameFormat format, const std::string &name);

    enum class SimpleNAT
    {
        GSM,
        UMTS,
        LTE
    };
    std::optional<at::response::cops::AccessTechnology> getCurrentNAT() const;
    std::optional<at::result::QNWINFO> getCurrentNetworkInfo() const;

    static SimpleNAT toSimpleNAT(at::response::cops::AccessTechnology nat);

  private:
    ServiceCellular &cellularService;
};