~aleteoryx/muditaos

ref: 70d3ba4c03655d7b1e90cbeab88f116bd892e600 muditaos/module-cellular/at/cmd/CLCC.hpp -rw-r--r-- 2.7 KiB
70d3ba4c — Dawid Wojtas [BH-1935] Fix the backlight in pre-wake up 1 year, 10 months 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include "Result.hpp"
#include <at/Cmd.hpp>
#include <PhoneNumber.hpp>

namespace ModemCall
{
    enum class CallState : uint8_t
    {
        Active = 0, // 0 active: call in progress (setup was successful)
        Held,       // 1 held: call on hold
        Dialing,    // 2 dialing (MO call): number dialed
        Alerting,   // 3 alerting (MO call): number dialed and the called party is alerted
        Incoming,   // 4 incoming (MT call): incoming call, ringtone played (AT RING notification)
        Waiting // 5 waiting (MT call): call waiting notification while another call is active (if call waiting feature
                // enabled)
    };

    enum class CallDir : uint8_t
    {
        MO = 0, // Mobile originated (MO) call
        MT = 1  // Mobile terminated (MT) call
    };

    enum class CallMode : uint8_t
    {
        Voice = 0,
        Data,
        FAX
    };
} // namespace ModemCall

namespace at
{
    namespace cmd
    {
        class CLCC;
    } // namespace cmd

    namespace result
    {
        /// please see documentation:
        /// QuectelEC2526EC21ATCommandsManualV13.1100970659
        /// page: 101 for more information
        struct CLCC : public Result
        {
          private:
            struct Data
            {
                const std::uint8_t idx;
                const ModemCall::CallDir dir;
                const ModemCall::CallState stateOfCall;
                const ModemCall::CallMode mode;
                const bool multiparty;
                const utils::PhoneNumber::View number;
                const std::string type;
                const std::string alpha;
                const std::size_t tokens;
            };

            std::vector<Data> data;
            friend cmd::CLCC;

          public:
            explicit CLCC(const Result &);
            [[nodiscard]] auto getData() const noexcept -> const std::vector<Data> &
            {
                return data;
            };
        };
    } // namespace result

    namespace cmd
    {
        class CLCC : public Cmd
        {
          protected:
            [[nodiscard]] static auto toBool(const std::string &text) -> bool;
            [[nodiscard]] static auto toUInt(const std::string &text) -> std::uint8_t;
            template <typename T>
            [[nodiscard]] static auto toEnum(const std::string &text) -> std::optional<T>;

          public:
            CLCC() noexcept;
            explicit CLCC(at::cmd::Modifier mod) noexcept;
            [[nodiscard]] auto parseCLCC(const Result &base_result) -> result::CLCC;
        };
    } // namespace cmd
} // namespace at