~aleteoryx/muditaos

ref: b2ca227fd5d78c988a111189eae8cadfdb79e5f8 muditaos/module-services/service-cellular/include/service-cellular/State.hpp -rw-r--r-- 2.6 KiB
b2ca227f — Wiktor S. Ovalle Correa [EGD-6746] Use new SimCard implementation 4 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
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
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

namespace sys
{
    class Service;
}

namespace cellular::service
{
    class State
    {
      public:
        enum class ST
        {
            Idle,                        /// does nothing
            WaitForStartPermission,      /// waiting for permission to start the module
            PowerUpRequest,              /// process request of power up
            StatusCheck,                 /// set on service start - check for modem status - skipped on T3 board
            PowerUpProcedure,            /// due to lack of Status pin on T3, we don't know whether is on or off
            PowerUpInProgress,           /// waiting for modem powered up by polling various bauds
            BaudDetect,                  /// baud detection procedure
            CellularConfProcedure,       /// configuration procedure
            AudioConfigurationProcedure, /// audio configuration for modem (could be in ModemConfiguration)
            APNConfProcedure,            /// Configure APN set by user, check if modem have similar
            SanityCheck,                 /// prior to ModemOn last sanity checks for one time configurations etc
            ModemOn,   /// modem ready - indicates that modem is fully configured, ( **SIM is not yet configured** )
            URCReady,  /// State indicates that URC handling is enabled
            SimInit,   /// initialize sim card
            SimSelect, /// triggers hw SIM selection (! state now will be **changed on URC** )
            ModemFatalFailure, /// modem full shutdown need
            Failed,
            Ready,            /// Service is fully initialized
            PowerDownStarted, /// modem is disconnecting from network. It might take a while if poor coverage
            PowerDownWaiting, /// modem has deregistered and is now approaching low power state
            PowerDown,        /// modem is known to be turned off
        };

        enum class PowerState
        {
            Off,
            On
        };

      private:
        enum ST state = ST::Idle;
        sys::Service *owner;

      public:
        explicit State(sys::Service *owner);

        [[nodiscard]] static const char *c_str(ST state);
        [[nodiscard]] const char *c_str() const;

        /// 1. sets state of ServiceCellular
        /// 2. sends Multicast notification of ServiceCellular state
        ///
        /// \note This is for service cellular only it could be private and friend
        void set(ST state);

        ST get() const;
    };
} // namespace cellular::service